mirror of https://git.musl-libc.org/git/musl
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.
This commit is contained in:
parent
8c1ac426e1
commit
13d1afa46f
2
Makefile
2
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)
|
||||
|
|
|
@ -96,8 +96,6 @@ struct symdef {
|
|||
struct dso *dso;
|
||||
};
|
||||
|
||||
void __init_libc(char **, char *);
|
||||
|
||||
static struct builtin_tls {
|
||||
char c;
|
||||
struct pthread pt;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#define _GNU_SOURCE
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include "libc.h"
|
||||
|
||||
static void dummy(char *old, char *new) {}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -0,0 +1,8 @@
|
|||
#ifndef LANGINFO_H
|
||||
#define LANGINFO_H
|
||||
|
||||
#include "../../include/langinfo.h"
|
||||
|
||||
char *__nl_langinfo_l(nl_item, locale_t);
|
||||
|
||||
#endif
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -0,0 +1,8 @@
|
|||
#ifndef SYS_SYSINFO_H
|
||||
#define SYS_SYSINFO_H
|
||||
|
||||
#include "../../../include/sys/sysinfo.h"
|
||||
|
||||
int __lsysinfo(struct sysinfo *);
|
||||
|
||||
#endif
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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 *);
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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];
|
||||
|
|
|
@ -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];
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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];
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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 };
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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];
|
||||
|
|
|
@ -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";
|
||||
|
|
|
@ -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];
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#include <string.h>
|
||||
|
||||
char *__strchrnul(const char *, int);
|
||||
|
||||
char *strchr(const char *s, int c)
|
||||
{
|
||||
char *r = __strchrnul(s, 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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -3,8 +3,6 @@
|
|||
#include <errno.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
char *__randname(char *);
|
||||
|
||||
char *mkdtemp(char *template)
|
||||
{
|
||||
size_t l = strlen(template);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
#include <stdlib.h>
|
||||
#include "libc.h"
|
||||
|
||||
int __mkostemps(char *, int, int);
|
||||
|
||||
int mkstemp(char *template)
|
||||
{
|
||||
return __mkostemps(template, 0, 0);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -4,8 +4,6 @@
|
|||
#include <errno.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
char *__randname(char *);
|
||||
|
||||
char *mktemp(char *template)
|
||||
{
|
||||
size_t l = strlen(template);
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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))
|
||||
{
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -13,8 +13,6 @@
|
|||
#include <pthread.h>
|
||||
#include "libc.h"
|
||||
|
||||
char *__shm_mapname(const char *, char *);
|
||||
|
||||
static struct {
|
||||
ino_t ino;
|
||||
sem_t *sem;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
#include <threads.h>
|
||||
|
||||
int __pthread_key_delete(tss_t k);
|
||||
#include <pthread.h>
|
||||
|
||||
void tss_delete(tss_t key)
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#include <time.h>
|
||||
|
||||
char *__asctime_r(const struct tm *, char *);
|
||||
|
||||
char *asctime(const struct tm *tm)
|
||||
{
|
||||
static char buf[26];
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
#include <time.h>
|
||||
#include <limits.h>
|
||||
|
||||
int __clock_gettime(clockid_t, struct timespec *);
|
||||
|
||||
clock_t clock()
|
||||
{
|
||||
struct timespec ts;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue