summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2018-09-10 23:26:40 -0400
committerRich Felker <dalias@aerifal.cx>2018-09-12 14:34:33 -0400
commit13d1afa46f8098df290008c681816c9eb89ffbdb (patch)
tree01ec1581298b49f20848f9c5ce61bfa9bccd7e1a
parent8c1ac426e15b27d2879afa26a500fd80010b33b9 (diff)
downloadmusl-13d1afa46f8098df290008c681816c9eb89ffbdb.tar.gz
overhaul internally-public declarations using wrapper headers
commits leading up to this one have moved the vast majority of libc-internal interface declarations to appropriate internal headers, allowing them to be type-checked and setting the stage to limit their visibility. the ones that have not yet been moved are mostly namespace-protected aliases for standard/public interfaces, which exist to facilitate implementing plain C functions in terms of POSIX functionality, or C or POSIX functionality in terms of extensions that are not standardized. some don't quite fit this description, but are "internally public" interfacs between subsystems of libc. rather than create a number of newly-named headers to declare these functions, and having to add explicit include directives for them to every source file where they're needed, I have introduced a method of wrapping the corresponding public headers. parallel to the public headers in $(srcdir)/include, we now have wrappers in $(srcdir)/src/include that come earlier in the include path order. they include the public header they're wrapping, then add declarations for namespace-protected versions of the same interfaces and any "internally public" interfaces for the subsystem they correspond to. along these lines, the wrapper for features.h is now responsible for the definition of the hidden, weak, and weak_alias macros. this means source files will no longer need to include any special headers to access these features. over time, it is my expectation that the scope of what is "internally public" will expand, reducing the number of source files which need to include *_impl.h and related headers down to those which are actually implementing the corresponding subsystems, not just using them.
-rw-r--r--Makefile2
-rw-r--r--ldso/dynlink.c2
-rw-r--r--src/conf/sysconf.c1
-rw-r--r--src/crypt/crypt.c2
-rw-r--r--src/crypt/crypt_r.c8
-rw-r--r--src/env/__libc_start_main.c3
-rw-r--r--src/env/clearenv.c1
-rw-r--r--src/env/getenv.c3
-rw-r--r--src/env/putenv.c3
-rw-r--r--src/env/setenv.c3
-rw-r--r--src/env/unsetenv.c3
-rw-r--r--src/include/arpa/inet.h8
-rw-r--r--src/include/crypt.h14
-rw-r--r--src/include/features.h11
-rw-r--r--src/include/langinfo.h8
-rw-r--r--src/include/pthread.h22
-rw-r--r--src/include/resolv.h12
-rw-r--r--src/include/signal.h14
-rw-r--r--src/include/stdlib.h11
-rw-r--r--src/include/string.h11
-rw-r--r--src/include/sys/mman.h20
-rw-r--r--src/include/sys/sysinfo.h8
-rw-r--r--src/include/sys/time.h8
-rw-r--r--src/include/time.h14
-rw-r--r--src/include/unistd.h12
-rw-r--r--src/internal/libc.h13
-rw-r--r--src/internal/malloc_impl.h6
-rw-r--r--src/internal/pthread_impl.h9
-rw-r--r--src/linux/utimes.c2
-rw-r--r--src/locale/dcngettext.c4
-rw-r--r--src/locale/locale_map.c5
-rw-r--r--src/locale/setlocale.c2
-rw-r--r--src/misc/ptsname.c2
-rw-r--r--src/mman/shm_open.c2
-rw-r--r--src/network/getnameinfo.c5
-rw-r--r--src/network/inet_addr.c2
-rw-r--r--src/network/lookup_ipliteral.c2
-rw-r--r--src/network/lookup_name.c4
-rw-r--r--src/network/res_query.c3
-rw-r--r--src/network/res_send.c2
-rw-r--r--src/process/posix_spawn.c2
-rw-r--r--src/process/posix_spawnp.c2
-rw-r--r--src/signal/signal.c2
-rw-r--r--src/stdio/freopen.c3
-rw-r--r--src/stdio/tempnam.c3
-rw-r--r--src/stdio/tmpfile.c3
-rw-r--r--src/stdio/tmpnam.c3
-rw-r--r--src/string/strchr.c2
-rw-r--r--src/string/strcpy.c2
-rw-r--r--src/string/strcspn.c2
-rw-r--r--src/string/strncpy.c2
-rw-r--r--src/string/strrchr.c2
-rw-r--r--src/temp/__randname.c2
-rw-r--r--src/temp/mkdtemp.c2
-rw-r--r--src/temp/mkostemp.c2
-rw-r--r--src/temp/mkostemps.c2
-rw-r--r--src/temp/mkstemp.c2
-rw-r--r--src/temp/mkstemps.c2
-rw-r--r--src/temp/mktemp.c2
-rw-r--r--src/thread/__timedwait.c3
-rw-r--r--src/thread/call_once.c3
-rw-r--r--src/thread/cnd_broadcast.c2
-rw-r--r--src/thread/cnd_signal.c2
-rw-r--r--src/thread/cnd_timedwait.c2
-rw-r--r--src/thread/mtx_timedlock.c2
-rw-r--r--src/thread/mtx_trylock.c2
-rw-r--r--src/thread/mtx_unlock.c2
-rw-r--r--src/thread/pthread_cond_broadcast.c2
-rw-r--r--src/thread/pthread_cond_signal.c2
-rw-r--r--src/thread/pthread_cond_timedwait.c5
-rw-r--r--src/thread/pthread_create.c4
-rw-r--r--src/thread/pthread_detach.c2
-rw-r--r--src/thread/pthread_join.c4
-rw-r--r--src/thread/pthread_mutex_lock.c2
-rw-r--r--src/thread/pthread_mutex_timedlock.c2
-rw-r--r--src/thread/sem_open.c2
-rw-r--r--src/thread/thrd_create.c2
-rw-r--r--src/thread/thrd_exit.c5
-rw-r--r--src/thread/thrd_join.c3
-rw-r--r--src/thread/tss_create.c3
-rw-r--r--src/thread/tss_delete.c3
-rw-r--r--src/time/__map_file.c2
-rw-r--r--src/time/__tz.c3
-rw-r--r--src/time/asctime.c2
-rw-r--r--src/time/asctime_r.c2
-rw-r--r--src/time/clock.c2
-rw-r--r--src/time/gmtime.c2
-rw-r--r--src/time/localtime.c2
-rw-r--r--src/time/strftime.c4
-rw-r--r--src/time/time.c2
-rw-r--r--src/time/time_impl.h1
-rw-r--r--src/time/timespec_get.c2
92 files changed, 200 insertions, 192 deletions
diff --git a/Makefile b/Makefile
index e23a8332..b46f8ca4 100644
--- a/Makefile
+++ b/Makefile
@@ -46,7 +46,7 @@ CFLAGS_AUTO = -Os -pipe
CFLAGS_C99FSE = -std=c99 -ffreestanding -nostdinc
CFLAGS_ALL = $(CFLAGS_C99FSE)
-CFLAGS_ALL += -D_XOPEN_SOURCE=700 -I$(srcdir)/arch/$(ARCH) -I$(srcdir)/arch/generic -Iobj/src/internal -I$(srcdir)/src/internal -Iobj/include -I$(srcdir)/include
+CFLAGS_ALL += -D_XOPEN_SOURCE=700 -I$(srcdir)/arch/$(ARCH) -I$(srcdir)/arch/generic -Iobj/src/internal -I$(srcdir)/src/include -I$(srcdir)/src/internal -Iobj/include -I$(srcdir)/include
CFLAGS_ALL += $(CPPFLAGS) $(CFLAGS_AUTO) $(CFLAGS)
LDFLAGS_ALL = $(LDFLAGS_AUTO) $(LDFLAGS)
diff --git a/ldso/dynlink.c b/ldso/dynlink.c
index 7200c817..e4829c3a 100644
--- a/ldso/dynlink.c
+++ b/ldso/dynlink.c
@@ -96,8 +96,6 @@ struct symdef {
struct dso *dso;
};
-void __init_libc(char **, char *);
-
static struct builtin_tls {
char c;
struct pthread pt;
diff --git a/src/conf/sysconf.c b/src/conf/sysconf.c
index 45ef1c16..3baaed32 100644
--- a/src/conf/sysconf.c
+++ b/src/conf/sysconf.c
@@ -204,7 +204,6 @@ long sysconf(int name)
case JT_PHYS_PAGES & 255:
case JT_AVPHYS_PAGES & 255: ;
unsigned long long mem;
- int __lsysinfo(struct sysinfo *);
struct sysinfo si;
__lsysinfo(&si);
if (!si.mem_unit) si.mem_unit = 1;
diff --git a/src/crypt/crypt.c b/src/crypt/crypt.c
index 46500737..e6237e39 100644
--- a/src/crypt/crypt.c
+++ b/src/crypt/crypt.c
@@ -1,8 +1,6 @@
#include <unistd.h>
#include <crypt.h>
-char *__crypt_r(const char *, const char *, struct crypt_data *);
-
char *crypt(const char *key, const char *salt)
{
/* This buffer is sufficiently large for all
diff --git a/src/crypt/crypt_r.c b/src/crypt/crypt_r.c
index 5982c4c9..5789973b 100644
--- a/src/crypt/crypt_r.c
+++ b/src/crypt/crypt_r.c
@@ -1,14 +1,6 @@
#include <crypt.h>
#include "libc.h"
-struct crypt_data;
-
-char *__crypt_des(const char *, const char *, char *);
-char *__crypt_md5(const char *, const char *, char *);
-char *__crypt_blowfish(const char *, const char *, char *);
-char *__crypt_sha256(const char *, const char *, char *);
-char *__crypt_sha512(const char *, const char *, char *);
-
char *__crypt_r(const char *key, const char *salt, struct crypt_data *data)
{
/* Per the crypt_r API, the caller has provided a pointer to
diff --git a/src/env/__libc_start_main.c b/src/env/__libc_start_main.c
index c1b06697..58da9e83 100644
--- a/src/env/__libc_start_main.c
+++ b/src/env/__libc_start_main.c
@@ -2,12 +2,11 @@
#include <poll.h>
#include <fcntl.h>
#include <signal.h>
+#include <unistd.h>
#include "syscall.h"
#include "atomic.h"
#include "libc.h"
-void __init_tls(size_t *);
-
static void dummy(void) {}
weak_alias(dummy, _init);
diff --git a/src/env/clearenv.c b/src/env/clearenv.c
index da187752..2e275b43 100644
--- a/src/env/clearenv.c
+++ b/src/env/clearenv.c
@@ -1,5 +1,6 @@
#define _GNU_SOURCE
#include <stdlib.h>
+#include <unistd.h>
#include "libc.h"
static void dummy(char *old, char *new) {}
diff --git a/src/env/getenv.c b/src/env/getenv.c
index cf34672c..f2797798 100644
--- a/src/env/getenv.c
+++ b/src/env/getenv.c
@@ -1,9 +1,8 @@
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
#include "libc.h"
-char *__strchrnul(const char *, int);
-
char *getenv(const char *name)
{
size_t l = __strchrnul(name, '=') - name;
diff --git a/src/env/putenv.c b/src/env/putenv.c
index fa4a4ddc..20f96022 100644
--- a/src/env/putenv.c
+++ b/src/env/putenv.c
@@ -1,9 +1,8 @@
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
#include "libc.h"
-char *__strchrnul(const char *, int);
-
static void dummy(char *old, char *new) {}
weak_alias(dummy, __env_rm_add);
diff --git a/src/env/setenv.c b/src/env/setenv.c
index a7dd2b60..c5226b6d 100644
--- a/src/env/setenv.c
+++ b/src/env/setenv.c
@@ -2,9 +2,6 @@
#include <string.h>
#include <errno.h>
-char *__strchrnul(const char *, int);
-int __putenv(char *, size_t, char *);
-
void __env_rm_add(char *old, char *new)
{
static char **env_alloced;
diff --git a/src/env/unsetenv.c b/src/env/unsetenv.c
index 8630e2d7..471219e8 100644
--- a/src/env/unsetenv.c
+++ b/src/env/unsetenv.c
@@ -1,10 +1,9 @@
#include <stdlib.h>
#include <string.h>
#include <errno.h>
+#include <unistd.h>
#include "libc.h"
-char *__strchrnul(const char *, int);
-
static void dummy(char *old, char *new) {}
weak_alias(dummy, __env_rm_add);
diff --git a/src/include/arpa/inet.h b/src/include/arpa/inet.h
new file mode 100644
index 00000000..2da6ddbc
--- /dev/null
+++ b/src/include/arpa/inet.h
@@ -0,0 +1,8 @@
+#ifndef ARPA_INET_H
+#define ARPA_INET_H
+
+#include "../../../include/arpa/inet.h"
+
+int __inet_aton(const char *, struct in_addr *);
+
+#endif
diff --git a/src/include/crypt.h b/src/include/crypt.h
new file mode 100644
index 00000000..6e5c2d30
--- /dev/null
+++ b/src/include/crypt.h
@@ -0,0 +1,14 @@
+#ifndef CRYPT_H
+#define CRYPT_H
+
+#include "../../include/crypt.h"
+
+char *__crypt_r(const char *, const char *, struct crypt_data *);
+
+char *__crypt_des(const char *, const char *, char *);
+char *__crypt_md5(const char *, const char *, char *);
+char *__crypt_blowfish(const char *, const char *, char *);
+char *__crypt_sha256(const char *, const char *, char *);
+char *__crypt_sha512(const char *, const char *, char *);
+
+#endif
diff --git a/src/include/features.h b/src/include/features.h
new file mode 100644
index 00000000..f17bd151
--- /dev/null
+++ b/src/include/features.h
@@ -0,0 +1,11 @@
+#ifndef FEATURES_H
+#define FEATURES_H
+
+#include "../../include/features.h"
+
+#define weak __attribute__((__weak__))
+#define hidden __attribute__((__visibility__("hidden")))
+#define weak_alias(old, new) \
+ extern __typeof(old) new __attribute__((__weak__, __alias__(#old)))
+
+#endif
diff --git a/src/include/langinfo.h b/src/include/langinfo.h
new file mode 100644
index 00000000..ab32b880
--- /dev/null
+++ b/src/include/langinfo.h
@@ -0,0 +1,8 @@
+#ifndef LANGINFO_H
+#define LANGINFO_H
+
+#include "../../include/langinfo.h"
+
+char *__nl_langinfo_l(nl_item, locale_t);
+
+#endif
diff --git a/src/include/pthread.h b/src/include/pthread.h
new file mode 100644
index 00000000..2beaa444
--- /dev/null
+++ b/src/include/pthread.h
@@ -0,0 +1,22 @@
+#ifndef PTHREAD_H
+#define PTHREAD_H
+
+#include "../../include/pthread.h"
+
+int __pthread_once(pthread_once_t *, void (*)(void));
+void __pthread_testcancel(void);
+int __pthread_setcancelstate(int, int *);
+int __pthread_create(pthread_t *restrict, const pthread_attr_t *restrict, void *(*)(void *), void *restrict);
+_Noreturn void __pthread_exit(void *);
+int __pthread_join(pthread_t, void **);
+int __pthread_mutex_lock(pthread_mutex_t *);
+int __pthread_mutex_trylock(pthread_mutex_t *);
+int __pthread_mutex_trylock_owner(pthread_mutex_t *);
+int __pthread_mutex_timedlock(pthread_mutex_t *restrict, const struct timespec *restrict);
+int __pthread_mutex_unlock(pthread_mutex_t *);
+int __private_cond_signal(pthread_cond_t *, int);
+int __pthread_cond_timedwait(pthread_cond_t *restrict, pthread_mutex_t *restrict, const struct timespec *restrict);
+int __pthread_key_create(pthread_key_t *, void (*)(void *));
+int __pthread_key_delete(pthread_key_t);
+
+#endif
diff --git a/src/include/resolv.h b/src/include/resolv.h
new file mode 100644
index 00000000..a66669b2
--- /dev/null
+++ b/src/include/resolv.h
@@ -0,0 +1,12 @@
+#ifndef RESOLV_H
+#define RESOLV_H
+
+#include "../../include/resolv.h"
+
+int __dn_expand(const unsigned char *, const unsigned char *, const unsigned char *, char *, int);
+
+int __res_mkquery(int, const char *, int, int, const unsigned char *, int, const unsigned char*, unsigned char *, int);
+int __res_send(const unsigned char *, int, unsigned char *, int);
+int __res_msend(int, const unsigned char *const *, const int *, unsigned char *const *, int *, int);
+
+#endif
diff --git a/src/include/signal.h b/src/include/signal.h
new file mode 100644
index 00000000..116c0ddd
--- /dev/null
+++ b/src/include/signal.h
@@ -0,0 +1,14 @@
+#ifndef SIGNAL_H
+#define SIGNAL_H
+
+#include "../../include/signal.h"
+
+int __sigaction(int, const struct sigaction *, struct sigaction *);
+
+void __block_all_sigs(void *);
+void __block_app_sigs(void *);
+void __restore_sigs(void *);
+
+void __get_handler_set(sigset_t *);
+
+#endif
diff --git a/src/include/stdlib.h b/src/include/stdlib.h
new file mode 100644
index 00000000..6e0dbda9
--- /dev/null
+++ b/src/include/stdlib.h
@@ -0,0 +1,11 @@
+#ifndef STDLIB_H
+#define STDLIB_H
+
+#include "../../include/stdlib.h"
+
+int __putenv(char *, size_t, char *);
+int __mkostemps(char *, int, int);
+int __ptsname_r(int, char *, size_t);
+char *__randname(char *);
+
+#endif
diff --git a/src/include/string.h b/src/include/string.h
new file mode 100644
index 00000000..1d10be70
--- /dev/null
+++ b/src/include/string.h
@@ -0,0 +1,11 @@
+#ifndef STRING_H
+#define STRING_H
+
+#include "../../include/string.h"
+
+void *__memrchr(const void *, int, size_t);
+char *__stpcpy(char *, const char *);
+char *__stpncpy(char *, const char *, size_t);
+char *__strchrnul(const char *, int);
+
+#endif
diff --git a/src/include/sys/mman.h b/src/include/sys/mman.h
new file mode 100644
index 00000000..28394dd5
--- /dev/null
+++ b/src/include/sys/mman.h
@@ -0,0 +1,20 @@
+#ifndef SYS_MMAN_H
+#define SYS_MMAN_H
+
+#include "../../../include/sys/mman.h"
+
+void __vm_wait(void);
+void __vm_lock(void);
+void __vm_unlock(void);
+
+void *__mmap(void *, size_t, int, int, int, off_t);
+int __munmap(void *, size_t);
+void *__mremap(void *, size_t, size_t, int, ...);
+int __madvise(void *, size_t, int);
+int __mprotect(void *, size_t, int);
+
+const unsigned char *__map_file(const char *, size_t *);
+
+char *__shm_mapname(const char *, char *);
+
+#endif
diff --git a/src/include/sys/sysinfo.h b/src/include/sys/sysinfo.h
new file mode 100644
index 00000000..c3d60bfd
--- /dev/null
+++ b/src/include/sys/sysinfo.h
@@ -0,0 +1,8 @@
+#ifndef SYS_SYSINFO_H
+#define SYS_SYSINFO_H
+
+#include "../../../include/sys/sysinfo.h"
+
+int __lsysinfo(struct sysinfo *);
+
+#endif
diff --git a/src/include/sys/time.h b/src/include/sys/time.h
new file mode 100644
index 00000000..79c5fcbc
--- /dev/null
+++ b/src/include/sys/time.h
@@ -0,0 +1,8 @@
+#ifndef SYS_TIME_H
+#define SYS_TIME_H
+
+#include "../../../include/sys/time.h"
+
+int __futimesat(int, const char *, const struct timeval [2]);
+
+#endif
diff --git a/src/include/time.h b/src/include/time.h
new file mode 100644
index 00000000..991f0b4d
--- /dev/null
+++ b/src/include/time.h
@@ -0,0 +1,14 @@
+#ifndef TIME_H
+#define TIME_H
+
+#include "../../include/time.h"
+
+int __clock_gettime(clockid_t, struct timespec *);
+
+char *__asctime_r(const struct tm *, char *);
+struct tm *__gmtime_r(const time_t *restrict, struct tm *restrict);
+struct tm *__localtime_r(const time_t *restrict, struct tm *restrict);
+
+size_t __strftime_l(char *restrict, size_t, const char *restrict, const struct tm *restrict, locale_t);
+
+#endif
diff --git a/src/include/unistd.h b/src/include/unistd.h
new file mode 100644
index 00000000..9cdf1d3e
--- /dev/null
+++ b/src/include/unistd.h
@@ -0,0 +1,12 @@
+#ifndef UNISTD_H
+#define UNISTD_H
+
+#include "../../include/unistd.h"
+
+extern char **__environ;
+
+int __dup3(int, int, int);
+int __mkostemps(char *, int, int);
+int __execvpe(const char *, char *const *, char *const *);
+
+#endif
diff --git a/src/internal/libc.h b/src/internal/libc.h
index f536eaf6..23988d92 100644
--- a/src/internal/libc.h
+++ b/src/internal/libc.h
@@ -33,12 +33,13 @@ struct __libc {
#define PAGE_SIZE libc.page_size
#endif
-#define weak __attribute__((__weak__))
-#define hidden __attribute__((__visibility__("hidden")))
-
extern hidden struct __libc __libc;
#define libc __libc
+void __init_libc(char **, char *);
+void __init_tls(size_t *);
+void __libc_start_init(void);
+
extern hidden size_t __hwcap;
extern hidden size_t __sysinfo;
extern char *__progname, *__progname_full;
@@ -56,12 +57,6 @@ hidden void __unlockfile(FILE *);
void __synccall(void (*)(void *), void *);
int __setxid(int, int, int, int);
-extern char **__environ;
-
-#undef weak_alias
-#define weak_alias(old, new) \
- extern __typeof(old) new __attribute__((__weak__, __alias__(#old)))
-
#undef LFS64_2
#define LFS64_2(x, y) weak_alias(x, y)
diff --git a/src/internal/malloc_impl.h b/src/internal/malloc_impl.h
index 88b4f670..e97337b3 100644
--- a/src/internal/malloc_impl.h
+++ b/src/internal/malloc_impl.h
@@ -2,11 +2,7 @@
#define MALLOC_IMPL_H
#include "libc.h"
-
-void *__mmap(void *, size_t, int, int, int, off_t);
-int __munmap(void *, size_t);
-void *__mremap(void *, size_t, size_t, int, ...);
-int __madvise(void *, size_t, int);
+#include <sys/mman.h>
void *__expand_heap(size_t *);
diff --git a/src/internal/pthread_impl.h b/src/internal/pthread_impl.h
index 813b5966..4457262d 100644
--- a/src/internal/pthread_impl.h
+++ b/src/internal/pthread_impl.h
@@ -5,6 +5,7 @@
#include <signal.h>
#include <errno.h>
#include <limits.h>
+#include <sys/mman.h>
#include "libc.h"
#include "syscall.h"
#include "atomic.h"
@@ -146,10 +147,6 @@ hidden int __set_thread_area(void *);
int __libc_sigaction(int, const struct sigaction *, struct sigaction *);
void __unmapself(void *, size_t);
-void __vm_wait(void);
-void __vm_lock(void);
-void __vm_unlock(void);
-
int __timedwait(volatile int *, int, clockid_t, const struct timespec *, int);
int __timedwait_cp(volatile int *, int, clockid_t, const struct timespec *, int);
void __wait(volatile int *, volatile int *, int, int);
@@ -171,10 +168,6 @@ void __acquire_ptc(void);
void __release_ptc(void);
void __inhibit_ptc(void);
-void __block_all_sigs(void *);
-void __block_app_sigs(void *);
-void __restore_sigs(void *);
-
#define DEFAULT_STACK_SIZE 81920
#define DEFAULT_GUARD_SIZE 4096
diff --git a/src/linux/utimes.c b/src/linux/utimes.c
index b814c88b..6ca025d9 100644
--- a/src/linux/utimes.c
+++ b/src/linux/utimes.c
@@ -2,8 +2,6 @@
#include "fcntl.h"
#include "syscall.h"
-int __futimesat(int, const char *, const struct timeval [2]);
-
int utimes(const char *path, const struct timeval times[2])
{
return __futimesat(AT_FDCWD, path, times);
diff --git a/src/locale/dcngettext.c b/src/locale/dcngettext.c
index de0828d9..fc1018df 100644
--- a/src/locale/dcngettext.c
+++ b/src/locale/dcngettext.c
@@ -4,6 +4,7 @@
#include <errno.h>
#include <limits.h>
#include <sys/stat.h>
+#include <sys/mman.h>
#include <ctype.h>
#include "locale_impl.h"
#include "libc.h"
@@ -113,9 +114,6 @@ static char *dummy_gettextdomain()
weak_alias(dummy_gettextdomain, __gettextdomain);
-const unsigned char *__map_file(const char *, size_t *);
-int __munmap(void *, size_t);
-
char *dcngettext(const char *domainname, const char *msgid1, const char *msgid2, unsigned long int n, int category)
{
static struct msgcat *volatile cats;
diff --git a/src/locale/locale_map.c b/src/locale/locale_map.c
index 79542310..e7b518a1 100644
--- a/src/locale/locale_map.c
+++ b/src/locale/locale_map.c
@@ -1,5 +1,6 @@
#include <locale.h>
#include <string.h>
+#include <sys/mman.h>
#include "locale_impl.h"
#include "libc.h"
#include "atomic.h"
@@ -11,10 +12,6 @@ const char *__lctrans_impl(const char *msg, const struct __locale_map *lm)
return trans ? trans : msg;
}
-const unsigned char *__map_file(const char *, size_t *);
-int __munmap(void *, size_t);
-char *__strchrnul(const char *, int);
-
static const char envvars[][12] = {
"LC_CTYPE",
"LC_NUMERIC",
diff --git a/src/locale/setlocale.c b/src/locale/setlocale.c
index 40bc7ece..60e3353c 100644
--- a/src/locale/setlocale.c
+++ b/src/locale/setlocale.c
@@ -17,8 +17,6 @@ static char *setlocale_one_unlocked(int cat, const char *name)
return lm ? (char *)lm->name : "C";
}
-char *__strchrnul(const char *, int);
-
char *setlocale(int cat, const char *name)
{
static volatile int lock[1];
diff --git a/src/misc/ptsname.c b/src/misc/ptsname.c
index a3477927..58c151c9 100644
--- a/src/misc/ptsname.c
+++ b/src/misc/ptsname.c
@@ -1,8 +1,6 @@
#include <stdlib.h>
#include <errno.h>
-int __ptsname_r(int, char *, size_t);
-
char *ptsname(int fd)
{
static char buf[9 + sizeof(int)*3 + 1];
diff --git a/src/mman/shm_open.c b/src/mman/shm_open.c
index d042a5a8..79784bd3 100644
--- a/src/mman/shm_open.c
+++ b/src/mman/shm_open.c
@@ -6,8 +6,6 @@
#include <limits.h>
#include <pthread.h>
-char *__strchrnul(const char *, int);
-
char *__shm_mapname(const char *name, char *buf)
{
char *p;
diff --git a/src/network/getnameinfo.c b/src/network/getnameinfo.c
index 79b9e6ea..84f5ed6c 100644
--- a/src/network/getnameinfo.c
+++ b/src/network/getnameinfo.c
@@ -7,13 +7,10 @@
#include <arpa/inet.h>
#include <net/if.h>
#include <ctype.h>
+#include <resolv.h>
#include "lookup.h"
#include "stdio_impl.h"
-int __dn_expand(const unsigned char *, const unsigned char *, const unsigned char *, char *, int);
-int __res_mkquery(int, const char *, int, int, const unsigned char *, int, const unsigned char*, unsigned char *, int);
-int __res_send(const unsigned char *, int, unsigned char *, int);
-
#define PTR_MAX (64 + sizeof ".in-addr.arpa")
#define RR_PTR 12
diff --git a/src/network/inet_addr.c b/src/network/inet_addr.c
index 10b21f21..11ece3d6 100644
--- a/src/network/inet_addr.c
+++ b/src/network/inet_addr.c
@@ -2,8 +2,6 @@
#include <netinet/in.h>
#include <arpa/inet.h>
-int __inet_aton(const char *, struct in_addr *);
-
in_addr_t inet_addr(const char *p)
{
struct in_addr a;
diff --git a/src/network/lookup_ipliteral.c b/src/network/lookup_ipliteral.c
index 8ed14605..2fddab73 100644
--- a/src/network/lookup_ipliteral.c
+++ b/src/network/lookup_ipliteral.c
@@ -9,8 +9,6 @@
#include <ctype.h>
#include "lookup.h"
-int __inet_aton(const char *, struct in_addr *);
-
int __lookup_ipliteral(struct address buf[static 1], const char *name, int family)
{
struct in_addr a4;
diff --git a/src/network/lookup_name.c b/src/network/lookup_name.c
index 5a096ac0..c93263a9 100644
--- a/src/network/lookup_name.c
+++ b/src/network/lookup_name.c
@@ -10,6 +10,7 @@
#include <unistd.h>
#include <pthread.h>
#include <errno.h>
+#include <resolv.h>
#include "lookup.h"
#include "stdio_impl.h"
#include "syscall.h"
@@ -98,9 +99,6 @@ struct dpc_ctx {
int cnt;
};
-int __dn_expand(const unsigned char *, const unsigned char *, const unsigned char *, char *, int);
-int __res_mkquery(int, const char *, int, int, const unsigned char *, int, const unsigned char*, unsigned char *, int);
-
#define RR_A 1
#define RR_CNAME 5
#define RR_AAAA 28
diff --git a/src/network/res_query.c b/src/network/res_query.c
index 2b4e4bb1..691ccb16 100644
--- a/src/network/res_query.c
+++ b/src/network/res_query.c
@@ -2,9 +2,6 @@
#include <netdb.h>
#include "libc.h"
-int __res_mkquery(int, const char *, int, int, const unsigned char *, int, const unsigned char*, unsigned char *, int);
-int __res_send(const unsigned char *, int, unsigned char *, int);
-
int __res_query(const char *name, int class, int type, unsigned char *dest, int len)
{
unsigned char q[280];
diff --git a/src/network/res_send.c b/src/network/res_send.c
index 19cfe0f6..6facc1bd 100644
--- a/src/network/res_send.c
+++ b/src/network/res_send.c
@@ -1,8 +1,6 @@
#include <resolv.h>
#include "libc.h"
-int __res_msend(int, const unsigned char *const *, const int *, unsigned char *const *, int *, int);
-
int __res_send(const unsigned char *msg, int msglen, unsigned char *answer, int anslen)
{
int r = __res_msend(1, &msg, &msglen, &answer, &anslen, anslen);
diff --git a/src/process/posix_spawn.c b/src/process/posix_spawn.c
index 16308fb7..2f8ef935 100644
--- a/src/process/posix_spawn.c
+++ b/src/process/posix_spawn.c
@@ -19,8 +19,6 @@ struct args {
char *const *argv, *const *envp;
};
-void __get_handler_set(sigset_t *);
-
static int __sys_dup2(int old, int new)
{
#ifdef SYS_dup2
diff --git a/src/process/posix_spawnp.c b/src/process/posix_spawnp.c
index 165be746..aad6133b 100644
--- a/src/process/posix_spawnp.c
+++ b/src/process/posix_spawnp.c
@@ -1,8 +1,6 @@
#include <spawn.h>
#include <unistd.h>
-int __execvpe(const char *, char *const *, char *const *);
-
int posix_spawnp(pid_t *restrict res, const char *restrict file,
const posix_spawn_file_actions_t *fa,
const posix_spawnattr_t *restrict attr,
diff --git a/src/signal/signal.c b/src/signal/signal.c
index 29e03c88..bcd56825 100644
--- a/src/signal/signal.c
+++ b/src/signal/signal.c
@@ -2,8 +2,6 @@
#include "syscall.h"
#include "libc.h"
-int __sigaction(int, const struct sigaction *, struct sigaction *);
-
void (*signal(int sig, void (*func)(int)))(int)
{
struct sigaction sa_old, sa = { .sa_handler = func, .sa_flags = SA_RESTART };
diff --git a/src/stdio/freopen.c b/src/stdio/freopen.c
index 6c1b575f..a9c83c85 100644
--- a/src/stdio/freopen.c
+++ b/src/stdio/freopen.c
@@ -1,5 +1,6 @@
#include "stdio_impl.h"
#include <fcntl.h>
+#include <unistd.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
@@ -9,8 +10,6 @@
* lock, via flockfile or otherwise, when freopen is called, and in that
* case, freopen cannot act until the lock is released. */
-int __dup3(int, int, int);
-
FILE *freopen(const char *restrict filename, const char *restrict mode, FILE *restrict f)
{
int fl = __fmodeflags(mode);
diff --git a/src/stdio/tempnam.c b/src/stdio/tempnam.c
index 5a559752..84f91978 100644
--- a/src/stdio/tempnam.c
+++ b/src/stdio/tempnam.c
@@ -4,12 +4,11 @@
#include <sys/stat.h>
#include <limits.h>
#include <string.h>
+#include <stdlib.h>
#include "syscall.h"
#define MAXTRIES 100
-char *__randname(char *);
-
char *tempnam(const char *dir, const char *pfx)
{
char s[PATH_MAX];
diff --git a/src/stdio/tmpfile.c b/src/stdio/tmpfile.c
index 525090aa..55d742fa 100644
--- a/src/stdio/tmpfile.c
+++ b/src/stdio/tmpfile.c
@@ -1,11 +1,10 @@
#include <stdio.h>
#include <fcntl.h>
+#include <stdlib.h>
#include "stdio_impl.h"
#define MAXTRIES 100
-char *__randname(char *);
-
FILE *tmpfile(void)
{
char s[] = "/tmp/tmpfile_XXXXXX";
diff --git a/src/stdio/tmpnam.c b/src/stdio/tmpnam.c
index 449eb9b0..6c7c253a 100644
--- a/src/stdio/tmpnam.c
+++ b/src/stdio/tmpnam.c
@@ -3,12 +3,11 @@
#include <errno.h>
#include <sys/stat.h>
#include <string.h>
+#include <stdlib.h>
#include "syscall.h"
#define MAXTRIES 100
-char *__randname(char *);
-
char *tmpnam(char *buf)
{
static char internal[L_tmpnam];
diff --git a/src/string/strchr.c b/src/string/strchr.c
index bfae8f9f..3cbc828b 100644
--- a/src/string/strchr.c
+++ b/src/string/strchr.c
@@ -1,7 +1,5 @@
#include <string.h>
-char *__strchrnul(const char *, int);
-
char *strchr(const char *s, int c)
{
char *r = __strchrnul(s, c);
diff --git a/src/string/strcpy.c b/src/string/strcpy.c
index 2883e930..6668a129 100644
--- a/src/string/strcpy.c
+++ b/src/string/strcpy.c
@@ -1,7 +1,5 @@
#include <string.h>
-char *__stpcpy(char *, const char *);
-
char *strcpy(char *restrict dest, const char *restrict src)
{
__stpcpy(dest, src);
diff --git a/src/string/strcspn.c b/src/string/strcspn.c
index cfdba114..a0c617bd 100644
--- a/src/string/strcspn.c
+++ b/src/string/strcspn.c
@@ -3,8 +3,6 @@
#define BITOP(a,b,op) \
((a)[(size_t)(b)/(8*sizeof *(a))] op (size_t)1<<((size_t)(b)%(8*sizeof *(a))))
-char *__strchrnul(const char *, int);
-
size_t strcspn(const char *s, const char *c)
{
const char *a = s;
diff --git a/src/string/strncpy.c b/src/string/strncpy.c
index 441ba033..545892e6 100644
--- a/src/string/strncpy.c
+++ b/src/string/strncpy.c
@@ -1,7 +1,5 @@
#include <string.h>
-char *__stpncpy(char *, const char *, size_t);
-
char *strncpy(char *restrict d, const char *restrict s, size_t n)
{
__stpncpy(d, s, n);
diff --git a/src/string/strrchr.c b/src/string/strrchr.c
index 635fb3c1..98ad1b04 100644
--- a/src/string/strrchr.c
+++ b/src/string/strrchr.c
@@ -1,7 +1,5 @@
#include <string.h>
-void *__memrchr(const void *, int, size_t);
-
char *strrchr(const char *s, int c)
{
return __memrchr(s, c, strlen(s) + 1);
diff --git a/src/temp/__randname.c b/src/temp/__randname.c
index 464b83d5..2bce37a0 100644
--- a/src/temp/__randname.c
+++ b/src/temp/__randname.c
@@ -1,8 +1,6 @@
#include <time.h>
#include <stdint.h>
-int __clock_gettime(clockid_t, struct timespec *);
-
/* This assumes that a check for the
template size has already been made */
char *__randname(char *template)
diff --git a/src/temp/mkdtemp.c b/src/temp/mkdtemp.c
index 6c2c16ef..5708257b 100644
--- a/src/temp/mkdtemp.c
+++ b/src/temp/mkdtemp.c
@@ -3,8 +3,6 @@
#include <errno.h>
#include <sys/stat.h>
-char *__randname(char *);
-
char *mkdtemp(char *template)
{
size_t l = strlen(template);
diff --git a/src/temp/mkostemp.c b/src/temp/mkostemp.c
index e73e22a6..4fe57137 100644
--- a/src/temp/mkostemp.c
+++ b/src/temp/mkostemp.c
@@ -2,8 +2,6 @@
#include <stdlib.h>
#include "libc.h"
-int __mkostemps(char *, int, int);
-
int mkostemp(char *template, int flags)
{
return __mkostemps(template, 0, flags);
diff --git a/src/temp/mkostemps.c b/src/temp/mkostemps.c
index 43d95c41..d1464b45 100644
--- a/src/temp/mkostemps.c
+++ b/src/temp/mkostemps.c
@@ -6,8 +6,6 @@
#include <errno.h>
#include "libc.h"
-char *__randname(char *);
-
int __mkostemps(char *template, int len, int flags)
{
size_t l = strlen(template);
diff --git a/src/temp/mkstemp.c b/src/temp/mkstemp.c
index 85764af7..19d40148 100644
--- a/src/temp/mkstemp.c
+++ b/src/temp/mkstemp.c
@@ -1,8 +1,6 @@
#include <stdlib.h>
#include "libc.h"
-int __mkostemps(char *, int, int);
-
int mkstemp(char *template)
{
return __mkostemps(template, 0, 0);
diff --git a/src/temp/mkstemps.c b/src/temp/mkstemps.c
index fda710b0..f2ab1bd3 100644
--- a/src/temp/mkstemps.c
+++ b/src/temp/mkstemps.c
@@ -2,8 +2,6 @@
#include <stdlib.h>
#include "libc.h"
-int __mkostemps(char *, int, int);
-
int mkstemps(char *template, int len)
{
return __mkostemps(template, len, 0);
diff --git a/src/temp/mktemp.c b/src/temp/mktemp.c
index 4ab0df20..7b3d2648 100644
--- a/src/temp/mktemp.c
+++ b/src/temp/mktemp.c
@@ -4,8 +4,6 @@
#include <errno.h>
#include <sys/stat.h>
-char *__randname(char *);
-
char *mktemp(char *template)
{
size_t l = strlen(template);
diff --git a/src/thread/__timedwait.c b/src/thread/__timedwait.c
index d2079c88..229db313 100644
--- a/src/thread/__timedwait.c
+++ b/src/thread/__timedwait.c
@@ -5,9 +5,6 @@
#include "syscall.h"
#include "pthread_impl.h"
-int __pthread_setcancelstate(int, int *);
-int __clock_gettime(clockid_t, struct timespec *);
-
int __timedwait_cp(volatile int *addr, int val,
clockid_t clk, const struct timespec *at, int priv)
{
diff --git a/src/thread/call_once.c b/src/thread/call_once.c
index a7bc9353..5ed30183 100644
--- a/src/thread/call_once.c
+++ b/src/thread/call_once.c
@@ -1,6 +1,5 @@
#include <threads.h>
-
-int __pthread_once(once_flag *, void (*)(void));
+#include <pthread.h>
void call_once(once_flag *flag, void (*func)(void))
{
diff --git a/src/thread/cnd_broadcast.c b/src/thread/cnd_broadcast.c
index 0ad061a3..e76b5a81 100644
--- a/src/thread/cnd_broadcast.c
+++ b/src/thread/cnd_broadcast.c
@@ -1,8 +1,6 @@
#include <threads.h>
#include <pthread.h>
-int __private_cond_signal(pthread_cond_t *, int);
-
int cnd_broadcast(cnd_t *c)
{
/* This internal function never fails, and always returns zero,
diff --git a/src/thread/cnd_signal.c b/src/thread/cnd_signal.c
index 8165dae1..02cdc6c6 100644
--- a/src/thread/cnd_signal.c
+++ b/src/thread/cnd_signal.c
@@ -1,8 +1,6 @@
#include <threads.h>
#include <pthread.h>
-int __private_cond_signal(pthread_cond_t *, int);
-
int cnd_signal(cnd_t *c)
{
/* This internal function never fails, and always returns zero,
diff --git a/src/thread/cnd_timedwait.c b/src/thread/cnd_timedwait.c
index 7bfe1045..2802af52 100644
--- a/src/thread/cnd_timedwait.c
+++ b/src/thread/cnd_timedwait.c
@@ -2,8 +2,6 @@
#include <pthread.h>
#include <errno.h>
-int __pthread_cond_timedwait(pthread_cond_t *restrict, pthread_mutex_t *restrict, const struct timespec *restrict);
-
int cnd_timedwait(cnd_t *restrict c, mtx_t *restrict m, const struct timespec *restrict ts)
{
int ret = __pthread_cond_timedwait((pthread_cond_t *)c, (pthread_mutex_t *)m, ts);
diff --git a/src/thread/mtx_timedlock.c b/src/thread/mtx_timedlock.c
index d098053b..d22c8cf4 100644
--- a/src/thread/mtx_timedlock.c
+++ b/src/thread/mtx_timedlock.c
@@ -2,8 +2,6 @@
#include <pthread.h>
#include <errno.h>
-int __pthread_mutex_timedlock(pthread_mutex_t *restrict, const struct timespec *restrict);
-
int mtx_timedlock(mtx_t *restrict m, const struct timespec *restrict ts)
{
int ret = __pthread_mutex_timedlock((pthread_mutex_t *)m, ts);
diff --git a/src/thread/mtx_trylock.c b/src/thread/mtx_trylock.c
index 8d1fb07c..40a8b8c2 100644
--- a/src/thread/mtx_trylock.c
+++ b/src/thread/mtx_trylock.c
@@ -1,8 +1,6 @@
#include "pthread_impl.h"
#include <threads.h>
-int __pthread_mutex_trylock(pthread_mutex_t *);
-
int mtx_trylock(mtx_t *m)
{
if (m->_m_type == PTHREAD_MUTEX_NORMAL)
diff --git a/src/thread/mtx_unlock.c b/src/thread/mtx_unlock.c
index ac91f993..2e5c8cf6 100644
--- a/src/thread/mtx_unlock.c
+++ b/src/thread/mtx_unlock.c
@@ -1,8 +1,6 @@
#include <threads.h>
#include <pthread.h>
-int __pthread_mutex_unlock(pthread_mutex_t *);
-
int mtx_unlock(mtx_t *mtx)
{
/* The only cases where pthread_mutex_unlock can return an
diff --git a/src/thread/pthread_cond_broadcast.c b/src/thread/pthread_cond_broadcast.c
index 69f840fb..6bfab78f 100644
--- a/src/thread/pthread_cond_broadcast.c
+++ b/src/thread/pthread_cond_broadcast.c
@@ -1,7 +1,5 @@
#include "pthread_impl.h"
-int __private_cond_signal(pthread_cond_t *, int);
-
int pthread_cond_broadcast(pthread_cond_t *c)
{
if (!c->_c_shared) return __private_cond_signal(c, -1);
diff --git a/src/thread/pthread_cond_signal.c b/src/thread/pthread_cond_signal.c
index 119c00ab..575ad54b 100644
--- a/src/thread/pthread_cond_signal.c
+++ b/src/thread/pthread_cond_signal.c
@@ -1,7 +1,5 @@
#include "pthread_impl.h"
-int __private_cond_signal(pthread_cond_t *, int);
-
int pthread_cond_signal(pthread_cond_t *c)
{
if (!c->_c_shared) return __private_cond_signal(c, 1);
diff --git a/src/thread/pthread_cond_timedwait.c b/src/thread/pthread_cond_timedwait.c
index ed8569c2..d1501240 100644
--- a/src/thread/pthread_cond_timedwait.c
+++ b/src/thread/pthread_cond_timedwait.c
@@ -1,10 +1,5 @@
#include "pthread_impl.h"
-void __pthread_testcancel(void);
-int __pthread_mutex_lock(pthread_mutex_t *);
-int __pthread_mutex_unlock(pthread_mutex_t *);
-int __pthread_setcancelstate(int, int *);
-
/*
* struct waiter
*
diff --git a/src/thread/pthread_create.c b/src/thread/pthread_create.c
index dc869dc1..23dfe0ad 100644
--- a/src/thread/pthread_create.c
+++ b/src/thread/pthread_create.c
@@ -6,10 +6,6 @@
#include <string.h>
#include <stddef.h>
-void *__mmap(void *, size_t, int, int, int, off_t);
-int __munmap(void *, size_t);
-int __mprotect(void *, size_t, int);
-
static void dummy_0()
{
}
diff --git a/src/thread/pthread_detach.c b/src/thread/pthread_detach.c
index 9cee7a89..16b0552d 100644
--- a/src/thread/pthread_detach.c
+++ b/src/thread/pthread_detach.c
@@ -1,8 +1,6 @@
#include "pthread_impl.h"
#include <threads.h>
-int __pthread_join(pthread_t, void **);
-
static int __pthread_detach(pthread_t t)
{
/* If the cas fails, detach state is either already-detached
diff --git a/src/thread/pthread_join.c b/src/thread/pthread_join.c
index 551c3675..54d81039 100644
--- a/src/thread/pthread_join.c
+++ b/src/thread/pthread_join.c
@@ -1,10 +1,6 @@
#include "pthread_impl.h"
#include <sys/mman.h>
-int __munmap(void *, size_t);
-void __pthread_testcancel(void);
-int __pthread_setcancelstate(int, int *);
-
static int __pthread_timedjoin_np(pthread_t t, void **res, const struct timespec *at)
{
int state, cs, r = 0;
diff --git a/src/thread/pthread_mutex_lock.c b/src/thread/pthread_mutex_lock.c
index d0c93cab..638d4b86 100644
--- a/src/thread/pthread_mutex_lock.c
+++ b/src/thread/pthread_mutex_lock.c
@@ -1,7 +1,5 @@
#include "pthread_impl.h"
-int __pthread_mutex_timedlock(pthread_mutex_t *restrict, const struct timespec *restrict);
-
int __pthread_mutex_lock(pthread_mutex_t *m)
{
if ((m->_m_type&15) == PTHREAD_MUTEX_NORMAL
diff --git a/src/thread/pthread_mutex_timedlock.c b/src/thread/pthread_mutex_timedlock.c
index d2bd1960..9867f389 100644
--- a/src/thread/pthread_mutex_timedlock.c
+++ b/src/thread/pthread_mutex_timedlock.c
@@ -1,7 +1,5 @@
#include "pthread_impl.h"
-int __pthread_mutex_trylock(pthread_mutex_t *);
-
int __pthread_mutex_timedlock(pthread_mutex_t *restrict m, const struct timespec *restrict at)
{
if ((m->_m_type&15) == PTHREAD_MUTEX_NORMAL
diff --git a/src/thread/sem_open.c b/src/thread/sem_open.c
index dc0279e8..1bd8020a 100644
--- a/src/thread/sem_open.c
+++ b/src/thread/sem_open.c
@@ -13,8 +13,6 @@
#include <pthread.h>
#include "libc.h"
-char *__shm_mapname(const char *, char *);
-
static struct {
ino_t ino;
sem_t *sem;
diff --git a/src/thread/thrd_create.c b/src/thread/thrd_create.c
index e0336695..76a683db 100644
--- a/src/thread/thrd_create.c
+++ b/src/thread/thrd_create.c
@@ -1,8 +1,6 @@
#include "pthread_impl.h"
#include <threads.h>
-int __pthread_create(pthread_t *restrict, const pthread_attr_t *restrict, void *(*)(void *), void *restrict);
-
int thrd_create(thrd_t *thr, thrd_start_t func, void *arg)
{
int ret = __pthread_create(thr, __ATTRP_C11_THREAD, (void *(*)(void *))func, arg);
diff --git a/src/thread/thrd_exit.c b/src/thread/thrd_exit.c
index b66bd996..9b291ae3 100644
--- a/src/thread/thrd_exit.c
+++ b/src/thread/thrd_exit.c
@@ -1,7 +1,6 @@
-#include "pthread_impl.h"
#include <threads.h>
-
-_Noreturn void __pthread_exit(void *);
+#include <pthread.h>
+#include <stdint.h>
_Noreturn void thrd_exit(int result)
{
diff --git a/src/thread/thrd_join.c b/src/thread/thrd_join.c
index ac667893..0d5fd302 100644
--- a/src/thread/thrd_join.c
+++ b/src/thread/thrd_join.c
@@ -1,7 +1,6 @@
#include <stdint.h>
#include <threads.h>
-
-int __pthread_join(thrd_t, void**);
+#include <pthread.h>
int thrd_join(thrd_t t, int *res)
{
diff --git a/src/thread/tss_create.c b/src/thread/tss_create.c
index 251d22b9..6d6ef96b 100644
--- a/src/thread/tss_create.c
+++ b/src/thread/tss_create.c
@@ -1,6 +1,5 @@
#include <threads.h>
-
-int __pthread_key_create(tss_t *, void (*)(void *));
+#include <pthread.h>
int tss_create(tss_t *tss, tss_dtor_t dtor)
{
diff --git a/src/thread/tss_delete.c b/src/thread/tss_delete.c
index 35db1032..6f51b07e 100644
--- a/src/thread/tss_delete.c
+++ b/src/thread/tss_delete.c
@@ -1,6 +1,5 @@
#include <threads.h>
-
-int __pthread_key_delete(tss_t k);
+#include <pthread.h>
void tss_delete(tss_t key)
{
diff --git a/src/time/__map_file.c b/src/time/__map_file.c
index b91eb8ed..750d1958 100644
--- a/src/time/__map_file.c
+++ b/src/time/__map_file.c
@@ -3,8 +3,6 @@
#include <sys/stat.h>
#include "syscall.h"
-void *__mmap(void *, size_t, int, int, int, off_t);
-
const char unsigned *__map_file(const char *pathname, size_t *size)
{
struct stat st;
diff --git a/src/time/__tz.c b/src/time/__tz.c
index 814edcdf..a2afe92a 100644
--- a/src/time/__tz.c
+++ b/src/time/__tz.c
@@ -3,6 +3,7 @@
#include <limits.h>
#include <stdlib.h>
#include <string.h>
+#include <sys/mman.h>
#include "libc.h"
long __timezone = 0;
@@ -113,8 +114,6 @@ static size_t zi_dotprod(const unsigned char *z, const unsigned char *v, size_t
return y;
}
-int __munmap(void *, size_t);
-
static void do_tzset()
{
char buf[NAME_MAX+25], *pathname=buf+24;
diff --git a/src/time/asctime.c b/src/time/asctime.c
index 57d15fe0..1febe544 100644
--- a/src/time/asctime.c
+++ b/src/time/asctime.c
@@ -1,7 +1,5 @@
#include <time.h>
-char *__asctime_r(const struct tm *, char *);
-
char *asctime(const struct tm *tm)
{
static char buf[26];
diff --git a/src/time/asctime_r.c b/src/time/asctime_r.c
index d1639ab0..af2618de 100644
--- a/src/time/asctime_r.c
+++ b/src/time/asctime_r.c
@@ -5,8 +5,6 @@
#include "atomic.h"
#include "libc.h"
-char *__nl_langinfo_l(nl_item, locale_t);
-
char *__asctime_r(const struct tm *restrict tm, char *restrict buf)
{
if (snprintf(buf, 26, "%.3s %.3s%3d %.2d:%.2d:%.2d %d\n",
diff --git a/src/time/clock.c b/src/time/clock.c
index c348e398..6724012b 100644
--- a/src/time/clock.c
+++ b/src/time/clock.c
@@ -1,8 +1,6 @@
#include <time.h>
#include <limits.h>
-int __clock_gettime(clockid_t, struct timespec *);
-
clock_t clock()
{
struct timespec ts;
diff --git a/src/time/gmtime.c b/src/time/gmtime.c
index 3791b24c..6320b637 100644
--- a/src/time/gmtime.c
+++ b/src/time/gmtime.c
@@ -1,8 +1,6 @@
#include "time_impl.h"
#include <errno.h>
-struct tm *__gmtime_r(const time_t *restrict, struct tm *restrict);
-
struct tm *gmtime(const time_t *t)
{
static struct tm tm;
diff --git a/src/time/localtime.c b/src/time/localtime.c
index bb6718c3..52104232 100644
--- a/src/time/localtime.c
+++ b/src/time/localtime.c
@@ -1,7 +1,5 @@
#include "time_impl.h"
-struct tm *__localtime_r(const time_t *restrict, struct tm *restrict);
-
struct tm *localtime(const time_t *t)
{
static struct tm tm;
diff --git a/src/time/strftime.c b/src/time/strftime.c
index ddb47772..ba18a27c 100644
--- a/src/time/strftime.c
+++ b/src/time/strftime.c
@@ -9,8 +9,6 @@
#include "libc.h"
#include "time_impl.h"
-char *__nl_langinfo_l(nl_item, locale_t);
-
static int is_leap(int y)
{
/* Avoid overflow */
@@ -45,8 +43,6 @@ static int week_num(const struct tm *tm)
return val;
}
-size_t __strftime_l(char *restrict, size_t, const char *restrict, const struct tm *restrict, locale_t);
-
const char *__strftime_fmt_1(char (*s)[100], size_t *l, int f, const struct tm *tm, locale_t loc, int pad)
{
nl_item item;
diff --git a/src/time/time.c b/src/time/time.c
index 4b95e752..ad0480f9 100644
--- a/src/time/time.c
+++ b/src/time/time.c
@@ -1,8 +1,6 @@
#include <time.h>
#include "syscall.h"
-int __clock_gettime(clockid_t, struct timespec *);
-
time_t time(time_t *t)
{
struct timespec ts;
diff --git a/src/time/time_impl.h b/src/time/time_impl.h
index 5cc2fe2f..50afe156 100644
--- a/src/time/time_impl.h
+++ b/src/time/time_impl.h
@@ -7,5 +7,4 @@ long long __tm_to_secs(const struct tm *);
const char *__tm_to_tzname(const struct tm *);
int __secs_to_tm(long long, struct tm *);
void __secs_to_zone(long long, int, int *, long *, long *, const char **);
-const unsigned char *__map_file(const char *, size_t *);
const char *__strftime_fmt_1(char (*)[100], size_t *, int, const struct tm *, locale_t, int);
diff --git a/src/time/timespec_get.c b/src/time/timespec_get.c
index 03c5a77b..40ea9c1c 100644
--- a/src/time/timespec_get.c
+++ b/src/time/timespec_get.c
@@ -1,7 +1,5 @@
#include <time.h>
-int __clock_gettime(clockid_t, struct timespec *);
-
/* There is no other implemented value than TIME_UTC; all other values
* are considered erroneous. */
int timespec_get(struct timespec * ts, int base)