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:
Rich Felker
2018-09-12 14:34:33 -04:00
parent 8c1ac426e1
commit 13d1afa46f
92 changed files with 200 additions and 192 deletions
+8
View File
@@ -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
+14
View File
@@ -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
+11
View File
@@ -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
+8
View File
@@ -0,0 +1,8 @@
#ifndef LANGINFO_H
#define LANGINFO_H
#include "../../include/langinfo.h"
char *__nl_langinfo_l(nl_item, locale_t);
#endif
+22
View File
@@ -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
+12
View File
@@ -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
+14
View File
@@ -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
+11
View File
@@ -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
+11
View File
@@ -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
+20
View File
@@ -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
+8
View File
@@ -0,0 +1,8 @@
#ifndef SYS_SYSINFO_H
#define SYS_SYSINFO_H
#include "../../../include/sys/sysinfo.h"
int __lsysinfo(struct sysinfo *);
#endif
+8
View File
@@ -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
+14
View File
@@ -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
+12
View File
@@ -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