summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 6e93dc07..f43795e9 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 42e4ee71..d235f4da 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 62ce69a6..efb99105 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 15561645..ffaef0e9 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 c684a866..c377271d 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 d33d8928..5cb84e30 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 2d27d29a..98ec029e 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 639d49a1..daa6c6ed 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 a85cfac1..3af2b50f 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 91b9b100..6204c5e1 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 031a1ed7..daa1b078 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 a2475ce7..62d50952 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 d141db13..4042869b 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 7493d970..35693354 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 c31f3dc3..89ff4ff3 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 f259c982..353f50b7 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 390ef758..4c34ba04 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 31d6744c..be442089 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 bdecb8c8..634c4bf3 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 e4a1bdbe..d99f4a50 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 4748eaf8..63d276d4 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 47b464d3..73072513 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 f8fd1cde..d81d83a9 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 623a6af3..682da6d0 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 a47995cb..0fc29ffc 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 d439a2a5..3565d95f 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 f31f4042..5fecdec2 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 13dfe4ef..2e5502d1 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 82b4fe75..0e69f145 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 1fc9bef4..056ad6d3 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 209ae742..8102ee64 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 06851f58..e00cf799 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 12152484..d1639cca 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 818b19d3..d63f4197 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 a7ed9e92..ad804225 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 1509e0aa..86358731 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 9758940a..1248fdbf 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 79a87078..9313b324 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 7029b748..0afec813 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 6a7e9e81..29a1ec64 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 2dbd0ad9..7e64f330 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 b3ae75e3..97f12cc5 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 964f7da1..ad040524 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 494cbcc0..cbc75d7a 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 eea2f80b..ca805430 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 9d574562..c3dfb473 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 e0f463b5..8576df2c 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 63557afe..c9a8f090 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 a5cbd757..0aaf0ac7 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 545d1859..922a9581 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 63d6aff5..b2e84bca 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 ba9cc62b..1cd61ce4 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 46db90d3..55ea3420 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 eaf35d3b..bb20475b 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 91aefd40..8488d75c 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 ab22806e..1813b266 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 25ba240e..82f5a07e 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 26d35649..96b47b12 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 c9714ef8..3a5a7433 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 db803661..35e834ee 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 c0e7e494..e001d844 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 33457f95..68b9960f 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 066cce60..3c1343ae 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 ec9e54ad..6710637a 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 250649f5..59f733db 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 a2e308b3..7eb05d45 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 d48a65e7..5cf8f3eb 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 6910ef37..de7ed84d 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 2480265b..79f3b8cf 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 c9b6388a..598e2241 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 c9f90da2..dc9d6621 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 0dc6dc00..27eb080f 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 fc49929a..5a94cc7c 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 3d115c75..33f89a38 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 ad0a7662..53b80b21 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 ca333437..14f9f4c4 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 8c25c53a..031003ad 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 d04a54aa..59700485 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 c3ad1090..3847da37 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 b6ec3101..9f104977 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 5ade6ad1..41424e80 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 2f18d925..d8d1c773 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 e95fdb2c..eb47b2a1 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 6f26c051..a0b320fc 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 80fbf384..3a02e573 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 105f810f..ccaffc37 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 8ab02a74..6507b429 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 f5b7b492..8cbdda06 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 16d07ea7..fc4adb46 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 6c07e6b3..6affee04 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 16337542..d9076275 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 6fa43bef..35063c5b 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 5499bd18..f7ff4a61 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 4d0a807a..16e7b4f5 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 5b0f6b18..992812fd 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 98dff61e..78bd7474 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 60b34054..94f92be6 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 dd1a8dbe..ab87d622 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 2974ff7f..b644cebb 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 9d2f23ab..c0f063ed 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 6c0f05df..363d2fec 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 eb4d184f..b75f0c5c 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 b0b3024b..31c1a030 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 1b6b38fd..cbe46284 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 6a5f6f15..cb2257f0 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 aeb50bc5..12e7ff0c 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 0cc18545..dbefc844 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 c35f5861..f324ba79 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 a2e4bd3c..afe12b5d 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 48480685..fdf8e4bb 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 cbf83d23..f75eb112 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 c7986096..d893fbac 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 c0e607f5..0091a8d4 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 75f04d72..f8f4b70f 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 79c3de63..797b664e 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 6c075e25..f29bc304 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 83f308d3..26fe9af8 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 5d6a388b..87c6007e 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 e76272fc..a07129f5 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 0f98b4a5..ba536b07 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 dd611251..252948f9 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 b85009c8..7c233d5e 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 a0472f78..4daff7bb 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 861fef2f..5211d759 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 c23ca69e..a297985e 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 17df2bf2..693c750b 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 feb9eb81..06623c44 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 0a2c2a9d..1f57a4dd 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 ceae4d45..05700ad6 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 4d3ff92a..193d7241 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 d6f8631d..929ddcbc 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 06491748..915c0a22 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 94d2e15c..6f37cc68 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 037d0965..3e28e287 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 37d69629..2bc2c270 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 6788a383..2a193263 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 55a8e1d8..52e6e6e0 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 cde4feec..e406f3d5 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 1a2a8618..07a037a0 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 38c99d3f..464b83d5 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 195e9cba..6c2c16ef 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 67130e16..4ab0df20 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 d9ce786e..545a0bf8 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 e9a168f3..94df18f9 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 66934889..969e0a38 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 b274bd0d..88c333f6 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 4127a413..a21578dc 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 ef1fb425..0ab47802 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 c8878b11..a2ff4839 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 0f66e6c6..d1d141e5 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 22754850..4b95e752 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 a2804ac8..8d2a2ebc 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 ffa9b758..77684050 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 a406c4eb..f984b7dd 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 37ce0d43..53866c6d 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 a2ce3511..8bac7b2f 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 ce1c8144..6c966526 100644
--- a/src/unistd/usleep.c
+++ b/src/unistd/usleep.c
@@ -1,3 +1,4 @@
+#define _GNU_SOURCE
#include <unistd.h>
#include <time.h>