aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2018-09-12 00:08:09 -0400
committerRich Felker <dalias@aerifal.cx>2018-09-12 14:34:37 -0400
commit5ce3737931bb411a8d167356d4d0287b53b0cbdc (patch)
tree726fc5dde9cc462316faa715158c38f0da72292d /src
parent0676c3a34c7bf12b33f8f5efb92476f4ffc7f20e (diff)
downloadmusl-5ce3737931bb411a8d167356d4d0287b53b0cbdc.zip
musl-5ce3737931bb411a8d167356d4d0287b53b0cbdc.tar.gz
musl-5ce3737931bb411a8d167356d4d0287b53b0cbdc.tar.bz2
reduce spurious inclusion of libc.h
libc.h was intended to be a header for access to global libc state and related interfaces, but ended up included all over the place because it was the way to get the weak_alias macro. most of the inclusions removed here are places where weak_alias was needed. a few were recently introduced for hidden. some go all the way back to when libc.h defined CANCELPT_BEGIN and _END, and all (wrongly implemented) cancellation points had to include it. remaining spurious users are mostly callers of the LOCK/UNLOCK macros and files that use the LFS64 macro to define the awful *64 aliases. in a few places, new inclusion of libc.h is added because several internal headers no longer implicitly include libc.h. declarations for __lockfile and __unlockfile are moved from libc.h to stdio_impl.h so that the latter does not need libc.h. putting them in libc.h made no sense at all, since the macros in stdio_impl.h are needed to use them correctly anyway.
Diffstat (limited to 'src')
-rw-r--r--src/aio/aio.c1
-rw-r--r--src/aio/aio_suspend.c1
-rw-r--r--src/aio/lio_listio.c1
-rw-r--r--src/conf/sysconf.c1
-rw-r--r--src/crypt/crypt_r.c1
-rw-r--r--src/ctype/isalnum.c1
-rw-r--r--src/ctype/isalpha.c1
-rw-r--r--src/ctype/isblank.c1
-rw-r--r--src/ctype/iscntrl.c1
-rw-r--r--src/ctype/isdigit.c1
-rw-r--r--src/ctype/isgraph.c1
-rw-r--r--src/ctype/islower.c1
-rw-r--r--src/ctype/isprint.c1
-rw-r--r--src/ctype/ispunct.c1
-rw-r--r--src/ctype/isspace.c1
-rw-r--r--src/ctype/isupper.c1
-rw-r--r--src/ctype/iswalnum.c1
-rw-r--r--src/ctype/iswalpha.c1
-rw-r--r--src/ctype/iswblank.c1
-rw-r--r--src/ctype/iswcntrl.c1
-rw-r--r--src/ctype/iswctype.c1
-rw-r--r--src/ctype/iswdigit.c1
-rw-r--r--src/ctype/iswgraph.c1
-rw-r--r--src/ctype/iswlower.c1
-rw-r--r--src/ctype/iswprint.c1
-rw-r--r--src/ctype/iswpunct.c1
-rw-r--r--src/ctype/iswspace.c1
-rw-r--r--src/ctype/iswupper.c1
-rw-r--r--src/ctype/iswxdigit.c1
-rw-r--r--src/ctype/isxdigit.c1
-rw-r--r--src/ctype/tolower.c1
-rw-r--r--src/ctype/toupper.c1
-rw-r--r--src/ctype/towctrans.c2
-rw-r--r--src/ctype/wctrans.c1
-rw-r--r--src/dirent/closedir.c2
-rw-r--r--src/env/__environ.c2
-rw-r--r--src/env/clearenv.c1
-rw-r--r--src/env/getenv.c1
-rw-r--r--src/env/putenv.c1
-rw-r--r--src/env/unsetenv.c1
-rw-r--r--src/errno/strerror.c1
-rw-r--r--src/fcntl/fcntl.c1
-rw-r--r--src/fenv/fesetround.c2
-rw-r--r--src/fenv/m68k/fenv.c2
-rw-r--r--src/fenv/powerpc64/fenv.c2
-rw-r--r--src/fenv/s390x/fenv.c2
-rw-r--r--src/internal/dynlink.h2
-rw-r--r--src/internal/fdpic_crt.h2
-rw-r--r--src/internal/libc.h2
-rw-r--r--src/internal/malloc_impl.h1
-rw-r--r--src/internal/sh/__shcall.c2
-rw-r--r--src/internal/stdio_impl.h4
-rw-r--r--src/internal/syscall.h2
-rw-r--r--src/ipc/msgrcv.c1
-rw-r--r--src/ipc/msgsnd.c1
-rw-r--r--src/ldso/__dlsym.c1
-rw-r--r--src/ldso/dladdr.c1
-rw-r--r--src/ldso/dlclose.c1
-rw-r--r--src/ldso/dlerror.c1
-rw-r--r--src/ldso/dlinfo.c1
-rw-r--r--src/ldso/dlopen.c1
-rw-r--r--src/ldso/tlsdesc.c1
-rw-r--r--src/legacy/euidaccess.c1
-rw-r--r--src/legacy/utmpx.c1
-rw-r--r--src/linux/cache.c1
-rw-r--r--src/linux/getdents.c2
-rw-r--r--src/linux/setfsgid.c1
-rw-r--r--src/linux/setfsuid.c1
-rw-r--r--src/linux/sysinfo.c1
-rw-r--r--src/linux/x32/sysinfo.c1
-rw-r--r--src/locale/__lctrans.c1
-rw-r--r--src/locale/dcngettext.c1
-rw-r--r--src/locale/freelocale.c1
-rw-r--r--src/locale/langinfo.c1
-rw-r--r--src/locale/newlocale.c1
-rw-r--r--src/locale/strcoll.c1
-rw-r--r--src/locale/strxfrm.c1
-rw-r--r--src/locale/textdomain.c2
-rw-r--r--src/locale/wcscoll.c1
-rw-r--r--src/locale/wcsxfrm.c1
-rw-r--r--src/malloc/memalign.c1
-rw-r--r--src/math/exp10.c1
-rw-r--r--src/math/exp10f.c1
-rw-r--r--src/math/exp10l.c1
-rw-r--r--src/math/lgamma_r.c1
-rw-r--r--src/math/lgammaf_r.c1
-rw-r--r--src/math/lgammal.c1
-rw-r--r--src/math/remainder.c1
-rw-r--r--src/math/remainderf.c1
-rw-r--r--src/math/signgam.c1
-rw-r--r--src/misc/basename.c1
-rw-r--r--src/misc/getopt.c1
-rw-r--r--src/misc/pty.c1
-rw-r--r--src/mman/madvise.c1
-rw-r--r--src/mman/mremap.c1
-rw-r--r--src/mman/munmap.c1
-rw-r--r--src/multibyte/internal.h2
-rw-r--r--src/network/accept.c1
-rw-r--r--src/network/accept4.c1
-rw-r--r--src/network/connect.c1
-rw-r--r--src/network/dn_expand.c1
-rw-r--r--src/network/ent.c1
-rw-r--r--src/network/getnameinfo.c1
-rw-r--r--src/network/inet_aton.c2
-rw-r--r--src/network/lookup_serv.c1
-rw-r--r--src/network/recvfrom.c1
-rw-r--r--src/network/recvmsg.c1
-rw-r--r--src/network/res_mkquery.c1
-rw-r--r--src/network/res_query.c1
-rw-r--r--src/network/res_send.c1
-rw-r--r--src/network/resolvconf.c1
-rw-r--r--src/network/sendmsg.c1
-rw-r--r--src/network/sendto.c1
-rw-r--r--src/passwd/pwf.h2
-rw-r--r--src/process/execvp.c1
-rw-r--r--src/process/posix_spawn.c1
-rw-r--r--src/process/system.c1
-rw-r--r--src/process/waitid.c1
-rw-r--r--src/process/waitpid.c1
-rw-r--r--src/search/hsearch.c1
-rw-r--r--src/select/poll.c1
-rw-r--r--src/select/pselect.c1
-rw-r--r--src/select/select.c1
-rw-r--r--src/signal/signal.c1
-rw-r--r--src/signal/sigsetjmp_tail.c1
-rw-r--r--src/signal/sigsuspend.c1
-rw-r--r--src/signal/sigtimedwait.c1
-rw-r--r--src/stat/futimesat.c1
-rw-r--r--src/stdio/__fdopen.c1
-rw-r--r--src/stdio/fclose.c2
-rw-r--r--src/stdio/fgetpos.c1
-rw-r--r--src/stdio/fmemopen.c2
-rw-r--r--src/stdio/fopen.c1
-rw-r--r--src/stdio/freopen.c1
-rw-r--r--src/stdio/fscanf.c1
-rw-r--r--src/stdio/fseek.c1
-rw-r--r--src/stdio/fsetpos.c1
-rw-r--r--src/stdio/ftell.c1
-rw-r--r--src/stdio/fwscanf.c1
-rw-r--r--src/stdio/getdelim.c1
-rw-r--r--src/stdio/open_memstream.c2
-rw-r--r--src/stdio/open_wmemstream.c2
-rw-r--r--src/stdio/scanf.c1
-rw-r--r--src/stdio/sscanf.c1
-rw-r--r--src/stdio/swscanf.c1
-rw-r--r--src/stdio/tmpfile.c1
-rw-r--r--src/stdio/vfprintf.c1
-rw-r--r--src/stdio/vfwprintf.c1
-rw-r--r--src/stdio/vfwscanf.c1
-rw-r--r--src/stdio/vscanf.c1
-rw-r--r--src/stdio/vsscanf.c1
-rw-r--r--src/stdio/vswprintf.c1
-rw-r--r--src/stdio/vswscanf.c1
-rw-r--r--src/stdio/vwscanf.c1
-rw-r--r--src/stdio/wscanf.c1
-rw-r--r--src/stdlib/strtod.c1
-rw-r--r--src/stdlib/strtol.c1
-rw-r--r--src/string/memrchr.c1
-rw-r--r--src/string/stpcpy.c1
-rw-r--r--src/string/stpncpy.c1
-rw-r--r--src/string/strcasecmp.c1
-rw-r--r--src/string/strchrnul.c1
-rw-r--r--src/string/strerror_r.c1
-rw-r--r--src/string/strlcpy.c1
-rw-r--r--src/string/strncasecmp.c1
-rw-r--r--src/string/wcsdup.c1
-rw-r--r--src/temp/mkostemps.c1
-rw-r--r--src/termios/cfsetospeed.c1
-rw-r--r--src/termios/tcdrain.c1
-rw-r--r--src/thread/__syscall_cp.c1
-rw-r--r--src/thread/__tls_get_addr.c1
-rw-r--r--src/thread/pthread_attr_setinheritsched.c1
-rw-r--r--src/thread/pthread_cancel.c1
-rw-r--r--src/thread/pthread_equal.c1
-rw-r--r--src/thread/pthread_self.c1
-rw-r--r--src/thread/pthread_testcancel.c1
-rw-r--r--src/thread/x32/syscall_cp_fixup.c2
-rw-r--r--src/time/asctime_r.c1
-rw-r--r--src/time/clock_gettime.c1
-rw-r--r--src/time/clock_nanosleep.c1
-rw-r--r--src/time/gmtime_r.c1
-rw-r--r--src/time/localtime_r.c2
-rw-r--r--src/time/nanosleep.c1
-rw-r--r--src/time/strftime.c1
-rw-r--r--src/time/wcsftime.c1
-rw-r--r--src/unistd/acct.c1
-rw-r--r--src/unistd/close.c1
-rw-r--r--src/unistd/dup3.c1
-rw-r--r--src/unistd/pause.c2
-rw-r--r--src/unistd/read.c1
-rw-r--r--src/unistd/readv.c1
-rw-r--r--src/unistd/write.c1
-rw-r--r--src/unistd/writev.c1
193 files changed, 43 insertions, 177 deletions
diff --git a/src/aio/aio.c b/src/aio/aio.c
index aafd8e8..a5f6443 100644
--- a/src/aio/aio.c
+++ b/src/aio/aio.c
@@ -7,7 +7,6 @@
#include <stdlib.h>
#include "syscall.h"
#include "atomic.h"
-#include "libc.h"
#include "pthread_impl.h"
/* The following is a threads-based implementation of AIO with minimal
diff --git a/src/aio/aio_suspend.c b/src/aio/aio_suspend.c
index b269dd0..0b3abe5 100644
--- a/src/aio/aio_suspend.c
+++ b/src/aio/aio_suspend.c
@@ -2,7 +2,6 @@
#include <errno.h>
#include <time.h>
#include "atomic.h"
-#include "libc.h"
#include "pthread_impl.h"
int aio_suspend(const struct aiocb *const cbs[], int cnt, const struct timespec *ts)
diff --git a/src/aio/lio_listio.c b/src/aio/lio_listio.c
index bd37767..bd64546 100644
--- a/src/aio/lio_listio.c
+++ b/src/aio/lio_listio.c
@@ -3,7 +3,6 @@
#include <unistd.h>
#include <string.h>
#include "pthread_impl.h"
-#include "libc.h"
struct lio_state {
struct sigevent *sev;
diff --git a/src/conf/sysconf.c b/src/conf/sysconf.c
index 3baaed3..5199ed2 100644
--- a/src/conf/sysconf.c
+++ b/src/conf/sysconf.c
@@ -5,7 +5,6 @@
#include <signal.h>
#include <sys/sysinfo.h>
#include "syscall.h"
-#include "libc.h"
#define JT(x) (-256|(x))
#define VER JT(1)
diff --git a/src/crypt/crypt_r.c b/src/crypt/crypt_r.c
index 5789973..db6015e 100644
--- a/src/crypt/crypt_r.c
+++ b/src/crypt/crypt_r.c
@@ -1,5 +1,4 @@
#include <crypt.h>
-#include "libc.h"
char *__crypt_r(const char *key, const char *salt, struct crypt_data *data)
{
diff --git a/src/ctype/isalnum.c b/src/ctype/isalnum.c
index 2214936..8018a2b 100644
--- a/src/ctype/isalnum.c
+++ b/src/ctype/isalnum.c
@@ -1,5 +1,4 @@
#include <ctype.h>
-#include "libc.h"
int isalnum(int c)
{
diff --git a/src/ctype/isalpha.c b/src/ctype/isalpha.c
index f155d3a..a87a937 100644
--- a/src/ctype/isalpha.c
+++ b/src/ctype/isalpha.c
@@ -1,5 +1,4 @@
#include <ctype.h>
-#include "libc.h"
#undef isalpha
int isalpha(int c)
diff --git a/src/ctype/isblank.c b/src/ctype/isblank.c
index 299120e..716da23 100644
--- a/src/ctype/isblank.c
+++ b/src/ctype/isblank.c
@@ -1,5 +1,4 @@
#include <ctype.h>
-#include "libc.h"
int isblank(int c)
{
diff --git a/src/ctype/iscntrl.c b/src/ctype/iscntrl.c
index cb4114a..f27837e 100644
--- a/src/ctype/iscntrl.c
+++ b/src/ctype/iscntrl.c
@@ -1,5 +1,4 @@
#include <ctype.h>
-#include "libc.h"
int iscntrl(int c)
{
diff --git a/src/ctype/isdigit.c b/src/ctype/isdigit.c
index 4d8a103..16beddb 100644
--- a/src/ctype/isdigit.c
+++ b/src/ctype/isdigit.c
@@ -1,5 +1,4 @@
#include <ctype.h>
-#include "libc.h"
#undef isdigit
int isdigit(int c)
diff --git a/src/ctype/isgraph.c b/src/ctype/isgraph.c
index a0aae08..292d198 100644
--- a/src/ctype/isgraph.c
+++ b/src/ctype/isgraph.c
@@ -1,5 +1,4 @@
#include <ctype.h>
-#include "libc.h"
#undef isgraph
int isgraph(int c)
diff --git a/src/ctype/islower.c b/src/ctype/islower.c
index 0264021..c3fa74c 100644
--- a/src/ctype/islower.c
+++ b/src/ctype/islower.c
@@ -1,5 +1,4 @@
#include <ctype.h>
-#include "libc.h"
#undef islower
int islower(int c)
diff --git a/src/ctype/isprint.c b/src/ctype/isprint.c
index 067275f..b950816 100644
--- a/src/ctype/isprint.c
+++ b/src/ctype/isprint.c
@@ -1,5 +1,4 @@
#include <ctype.h>
-#include "libc.h"
#undef isprint
int isprint(int c)
diff --git a/src/ctype/ispunct.c b/src/ctype/ispunct.c
index e772d76..a491d5d 100644
--- a/src/ctype/ispunct.c
+++ b/src/ctype/ispunct.c
@@ -1,5 +1,4 @@
#include <ctype.h>
-#include "libc.h"
int ispunct(int c)
{
diff --git a/src/ctype/isspace.c b/src/ctype/isspace.c
index 231e907..428813e 100644
--- a/src/ctype/isspace.c
+++ b/src/ctype/isspace.c
@@ -1,5 +1,4 @@
#include <ctype.h>
-#include "libc.h"
#undef isspace
int isspace(int c)
diff --git a/src/ctype/isupper.c b/src/ctype/isupper.c
index 68c36f4..bfd15ac 100644
--- a/src/ctype/isupper.c
+++ b/src/ctype/isupper.c
@@ -1,5 +1,4 @@
#include <ctype.h>
-#include "libc.h"
#undef isupper
int isupper(int c)
diff --git a/src/ctype/iswalnum.c b/src/ctype/iswalnum.c
index a6082da..046c399 100644
--- a/src/ctype/iswalnum.c
+++ b/src/ctype/iswalnum.c
@@ -1,5 +1,4 @@
#include <wctype.h>
-#include "libc.h"
int iswalnum(wint_t wc)
{
diff --git a/src/ctype/iswalpha.c b/src/ctype/iswalpha.c
index 00f9d81..1c5485d 100644
--- a/src/ctype/iswalpha.c
+++ b/src/ctype/iswalpha.c
@@ -1,5 +1,4 @@
#include <wctype.h>
-#include "libc.h"
static const unsigned char table[] = {
#include "alpha.h"
diff --git a/src/ctype/iswblank.c b/src/ctype/iswblank.c
index d9b33ef..68c8800 100644
--- a/src/ctype/iswblank.c
+++ b/src/ctype/iswblank.c
@@ -1,6 +1,5 @@
#include <wctype.h>
#include <ctype.h>
-#include "libc.h"
int iswblank(wint_t wc)
{
diff --git a/src/ctype/iswcntrl.c b/src/ctype/iswcntrl.c
index daace82..feccfcd 100644
--- a/src/ctype/iswcntrl.c
+++ b/src/ctype/iswcntrl.c
@@ -1,5 +1,4 @@
#include <wctype.h>
-#include "libc.h"
int iswcntrl(wint_t wc)
{
diff --git a/src/ctype/iswctype.c b/src/ctype/iswctype.c
index 3d9c2cc..71b09b8 100644
--- a/src/ctype/iswctype.c
+++ b/src/ctype/iswctype.c
@@ -1,6 +1,5 @@
#include <wctype.h>
#include <string.h>
-#include "libc.h"
#define WCTYPE_ALNUM 1
#define WCTYPE_ALPHA 2
diff --git a/src/ctype/iswdigit.c b/src/ctype/iswdigit.c
index ed9a88e..db817ed 100644
--- a/src/ctype/iswdigit.c
+++ b/src/ctype/iswdigit.c
@@ -1,5 +1,4 @@
#include <wctype.h>
-#include "libc.h"
#undef iswdigit
diff --git a/src/ctype/iswgraph.c b/src/ctype/iswgraph.c
index 0ea5ca3..ecdf466 100644
--- a/src/ctype/iswgraph.c
+++ b/src/ctype/iswgraph.c
@@ -1,5 +1,4 @@
#include <wctype.h>
-#include "libc.h"
int iswgraph(wint_t wc)
{
diff --git a/src/ctype/iswlower.c b/src/ctype/iswlower.c
index 79df44a..f02a436 100644
--- a/src/ctype/iswlower.c
+++ b/src/ctype/iswlower.c
@@ -1,5 +1,4 @@
#include <wctype.h>
-#include "libc.h"
int iswlower(wint_t wc)
{
diff --git a/src/ctype/iswprint.c b/src/ctype/iswprint.c
index 69856e0..86f9d64 100644
--- a/src/ctype/iswprint.c
+++ b/src/ctype/iswprint.c
@@ -1,5 +1,4 @@
#include <wctype.h>
-#include "libc.h"
/* Consider all legal codepoints as printable except for:
* - C0 and C1 control characters
diff --git a/src/ctype/iswpunct.c b/src/ctype/iswpunct.c
index d880104..f0b9ea0 100644
--- a/src/ctype/iswpunct.c
+++ b/src/ctype/iswpunct.c
@@ -1,5 +1,4 @@
#include <wctype.h>
-#include "libc.h"
static const unsigned char table[] = {
#include "punct.h"
diff --git a/src/ctype/iswspace.c b/src/ctype/iswspace.c
index 75ae7e8..263afa1 100644
--- a/src/ctype/iswspace.c
+++ b/src/ctype/iswspace.c
@@ -1,6 +1,5 @@
#include <wchar.h>
#include <wctype.h>
-#include "libc.h"
/* Our definition of whitespace is the Unicode White_Space property,
* minus non-breaking spaces (U+00A0, U+2007, and U+202F) and script-
diff --git a/src/ctype/iswupper.c b/src/ctype/iswupper.c
index 6e1e029..7e48666 100644
--- a/src/ctype/iswupper.c
+++ b/src/ctype/iswupper.c
@@ -1,5 +1,4 @@
#include <wctype.h>
-#include "libc.h"
int iswupper(wint_t wc)
{
diff --git a/src/ctype/iswxdigit.c b/src/ctype/iswxdigit.c
index 1e27f1f..62bc9e7 100644
--- a/src/ctype/iswxdigit.c
+++ b/src/ctype/iswxdigit.c
@@ -1,5 +1,4 @@
#include <wctype.h>
-#include "libc.h"
int iswxdigit(wint_t wc)
{
diff --git a/src/ctype/isxdigit.c b/src/ctype/isxdigit.c
index 0e9152a..aab1a74 100644
--- a/src/ctype/isxdigit.c
+++ b/src/ctype/isxdigit.c
@@ -1,5 +1,4 @@
#include <ctype.h>
-#include "libc.h"
int isxdigit(int c)
{
diff --git a/src/ctype/tolower.c b/src/ctype/tolower.c
index 362d6b2..f10132e 100644
--- a/src/ctype/tolower.c
+++ b/src/ctype/tolower.c
@@ -1,5 +1,4 @@
#include <ctype.h>
-#include "libc.h"
int tolower(int c)
{
diff --git a/src/ctype/toupper.c b/src/ctype/toupper.c
index bbf4e06..4e74a55 100644
--- a/src/ctype/toupper.c
+++ b/src/ctype/toupper.c
@@ -1,5 +1,4 @@
#include <ctype.h>
-#include "libc.h"
int toupper(int c)
{
diff --git a/src/ctype/towctrans.c b/src/ctype/towctrans.c
index 12355af..8f68101 100644
--- a/src/ctype/towctrans.c
+++ b/src/ctype/towctrans.c
@@ -1,6 +1,6 @@
#include <ctype.h>
+#include <stddef.h>
#include <wctype.h>
-#include "libc.h"
#define CASEMAP(u1,u2,l) { (u1), (l)-(u1), (u2)-(u1)+1 }
#define CASELACE(u1,u2) CASEMAP((u1),(u2),(u1)+1)
diff --git a/src/ctype/wctrans.c b/src/ctype/wctrans.c
index b1b1265..d3eda52 100644
--- a/src/ctype/wctrans.c
+++ b/src/ctype/wctrans.c
@@ -1,6 +1,5 @@
#include <wctype.h>
#include <string.h>
-#include "libc.h"
wctrans_t wctrans(const char *class)
{
diff --git a/src/dirent/closedir.c b/src/dirent/closedir.c
index 81e9591..e794ae9 100644
--- a/src/dirent/closedir.c
+++ b/src/dirent/closedir.c
@@ -1,7 +1,7 @@
#include <dirent.h>
#include <unistd.h>
+#include <stdlib.h>
#include "__dirent.h"
-#include "libc.h"
int closedir(DIR *dir)
{
diff --git a/src/env/__environ.c b/src/env/__environ.c
index e6c6faa..fe8abcf 100644
--- a/src/env/__environ.c
+++ b/src/env/__environ.c
@@ -1,4 +1,4 @@
-#include "libc.h"
+#include <unistd.h>
char **__environ = 0;
weak_alias(__environ, ___environ);
diff --git a/src/env/clearenv.c b/src/env/clearenv.c
index 2e275b4..db8e8e9 100644
--- a/src/env/clearenv.c
+++ b/src/env/clearenv.c
@@ -1,7 +1,6 @@
#define _GNU_SOURCE
#include <stdlib.h>
#include <unistd.h>
-#include "libc.h"
static void dummy(char *old, char *new) {}
weak_alias(dummy, __env_rm_add);
diff --git a/src/env/getenv.c b/src/env/getenv.c
index f279779..a90d39c 100644
--- a/src/env/getenv.c
+++ b/src/env/getenv.c
@@ -1,7 +1,6 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
-#include "libc.h"
char *getenv(const char *name)
{
diff --git a/src/env/putenv.c b/src/env/putenv.c
index 20f9602..dce8c82 100644
--- a/src/env/putenv.c
+++ b/src/env/putenv.c
@@ -1,7 +1,6 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
-#include "libc.h"
static void dummy(char *old, char *new) {}
weak_alias(dummy, __env_rm_add);
diff --git a/src/env/unsetenv.c b/src/env/unsetenv.c
index 471219e..b14c4c9 100644
--- a/src/env/unsetenv.c
+++ b/src/env/unsetenv.c
@@ -2,7 +2,6 @@
#include <string.h>
#include <errno.h>
#include <unistd.h>
-#include "libc.h"
static void dummy(char *old, char *new) {}
weak_alias(dummy, __env_rm_add);
diff --git a/src/errno/strerror.c b/src/errno/strerror.c
index 24c94d3..e3ed771 100644
--- a/src/errno/strerror.c
+++ b/src/errno/strerror.c
@@ -1,7 +1,6 @@
#include <errno.h>
#include <string.h>
#include "locale_impl.h"
-#include "libc.h"
#define E(a,b) ((unsigned char)a),
static const unsigned char errid[] = {
diff --git a/src/fcntl/fcntl.c b/src/fcntl/fcntl.c
index ce615d0..d3bff5c 100644
--- a/src/fcntl/fcntl.c
+++ b/src/fcntl/fcntl.c
@@ -3,7 +3,6 @@
#include <stdarg.h>
#include <errno.h>
#include "syscall.h"
-#include "libc.h"
int fcntl(int fd, int cmd, ...)
{
diff --git a/src/fenv/fesetround.c b/src/fenv/fesetround.c
index a85db71..50e58f1 100644
--- a/src/fenv/fesetround.c
+++ b/src/fenv/fesetround.c
@@ -1,5 +1,5 @@
#include <fenv.h>
-#include "libc.h"
+#include <features.h>
/* __fesetround wrapper for arch independent argument check */
diff --git a/src/fenv/m68k/fenv.c b/src/fenv/m68k/fenv.c
index fa85379..d0658e6 100644
--- a/src/fenv/m68k/fenv.c
+++ b/src/fenv/m68k/fenv.c
@@ -1,5 +1,5 @@
#include <fenv.h>
-#include "libc.h"
+#include <features.h>
#if __HAVE_68881__ || __mcffpu__
diff --git a/src/fenv/powerpc64/fenv.c b/src/fenv/powerpc64/fenv.c
index 9db0fb6..90dabdc 100644
--- a/src/fenv/powerpc64/fenv.c
+++ b/src/fenv/powerpc64/fenv.c
@@ -1,6 +1,6 @@
#define _GNU_SOURCE
#include <fenv.h>
-#include "libc.h"
+#include <features.h>
static inline double get_fpscr_f(void)
{
diff --git a/src/fenv/s390x/fenv.c b/src/fenv/s390x/fenv.c
index 72b9dbe..fd4e60c 100644
--- a/src/fenv/s390x/fenv.c
+++ b/src/fenv/s390x/fenv.c
@@ -1,5 +1,5 @@
#include <fenv.h>
-#include "libc.h"
+#include <features.h>
static inline unsigned get_fpc(void)
{
diff --git a/src/internal/dynlink.h b/src/internal/dynlink.h
index 90b6e48..cbe0a6f 100644
--- a/src/internal/dynlink.h
+++ b/src/internal/dynlink.h
@@ -5,7 +5,7 @@
#include <elf.h>
#include <stdint.h>
#include <stddef.h>
-#include "libc.h"
+#include <stdarg.h>
#if UINTPTR_MAX == 0xffffffff
typedef Elf32_Ehdr Ehdr;
diff --git a/src/internal/fdpic_crt.h b/src/internal/fdpic_crt.h
index 3c3f077..7e9632b 100644
--- a/src/internal/fdpic_crt.h
+++ b/src/internal/fdpic_crt.h
@@ -1,5 +1,5 @@
#include <stdint.h>
-#include "libc.h"
+#include <features.h>
hidden void *__fdpic_fixup(void *map, uintptr_t *a, uintptr_t *z)
{
diff --git a/src/internal/libc.h b/src/internal/libc.h
index 155a299..83ad398 100644
--- a/src/internal/libc.h
+++ b/src/internal/libc.h
@@ -53,8 +53,6 @@ extern hidden const char __libc_version[];
/* Designed to avoid any overhead in non-threaded processes */
hidden void __lock(volatile int *);
hidden void __unlock(volatile int *);
-hidden int __lockfile(FILE *);
-hidden void __unlockfile(FILE *);
#define LOCK(x) __lock(x)
#define UNLOCK(x) __unlock(x)
diff --git a/src/internal/malloc_impl.h b/src/internal/malloc_impl.h
index b6eacd8..59785a7 100644
--- a/src/internal/malloc_impl.h
+++ b/src/internal/malloc_impl.h
@@ -1,7 +1,6 @@
#ifndef MALLOC_IMPL_H
#define MALLOC_IMPL_H
-#include "libc.h"
#include <sys/mman.h>
hidden void *__expand_heap(size_t *);
diff --git a/src/internal/sh/__shcall.c b/src/internal/sh/__shcall.c
index 2365590..4e073e8 100644
--- a/src/internal/sh/__shcall.c
+++ b/src/internal/sh/__shcall.c
@@ -1,4 +1,4 @@
-#include "libc.h"
+#include <features.h>
hidden int __shcall(void *arg, int (*func)(void *))
{
diff --git a/src/internal/stdio_impl.h b/src/internal/stdio_impl.h
index 92f7be6..4afb7ea 100644
--- a/src/internal/stdio_impl.h
+++ b/src/internal/stdio_impl.h
@@ -3,7 +3,6 @@
#include <stdio.h>
#include "syscall.h"
-#include "libc.h"
#define UNGET 8
@@ -54,6 +53,9 @@ extern hidden FILE *volatile __stdin_used;
extern hidden FILE *volatile __stdout_used;
extern hidden FILE *volatile __stderr_used;
+hidden int __lockfile(FILE *);
+hidden void __unlockfile(FILE *);
+
hidden size_t __stdio_read(FILE *, unsigned char *, size_t);
hidden size_t __stdio_write(FILE *, const unsigned char *, size_t);
hidden size_t __stdout_write(FILE *, const unsigned char *, size_t);
diff --git a/src/internal/syscall.h b/src/internal/syscall.h
index 3cb0a77..da70ce9 100644
--- a/src/internal/syscall.h
+++ b/src/internal/syscall.h
@@ -1,8 +1,8 @@
#ifndef _INTERNAL_SYSCALL_H
#define _INTERNAL_SYSCALL_H
+#include <features.h>
#include <sys/syscall.h>
-#include "libc.h"
#include "syscall_arch.h"
#ifndef SYSCALL_RLIM_INFINITY
diff --git a/src/ipc/msgrcv.c b/src/ipc/msgrcv.c
index ed4a448..0a344e5 100644
--- a/src/ipc/msgrcv.c
+++ b/src/ipc/msgrcv.c
@@ -1,7 +1,6 @@
#include <sys/msg.h>
#include "syscall.h"
#include "ipc.h"
-#include "libc.h"
ssize_t msgrcv(int q, void *m, size_t len, long type, int flag)
{
diff --git a/src/ipc/msgsnd.c b/src/ipc/msgsnd.c
index 23f4a4c..e1abde3 100644
--- a/src/ipc/msgsnd.c
+++ b/src/ipc/msgsnd.c
@@ -1,7 +1,6 @@
#include <sys/msg.h>
#include "syscall.h"
#include "ipc.h"
-#include "libc.h"
int msgsnd(int q, const void *m, size_t len, int flag)
{
diff --git a/src/ldso/__dlsym.c b/src/ldso/__dlsym.c
index 012994a..8ac0a33 100644
--- a/src/ldso/__dlsym.c
+++ b/src/ldso/__dlsym.c
@@ -1,6 +1,5 @@
#include <dlfcn.h>
#include "dynlink.h"
-#include "libc.h"
static void *stub_dlsym(void *restrict p, const char *restrict s, void *restrict ra)
{
diff --git a/src/ldso/dladdr.c b/src/ldso/dladdr.c
index 659ab91..e5c8020 100644
--- a/src/ldso/dladdr.c
+++ b/src/ldso/dladdr.c
@@ -1,6 +1,5 @@
#define _GNU_SOURCE
#include <dlfcn.h>
-#include "libc.h"
static int stub_dladdr(const void *addr, Dl_info *info)
{
diff --git a/src/ldso/dlclose.c b/src/ldso/dlclose.c
index b839fe2..e437422 100644
--- a/src/ldso/dlclose.c
+++ b/src/ldso/dlclose.c
@@ -1,6 +1,5 @@
#include <dlfcn.h>
#include "dynlink.h"
-#include "libc.h"
int dlclose(void *p)
{
diff --git a/src/ldso/dlerror.c b/src/ldso/dlerror.c
index 7e5ec23..06ed854 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 "libc.h"
char *dlerror()
{
diff --git a/src/ldso/dlinfo.c b/src/ldso/dlinfo.c
index a8a5ad5..b55f5fe 100644
--- a/src/ldso/dlinfo.c
+++ b/src/ldso/dlinfo.c
@@ -1,7 +1,6 @@
#define _GNU_SOURCE
#include <dlfcn.h>
#include "dynlink.h"
-#include "libc.h"
int dlinfo(void *dso, int req, void *res)
{
diff --git a/src/ldso/dlopen.c b/src/ldso/dlopen.c
index 9544741..69372a2 100644
--- a/src/ldso/dlopen.c
+++ b/src/ldso/dlopen.c
@@ -1,6 +1,5 @@
#include <dlfcn.h>
#include "dynlink.h"
-#include "libc.h"
static void *stub_dlopen(const char *file, int mode)
{
diff --git a/src/ldso/tlsdesc.c b/src/ldso/tlsdesc.c
index caf8dc0..49a1f18 100644
--- a/src/ldso/tlsdesc.c
+++ b/src/ldso/tlsdesc.c
@@ -1,6 +1,5 @@
#include <stddef.h>
#include <dynlink.h>
-#include "libc.h"
ptrdiff_t __tlsdesc_static()
{
diff --git a/src/legacy/euidaccess.c b/src/legacy/euidaccess.c
index 7307251..6e1f398 100644
--- a/src/legacy/euidaccess.c
+++ b/src/legacy/euidaccess.c
@@ -1,7 +1,6 @@
#define _GNU_SOURCE
#include <unistd.h>
#include <fcntl.h>
-#include "libc.h"
int euidaccess(const char *filename, int amode)
{
diff --git a/src/legacy/utmpx.c b/src/legacy/utmpx.c
index 3c98367..7aa65da 100644
--- a/src/legacy/utmpx.c
+++ b/src/legacy/utmpx.c
@@ -2,7 +2,6 @@
#include <utmpx.h>
#include <stddef.h>
#include <errno.h>
-#include "libc.h"
void endutxent(void)
{
diff --git a/src/linux/cache.c b/src/linux/cache.c
index 3f0abc7..84a138a 100644
--- a/src/linux/cache.c
+++ b/src/linux/cache.c
@@ -1,5 +1,4 @@
#include "syscall.h"
-#include "libc.h"
#ifdef SYS_cacheflush
int _flush_cache(void *addr, int len, int op)
diff --git a/src/linux/getdents.c b/src/linux/getdents.c
index 90f7556..cab2995 100644
--- a/src/linux/getdents.c
+++ b/src/linux/getdents.c
@@ -1,5 +1,7 @@
+#define _BSD_SOURCE
#include <dirent.h>
#include "syscall.h"
+#include "libc.h"
int getdents(int fd, struct dirent *buf, size_t len)
{
diff --git a/src/linux/setfsgid.c b/src/linux/setfsgid.c
index ad80422..e29d9c0 100644
--- a/src/linux/setfsgid.c
+++ b/src/linux/setfsgid.c
@@ -1,6 +1,5 @@
#include <sys/fsuid.h>
#include "syscall.h"
-#include "libc.h"
int setfsgid(gid_t gid)
{
diff --git a/src/linux/setfsuid.c b/src/linux/setfsuid.c
index 8635873..1bae441 100644
--- a/src/linux/setfsuid.c
+++ b/src/linux/setfsuid.c
@@ -1,6 +1,5 @@
#include <sys/fsuid.h>
#include "syscall.h"
-#include "libc.h"
int setfsuid(uid_t uid)
{
diff --git a/src/linux/sysinfo.c b/src/linux/sysinfo.c
index 4b5a798..db86476 100644
--- a/src/linux/sysinfo.c
+++ b/src/linux/sysinfo.c
@@ -1,6 +1,5 @@
#include <sys/sysinfo.h>
#include "syscall.h"
-#include "libc.h"
int __lsysinfo(struct sysinfo *info)
{
diff --git a/src/linux/x32/sysinfo.c b/src/linux/x32/sysinfo.c
index d1c1b14..59b3bb7 100644
--- a/src/linux/x32/sysinfo.c
+++ b/src/linux/x32/sysinfo.c
@@ -1,6 +1,5 @@
#include <sys/sysinfo.h>
#include "syscall.h"
-#include "libc.h"
#define klong long long
#define kulong unsigned long long
diff --git a/src/locale/__lctrans.c b/src/locale/__lctrans.c
index 107fe14..9fbe762 100644
--- a/src/locale/__lctrans.c
+++ b/src/locale/__lctrans.c
@@ -1,6 +1,5 @@
#include <locale.h>
#include "locale_impl.h"
-#include "libc.h"
static const char *dummy(const char *msg, const struct __locale_map *lm)
{
diff --git a/src/locale/dcngettext.c b/src/locale/dcngettext.c
index fc1018d..eefa31a 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 "libc.h"
#include "atomic.h"
#include "pleval.h"
diff --git a/src/locale/freelocale.c b/src/locale/freelocale.c
index e75acd6..802b8bf 100644
--- a/src/locale/freelocale.c
+++ b/src/locale/freelocale.c
@@ -1,6 +1,5 @@
#include <stdlib.h>
#include "locale_impl.h"
-#include "libc.h"
void freelocale(locale_t l)
{
diff --git a/src/locale/langinfo.c b/src/locale/langinfo.c
index 83be643..1477309 100644
--- a/src/locale/langinfo.c
+++ b/src/locale/langinfo.c
@@ -1,7 +1,6 @@
#include <locale.h>
#include <langinfo.h>
#include "locale_impl.h"
-#include "libc.h"
static const char c_time[] =
"Sun\0" "Mon\0" "Tue\0" "Wed\0" "Thu\0" "Fri\0" "Sat\0"
diff --git a/src/locale/newlocale.c b/src/locale/newlocale.c
index f50bbe9..8fb006a 100644
--- a/src/locale/newlocale.c
+++ b/src/locale/newlocale.c
@@ -1,7 +1,6 @@
#include <stdlib.h>
#include <string.h>
#include "locale_impl.h"
-#include "libc.h"
int __loc_is_allocated(locale_t loc)
{
diff --git a/src/locale/strcoll.c b/src/locale/strcoll.c
index 84f199f..dd3cbc4 100644
--- a/src/locale/strcoll.c
+++ b/src/locale/strcoll.c
@@ -1,7 +1,6 @@
#include <string.h>
#include <locale.h>
#include "locale_impl.h"
-#include "libc.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 14b76a6..c66c620 100644
--- a/src/locale/strxfrm.c
+++ b/src/locale/strxfrm.c
@@ -1,7 +1,6 @@
#include <string.h>
#include <locale.h>
#include "locale_impl.h"
-#include "libc.h"
/* collate only by code points */
size_t __strxfrm_l(char *restrict dest, const char *restrict src, size_t n, locale_t loc)
diff --git a/src/locale/textdomain.c b/src/locale/textdomain.c
index c501501..d727539 100644
--- a/src/locale/textdomain.c
+++ b/src/locale/textdomain.c
@@ -3,8 +3,6 @@
#include <stdlib.h>
#include <errno.h>
#include <limits.h>
-#include "libc.h"
-#include "atomic.h"
static char *current_domain;
diff --git a/src/locale/wcscoll.c b/src/locale/wcscoll.c
index 14bb8b9..ad2cc69 100644
--- a/src/locale/wcscoll.c
+++ b/src/locale/wcscoll.c
@@ -1,7 +1,6 @@
#include <wchar.h>
#include <locale.h>
#include "locale_impl.h"
-#include "libc.h"
/* FIXME: stub */
int __wcscoll_l(const wchar_t *l, const wchar_t *r, locale_t locale)
diff --git a/src/locale/wcsxfrm.c b/src/locale/wcsxfrm.c
index 0a0b776..05e3e11 100644
--- a/src/locale/wcsxfrm.c
+++ b/src/locale/wcsxfrm.c
@@ -1,7 +1,6 @@
#include <wchar.h>
#include <locale.h>
#include "locale_impl.h"
-#include "libc.h"
/* collate only by code points */
size_t __wcsxfrm_l(wchar_t *restrict dest, const wchar_t *restrict src, size_t n, locale_t loc)
diff --git a/src/malloc/memalign.c b/src/malloc/memalign.c
index 8a6152f..cf9dfbd 100644
--- a/src/malloc/memalign.c
+++ b/src/malloc/memalign.c
@@ -1,7 +1,6 @@
#include <stdlib.h>
#include <stdint.h>
#include <errno.h>
-#include "libc.h"
#include "malloc_impl.h"
void *__memalign(size_t align, size_t len)
diff --git a/src/math/exp10.c b/src/math/exp10.c
index 9f5e3c2..26899eb 100644
--- a/src/math/exp10.c
+++ b/src/math/exp10.c
@@ -1,7 +1,6 @@
#define _GNU_SOURCE
#include <math.h>
#include <stdint.h>
-#include "libc.h"
double exp10(double x)
{
diff --git a/src/math/exp10f.c b/src/math/exp10f.c
index 7a8d447..d009f0a 100644
--- a/src/math/exp10f.c
+++ b/src/math/exp10f.c
@@ -1,7 +1,6 @@
#define _GNU_SOURCE
#include <math.h>
#include <stdint.h>
-#include "libc.h"
float exp10f(float x)
{
diff --git a/src/math/exp10l.c b/src/math/exp10l.c
index b758ebf..f3da1a0 100644
--- a/src/math/exp10l.c
+++ b/src/math/exp10l.c
@@ -1,7 +1,6 @@
#define _GNU_SOURCE
#include <float.h>
#include <math.h>
-#include "libc.h"
#include "libm.h"
#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
diff --git a/src/math/lgamma_r.c b/src/math/lgamma_r.c
index fff565d..f9984cd 100644
--- a/src/math/lgamma_r.c
+++ b/src/math/lgamma_r.c
@@ -79,7 +79,6 @@
*/
#include "libm.h"
-#include "libc.h"
static const double
pi = 3.14159265358979311600e+00, /* 0x400921FB, 0x54442D18 */
diff --git a/src/math/lgammaf_r.c b/src/math/lgammaf_r.c
index c5b43db..3f353f1 100644
--- a/src/math/lgammaf_r.c
+++ b/src/math/lgammaf_r.c
@@ -14,7 +14,6 @@
*/
#include "libm.h"
-#include "libc.h"
static const float
pi = 3.1415927410e+00, /* 0x40490fdb */
diff --git a/src/math/lgammal.c b/src/math/lgammal.c
index 8c79812..abbd4fc 100644
--- a/src/math/lgammal.c
+++ b/src/math/lgammal.c
@@ -87,7 +87,6 @@
#define _GNU_SOURCE
#include "libm.h"
-#include "libc.h"
#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
long double __lgammal_r(long double x, int *sg)
diff --git a/src/math/remainder.c b/src/math/remainder.c
index 6cd089c..612155f 100644
--- a/src/math/remainder.c
+++ b/src/math/remainder.c
@@ -1,5 +1,4 @@
#include <math.h>
-#include "libc.h"
double remainder(double x, double y)
{
diff --git a/src/math/remainderf.c b/src/math/remainderf.c
index 420d3bf..bf1d7b2 100644
--- a/src/math/remainderf.c
+++ b/src/math/remainderf.c
@@ -1,5 +1,4 @@
#include <math.h>
-#include "libc.h"
float remainderf(float x, float y)
{
diff --git a/src/math/signgam.c b/src/math/signgam.c
index b4903a5..ee331b2 100644
--- a/src/math/signgam.c
+++ b/src/math/signgam.c
@@ -1,6 +1,5 @@
#include <math.h>
#include "libm.h"
-#include "libc.h"
int __signgam = 0;
diff --git a/src/misc/basename.c b/src/misc/basename.c
index cc4f778..438377b 100644
--- a/src/misc/basename.c
+++ b/src/misc/basename.c
@@ -1,6 +1,5 @@
#include <string.h>
#include <libgen.h>
-#include "libc.h"
char *basename(char *s)
{
diff --git a/src/misc/getopt.c b/src/misc/getopt.c
index 7d7b116..864d52c 100644
--- a/src/misc/getopt.c
+++ b/src/misc/getopt.c
@@ -3,7 +3,6 @@
#include <string.h>
#include <limits.h>
#include <stdlib.h>
-#include "libc.h"
#include "locale_impl.h"
#include "stdio_impl.h"
diff --git a/src/misc/pty.c b/src/misc/pty.c
index b395d2c..b9cb5ea 100644
--- a/src/misc/pty.c
+++ b/src/misc/pty.c
@@ -3,7 +3,6 @@
#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
-#include "libc.h"
#include "syscall.h"
int posix_openpt(int flags)
diff --git a/src/mman/madvise.c b/src/mman/madvise.c
index f80926b..e0c7c0e 100644
--- a/src/mman/madvise.c
+++ b/src/mman/madvise.c
@@ -1,6 +1,5 @@
#include <sys/mman.h>
#include "syscall.h"
-#include "libc.h"
int __madvise(void *addr, size_t len, int advice)
{
diff --git a/src/mman/mremap.c b/src/mman/mremap.c
index ce4e8ea..cc6991a 100644
--- a/src/mman/mremap.c
+++ b/src/mman/mremap.c
@@ -5,7 +5,6 @@
#include <stdint.h>
#include <stdarg.h>
#include "syscall.h"
-#include "libc.h"
static void dummy(void) { }
weak_alias(dummy, __vm_wait);
diff --git a/src/mman/munmap.c b/src/mman/munmap.c
index 3f711ee..2bf83bb 100644
--- a/src/mman/munmap.c
+++ b/src/mman/munmap.c
@@ -1,6 +1,5 @@
#include <sys/mman.h>
#include "syscall.h"
-#include "libc.h"
static void dummy(void) { }
weak_alias(dummy, __vm_wait);
diff --git a/src/multibyte/internal.h b/src/multibyte/internal.h
index 7d0e782..45bbc6d 100644
--- a/src/multibyte/internal.h
+++ b/src/multibyte/internal.h
@@ -1,7 +1,7 @@
#define bittab __fsmu8
#include <stdint.h>
-#include "libc.h"
+#include <features.h>
extern hidden const uint32_t bittab[];
diff --git a/src/network/accept.c b/src/network/accept.c
index 521e9ef..a92406f 100644
--- a/src/network/accept.c
+++ b/src/network/accept.c
@@ -1,6 +1,5 @@
#include <sys/socket.h>
#include "syscall.h"
-#include "libc.h"
int accept(int fd, struct sockaddr *restrict addr, socklen_t *restrict len)
{
diff --git a/src/network/accept4.c b/src/network/accept4.c
index 285d858..59ab172 100644
--- a/src/network/accept4.c
+++ b/src/network/accept4.c
@@ -3,7 +3,6 @@
#include <errno.h>
#include <fcntl.h>
#include "syscall.h"
-#include "libc.h"
int accept4(int fd, struct sockaddr *restrict addr, socklen_t *restrict len, int flg)
{
diff --git a/src/network/connect.c b/src/network/connect.c
index 57f01a1..289127b 100644
--- a/src/network/connect.c
+++ b/src/network/connect.c
@@ -1,6 +1,5 @@
#include <sys/socket.h>
#include "syscall.h"
-#include "libc.h"
int connect(int fd, const struct sockaddr *addr, socklen_t len)
{
diff --git a/src/network/dn_expand.c b/src/network/dn_expand.c
index d9b3393..eac343a 100644
--- a/src/network/dn_expand.c
+++ b/src/network/dn_expand.c
@@ -1,5 +1,4 @@
#include <resolv.h>
-#include "libc.h"
int __dn_expand(const unsigned char *base, const unsigned char *end, const unsigned char *src, char *dest, int space)
{
diff --git a/src/network/ent.c b/src/network/ent.c
index 5abea63..c6e0123 100644
--- a/src/network/ent.c
+++ b/src/network/ent.c
@@ -1,5 +1,4 @@
#include <netdb.h>
-#include "libc.h"
void sethostent(int x)
{
diff --git a/src/network/getnameinfo.c b/src/network/getnameinfo.c
index 84f5ed6..f77e73a 100644
--- a/src/network/getnameinfo.c
+++ b/src/network/getnameinfo.c
@@ -2,6 +2,7 @@
#include <limits.h>
#include <string.h>
#include <stdio.h>
+#include <stdlib.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
diff --git a/src/network/inet_aton.c b/src/network/inet_aton.c
index 0f9a45f..c65f7c2 100644
--- a/src/network/inet_aton.c
+++ b/src/network/inet_aton.c
@@ -2,7 +2,7 @@
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
-#include "libc.h"
+#include <stdlib.h>
int __inet_aton(const char *s0, struct in_addr *dest)
{
diff --git a/src/network/lookup_serv.c b/src/network/lookup_serv.c
index 403b12a..ae38277 100644
--- a/src/network/lookup_serv.c
+++ b/src/network/lookup_serv.c
@@ -3,6 +3,7 @@
#include <netdb.h>
#include <ctype.h>
#include <string.h>
+#include <stdlib.h>
#include <fcntl.h>
#include <errno.h>
#include "lookup.h"
diff --git a/src/network/recvfrom.c b/src/network/recvfrom.c
index 436f344..6191166 100644
--- a/src/network/recvfrom.c
+++ b/src/network/recvfrom.c
@@ -1,6 +1,5 @@
#include <sys/socket.h>
#include "syscall.h"
-#include "libc.h"
ssize_t recvfrom(int fd, void *restrict buf, size_t len, int flags, struct sockaddr *restrict addr, socklen_t *restrict alen)
{
diff --git a/src/network/recvmsg.c b/src/network/recvmsg.c
index 4f52665..4ca7da8 100644
--- a/src/network/recvmsg.c
+++ b/src/network/recvmsg.c
@@ -1,7 +1,6 @@
#include <sys/socket.h>
#include <limits.h>
#include "syscall.h"
-#include "libc.h"
ssize_t recvmsg(int fd, struct msghdr *msg, int flags)
{
diff --git a/src/network/res_mkquery.c b/src/network/res_mkquery.c
index ec4568a..6fa04a5 100644
--- a/src/network/res_mkquery.c
+++ b/src/network/res_mkquery.c
@@ -1,7 +1,6 @@
#include <resolv.h>
#include <string.h>
#include <time.h>
-#include "libc.h"
int __res_mkquery(int op, const char *dname, int class, int type,
const unsigned char *data, int datalen,
diff --git a/src/network/res_query.c b/src/network/res_query.c
index 33543dc..2f4da2e 100644
--- a/src/network/res_query.c
+++ b/src/network/res_query.c
@@ -1,6 +1,5 @@
#include <resolv.h>
#include <netdb.h>
-#include "libc.h"
int res_query(const char *name, int class, int type, unsigned char *dest, int len)
{
diff --git a/src/network/res_send.c b/src/network/res_send.c
index 6facc1b..b9cea0b 100644
--- a/src/network/res_send.c
+++ b/src/network/res_send.c
@@ -1,5 +1,4 @@
#include <resolv.h>
-#include "libc.h"
int __res_send(const unsigned char *msg, int msglen, unsigned char *answer, int anslen)
{
diff --git a/src/network/resolvconf.c b/src/network/resolvconf.c
index 4c3e4c4..ceabf08 100644
--- a/src/network/resolvconf.c
+++ b/src/network/resolvconf.c
@@ -3,6 +3,7 @@
#include <ctype.h>
#include <errno.h>
#include <string.h>
+#include <stdlib.h>
#include <netinet/in.h>
int __get_resolv_conf(struct resolvconf *conf, char *search, size_t search_sz)
diff --git a/src/network/sendmsg.c b/src/network/sendmsg.c
index 5f08000..80cc5f4 100644
--- a/src/network/sendmsg.c
+++ b/src/network/sendmsg.c
@@ -3,7 +3,6 @@
#include <string.h>
#include <errno.h>
#include "syscall.h"
-#include "libc.h"
ssize_t sendmsg(int fd, const struct msghdr *msg, int flags)
{
diff --git a/src/network/sendto.c b/src/network/sendto.c
index 899eecf..c598797 100644
--- a/src/network/sendto.c
+++ b/src/network/sendto.c
@@ -1,6 +1,5 @@
#include <sys/socket.h>
#include "syscall.h"
-#include "libc.h"
ssize_t sendto(int fd, const void *buf, size_t len, int flags, const struct sockaddr *addr, socklen_t alen)
{
diff --git a/src/passwd/pwf.h b/src/passwd/pwf.h
index ab7e166..95bb6e0 100644
--- a/src/passwd/pwf.h
+++ b/src/passwd/pwf.h
@@ -4,9 +4,9 @@
#include <stdio.h>
#include <errno.h>
#include <stdint.h>
+#include <stdlib.h>
#include <string.h>
#include <limits.h>
-#include "libc.h"
hidden int __getpwent_a(FILE *f, struct passwd *pw, char **line, size_t *size, struct passwd **res);
hidden int __getpw_a(const char *name, uid_t uid, struct passwd *pw, char **buf, size_t *size, struct passwd **res);
diff --git a/src/process/execvp.c b/src/process/execvp.c
index 2dddedd..1fdf036 100644
--- a/src/process/execvp.c
+++ b/src/process/execvp.c
@@ -3,7 +3,6 @@
#include <unistd.h>
#include <errno.h>
#include <limits.h>
-#include "libc.h"
extern char **__environ;
diff --git a/src/process/posix_spawn.c b/src/process/posix_spawn.c
index 2f8ef93..5aaf829 100644
--- a/src/process/posix_spawn.c
+++ b/src/process/posix_spawn.c
@@ -8,7 +8,6 @@
#include "syscall.h"
#include "pthread_impl.h"
#include "fdop.h"
-#include "libc.h"
struct args {
int p[2];
diff --git a/src/process/system.c b/src/process/system.c
index 9135b81..5af59b8 100644
--- a/src/process/system.c
+++ b/src/process/system.c
@@ -5,7 +5,6 @@
#include <spawn.h>
#include <errno.h>
#include "pthread_impl.h"
-#include "libc.h"
extern char **__environ;
diff --git a/src/process/waitid.c b/src/process/waitid.c
index c67feac..d688650 100644
--- a/src/process/waitid.c
+++ b/src/process/waitid.c
@@ -1,6 +1,5 @@
#include <sys/wait.h>
#include "syscall.h"
-#include "libc.h"
int waitid(idtype_t type, id_t id, siginfo_t *info, int options)
{
diff --git a/src/process/waitpid.c b/src/process/waitpid.c
index f75e31e..1b65bf0 100644
--- a/src/process/waitpid.c
+++ b/src/process/waitpid.c
@@ -1,6 +1,5 @@
#include <sys/wait.h>
#include "syscall.h"
-#include "libc.h"
pid_t waitpid(pid_t pid, int *status, int options)
{
diff --git a/src/search/hsearch.c b/src/search/hsearch.c
index 1dcb4d8..b3ac879 100644
--- a/src/search/hsearch.c
+++ b/src/search/hsearch.c
@@ -2,7 +2,6 @@
#include <stdlib.h>
#include <string.h>
#include <search.h>
-#include "libc.h"
/*
open addressing hash table with 2^n table size
diff --git a/src/select/poll.c b/src/select/poll.c
index 9e0bcbd..c84c8a9 100644
--- a/src/select/poll.c
+++ b/src/select/poll.c
@@ -2,7 +2,6 @@
#include <time.h>
#include <signal.h>
#include "syscall.h"
-#include "libc.h"
int poll(struct pollfd *fds, nfds_t n, int timeout)
{
diff --git a/src/select/pselect.c b/src/select/pselect.c
index 4e2d7b0..762af37 100644
--- a/src/select/pselect.c
+++ b/src/select/pselect.c
@@ -2,7 +2,6 @@
#include <signal.h>
#include <stdint.h>
#include "syscall.h"
-#include "libc.h"
int pselect(int n, fd_set *restrict rfds, fd_set *restrict wfds, fd_set *restrict efds, const struct timespec *restrict ts, const sigset_t *restrict mask)
{
diff --git a/src/select/select.c b/src/select/select.c
index 7b5f6dc..02fd75c 100644
--- a/src/select/select.c
+++ b/src/select/select.c
@@ -3,7 +3,6 @@
#include <stdint.h>
#include <errno.h>
#include "syscall.h"
-#include "libc.h"
int select(int n, fd_set *restrict rfds, fd_set *restrict wfds, fd_set *restrict efds, struct timeval *restrict tv)
{
diff --git a/src/signal/signal.c b/src/signal/signal.c
index bcd5682..7a6dd17 100644
--- a/src/signal/signal.c
+++ b/src/signal/signal.c
@@ -1,6 +1,5 @@
#include <signal.h>
#include "syscall.h"
-#include "libc.h"
void (*signal(int sig, void (*func)(int)))(int)
{
diff --git a/src/signal/sigsetjmp_tail.c b/src/signal/sigsetjmp_tail.c
index 252529a..f2aa288 100644
--- a/src/signal/sigsetjmp_tail.c
+++ b/src/signal/sigsetjmp_tail.c
@@ -1,7 +1,6 @@
#include <setjmp.h>
#include <signal.h>
#include "syscall.h"
-#include "libc.h"
hidden int __sigsetjmp_tail(sigjmp_buf jb, int ret)
{
diff --git a/src/signal/sigsuspend.c b/src/signal/sigsuspend.c
index 0b42725..36e0602 100644
--- a/src/signal/sigsuspend.c
+++ b/src/signal/sigsuspend.c
@@ -1,6 +1,5 @@
#include <signal.h>
#include "syscall.h"
-#include "libc.h"
int sigsuspend(const sigset_t *mask)
{
diff --git a/src/signal/sigtimedwait.c b/src/signal/sigtimedwait.c
index 0739986..7bcfe72 100644
--- a/src/signal/sigtimedwait.c
+++ b/src/signal/sigtimedwait.c
@@ -1,7 +1,6 @@
#include <signal.h>
#include <errno.h>
#include "syscall.h"
-#include "libc.h"
int sigtimedwait(const sigset_t *restrict mask, siginfo_t *restrict si, const struct timespec *restrict timeout)
{
diff --git a/src/stat/futimesat.c b/src/stat/futimesat.c
index b4eea1d..4bdb1c2 100644
--- a/src/stat/futimesat.c
+++ b/src/stat/futimesat.c
@@ -3,7 +3,6 @@
#include <sys/stat.h>
#include <errno.h>
#include "syscall.h"
-#include "libc.h"
int __futimesat(int dirfd, const char *pathname, const struct timeval times[2])
{
diff --git a/src/stdio/__fdopen.c b/src/stdio/__fdopen.c
index 8d6ce81..116e78e 100644
--- a/src/stdio/__fdopen.c
+++ b/src/stdio/__fdopen.c
@@ -4,6 +4,7 @@
#include <fcntl.h>
#include <errno.h>
#include <string.h>
+#include "libc.h"
FILE *__fdopen(int fd, const char *mode)
{
diff --git a/src/stdio/fclose.c b/src/stdio/fclose.c
index c675413..889b96d 100644
--- a/src/stdio/fclose.c
+++ b/src/stdio/fclose.c
@@ -1,5 +1,5 @@
#include "stdio_impl.h"
-#include "libc.h"
+#include <stdlib.h>
static void dummy(FILE *f) { }
weak_alias(dummy, __unlist_locked_file);
diff --git a/src/stdio/fgetpos.c b/src/stdio/fgetpos.c
index 6eb361e..6b45f57 100644
--- a/src/stdio/fgetpos.c
+++ b/src/stdio/fgetpos.c
@@ -1,4 +1,5 @@
#include "stdio_impl.h"
+#include "libc.h"
int fgetpos(FILE *restrict f, fpos_t *restrict pos)
{
diff --git a/src/stdio/fmemopen.c b/src/stdio/fmemopen.c
index 5e0eeb5..82413b2 100644
--- a/src/stdio/fmemopen.c
+++ b/src/stdio/fmemopen.c
@@ -1,7 +1,9 @@
#include "stdio_impl.h"
#include <errno.h>
#include <string.h>
+#include <stdlib.h>
#include <inttypes.h>
+#include "libc.h"
struct cookie {
size_t pos, len, size;
diff --git a/src/stdio/fopen.c b/src/stdio/fopen.c
index 252f082..2a20c7f 100644
--- a/src/stdio/fopen.c
+++ b/src/stdio/fopen.c
@@ -2,6 +2,7 @@
#include <fcntl.h>
#include <string.h>
#include <errno.h>
+#include "libc.h"
FILE *fopen(const char *restrict filename, const char *restrict mode)
{
diff --git a/src/stdio/freopen.c b/src/stdio/freopen.c
index a9c83c8..6d6d21d 100644
--- a/src/stdio/freopen.c
+++ b/src/stdio/freopen.c
@@ -1,6 +1,7 @@
#include "stdio_impl.h"
#include <fcntl.h>
#include <unistd.h>
+#include "libc.h"
/* The basic idea of this implementation is to open a new FILE,
* hack the necessary parts of the new FILE into the old one, then
diff --git a/src/stdio/fscanf.c b/src/stdio/fscanf.c
index acb8a10..f639e11 100644
--- a/src/stdio/fscanf.c
+++ b/src/stdio/fscanf.c
@@ -1,6 +1,5 @@
#include <stdio.h>
#include <stdarg.h>
-#include "libc.h"
int fscanf(FILE *restrict f, const char *restrict fmt, ...)
{
diff --git a/src/stdio/fseek.c b/src/stdio/fseek.c
index b160b74..26d9f7e 100644
--- a/src/stdio/fseek.c
+++ b/src/stdio/fseek.c
@@ -1,4 +1,5 @@
#include "stdio_impl.h"
+#include "libc.h"
int __fseeko_unlocked(FILE *f, off_t off, int whence)
{
diff --git a/src/stdio/fsetpos.c b/src/stdio/fsetpos.c
index 6310424..cea5ddb 100644
--- a/src/stdio/fsetpos.c
+++ b/src/stdio/fsetpos.c
@@ -1,4 +1,5 @@
#include "stdio_impl.h"
+#include "libc.h"
int fsetpos(FILE *f, const fpos_t *pos)
{
diff --git a/src/stdio/ftell.c b/src/stdio/ftell.c
index bb62897..aad352b 100644
--- a/src/stdio/ftell.c
+++ b/src/stdio/ftell.c
@@ -1,6 +1,7 @@
#include "stdio_impl.h"
#include <limits.h>
#include <errno.h>
+#include "libc.h"
off_t __ftello_unlocked(FILE *f)
{
diff --git a/src/stdio/fwscanf.c b/src/stdio/fwscanf.c
index cb114b3..530bb7c 100644
--- a/src/stdio/fwscanf.c
+++ b/src/stdio/fwscanf.c
@@ -1,7 +1,6 @@
#include <stdio.h>
#include <stdarg.h>
#include <wchar.h>
-#include "libc.h"
int fwscanf(FILE *restrict f, const wchar_t *restrict fmt, ...)
{
diff --git a/src/stdio/getdelim.c b/src/stdio/getdelim.c
index d4b2388..26a5678 100644
--- a/src/stdio/getdelim.c
+++ b/src/stdio/getdelim.c
@@ -1,5 +1,6 @@
#include "stdio_impl.h"
#include <string.h>
+#include <stdlib.h>
#include <inttypes.h>
#include <errno.h>
diff --git a/src/stdio/open_memstream.c b/src/stdio/open_memstream.c
index 40f5ad6..600d277 100644
--- a/src/stdio/open_memstream.c
+++ b/src/stdio/open_memstream.c
@@ -2,6 +2,8 @@
#include <errno.h>
#include <limits.h>
#include <string.h>
+#include <stdlib.h>
+#include "libc.h"
struct cookie {
char **bufp;
diff --git a/src/stdio/open_wmemstream.c b/src/stdio/open_wmemstream.c
index a7c3a64..ed1b561 100644
--- a/src/stdio/open_wmemstream.c
+++ b/src/stdio/open_wmemstream.c
@@ -3,6 +3,8 @@
#include <errno.h>
#include <limits.h>
#include <string.h>
+#include <stdlib.h>
+#include "libc.h"
struct cookie {
wchar_t **bufp;
diff --git a/src/stdio/scanf.c b/src/stdio/scanf.c
index a740056..bd77699 100644
--- a/src/stdio/scanf.c
+++ b/src/stdio/scanf.c
@@ -1,6 +1,5 @@
#include <stdio.h>
#include <stdarg.h>
-#include "libc.h"
int scanf(const char *restrict fmt, ...)
{
diff --git a/src/stdio/sscanf.c b/src/stdio/sscanf.c
index 8a2302f..f2ac2f5 100644
--- a/src/stdio/sscanf.c
+++ b/src/stdio/sscanf.c
@@ -1,6 +1,5 @@
#include <stdio.h>
#include <stdarg.h>
-#include "libc.h"
int sscanf(const char *restrict s, const char *restrict fmt, ...)
{
diff --git a/src/stdio/swscanf.c b/src/stdio/swscanf.c
index d893fba..03d572d 100644
--- a/src/stdio/swscanf.c
+++ b/src/stdio/swscanf.c
@@ -1,6 +1,5 @@
#include <stdarg.h>
#include <wchar.h>
-#include "libc.h"
int swscanf(const wchar_t *restrict s, const wchar_t *restrict fmt, ...)
{
diff --git a/src/stdio/tmpfile.c b/src/stdio/tmpfile.c
index 55d742f..7013f64 100644
--- a/src/stdio/tmpfile.c
+++ b/src/stdio/tmpfile.c
@@ -2,6 +2,7 @@
#include <fcntl.h>
#include <stdlib.h>
#include "stdio_impl.h"
+#include "libc.h"
#define MAXTRIES 100
diff --git a/src/stdio/vfprintf.c b/src/stdio/vfprintf.c
index 2100eb5..9b961e7 100644
--- a/src/stdio/vfprintf.c
+++ b/src/stdio/vfprintf.c
@@ -5,6 +5,7 @@
#include <string.h>
#include <stdarg.h>
#include <stddef.h>
+#include <stdlib.h>
#include <wchar.h>
#include <inttypes.h>
#include <math.h>
diff --git a/src/stdio/vfwprintf.c b/src/stdio/vfwprintf.c
index 9d774fc..0adf0b7 100644
--- a/src/stdio/vfwprintf.c
+++ b/src/stdio/vfwprintf.c
@@ -5,6 +5,7 @@
#include <string.h>
#include <stdarg.h>
#include <stddef.h>
+#include <stdlib.h>
#include <wchar.h>
#include <inttypes.h>
diff --git a/src/stdio/vfwscanf.c b/src/stdio/vfwscanf.c
index a7cd092..7be6634 100644
--- a/src/stdio/vfwscanf.c
+++ b/src/stdio/vfwscanf.c
@@ -11,7 +11,6 @@
#include "shgetc.h"
#include "intscan.h"
#include "floatscan.h"
-#include "libc.h"
#define SIZE_hh -2
#define SIZE_h -1
diff --git a/src/stdio/vscanf.c b/src/stdio/vscanf.c
index 43892f0..9d46ab0 100644
--- a/src/stdio/vscanf.c
+++ b/src/stdio/vscanf.c
@@ -1,6 +1,5 @@
#include <stdio.h>
#include <stdarg.h>
-#include "libc.h"
int vscanf(const char *restrict fmt, va_list ap)
{
diff --git a/src/stdio/vsscanf.c b/src/stdio/vsscanf.c
index 929ffa3..9850022 100644
--- a/src/stdio/vsscanf.c
+++ b/src/stdio/vsscanf.c
@@ -1,5 +1,4 @@
#include "stdio_impl.h"
-#include "libc.h"
static size_t do_read(FILE *f, unsigned char *buf, size_t len)
{
diff --git a/src/stdio/vswprintf.c b/src/stdio/vswprintf.c
index 38efed6..7f98c5c 100644
--- a/src/stdio/vswprintf.c
+++ b/src/stdio/vswprintf.c
@@ -2,6 +2,7 @@
#include <limits.h>
#include <errno.h>
#include <stdint.h>
+#include <stdlib.h>
#include <wchar.h>
struct cookie {
diff --git a/src/stdio/vswscanf.c b/src/stdio/vswscanf.c
index 411dd39..00b614b 100644
--- a/src/stdio/vswscanf.c
+++ b/src/stdio/vswscanf.c
@@ -1,5 +1,4 @@
#include "stdio_impl.h"
-#include "libc.h"
#include <wchar.h>
static size_t wstring_read(FILE *f, unsigned char *buf, size_t len)
diff --git a/src/stdio/vwscanf.c b/src/stdio/vwscanf.c
index 63c9cce..5a3931e 100644
--- a/src/stdio/vwscanf.c
+++ b/src/stdio/vwscanf.c
@@ -1,7 +1,6 @@
#include <stdio.h>
#include <stdarg.h>
#include <wchar.h>
-#include "libc.h"
int vwscanf(const wchar_t *restrict fmt, va_list ap)
{
diff --git a/src/stdio/wscanf.c b/src/stdio/wscanf.c
index 8041225..4dfec25 100644
--- a/src/stdio/wscanf.c
+++ b/src/stdio/wscanf.c
@@ -1,7 +1,6 @@
#include <stdio.h>
#include <stdarg.h>
#include <wchar.h>
-#include "libc.h"
int wscanf(const wchar_t *restrict fmt, ...)
{
diff --git a/src/stdlib/strtod.c b/src/stdlib/strtod.c
index 461dcf8..a898b1d 100644
--- a/src/stdlib/strtod.c
+++ b/src/stdlib/strtod.c
@@ -2,7 +2,6 @@
#include "shgetc.h"
#include "floatscan.h"
#include "stdio_impl.h"
-#include "libc.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 730bf2d..d82ecf7 100644
--- a/src/stdlib/strtol.c
+++ b/src/stdlib/strtol.c
@@ -4,7 +4,6 @@
#include <inttypes.h>
#include <limits.h>
#include <ctype.h>
-#include "libc.h"
static unsigned long long strtox(const char *s, char **p, int base, unsigned long long lim)
{
diff --git a/src/string/memrchr.c b/src/string/memrchr.c
index a78e9d6..e51748b 100644
--- a/src/string/memrchr.c
+++ b/src/string/memrchr.c
@@ -1,5 +1,4 @@
#include <string.h>
-#include "libc.h"
void *__memrchr(const void *m, int c, size_t n)
{
diff --git a/src/string/stpcpy.c b/src/string/stpcpy.c
index 06623c4..54cf9ca 100644
--- a/src/string/stpcpy.c
+++ b/src/string/stpcpy.c
@@ -1,7 +1,6 @@
#include <string.h>
#include <stdint.h>
#include <limits.h>
-#include "libc.h"
#define ALIGN (sizeof(size_t))
#define ONES ((size_t)-1/UCHAR_MAX)
diff --git a/src/string/stpncpy.c b/src/string/stpncpy.c
index 1f57a4d..d6d92ff 100644
--- a/src/string/stpncpy.c
+++ b/src/string/stpncpy.c
@@ -1,7 +1,6 @@
#include <string.h>
#include <stdint.h>
#include <limits.h>
-#include "libc.h"
#define ALIGN (sizeof(size_t)-1)
#define ONES ((size_t)-1/UCHAR_MAX)
diff --git a/src/string/strcasecmp.c b/src/string/strcasecmp.c
index 3cd5f2d..002c6aa 100644
--- a/src/string/strcasecmp.c
+++ b/src/string/strcasecmp.c
@@ -1,6 +1,5 @@
#include <strings.h>
#include <ctype.h>
-#include "libc.h"
int strcasecmp(const char *_l, const char *_r)
{
diff --git a/src/string/strchrnul.c b/src/string/strchrnul.c
index 05700ad..f2b9ae1 100644
--- a/src/string/strchrnul.c
+++ b/src/string/strchrnul.c
@@ -1,7 +1,6 @@
#include <string.h>
#include <stdint.h>
#include <limits.h>
-#include "libc.h"
#define ALIGN (sizeof(size_t))
#define ONES ((size_t)-1/UCHAR_MAX)
diff --git a/src/string/strerror_r.c b/src/string/strerror_r.c
index da26b4f..1dc88bb 100644
--- a/src/string/strerror_r.c
+++ b/src/string/strerror_r.c
@@ -1,6 +1,5 @@
#include <string.h>
#include <errno.h>
-#include "libc.h"
int strerror_r(int err, char *buf, size_t buflen)
{
diff --git a/src/string/strlcpy.c b/src/string/strlcpy.c
index 193d724..dcb22f6 100644
--- a/src/string/strlcpy.c
+++ b/src/string/strlcpy.c
@@ -2,7 +2,6 @@
#include <string.h>
#include <stdint.h>
#include <limits.h>
-#include "libc.h"
#define ALIGN (sizeof(size_t)-1)
#define ONES ((size_t)-1/UCHAR_MAX)
diff --git a/src/string/strncasecmp.c b/src/string/strncasecmp.c
index 3af5300..e0ef93c 100644
--- a/src/string/strncasecmp.c
+++ b/src/string/strncasecmp.c
@@ -1,6 +1,5 @@
#include <strings.h>
#include <ctype.h>
-#include "libc.h"
int strncasecmp(const char *_l, const char *_r, size_t n)
{
diff --git a/src/string/wcsdup.c b/src/string/wcsdup.c
index dd49c1b..f398e80 100644
--- a/src/string/wcsdup.c
+++ b/src/string/wcsdup.c
@@ -1,6 +1,5 @@
#include <stdlib.h>
#include <wchar.h>
-#include "libc.h"
wchar_t *wcsdup(const wchar_t *s)
{
diff --git a/src/temp/mkostemps.c b/src/temp/mkostemps.c
index d1464b4..ef24eea 100644
--- a/src/temp/mkostemps.c
+++ b/src/temp/mkostemps.c
@@ -4,7 +4,6 @@
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
-#include "libc.h"
int __mkostemps(char *template, int len, int flags)
{
diff --git a/src/termios/cfsetospeed.c b/src/termios/cfsetospeed.c
index b571f62..c9cbdd9 100644
--- a/src/termios/cfsetospeed.c
+++ b/src/termios/cfsetospeed.c
@@ -2,7 +2,6 @@
#include <termios.h>
#include <sys/ioctl.h>
#include <errno.h>
-#include "libc.h"
int cfsetospeed(struct termios *tio, speed_t speed)
{
diff --git a/src/termios/tcdrain.c b/src/termios/tcdrain.c
index 6e43afb..c0e542b 100644
--- a/src/termios/tcdrain.c
+++ b/src/termios/tcdrain.c
@@ -1,6 +1,5 @@
#include <termios.h>
#include <sys/ioctl.h>
-#include "libc.h"
#include "syscall.h"
int tcdrain(int fd)
diff --git a/src/thread/__syscall_cp.c b/src/thread/__syscall_cp.c
index afd82ef..af666f0 100644
--- a/src/thread/__syscall_cp.c
+++ b/src/thread/__syscall_cp.c
@@ -1,6 +1,5 @@
#include "pthread_impl.h"
#include "syscall.h"
-#include "libc.h"
hidden long __syscall_cp_c();
diff --git a/src/thread/__tls_get_addr.c b/src/thread/__tls_get_addr.c
index 013817b..34fbc46 100644
--- a/src/thread/__tls_get_addr.c
+++ b/src/thread/__tls_get_addr.c
@@ -1,6 +1,5 @@
#include <stddef.h>
#include "pthread_impl.h"
-#include "libc.h"
void *__tls_get_addr(tls_mod_off_t *v)
{
diff --git a/src/thread/pthread_attr_setinheritsched.c b/src/thread/pthread_attr_setinheritsched.c
index 605af97..6a64837 100644
--- a/src/thread/pthread_attr_setinheritsched.c
+++ b/src/thread/pthread_attr_setinheritsched.c
@@ -1,6 +1,5 @@
#include "pthread_impl.h"
#include "syscall.h"
-#include "libc.h"
hidden void *__start_sched(void *p)
{
diff --git a/src/thread/pthread_cancel.c b/src/thread/pthread_cancel.c
index 43f8d40..2f9d5e9 100644
--- a/src/thread/pthread_cancel.c
+++ b/src/thread/pthread_cancel.c
@@ -2,7 +2,6 @@
#include <string.h>
#include "pthread_impl.h"
#include "syscall.h"
-#include "libc.h"
hidden long __cancel(), __syscall_cp_asm(), __syscall_cp_c();
diff --git a/src/thread/pthread_equal.c b/src/thread/pthread_equal.c
index 7c31482..dbb7365 100644
--- a/src/thread/pthread_equal.c
+++ b/src/thread/pthread_equal.c
@@ -1,6 +1,5 @@
#include <pthread.h>
#include <threads.h>
-#include "libc.h"
static int __pthread_equal(pthread_t a, pthread_t b)
{
diff --git a/src/thread/pthread_self.c b/src/thread/pthread_self.c
index 241a620..bd3bf95 100644
--- a/src/thread/pthread_self.c
+++ b/src/thread/pthread_self.c
@@ -1,6 +1,5 @@
#include "pthread_impl.h"
#include <threads.h>
-#include "libc.h"
static pthread_t __pthread_self_internal()
{
diff --git a/src/thread/pthread_testcancel.c b/src/thread/pthread_testcancel.c
index ee48e6d..d772449 100644
--- a/src/thread/pthread_testcancel.c
+++ b/src/thread/pthread_testcancel.c
@@ -1,5 +1,4 @@
#include "pthread_impl.h"
-#include "libc.h"
static void dummy()
{
diff --git a/src/thread/x32/syscall_cp_fixup.c b/src/thread/x32/syscall_cp_fixup.c
index b1a1faa..4956610 100644
--- a/src/thread/x32/syscall_cp_fixup.c
+++ b/src/thread/x32/syscall_cp_fixup.c
@@ -1,5 +1,5 @@
#include <sys/syscall.h>
-#include "libc.h"
+#include <features.h>
hidden long __syscall_cp_internal(volatile void*, long long, long long,
long long, long long, long long,
diff --git a/src/time/asctime_r.c b/src/time/asctime_r.c
index af2618d..26809ca 100644
--- a/src/time/asctime_r.c
+++ b/src/time/asctime_r.c
@@ -3,7 +3,6 @@
#include <langinfo.h>
#include "locale_impl.h"
#include "atomic.h"
-#include "libc.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 c24fe17..8fd1b8f 100644
--- a/src/time/clock_gettime.c
+++ b/src/time/clock_gettime.c
@@ -2,7 +2,6 @@
#include <errno.h>
#include <stdint.h>
#include "syscall.h"
-#include "libc.h"
#include "atomic.h"
#ifdef VDSO_CGT_SYM
diff --git a/src/time/clock_nanosleep.c b/src/time/clock_nanosleep.c
index 9e4d9f1..32f0c07 100644
--- a/src/time/clock_nanosleep.c
+++ b/src/time/clock_nanosleep.c
@@ -1,7 +1,6 @@
#include <time.h>
#include <errno.h>
#include "syscall.h"
-#include "libc.h"
int clock_nanosleep(clockid_t clk, int flags, const struct timespec *req, struct timespec *rem)
{
diff --git a/src/time/gmtime_r.c b/src/time/gmtime_r.c
index e529799..22aec2c 100644
--- a/src/time/gmtime_r.c
+++ b/src/time/gmtime_r.c
@@ -1,6 +1,5 @@
#include "time_impl.h"
#include <errno.h>
-#include "libc.h"
struct tm *__gmtime_r(const time_t *restrict t, struct tm *restrict tm)
{
diff --git a/src/time/localtime_r.c b/src/time/localtime_r.c
index 2e62c29..1a15b31 100644
--- a/src/time/localtime_r.c
+++ b/src/time/localtime_r.c
@@ -1,6 +1,6 @@
#include "time_impl.h"
#include <errno.h>
-#include "libc.h"
+#include <limits.h>
struct tm *__localtime_r(const time_t *restrict t, struct tm *restrict tm)
{
diff --git a/src/time/nanosleep.c b/src/time/nanosleep.c
index a2ff483..1e6f392 100644
--- a/src/time/nanosleep.c
+++ b/src/time/nanosleep.c
@@ -1,6 +1,5 @@
#include <time.h>
#include "syscall.h"
-#include "libc.h"
int nanosleep(const struct timespec *req, struct timespec *rem)
{
diff --git a/src/time/strftime.c b/src/time/strftime.c
index ba18a27..cc53d53 100644
--- a/src/time/strftime.c
+++ b/src/time/strftime.c
@@ -6,7 +6,6 @@
#include <time.h>
#include <limits.h>
#include "locale_impl.h"
-#include "libc.h"
#include "time_impl.h"
static int is_leap(int y)
diff --git a/src/time/wcsftime.c b/src/time/wcsftime.c
index 31b30ca..8e1437b 100644
--- a/src/time/wcsftime.c
+++ b/src/time/wcsftime.c
@@ -3,7 +3,6 @@
#include <locale.h>
#include "locale_impl.h"
#include "time_impl.h"
-#include "libc.h"
size_t __wcsftime_l(wchar_t *restrict s, size_t n, const wchar_t *restrict f, const struct tm *restrict tm, locale_t loc)
{
diff --git a/src/unistd/acct.c b/src/unistd/acct.c
index f6f25a8..308ffc3 100644
--- a/src/unistd/acct.c
+++ b/src/unistd/acct.c
@@ -1,7 +1,6 @@
#define _GNU_SOURCE
#include <unistd.h>
#include "syscall.h"
-#include "libc.h"
int acct(const char *filename)
{
diff --git a/src/unistd/close.c b/src/unistd/close.c
index fa3c6ca..5b38e01 100644
--- a/src/unistd/close.c
+++ b/src/unistd/close.c
@@ -1,7 +1,6 @@
#include <unistd.h>
#include <errno.h>
#include "syscall.h"
-#include "libc.h"
static int dummy(int fd)
{
diff --git a/src/unistd/dup3.c b/src/unistd/dup3.c
index 0eb6caf..f919f79 100644
--- a/src/unistd/dup3.c
+++ b/src/unistd/dup3.c
@@ -3,7 +3,6 @@
#include <errno.h>
#include <fcntl.h>
#include "syscall.h"
-#include "libc.h"
int __dup3(int old, int new, int flags)
{
diff --git a/src/unistd/pause.c b/src/unistd/pause.c
index 56eb171..90bbf4c 100644
--- a/src/unistd/pause.c
+++ b/src/unistd/pause.c
@@ -1,7 +1,5 @@
#include <unistd.h>
-#include <signal.h>
#include "syscall.h"
-#include "libc.h"
int pause(void)
{
diff --git a/src/unistd/read.c b/src/unistd/read.c
index eb882fc..f3589c0 100644
--- a/src/unistd/read.c
+++ b/src/unistd/read.c
@@ -1,6 +1,5 @@
#include <unistd.h>
#include "syscall.h"
-#include "libc.h"
ssize_t read(int fd, void *buf, size_t count)
{
diff --git a/src/unistd/readv.c b/src/unistd/readv.c
index e45cb48..91e6de8 100644
--- a/src/unistd/readv.c
+++ b/src/unistd/readv.c
@@ -1,6 +1,5 @@
#include <sys/uio.h>
#include "syscall.h"
-#include "libc.h"
ssize_t readv(int fd, const struct iovec *iov, int count)
{
diff --git a/src/unistd/write.c b/src/unistd/write.c
index e2f7e1f..8fd5bc5 100644
--- a/src/unistd/write.c
+++ b/src/unistd/write.c
@@ -1,6 +1,5 @@
#include <unistd.h>
#include "syscall.h"
-#include "libc.h"
ssize_t write(int fd, const void *buf, size_t count)
{
diff --git a/src/unistd/writev.c b/src/unistd/writev.c
index ef300dd..5a46c95 100644
--- a/src/unistd/writev.c
+++ b/src/unistd/writev.c
@@ -1,6 +1,5 @@
#include <sys/uio.h>
#include "syscall.h"
-#include "libc.h"
ssize_t writev(int fd, const struct iovec *iov, int count)
{