mailing list of musl libc
 help / color / mirror / code / Atom feed
* [musl] [PATCH] cleanup unused include headers
@ 2025-01-10 14:44 Abhisit Sangjan
  2025-01-11  8:46 ` Rich Felker
  0 siblings, 1 reply; 2+ messages in thread
From: Abhisit Sangjan @ 2025-01-10 14:44 UTC (permalink / raw)
  To: musl; +Cc: Rich Felker, Abhisit Sangjan

---
 compat/time32/adjtime32.c                        | 1 -
 compat/time32/clock_adjtime32.c                  | 3 ---
 compat/time32/fstat_time32.c                     | 1 -
 compat/time32/fstatat_time32.c                   | 1 -
 compat/time32/futimes_time32.c                   | 1 -
 compat/time32/futimesat_time32.c                 | 1 -
 compat/time32/getitimer_time32.c                 | 1 -
 compat/time32/lstat_time32.c                     | 1 -
 compat/time32/lutimes_time32.c                   | 1 -
 compat/time32/select_time32.c                    | 1 -
 compat/time32/setitimer_time32.c                 | 1 -
 compat/time32/stat_time32.c                      | 1 -
 compat/time32/utime_time32.c                     | 1 -
 compat/time32/utimes_time32.c                    | 1 -
 crt/crt1.c                                       | 1 -
 ldso/dlstart.c                                   | 1 -
 src/aio/aio.c                                    | 2 --
 src/aio/aio_suspend.c                            | 1 -
 src/crypt/encrypt.c                              | 1 -
 src/ctype/__ctype_get_mb_cur_max.c               | 1 -
 src/env/__init_tls.c                             | 1 -
 src/exit/_Exit.c                                 | 1 -
 src/exit/abort.c                                 | 1 -
 src/exit/exit.c                                  | 1 -
 src/ldso/dlerror.c                               | 1 -
 src/legacy/getloadavg.c                          | 1 -
 src/legacy/getpass.c                             | 1 -
 src/linux/adjtime.c                              | 1 -
 src/linux/renameat2.c                            | 1 -
 src/linux/statx.c                                | 1 -
 src/linux/utimes.c                               | 1 -
 src/linux/wait3.c                                | 1 -
 src/locale/dcngettext.c                          | 1 -
 src/locale/iconv.c                               | 2 --
 src/locale/locale_map.c                          | 1 -
 src/locale/strcoll.c                             | 1 -
 src/locale/strxfrm.c                             | 1 -
 src/locale/wcscoll.c                             | 1 -
 src/locale/wcsxfrm.c                             | 1 -
 src/malloc/lite_malloc.c                         | 1 -
 src/malloc/mallocng/donate.c                     | 2 --
 src/malloc/mallocng/malloc.c                     | 1 -
 src/misc/a64l.c                                  | 1 -
 src/misc/get_current_dir_name.c                  | 1 -
 src/misc/getopt_long.c                           | 2 --
 src/misc/initgroups.c                            | 1 -
 src/misc/openpty.c                               | 1 -
 src/misc/syslog.c                                | 1 -
 src/misc/wordexp.c                               | 1 -
 src/mman/mmap.c                                  | 1 -
 src/mq/mq_getattr.c                              | 1 -
 src/network/dns_parse.c                          | 1 -
 src/network/gethostbyaddr_r.c                    | 1 -
 src/network/gethostbyname.c                      | 1 -
 src/network/getifaddrs.c                         | 1 -
 src/network/getnameinfo.c                        | 1 -
 src/network/getservbyname_r.c                    | 1 -
 src/network/getservbyport_r.c                    | 1 -
 src/network/lookup_name.c                        | 1 -
 src/network/netlink.c                            | 1 -
 src/network/recvmsg.c                            | 1 -
 src/network/res_msend.c                          | 2 --
 src/network/sendmmsg.c                           | 1 -
 src/passwd/getgrouplist.c                        | 1 -
 src/passwd/getspnam_r.c                          | 1 -
 src/prng/drand48.c                               | 2 --
 src/prng/lcong48.c                               | 1 -
 src/prng/lrand48.c                               | 2 --
 src/prng/mrand48.c                               | 2 --
 src/prng/rand_r.c                                | 1 -
 src/prng/seed48.c                                | 1 -
 src/process/posix_spawn_file_actions_addfchdir.c | 1 -
 src/regex/fnmatch.c                              | 1 -
 src/regex/regcomp.c                              | 1 -
 src/regex/regexec.c                              | 1 -
 src/sched/sched_getcpu.c                         | 1 -
 src/select/poll.c                                | 1 -
 src/select/select.c                              | 1 -
 src/signal/block.c                               | 1 -
 src/signal/psignal.c                             | 1 -
 src/signal/raise.c                               | 1 -
 src/signal/sigemptyset.c                         | 1 -
 src/signal/siglongjmp.c                          | 3 ---
 src/signal/signal.c                              | 1 -
 src/signal/sigqueue.c                            | 1 -
 src/signal/sigrtmin.c                            | 1 -
 src/stat/fstatat.c                               | 1 -
 src/stdio/funlockfile.c                          | 1 -
 src/stdio/gets.c                                 | 1 -
 src/stdio/getwc.c                                | 1 -
 src/stdio/putwc.c                                | 1 -
 src/stdio/vfscanf.c                              | 1 -
 src/stdio/vfwscanf.c                             | 4 ----
 src/stdio/vscanf.c                               | 1 -
 src/stdio/vsnprintf.c                            | 3 ---
 src/stdio/vswprintf.c                            | 3 ---
 src/stdio/vwscanf.c                              | 1 -
 src/stdlib/gcvt.c                                | 1 -
 src/stdlib/qsort.c                               | 1 -
 src/stdlib/strtod.c                              | 1 -
 src/stdlib/strtol.c                              | 2 --
 src/stdlib/wcstod.c                              | 1 -
 src/stdlib/wcstol.c                              | 1 -
 src/string/strsignal.c                           | 1 -
 src/string/wcscasecmp.c                          | 1 -
 src/temp/__randname.c                            | 1 -
 src/thread/__syscall_cp.c                        | 1 -
 src/thread/__unmapself.c                         | 1 -
 src/time/asctime_r.c                             | 1 -
 src/time/clock_gettime.c                         | 1 -
 src/time/gettimeofday.c                          | 1 -
 src/time/gmtime.c                                | 1 -
 src/time/strftime.c                              | 1 -
 src/time/time.c                                  | 1 -
 src/time/timer_create.c                          | 1 -
 src/time/wcsftime.c                              | 1 -
 src/unistd/alarm.c                               | 1 -
 src/unistd/ctermid.c                             | 1 -
 src/unistd/isatty.c                              | 1 -
 src/unistd/nice.c                                | 1 -
 src/unistd/renameat.c                            | 1 -
 121 files changed, 141 deletions(-)

diff --git a/compat/time32/adjtime32.c b/compat/time32/adjtime32.c
index b0042c63..10b52779 100644
--- a/compat/time32/adjtime32.c
+++ b/compat/time32/adjtime32.c
@@ -1,6 +1,5 @@
 #define _GNU_SOURCE
 #include "time32.h"
-#include <time.h>
 #include <sys/time.h>
 #include <sys/timex.h>
 
diff --git a/compat/time32/clock_adjtime32.c b/compat/time32/clock_adjtime32.c
index 5a25b8ac..3262cd6b 100644
--- a/compat/time32/clock_adjtime32.c
+++ b/compat/time32/clock_adjtime32.c
@@ -1,9 +1,6 @@
 #include "time32.h"
-#include <time.h>
 #include <sys/time.h>
 #include <sys/timex.h>
-#include <string.h>
-#include <stddef.h>
 
 struct timex32 {
 	unsigned modes;
diff --git a/compat/time32/fstat_time32.c b/compat/time32/fstat_time32.c
index e5d52022..7ae75bc7 100644
--- a/compat/time32/fstat_time32.c
+++ b/compat/time32/fstat_time32.c
@@ -1,5 +1,4 @@
 #include "time32.h"
-#include <time.h>
 #include <string.h>
 #include <sys/stat.h>
 #include <stddef.h>
diff --git a/compat/time32/fstatat_time32.c b/compat/time32/fstatat_time32.c
index 31d42e63..471ed44d 100644
--- a/compat/time32/fstatat_time32.c
+++ b/compat/time32/fstatat_time32.c
@@ -1,5 +1,4 @@
 #include "time32.h"
-#include <time.h>
 #include <string.h>
 #include <sys/stat.h>
 #include <stddef.h>
diff --git a/compat/time32/futimes_time32.c b/compat/time32/futimes_time32.c
index f29533f1..617d7363 100644
--- a/compat/time32/futimes_time32.c
+++ b/compat/time32/futimes_time32.c
@@ -1,6 +1,5 @@
 #define _GNU_SOURCE
 #include "time32.h"
-#include <time.h>
 #include <sys/time.h>
 #include <sys/stat.h>
 
diff --git a/compat/time32/futimesat_time32.c b/compat/time32/futimesat_time32.c
index 5a1295bd..12a2fa1d 100644
--- a/compat/time32/futimesat_time32.c
+++ b/compat/time32/futimesat_time32.c
@@ -1,6 +1,5 @@
 #define _GNU_SOURCE
 #include "time32.h"
-#include <time.h>
 #include <sys/time.h>
 #include <sys/stat.h>
 
diff --git a/compat/time32/getitimer_time32.c b/compat/time32/getitimer_time32.c
index 4bac4bf5..d9a57e1a 100644
--- a/compat/time32/getitimer_time32.c
+++ b/compat/time32/getitimer_time32.c
@@ -1,5 +1,4 @@
 #include "time32.h"
-#include <time.h>
 #include <sys/time.h>
 
 int __getitimer_time32(int which, struct itimerval32 *old32)
diff --git a/compat/time32/lstat_time32.c b/compat/time32/lstat_time32.c
index 28cb5a0b..7d9d84ab 100644
--- a/compat/time32/lstat_time32.c
+++ b/compat/time32/lstat_time32.c
@@ -1,5 +1,4 @@
 #include "time32.h"
-#include <time.h>
 #include <string.h>
 #include <sys/stat.h>
 #include <stddef.h>
diff --git a/compat/time32/lutimes_time32.c b/compat/time32/lutimes_time32.c
index 7f75cd4a..b89e56b6 100644
--- a/compat/time32/lutimes_time32.c
+++ b/compat/time32/lutimes_time32.c
@@ -1,6 +1,5 @@
 #define _GNU_SOURCE
 #include "time32.h"
-#include <time.h>
 #include <sys/time.h>
 #include <sys/stat.h>
 
diff --git a/compat/time32/select_time32.c b/compat/time32/select_time32.c
index 2d8df9ac..cb23b65c 100644
--- a/compat/time32/select_time32.c
+++ b/compat/time32/select_time32.c
@@ -1,5 +1,4 @@
 #include "time32.h"
-#include <time.h>
 #include <sys/time.h>
 #include <sys/select.h>
 
diff --git a/compat/time32/setitimer_time32.c b/compat/time32/setitimer_time32.c
index 2475fd8c..a8f5ef6c 100644
--- a/compat/time32/setitimer_time32.c
+++ b/compat/time32/setitimer_time32.c
@@ -1,5 +1,4 @@
 #include "time32.h"
-#include <time.h>
 #include <sys/time.h>
 
 int __setitimer_time32(int which, const struct itimerval32 *restrict new32, struct itimerval32 *restrict old32)
diff --git a/compat/time32/stat_time32.c b/compat/time32/stat_time32.c
index b154b0f9..15b4e1af 100644
--- a/compat/time32/stat_time32.c
+++ b/compat/time32/stat_time32.c
@@ -1,5 +1,4 @@
 #include "time32.h"
-#include <time.h>
 #include <string.h>
 #include <sys/stat.h>
 #include <stddef.h>
diff --git a/compat/time32/utime_time32.c b/compat/time32/utime_time32.c
index 65f11d46..730def2c 100644
--- a/compat/time32/utime_time32.c
+++ b/compat/time32/utime_time32.c
@@ -1,5 +1,4 @@
 #include "time32.h"
-#include <time.h>
 #include <utime.h>
 
 struct utimbuf32 {
diff --git a/compat/time32/utimes_time32.c b/compat/time32/utimes_time32.c
index 59248f62..6e1518b6 100644
--- a/compat/time32/utimes_time32.c
+++ b/compat/time32/utimes_time32.c
@@ -1,5 +1,4 @@
 #include "time32.h"
-#include <time.h>
 #include <sys/time.h>
 #include <sys/stat.h>
 
diff --git a/crt/crt1.c b/crt/crt1.c
index 10601215..d024df1a 100644
--- a/crt/crt1.c
+++ b/crt/crt1.c
@@ -1,5 +1,4 @@
 #include <features.h>
-#include "libc.h"
 
 #define START "_start"
 
diff --git a/ldso/dlstart.c b/ldso/dlstart.c
index 259f5e18..287e0bac 100644
--- a/ldso/dlstart.c
+++ b/ldso/dlstart.c
@@ -1,6 +1,5 @@
 #include <stddef.h>
 #include "dynlink.h"
-#include "libc.h"
 
 #ifndef START
 #define START "_dlstart"
diff --git a/src/aio/aio.c b/src/aio/aio.c
index d7e063bf..6b34614f 100644
--- a/src/aio/aio.c
+++ b/src/aio/aio.c
@@ -1,13 +1,11 @@
 #include <aio.h>
 #include <pthread.h>
 #include <semaphore.h>
-#include <limits.h>
 #include <errno.h>
 #include <unistd.h>
 #include <stdlib.h>
 #include <sys/auxv.h>
 #include "syscall.h"
-#include "atomic.h"
 #include "pthread_impl.h"
 #include "aio_impl.h"
 
diff --git a/src/aio/aio_suspend.c b/src/aio/aio_suspend.c
index 1f0c9aaa..3baf78d2 100644
--- a/src/aio/aio_suspend.c
+++ b/src/aio/aio_suspend.c
@@ -1,7 +1,6 @@
 #include <aio.h>
 #include <errno.h>
 #include <time.h>
-#include "atomic.h"
 #include "pthread_impl.h"
 #include "aio_impl.h"
 
diff --git a/src/crypt/encrypt.c b/src/crypt/encrypt.c
index 216abc91..f373639f 100644
--- a/src/crypt/encrypt.c
+++ b/src/crypt/encrypt.c
@@ -1,5 +1,4 @@
 #include <stdint.h>
-#include <stdlib.h>
 #include <unistd.h>
 
 #include "crypt_des.h"
diff --git a/src/ctype/__ctype_get_mb_cur_max.c b/src/ctype/__ctype_get_mb_cur_max.c
index 8e946fc1..4b20e81f 100644
--- a/src/ctype/__ctype_get_mb_cur_max.c
+++ b/src/ctype/__ctype_get_mb_cur_max.c
@@ -1,5 +1,4 @@
 #include <stdlib.h>
-#include "locale_impl.h"
 
 size_t __ctype_get_mb_cur_max()
 {
diff --git a/src/env/__init_tls.c b/src/env/__init_tls.c
index a93141ed..17ba228d 100644
--- a/src/env/__init_tls.c
+++ b/src/env/__init_tls.c
@@ -6,7 +6,6 @@
 #include <stddef.h>
 #include "pthread_impl.h"
 #include "libc.h"
-#include "atomic.h"
 #include "syscall.h"
 
 volatile int __thread_list_lock;
diff --git a/src/exit/_Exit.c b/src/exit/_Exit.c
index 7a6115c7..af68b512 100644
--- a/src/exit/_Exit.c
+++ b/src/exit/_Exit.c
@@ -1,4 +1,3 @@
-#include <stdlib.h>
 #include "syscall.h"
 
 _Noreturn void _Exit(int ec)
diff --git a/src/exit/abort.c b/src/exit/abort.c
index f21f458e..52471d80 100644
--- a/src/exit/abort.c
+++ b/src/exit/abort.c
@@ -2,7 +2,6 @@
 #include <signal.h>
 #include "syscall.h"
 #include "pthread_impl.h"
-#include "atomic.h"
 #include "lock.h"
 #include "ksigaction.h"
 
diff --git a/src/exit/exit.c b/src/exit/exit.c
index 17b33cc6..6ecbec3a 100644
--- a/src/exit/exit.c
+++ b/src/exit/exit.c
@@ -2,7 +2,6 @@
 #include <stdint.h>
 #include "libc.h"
 #include "pthread_impl.h"
-#include "atomic.h"
 #include "syscall.h"
 
 static void dummy()
diff --git a/src/ldso/dlerror.c b/src/ldso/dlerror.c
index dae0f3a9..4d983f85 100644
--- a/src/ldso/dlerror.c
+++ b/src/ldso/dlerror.c
@@ -3,7 +3,6 @@
 #include <stdarg.h>
 #include "pthread_impl.h"
 #include "dynlink.h"
-#include "atomic.h"
 
 #define malloc __libc_malloc
 #define calloc __libc_calloc
diff --git a/src/legacy/getloadavg.c b/src/legacy/getloadavg.c
index ff06de0f..99950066 100644
--- a/src/legacy/getloadavg.c
+++ b/src/legacy/getloadavg.c
@@ -1,5 +1,4 @@
 #define _GNU_SOURCE
-#include <stdlib.h>
 #include <sys/sysinfo.h>
 
 int getloadavg(double *a, int n)
diff --git a/src/legacy/getpass.c b/src/legacy/getpass.c
index d51286c0..5a0693e4 100644
--- a/src/legacy/getpass.c
+++ b/src/legacy/getpass.c
@@ -3,7 +3,6 @@
 #include <termios.h>
 #include <unistd.h>
 #include <fcntl.h>
-#include <string.h>
 
 char *getpass(const char *prompt)
 {
diff --git a/src/linux/adjtime.c b/src/linux/adjtime.c
index 5a707f2f..92410b69 100644
--- a/src/linux/adjtime.c
+++ b/src/linux/adjtime.c
@@ -2,7 +2,6 @@
 #include <sys/time.h>
 #include <sys/timex.h>
 #include <errno.h>
-#include "syscall.h"
 
 int adjtime(const struct timeval *in, struct timeval *out)
 {
diff --git a/src/linux/renameat2.c b/src/linux/renameat2.c
index b8060388..76de2b88 100644
--- a/src/linux/renameat2.c
+++ b/src/linux/renameat2.c
@@ -1,5 +1,4 @@
 #define _GNU_SOURCE
-#include <stdio.h>
 #include "syscall.h"
 
 int renameat2(int oldfd, const char *old, int newfd, const char *new, unsigned flags)
diff --git a/src/linux/statx.c b/src/linux/statx.c
index 4fb96e4b..540d2c0a 100644
--- a/src/linux/statx.c
+++ b/src/linux/statx.c
@@ -1,6 +1,5 @@
 #define _GNU_SOURCE
 #include <sys/stat.h>
-#include <string.h>
 #include <syscall.h>
 #include <sys/sysmacros.h>
 #include <errno.h>
diff --git a/src/linux/utimes.c b/src/linux/utimes.c
index 6ca025d9..ccf63fe3 100644
--- a/src/linux/utimes.c
+++ b/src/linux/utimes.c
@@ -1,6 +1,5 @@
 #include <sys/time.h>
 #include "fcntl.h"
-#include "syscall.h"
 
 int utimes(const char *path, const struct timeval times[2])
 {
diff --git a/src/linux/wait3.c b/src/linux/wait3.c
index 61c73594..d3fc529f 100644
--- a/src/linux/wait3.c
+++ b/src/linux/wait3.c
@@ -1,7 +1,6 @@
 #define _GNU_SOURCE
 #include <sys/wait.h>
 #include <sys/resource.h>
-#include "syscall.h"
 
 pid_t wait3(int *status, int options, struct rusage *usage)
 {
diff --git a/src/locale/dcngettext.c b/src/locale/dcngettext.c
index 0b53286d..70c0e6fc 100644
--- a/src/locale/dcngettext.c
+++ b/src/locale/dcngettext.c
@@ -7,7 +7,6 @@
 #include <sys/mman.h>
 #include <ctype.h>
 #include "locale_impl.h"
-#include "atomic.h"
 #include "pleval.h"
 #include "lock.h"
 #include "fork_impl.h"
diff --git a/src/locale/iconv.c b/src/locale/iconv.c
index 7fb2e1ef..4d9b3c1e 100644
--- a/src/locale/iconv.c
+++ b/src/locale/iconv.c
@@ -3,8 +3,6 @@
 #include <wchar.h>
 #include <string.h>
 #include <stdlib.h>
-#include <limits.h>
-#include <stdint.h>
 #include "locale_impl.h"
 
 #define UTF_32BE    0300
diff --git a/src/locale/locale_map.c b/src/locale/locale_map.c
index da61f7fc..3a0f119b 100644
--- a/src/locale/locale_map.c
+++ b/src/locale/locale_map.c
@@ -4,7 +4,6 @@
 #include <stdlib.h>
 #include "locale_impl.h"
 #include "libc.h"
-#include "lock.h"
 #include "fork_impl.h"
 
 #define malloc __libc_malloc
diff --git a/src/locale/strcoll.c b/src/locale/strcoll.c
index dd3cbc48..69d0c8b3 100644
--- a/src/locale/strcoll.c
+++ b/src/locale/strcoll.c
@@ -1,5 +1,4 @@
 #include <string.h>
-#include <locale.h>
 #include "locale_impl.h"
 
 int __strcoll_l(const char *l, const char *r, locale_t loc)
diff --git a/src/locale/strxfrm.c b/src/locale/strxfrm.c
index c66c6203..1c7a474e 100644
--- a/src/locale/strxfrm.c
+++ b/src/locale/strxfrm.c
@@ -1,5 +1,4 @@
 #include <string.h>
-#include <locale.h>
 #include "locale_impl.h"
 
 /* collate only by code points */
diff --git a/src/locale/wcscoll.c b/src/locale/wcscoll.c
index ad2cc691..e28fc0b5 100644
--- a/src/locale/wcscoll.c
+++ b/src/locale/wcscoll.c
@@ -1,5 +1,4 @@
 #include <wchar.h>
-#include <locale.h>
 #include "locale_impl.h"
 
 /* FIXME: stub */
diff --git a/src/locale/wcsxfrm.c b/src/locale/wcsxfrm.c
index 05e3e115..ad4e5456 100644
--- a/src/locale/wcsxfrm.c
+++ b/src/locale/wcsxfrm.c
@@ -1,5 +1,4 @@
 #include <wchar.h>
-#include <locale.h>
 #include "locale_impl.h"
 
 /* collate only by code points */
diff --git a/src/malloc/lite_malloc.c b/src/malloc/lite_malloc.c
index 43a988fb..8c254b04 100644
--- a/src/malloc/lite_malloc.c
+++ b/src/malloc/lite_malloc.c
@@ -1,6 +1,5 @@
 #include <stdlib.h>
 #include <stdint.h>
-#include <limits.h>
 #include <errno.h>
 #include <sys/mman.h>
 #include "libc.h"
diff --git a/src/malloc/mallocng/donate.c b/src/malloc/mallocng/donate.c
index 41d850f3..a461bd33 100644
--- a/src/malloc/mallocng/donate.c
+++ b/src/malloc/mallocng/donate.c
@@ -1,9 +1,7 @@
 #include <stdlib.h>
 #include <stdint.h>
-#include <limits.h>
 #include <string.h>
 #include <sys/mman.h>
-#include <errno.h>
 
 #include "meta.h"
 
diff --git a/src/malloc/mallocng/malloc.c b/src/malloc/mallocng/malloc.c
index d695ab8e..b5bc69b3 100644
--- a/src/malloc/mallocng/malloc.c
+++ b/src/malloc/mallocng/malloc.c
@@ -1,6 +1,5 @@
 #include <stdlib.h>
 #include <stdint.h>
-#include <limits.h>
 #include <string.h>
 #include <sys/mman.h>
 #include <errno.h>
diff --git a/src/misc/a64l.c b/src/misc/a64l.c
index 60557710..e56d9c5b 100644
--- a/src/misc/a64l.c
+++ b/src/misc/a64l.c
@@ -1,4 +1,3 @@
-#include <stdlib.h>
 #include <string.h>
 #include <stdint.h>
 
diff --git a/src/misc/get_current_dir_name.c b/src/misc/get_current_dir_name.c
index 782cddcd..da0a66f0 100644
--- a/src/misc/get_current_dir_name.c
+++ b/src/misc/get_current_dir_name.c
@@ -1,7 +1,6 @@
 #define _GNU_SOURCE
 #include <stdlib.h>
 #include <string.h>
-#include <limits.h>
 #include <unistd.h>
 #include <sys/stat.h>
 
diff --git a/src/misc/getopt_long.c b/src/misc/getopt_long.c
index 6949ab1c..b6bcad63 100644
--- a/src/misc/getopt_long.c
+++ b/src/misc/getopt_long.c
@@ -1,9 +1,7 @@
 #define _GNU_SOURCE
-#include <stddef.h>
 #include <stdlib.h>
 #include <limits.h>
 #include <getopt.h>
-#include <stdio.h>
 #include <string.h>
 #include "stdio_impl.h"
 
diff --git a/src/misc/initgroups.c b/src/misc/initgroups.c
index 101f5c7b..762e711a 100644
--- a/src/misc/initgroups.c
+++ b/src/misc/initgroups.c
@@ -1,6 +1,5 @@
 #define _GNU_SOURCE
 #include <grp.h>
-#include <limits.h>
 #include <stdlib.h>
 
 int initgroups(const char *user, gid_t gid)
diff --git a/src/misc/openpty.c b/src/misc/openpty.c
index c1074060..3b324071 100644
--- a/src/misc/openpty.c
+++ b/src/misc/openpty.c
@@ -1,4 +1,3 @@
-#include <stdlib.h>
 #include <fcntl.h>
 #include <unistd.h>
 #include <pty.h>
diff --git a/src/misc/syslog.c b/src/misc/syslog.c
index 710202f9..b884ffdc 100644
--- a/src/misc/syslog.c
+++ b/src/misc/syslog.c
@@ -4,7 +4,6 @@
 #include <unistd.h>
 #include <syslog.h>
 #include <time.h>
-#include <signal.h>
 #include <string.h>
 #include <pthread.h>
 #include <errno.h>
diff --git a/src/misc/wordexp.c b/src/misc/wordexp.c
index db83a69f..b86221b4 100644
--- a/src/misc/wordexp.c
+++ b/src/misc/wordexp.c
@@ -2,7 +2,6 @@
 #include <unistd.h>
 #include <stdio.h>
 #include <string.h>
-#include <limits.h>
 #include <stdint.h>
 #include <stdlib.h>
 #include <sys/wait.h>
diff --git a/src/mman/mmap.c b/src/mman/mmap.c
index 43e5e029..edb4d274 100644
--- a/src/mman/mmap.c
+++ b/src/mman/mmap.c
@@ -2,7 +2,6 @@
 #include <sys/mman.h>
 #include <errno.h>
 #include <stdint.h>
-#include <limits.h>
 #include "syscall.h"
 
 static void dummy(void) { }
diff --git a/src/mq/mq_getattr.c b/src/mq/mq_getattr.c
index dce18069..9ddb21ae 100644
--- a/src/mq/mq_getattr.c
+++ b/src/mq/mq_getattr.c
@@ -1,5 +1,4 @@
 #include <mqueue.h>
-#include "syscall.h"
 
 int mq_getattr(mqd_t mqd, struct mq_attr *attr)
 {
diff --git a/src/network/dns_parse.c b/src/network/dns_parse.c
index 09813112..5871f43a 100644
--- a/src/network/dns_parse.c
+++ b/src/network/dns_parse.c
@@ -1,4 +1,3 @@
-#include <string.h>
 #include "lookup.h"
 
 int __dns_parse(const unsigned char *r, int rlen, int (*callback)(void *, int, const void *, int, const void *, int), void *ctx)
diff --git a/src/network/gethostbyaddr_r.c b/src/network/gethostbyaddr_r.c
index ceaf3935..91c48c4a 100644
--- a/src/network/gethostbyaddr_r.c
+++ b/src/network/gethostbyaddr_r.c
@@ -5,7 +5,6 @@
 #include <string.h>
 #include <netinet/in.h>
 #include <errno.h>
-#include <inttypes.h>
 
 int gethostbyaddr_r(const void *a, socklen_t l, int af,
 	struct hostent *h, char *buf, size_t buflen,
diff --git a/src/network/gethostbyname.c b/src/network/gethostbyname.c
index bfedf52a..bb8ce058 100644
--- a/src/network/gethostbyname.c
+++ b/src/network/gethostbyname.c
@@ -2,7 +2,6 @@
 
 #include <sys/socket.h>
 #include <netdb.h>
-#include <string.h>
 #include <netinet/in.h>
 
 struct hostent *gethostbyname(const char *name)
diff --git a/src/network/getifaddrs.c b/src/network/getifaddrs.c
index 74df4d6c..3c860c2f 100644
--- a/src/network/getifaddrs.c
+++ b/src/network/getifaddrs.c
@@ -1,5 +1,4 @@
 #define _GNU_SOURCE
-#include <errno.h>
 #include <string.h>
 #include <stdlib.h>
 #include <unistd.h>
diff --git a/src/network/getnameinfo.c b/src/network/getnameinfo.c
index 133c15b3..bcea1d27 100644
--- a/src/network/getnameinfo.c
+++ b/src/network/getnameinfo.c
@@ -1,5 +1,4 @@
 #include <netdb.h>
-#include <limits.h>
 #include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/src/network/getservbyname_r.c b/src/network/getservbyname_r.c
index cad6317a..62d61eda 100644
--- a/src/network/getservbyname_r.c
+++ b/src/network/getservbyname_r.c
@@ -2,7 +2,6 @@
 #include <sys/socket.h>
 #include <netinet/in.h>
 #include <netdb.h>
-#include <inttypes.h>
 #include <errno.h>
 #include <string.h>
 #include <stdlib.h>
diff --git a/src/network/getservbyport_r.c b/src/network/getservbyport_r.c
index e4cc3079..ee1d59c0 100644
--- a/src/network/getservbyport_r.c
+++ b/src/network/getservbyport_r.c
@@ -2,7 +2,6 @@
 #include <sys/socket.h>
 #include <netinet/in.h>
 #include <netdb.h>
-#include <inttypes.h>
 #include <errno.h>
 #include <string.h>
 #include <stdlib.h>
diff --git a/src/network/lookup_name.c b/src/network/lookup_name.c
index 35218185..98f04eaa 100644
--- a/src/network/lookup_name.c
+++ b/src/network/lookup_name.c
@@ -13,7 +13,6 @@
 #include <resolv.h>
 #include "lookup.h"
 #include "stdio_impl.h"
-#include "syscall.h"
 
 static int is_valid_hostname(const char *host)
 {
diff --git a/src/network/netlink.c b/src/network/netlink.c
index 94dba7f5..191c7949 100644
--- a/src/network/netlink.c
+++ b/src/network/netlink.c
@@ -1,4 +1,3 @@
-#include <errno.h>
 #include <string.h>
 #include <syscall.h>
 #include <sys/socket.h>
diff --git a/src/network/recvmsg.c b/src/network/recvmsg.c
index 03641625..ac1277e5 100644
--- a/src/network/recvmsg.c
+++ b/src/network/recvmsg.c
@@ -1,6 +1,5 @@
 #include <sys/socket.h>
 #include <limits.h>
-#include <time.h>
 #include <sys/time.h>
 #include <string.h>
 #include "syscall.h"
diff --git a/src/network/res_msend.c b/src/network/res_msend.c
index 86c2fcf4..08af7e04 100644
--- a/src/network/res_msend.c
+++ b/src/network/res_msend.c
@@ -7,11 +7,9 @@
 #include <string.h>
 #include <poll.h>
 #include <time.h>
-#include <ctype.h>
 #include <unistd.h>
 #include <errno.h>
 #include <pthread.h>
-#include "stdio_impl.h"
 #include "syscall.h"
 #include "lookup.h"
 
diff --git a/src/network/sendmmsg.c b/src/network/sendmmsg.c
index eeae1d0a..5804feec 100644
--- a/src/network/sendmmsg.c
+++ b/src/network/sendmmsg.c
@@ -1,7 +1,6 @@
 #define _GNU_SOURCE
 #include <sys/socket.h>
 #include <limits.h>
-#include <errno.h>
 #include "syscall.h"
 
 int sendmmsg(int fd, struct mmsghdr *msgvec, unsigned int vlen, unsigned int flags)
diff --git a/src/passwd/getgrouplist.c b/src/passwd/getgrouplist.c
index 301824ce..86f08213 100644
--- a/src/passwd/getgrouplist.c
+++ b/src/passwd/getgrouplist.c
@@ -2,7 +2,6 @@
 #include "pwf.h"
 #include <grp.h>
 #include <string.h>
-#include <limits.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <byteswap.h>
diff --git a/src/passwd/getspnam_r.c b/src/passwd/getspnam_r.c
index 541e8531..0944dec5 100644
--- a/src/passwd/getspnam_r.c
+++ b/src/passwd/getspnam_r.c
@@ -1,7 +1,6 @@
 #include <fcntl.h>
 #include <unistd.h>
 #include <sys/stat.h>
-#include <ctype.h>
 #include <pthread.h>
 #include "pwf.h"
 
diff --git a/src/prng/drand48.c b/src/prng/drand48.c
index 08283e24..4f638396 100644
--- a/src/prng/drand48.c
+++ b/src/prng/drand48.c
@@ -1,5 +1,3 @@
-#include <stdlib.h>
-#include <inttypes.h>
 #include "rand48.h"
 
 double erand48(unsigned short s[3])
diff --git a/src/prng/lcong48.c b/src/prng/lcong48.c
index 030e5148..5790ec78 100644
--- a/src/prng/lcong48.c
+++ b/src/prng/lcong48.c
@@ -1,4 +1,3 @@
-#include <stdlib.h>
 #include <string.h>
 #include "rand48.h"
 
diff --git a/src/prng/lrand48.c b/src/prng/lrand48.c
index 07e2b784..9a8ac8f8 100644
--- a/src/prng/lrand48.c
+++ b/src/prng/lrand48.c
@@ -1,5 +1,3 @@
-#include <stdlib.h>
-#include <inttypes.h>
 #include "rand48.h"
 
 long nrand48(unsigned short s[3])
diff --git a/src/prng/mrand48.c b/src/prng/mrand48.c
index f4a56e61..cf3cc08c 100644
--- a/src/prng/mrand48.c
+++ b/src/prng/mrand48.c
@@ -1,5 +1,3 @@
-#include <stdlib.h>
-#include <inttypes.h>
 #include "rand48.h"
 
 long jrand48(unsigned short s[3])
diff --git a/src/prng/rand_r.c b/src/prng/rand_r.c
index 638614c8..a8f82055 100644
--- a/src/prng/rand_r.c
+++ b/src/prng/rand_r.c
@@ -1,4 +1,3 @@
-#include <stdlib.h>
 
 static unsigned temper(unsigned x)
 {
diff --git a/src/prng/seed48.c b/src/prng/seed48.c
index bce7b339..957b0072 100644
--- a/src/prng/seed48.c
+++ b/src/prng/seed48.c
@@ -1,4 +1,3 @@
-#include <stdlib.h>
 #include <string.h>
 #include "rand48.h"
 
diff --git a/src/process/posix_spawn_file_actions_addfchdir.c b/src/process/posix_spawn_file_actions_addfchdir.c
index e89ede8c..1fe0049d 100644
--- a/src/process/posix_spawn_file_actions_addfchdir.c
+++ b/src/process/posix_spawn_file_actions_addfchdir.c
@@ -1,6 +1,5 @@
 #include <spawn.h>
 #include <stdlib.h>
-#include <string.h>
 #include <errno.h>
 #include "fdop.h"
 
diff --git a/src/regex/fnmatch.c b/src/regex/fnmatch.c
index 978fff88..9e908520 100644
--- a/src/regex/fnmatch.c
+++ b/src/regex/fnmatch.c
@@ -18,7 +18,6 @@
 #include <stdlib.h>
 #include <wchar.h>
 #include <wctype.h>
-#include "locale_impl.h"
 
 #define END 0
 #define UNMATCHABLE -2
diff --git a/src/regex/regcomp.c b/src/regex/regcomp.c
index fb24556e..3f49c20f 100644
--- a/src/regex/regcomp.c
+++ b/src/regex/regcomp.c
@@ -33,7 +33,6 @@
 #include <stdlib.h>
 #include <regex.h>
 #include <limits.h>
-#include <stdint.h>
 #include <ctype.h>
 
 #include "tre.h"
diff --git a/src/regex/regexec.c b/src/regex/regexec.c
index 253b0e14..c8cd48d7 100644
--- a/src/regex/regexec.c
+++ b/src/regex/regexec.c
@@ -32,7 +32,6 @@
 #include <stdlib.h>
 #include <string.h>
 #include <wchar.h>
-#include <wctype.h>
 #include <limits.h>
 #include <stdint.h>
 
diff --git a/src/sched/sched_getcpu.c b/src/sched/sched_getcpu.c
index 4ec5eaf6..faff6211 100644
--- a/src/sched/sched_getcpu.c
+++ b/src/sched/sched_getcpu.c
@@ -2,7 +2,6 @@
 #include <errno.h>
 #include <sched.h>
 #include "syscall.h"
-#include "atomic.h"
 
 #ifdef VDSO_GETCPU_SYM
 
diff --git a/src/select/poll.c b/src/select/poll.c
index 7883dfab..4f3e64fb 100644
--- a/src/select/poll.c
+++ b/src/select/poll.c
@@ -1,5 +1,4 @@
 #include <poll.h>
-#include <time.h>
 #include <signal.h>
 #include "syscall.h"
 
diff --git a/src/select/select.c b/src/select/select.c
index f1d72863..4e546822 100644
--- a/src/select/select.c
+++ b/src/select/select.c
@@ -1,6 +1,5 @@
 #include <sys/select.h>
 #include <signal.h>
-#include <stdint.h>
 #include <errno.h>
 #include "syscall.h"
 
diff --git a/src/signal/block.c b/src/signal/block.c
index cc8698f0..4ee37f73 100644
--- a/src/signal/block.c
+++ b/src/signal/block.c
@@ -1,4 +1,3 @@
-#include "pthread_impl.h"
 #include "syscall.h"
 #include <signal.h>
 
diff --git a/src/signal/psignal.c b/src/signal/psignal.c
index 138dbe00..6dd18422 100644
--- a/src/signal/psignal.c
+++ b/src/signal/psignal.c
@@ -1,6 +1,5 @@
 #include "stdio_impl.h"
 #include <string.h>
-#include <signal.h>
 #include <errno.h>
 
 void psignal(int sig, const char *msg)
diff --git a/src/signal/raise.c b/src/signal/raise.c
index f0512019..6277d2d7 100644
--- a/src/signal/raise.c
+++ b/src/signal/raise.c
@@ -1,5 +1,4 @@
 #include <signal.h>
-#include <stdint.h>
 #include "syscall.h"
 #include "pthread_impl.h"
 
diff --git a/src/signal/sigemptyset.c b/src/signal/sigemptyset.c
index 1d07471d..2e52ab25 100644
--- a/src/signal/sigemptyset.c
+++ b/src/signal/sigemptyset.c
@@ -1,5 +1,4 @@
 #include <signal.h>
-#include <string.h>
 
 int sigemptyset(sigset_t *set)
 {
diff --git a/src/signal/siglongjmp.c b/src/signal/siglongjmp.c
index 53789b23..3d06a00e 100644
--- a/src/signal/siglongjmp.c
+++ b/src/signal/siglongjmp.c
@@ -1,7 +1,4 @@
 #include <setjmp.h>
-#include <signal.h>
-#include "syscall.h"
-#include "pthread_impl.h"
 
 _Noreturn void siglongjmp(sigjmp_buf buf, int ret)
 {
diff --git a/src/signal/signal.c b/src/signal/signal.c
index 7a6dd172..2b20c6fa 100644
--- a/src/signal/signal.c
+++ b/src/signal/signal.c
@@ -1,5 +1,4 @@
 #include <signal.h>
-#include "syscall.h"
 
 void (*signal(int sig, void (*func)(int)))(int)
 {
diff --git a/src/signal/sigqueue.c b/src/signal/sigqueue.c
index b75f0c5c..d1922d40 100644
--- a/src/signal/sigqueue.c
+++ b/src/signal/sigqueue.c
@@ -2,7 +2,6 @@
 #include <string.h>
 #include <unistd.h>
 #include "syscall.h"
-#include "pthread_impl.h"
 
 int sigqueue(pid_t pid, int sig, const union sigval value)
 {
diff --git a/src/signal/sigrtmin.c b/src/signal/sigrtmin.c
index c5a1fd92..e0dabd52 100644
--- a/src/signal/sigrtmin.c
+++ b/src/signal/sigrtmin.c
@@ -1,4 +1,3 @@
-#include <signal.h>
 
 int __libc_current_sigrtmin()
 {
diff --git a/src/stat/fstatat.c b/src/stat/fstatat.c
index 9eed063b..e740fae7 100644
--- a/src/stat/fstatat.c
+++ b/src/stat/fstatat.c
@@ -1,6 +1,5 @@
 #define _BSD_SOURCE
 #include <sys/stat.h>
-#include <string.h>
 #include <fcntl.h>
 #include <errno.h>
 #include <stdint.h>
diff --git a/src/stdio/funlockfile.c b/src/stdio/funlockfile.c
index 44d8b0df..76bbd6cc 100644
--- a/src/stdio/funlockfile.c
+++ b/src/stdio/funlockfile.c
@@ -1,5 +1,4 @@
 #include "stdio_impl.h"
-#include "pthread_impl.h"
 
 void funlockfile(FILE *f)
 {
diff --git a/src/stdio/gets.c b/src/stdio/gets.c
index 17963b93..94dc19bf 100644
--- a/src/stdio/gets.c
+++ b/src/stdio/gets.c
@@ -1,5 +1,4 @@
 #include "stdio_impl.h"
-#include <limits.h>
 #include <string.h>
 
 char *gets(char *s)
diff --git a/src/stdio/getwc.c b/src/stdio/getwc.c
index a5008f0e..7195cea4 100644
--- a/src/stdio/getwc.c
+++ b/src/stdio/getwc.c
@@ -1,4 +1,3 @@
-#include "stdio_impl.h"
 #include <wchar.h>
 
 wint_t getwc(FILE *f)
diff --git a/src/stdio/putwc.c b/src/stdio/putwc.c
index 4bb74733..b8253a37 100644
--- a/src/stdio/putwc.c
+++ b/src/stdio/putwc.c
@@ -1,4 +1,3 @@
-#include "stdio_impl.h"
 #include <wchar.h>
 
 wint_t putwc(wchar_t c, FILE *f)
diff --git a/src/stdio/vfscanf.c b/src/stdio/vfscanf.c
index b78a374d..da091ed3 100644
--- a/src/stdio/vfscanf.c
+++ b/src/stdio/vfscanf.c
@@ -2,7 +2,6 @@
 #include <stdarg.h>
 #include <ctype.h>
 #include <wchar.h>
-#include <wctype.h>
 #include <limits.h>
 #include <string.h>
 #include <stdint.h>
diff --git a/src/stdio/vfwscanf.c b/src/stdio/vfwscanf.c
index 82f48604..3f95d7ea 100644
--- a/src/stdio/vfwscanf.c
+++ b/src/stdio/vfwscanf.c
@@ -1,16 +1,12 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdarg.h>
-#include <ctype.h>
 #include <wchar.h>
 #include <wctype.h>
-#include <limits.h>
 #include <string.h>
 
 #include "stdio_impl.h"
 #include "shgetc.h"
-#include "intscan.h"
-#include "floatscan.h"
 
 #define SIZE_hh -2
 #define SIZE_h  -1
diff --git a/src/stdio/vscanf.c b/src/stdio/vscanf.c
index 9d46ab09..48d78dc3 100644
--- a/src/stdio/vscanf.c
+++ b/src/stdio/vscanf.c
@@ -1,5 +1,4 @@
 #include <stdio.h>
-#include <stdarg.h>
 
 int vscanf(const char *restrict fmt, va_list ap)
 {
diff --git a/src/stdio/vsnprintf.c b/src/stdio/vsnprintf.c
index 409b9c85..4418f752 100644
--- a/src/stdio/vsnprintf.c
+++ b/src/stdio/vsnprintf.c
@@ -1,8 +1,5 @@
 #include "stdio_impl.h"
-#include <limits.h>
 #include <string.h>
-#include <errno.h>
-#include <stdint.h>
 
 struct cookie {
 	char *s;
diff --git a/src/stdio/vswprintf.c b/src/stdio/vswprintf.c
index 5e9a4dad..bd7a7326 100644
--- a/src/stdio/vswprintf.c
+++ b/src/stdio/vswprintf.c
@@ -1,7 +1,4 @@
 #include "stdio_impl.h"
-#include <limits.h>
-#include <errno.h>
-#include <stdint.h>
 #include <stdlib.h>
 #include <wchar.h>
 
diff --git a/src/stdio/vwscanf.c b/src/stdio/vwscanf.c
index 5a3931e1..f14f4e37 100644
--- a/src/stdio/vwscanf.c
+++ b/src/stdio/vwscanf.c
@@ -1,5 +1,4 @@
 #include <stdio.h>
-#include <stdarg.h>
 #include <wchar.h>
 
 int vwscanf(const wchar_t *restrict fmt, va_list ap)
diff --git a/src/stdlib/gcvt.c b/src/stdlib/gcvt.c
index f29bc304..5bff1f54 100644
--- a/src/stdlib/gcvt.c
+++ b/src/stdlib/gcvt.c
@@ -1,5 +1,4 @@
 #define _GNU_SOURCE
-#include <stdlib.h>
 #include <stdio.h>
 
 char *gcvt(double x, int n, char *b)
diff --git a/src/stdlib/qsort.c b/src/stdlib/qsort.c
index ab79dc6f..8e2a3e29 100644
--- a/src/stdlib/qsort.c
+++ b/src/stdlib/qsort.c
@@ -25,7 +25,6 @@
    Run time: Worst case O(n log n), close to O(n) in the mostly-sorted case. */
 
 #define _BSD_SOURCE
-#include <stdint.h>
 #include <stdlib.h>
 #include <string.h>
 
diff --git a/src/stdlib/strtod.c b/src/stdlib/strtod.c
index 39b9daad..50745037 100644
--- a/src/stdlib/strtod.c
+++ b/src/stdlib/strtod.c
@@ -1,7 +1,6 @@
 #include <stdlib.h>
 #include "shgetc.h"
 #include "floatscan.h"
-#include "stdio_impl.h"
 
 static long double strtox(const char *s, char **p, int prec)
 {
diff --git a/src/stdlib/strtol.c b/src/stdlib/strtol.c
index bfefea69..e632932d 100644
--- a/src/stdlib/strtol.c
+++ b/src/stdlib/strtol.c
@@ -1,9 +1,7 @@
-#include "stdio_impl.h"
 #include "intscan.h"
 #include "shgetc.h"
 #include <inttypes.h>
 #include <limits.h>
-#include <ctype.h>
 
 static unsigned long long strtox(const char *s, char **p, int base, unsigned long long lim)
 {
diff --git a/src/stdlib/wcstod.c b/src/stdlib/wcstod.c
index 0deb7010..05acf165 100644
--- a/src/stdlib/wcstod.c
+++ b/src/stdlib/wcstod.c
@@ -1,6 +1,5 @@
 #include "shgetc.h"
 #include "floatscan.h"
-#include "stdio_impl.h"
 #include <wchar.h>
 #include <wctype.h>
 
diff --git a/src/stdlib/wcstol.c b/src/stdlib/wcstol.c
index 1eeb495f..5d27ebd2 100644
--- a/src/stdlib/wcstol.c
+++ b/src/stdlib/wcstol.c
@@ -1,4 +1,3 @@
-#include "stdio_impl.h"
 #include "intscan.h"
 #include "shgetc.h"
 #include <inttypes.h>
diff --git a/src/string/strsignal.c b/src/string/strsignal.c
index 5156366e..9a22d0af 100644
--- a/src/string/strsignal.c
+++ b/src/string/strsignal.c
@@ -1,5 +1,4 @@
 #include <signal.h>
-#include <string.h>
 #include "locale_impl.h"
 
 #if (SIGHUP == 1) && (SIGINT == 2) && (SIGQUIT == 3) && (SIGILL == 4) \
diff --git a/src/string/wcscasecmp.c b/src/string/wcscasecmp.c
index 3edeec7d..acc44a02 100644
--- a/src/string/wcscasecmp.c
+++ b/src/string/wcscasecmp.c
@@ -1,5 +1,4 @@
 #include <wchar.h>
-#include <wctype.h>
 
 int wcscasecmp(const wchar_t *l, const wchar_t *r)
 {
diff --git a/src/temp/__randname.c b/src/temp/__randname.c
index e9b970f1..36963acf 100644
--- a/src/temp/__randname.c
+++ b/src/temp/__randname.c
@@ -1,5 +1,4 @@
 #include <time.h>
-#include <stdint.h>
 #include "pthread_impl.h"
 
 /* This assumes that a check for the
diff --git a/src/thread/__syscall_cp.c b/src/thread/__syscall_cp.c
index 42a01674..d37f57ef 100644
--- a/src/thread/__syscall_cp.c
+++ b/src/thread/__syscall_cp.c
@@ -1,4 +1,3 @@
-#include "pthread_impl.h"
 #include "syscall.h"
 
 hidden long __syscall_cp_c();
diff --git a/src/thread/__unmapself.c b/src/thread/__unmapself.c
index 31d94e67..9b6eb909 100644
--- a/src/thread/__unmapself.c
+++ b/src/thread/__unmapself.c
@@ -1,5 +1,4 @@
 #include "pthread_impl.h"
-#include "atomic.h"
 #include "syscall.h"
 /* cheat and reuse CRTJMP macro from dynlink code */
 #include "dynlink.h"
diff --git a/src/time/asctime_r.c b/src/time/asctime_r.c
index 26809ca2..9bf9912f 100644
--- a/src/time/asctime_r.c
+++ b/src/time/asctime_r.c
@@ -2,7 +2,6 @@
 #include <stdio.h>
 #include <langinfo.h>
 #include "locale_impl.h"
-#include "atomic.h"
 
 char *__asctime_r(const struct tm *restrict tm, char *restrict buf)
 {
diff --git a/src/time/clock_gettime.c b/src/time/clock_gettime.c
index 4d2ec22f..003d3467 100644
--- a/src/time/clock_gettime.c
+++ b/src/time/clock_gettime.c
@@ -1,6 +1,5 @@
 #include <time.h>
 #include <errno.h>
-#include <stdint.h>
 #include "syscall.h"
 #include "atomic.h"
 
diff --git a/src/time/gettimeofday.c b/src/time/gettimeofday.c
index 691f8e90..6fc88959 100644
--- a/src/time/gettimeofday.c
+++ b/src/time/gettimeofday.c
@@ -1,6 +1,5 @@
 #include <time.h>
 #include <sys/time.h>
-#include "syscall.h"
 
 int gettimeofday(struct timeval *restrict tv, void *restrict tz)
 {
diff --git a/src/time/gmtime.c b/src/time/gmtime.c
index 6320b637..a4610e51 100644
--- a/src/time/gmtime.c
+++ b/src/time/gmtime.c
@@ -1,5 +1,4 @@
 #include "time_impl.h"
-#include <errno.h>
 
 struct tm *gmtime(const time_t *t)
 {
diff --git a/src/time/strftime.c b/src/time/strftime.c
index c40246db..249af2ca 100644
--- a/src/time/strftime.c
+++ b/src/time/strftime.c
@@ -2,7 +2,6 @@
 #include <stdlib.h>
 #include <string.h>
 #include <langinfo.h>
-#include <locale.h>
 #include <ctype.h>
 #include <time.h>
 #include <limits.h>
diff --git a/src/time/time.c b/src/time/time.c
index ad0480f9..cec1ca36 100644
--- a/src/time/time.c
+++ b/src/time/time.c
@@ -1,5 +1,4 @@
 #include <time.h>
-#include "syscall.h"
 
 time_t time(time_t *t)
 {
diff --git a/src/time/timer_create.c b/src/time/timer_create.c
index 424c70b7..30d5c296 100644
--- a/src/time/timer_create.c
+++ b/src/time/timer_create.c
@@ -3,7 +3,6 @@
 #include <limits.h>
 #include <semaphore.h>
 #include "pthread_impl.h"
-#include "atomic.h"
 
 struct ksigevent {
 	union sigval sigev_value;
diff --git a/src/time/wcsftime.c b/src/time/wcsftime.c
index 8e1437b3..4c865e5f 100644
--- a/src/time/wcsftime.c
+++ b/src/time/wcsftime.c
@@ -1,6 +1,5 @@
 #include <wchar.h>
 #include <time.h>
-#include <locale.h>
 #include "locale_impl.h"
 #include "time_impl.h"
 
diff --git a/src/unistd/alarm.c b/src/unistd/alarm.c
index a5e0c822..adc99bb2 100644
--- a/src/unistd/alarm.c
+++ b/src/unistd/alarm.c
@@ -1,6 +1,5 @@
 #include <unistd.h>
 #include <sys/time.h>
-#include "syscall.h"
 
 unsigned alarm(unsigned seconds)
 {
diff --git a/src/unistd/ctermid.c b/src/unistd/ctermid.c
index 1612770a..0ac24315 100644
--- a/src/unistd/ctermid.c
+++ b/src/unistd/ctermid.c
@@ -1,4 +1,3 @@
-#include <stdio.h>
 #include <string.h>
 
 char *ctermid(char *s)
diff --git a/src/unistd/isatty.c b/src/unistd/isatty.c
index 21222eda..87c2ab04 100644
--- a/src/unistd/isatty.c
+++ b/src/unistd/isatty.c
@@ -1,5 +1,4 @@
 #include <unistd.h>
-#include <errno.h>
 #include <sys/ioctl.h>
 #include "syscall.h"
 
diff --git a/src/unistd/nice.c b/src/unistd/nice.c
index 1c2295ff..a6cee35d 100644
--- a/src/unistd/nice.c
+++ b/src/unistd/nice.c
@@ -2,7 +2,6 @@
 #include <errno.h>
 #include <sys/resource.h>
 #include <limits.h>
-#include "syscall.h"
 
 int nice(int inc)
 {
diff --git a/src/unistd/renameat.c b/src/unistd/renameat.c
index c3b40a25..605429a4 100644
--- a/src/unistd/renameat.c
+++ b/src/unistd/renameat.c
@@ -1,4 +1,3 @@
-#include <stdio.h>
 #include "syscall.h"
 
 int renameat(int oldfd, const char *old, int newfd, const char *new)
-- 
2.34.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [musl] [PATCH] cleanup unused include headers
  2025-01-10 14:44 [musl] [PATCH] cleanup unused include headers Abhisit Sangjan
@ 2025-01-11  8:46 ` Rich Felker
  0 siblings, 0 replies; 2+ messages in thread
From: Rich Felker @ 2025-01-11  8:46 UTC (permalink / raw)
  To: Abhisit Sangjan; +Cc: musl

Could you explain the methodology and motivation for this patch? As
submitted it's incorrect and breaking (see inline comments below) -
seems untested. Testing for such a patch would involved comparing .o
files before and after and checking that they're identical, since
presumably this patch is not intended to alter codegen.

Aside from breaking changes though, there are two non-functional
principles this patch seems to be violating:

1. All source files for public interfaces include the public header
for the interface. This is to ensure the compiler checks that the
implementatin signature matches the public signature. Many files will
build fine with the include removed, but then the checking is lost.

2. All files are expected to directly include the headaer declaring
any interfaces they need, not assume another header has indirectly
included it. For example pthread_impl.h included atomic.h probably for
historical reasons (I think at one point it had inline functions using
it), but this should be treated as an implementation detail, and we
should be able to remove that if it's no longer needed, without
breaking other files.

See further below:

On Fri, Jan 10, 2025 at 09:44:00PM +0700, Abhisit Sangjan wrote:
> diff --git a/compat/time32/adjtime32.c b/compat/time32/adjtime32.c
> index b0042c63..10b52779 100644
> --- a/compat/time32/adjtime32.c
> +++ b/compat/time32/adjtime32.c
> @@ -1,6 +1,5 @@
>  #define _GNU_SOURCE
>  #include "time32.h"
> -#include <time.h>
>  #include <sys/time.h>
>  #include <sys/timex.h>

These time32 changes may be ok for interfaces not declared in or using
time.h.

> diff --git a/crt/crt1.c b/crt/crt1.c
> index 10601215..d024df1a 100644
> --- a/crt/crt1.c
> +++ b/crt/crt1.c
> @@ -1,5 +1,4 @@
>  #include <features.h>
> -#include "libc.h"
>  
>  #define START "_start"
>  
> diff --git a/ldso/dlstart.c b/ldso/dlstart.c
> index 259f5e18..287e0bac 100644
> --- a/ldso/dlstart.c
> +++ b/ldso/dlstart.c
> @@ -1,6 +1,5 @@
>  #include <stddef.h>
>  #include "dynlink.h"
> -#include "libc.h"
>  
>  #ifndef START
>  #define START "_dlstart"

These might be ok, worth checking. Some things were probably missed in
the last round of removing unnecessary libc.h inclusion.

> diff --git a/src/ctype/__ctype_get_mb_cur_max.c b/src/ctype/__ctype_get_mb_cur_max.c
> index 8e946fc1..4b20e81f 100644
> --- a/src/ctype/__ctype_get_mb_cur_max.c
> +++ b/src/ctype/__ctype_get_mb_cur_max.c
> @@ -1,5 +1,4 @@
>  #include <stdlib.h>
> -#include "locale_impl.h"
>  
>  size_t __ctype_get_mb_cur_max()
>  {

This was the first flagrantly breaking change I noticed. It converts
__ctype_get_mb_cur_max() into an infinitely recursive call to itself.

> diff --git a/src/linux/statx.c b/src/linux/statx.c
> index 4fb96e4b..540d2c0a 100644
> --- a/src/linux/statx.c
> +++ b/src/linux/statx.c
> @@ -1,6 +1,5 @@
>  #define _GNU_SOURCE
>  #include <sys/stat.h>
> -#include <string.h>
>  #include <syscall.h>
>  #include <sys/sysmacros.h>
>  #include <errno.h>

This is probably right. Leftover from a removed memset.

> diff --git a/src/malloc/mallocng/malloc.c b/src/malloc/mallocng/malloc.c
> index d695ab8e..b5bc69b3 100644
> --- a/src/malloc/mallocng/malloc.c
> +++ b/src/malloc/mallocng/malloc.c
> @@ -1,6 +1,5 @@
>  #include <stdlib.h>
>  #include <stdint.h>
> -#include <limits.h>
>  #include <string.h>
>  #include <sys/mman.h>
>  #include <errno.h>

This breaks use of malloc.c in contexts outside of musl with musl's
glue.h

I haven't reviewed the remainder in detail. If you'd like to pursue
this further, please submit a patch that doesn't make functional
changes and that follow the two principles above.

Rich

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-01-11  8:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-01-10 14:44 [musl] [PATCH] cleanup unused include headers Abhisit Sangjan
2025-01-11  8:46 ` Rich Felker

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).