提交 5ce37379 编写于 作者: R Rich Felker

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.
上级 0676c3a3
......@@ -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
......
......@@ -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)
......
......@@ -3,7 +3,6 @@
#include <unistd.h>
#include <string.h>
#include "pthread_impl.h"
#include "libc.h"
struct lio_state {
struct sigevent *sev;
......
......@@ -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)
......
#include <crypt.h>
#include "libc.h"
char *__crypt_r(const char *key, const char *salt, struct crypt_data *data)
{
......
#include <ctype.h>
#include "libc.h"
int isalnum(int c)
{
......
#include <ctype.h>
#include "libc.h"
#undef isalpha
int isalpha(int c)
......
#include <ctype.h>
#include "libc.h"
int isblank(int c)
{
......
#include <ctype.h>
#include "libc.h"
int iscntrl(int c)
{
......
#include <ctype.h>
#include "libc.h"
#undef isdigit
int isdigit(int c)
......
#include <ctype.h>
#include "libc.h"
#undef isgraph
int isgraph(int c)
......
#include <ctype.h>
#include "libc.h"
#undef islower
int islower(int c)
......
#include <ctype.h>
#include "libc.h"
#undef isprint
int isprint(int c)
......
#include <ctype.h>
#include "libc.h"
int ispunct(int c)
{
......
#include <ctype.h>
#include "libc.h"
#undef isspace
int isspace(int c)
......
#include <ctype.h>
#include "libc.h"
#undef isupper
int isupper(int c)
......
#include <wctype.h>
#include "libc.h"
int iswalnum(wint_t wc)
{
......
#include <wctype.h>
#include "libc.h"
static const unsigned char table[] = {
#include "alpha.h"
......
#include <wctype.h>
#include <ctype.h>
#include "libc.h"
int iswblank(wint_t wc)
{
......
#include <wctype.h>
#include "libc.h"
int iswcntrl(wint_t wc)
{
......
#include <wctype.h>
#include <string.h>
#include "libc.h"
#define WCTYPE_ALNUM 1
#define WCTYPE_ALPHA 2
......
#include <wctype.h>
#include "libc.h"
#undef iswdigit
......
#include <wctype.h>
#include "libc.h"
int iswgraph(wint_t wc)
{
......
#include <wctype.h>
#include "libc.h"
int iswlower(wint_t wc)
{
......
#include <wctype.h>
#include "libc.h"
/* Consider all legal codepoints as printable except for:
* - C0 and C1 control characters
......
#include <wctype.h>
#include "libc.h"
static const unsigned char table[] = {
#include "punct.h"
......
#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-
......
#include <wctype.h>
#include "libc.h"
int iswupper(wint_t wc)
{
......
#include <wctype.h>
#include "libc.h"
int iswxdigit(wint_t wc)
{
......
#include <ctype.h>
#include "libc.h"
int isxdigit(int c)
{
......
#include <ctype.h>
#include "libc.h"
int tolower(int c)
{
......
#include <ctype.h>
#include "libc.h"
int toupper(int c)
{
......
#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)
......
#include <wctype.h>
#include <string.h>
#include "libc.h"
wctrans_t wctrans(const char *class)
{
......
#include <dirent.h>
#include <unistd.h>
#include <stdlib.h>
#include "__dirent.h"
#include "libc.h"
int closedir(DIR *dir)
{
......
#include "libc.h"
#include <unistd.h>
char **__environ = 0;
weak_alias(__environ, ___environ);
......
#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);
......
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "libc.h"
char *getenv(const char *name)
{
......
#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);
......
......@@ -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);
......
#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[] = {
......
......@@ -3,7 +3,6 @@
#include <stdarg.h>
#include <errno.h>
#include "syscall.h"
#include "libc.h"
int fcntl(int fd, int cmd, ...)
{
......
#include <fenv.h>
#include "libc.h"
#include <features.h>
/* __fesetround wrapper for arch independent argument check */
......
#include <fenv.h>
#include "libc.h"
#include <features.h>
#if __HAVE_68881__ || __mcffpu__
......
#define _GNU_SOURCE
#include <fenv.h>
#include "libc.h"
#include <features.h>
static inline double get_fpscr_f(void)
{
......
#include <fenv.h>
#include "libc.h"
#include <features.h>
static inline unsigned get_fpc(void)
{
......
......@@ -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;
......
#include <stdint.h>
#include "libc.h"
#include <features.h>
hidden void *__fdpic_fixup(void *map, uintptr_t *a, uintptr_t *z)
{
......
......@@ -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)
......
#ifndef MALLOC_IMPL_H
#define MALLOC_IMPL_H
#include "libc.h"
#include <sys/mman.h>
hidden void *__expand_heap(size_t *);
......
#include "libc.h"
#include <features.h>
hidden int __shcall(void *arg, int (*func)(void *))
{
......
......@@ -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);
......
#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
......
#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)
{
......
#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)
{
......
#include <dlfcn.h>
#include "dynlink.h"
#include "libc.h"
static void *stub_dlsym(void *restrict p, const char *restrict s, void *restrict ra)
{
......
#define _GNU_SOURCE
#include <dlfcn.h>
#include "libc.h"
static int stub_dladdr(const void *addr, Dl_info *info)
{
......
#include <dlfcn.h>
#include "dynlink.h"
#include "libc.h"
int dlclose(void *p)
{
......
......@@ -3,7 +3,6 @@
#include <stdarg.h>
#include "pthread_impl.h"
#include "dynlink.h"
#include "libc.h"
char *dlerror()
{
......
#define _GNU_SOURCE
#include <dlfcn.h>
#include "dynlink.h"
#include "libc.h"
int dlinfo(void *dso, int req, void *res)
{
......
#include <dlfcn.h>
#include "dynlink.h"
#include "libc.h"
static void *stub_dlopen(const char *file, int mode)
{
......
#include <stddef.h>
#include <dynlink.h>
#include "libc.h"
ptrdiff_t __tlsdesc_static()
{
......
#define _GNU_SOURCE
#include <unistd.h>
#include <fcntl.h>
#include "libc.h"
int euidaccess(const char *filename, int amode)
{
......
......@@ -2,7 +2,6 @@
#include <utmpx.h>
#include <stddef.h>
#include <errno.h>
#include "libc.h"
void endutxent(void)
{
......
#include "syscall.h"
#include "libc.h"
#ifdef SYS_cacheflush
int _flush_cache(void *addr, int len, int op)
......
#define _BSD_SOURCE
#include <dirent.h>
#include "syscall.h"
#include "libc.h"
int getdents(int fd, struct dirent *buf, size_t len)
{
......
#include <sys/fsuid.h>
#include "syscall.h"
#include "libc.h"
int setfsgid(gid_t gid)
{
......
#include <sys/fsuid.h>
#include "syscall.h"
#include "libc.h"
int setfsuid(uid_t uid)
{
......
#include <sys/sysinfo.h>
#include "syscall.h"
#include "libc.h"
int __lsysinfo(struct sysinfo *info)
{
......
#include <sys/sysinfo.h>
#include "syscall.h"
#include "libc.h"
#define klong long long
#define kulong unsigned long long
......
#include <locale.h>
#include "locale_impl.h"
#include "libc.h"
static const char *dummy(const char *msg, const struct __locale_map *lm)
{
......
......@@ -7,7 +7,6 @@
#include <sys/mman.h>
#include <ctype.h>
#include "locale_impl.h"
#include "libc.h"
#include "atomic.h"
#include "pleval.h"
......
#include <stdlib.h>
#include "locale_impl.h"
#include "libc.h"
void freelocale(locale_t l)
{
......
#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"
......
#include <stdlib.h>
#include <string.h>
#include "locale_impl.h"
#include "libc.h"
int __loc_is_allocated(locale_t loc)
{
......
#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)
{
......
#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)
......
......@@ -3,8 +3,6 @@
#include <stdlib.h>
#include <errno.h>
#include <limits.h>
#include "libc.h"
#include "atomic.h"
static char *current_domain;
......
#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)
......
#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)
......
#include <stdlib.h>
#include <stdint.h>
#include <errno.h>
#include "libc.h"
#include "malloc_impl.h"
void *__memalign(size_t align, size_t len)
......
#define _GNU_SOURCE
#include <math.h>
#include <stdint.h>
#include "libc.h"
double exp10(double x)
{
......
#define _GNU_SOURCE
#include <math.h>
#include <stdint.h>
#include "libc.h"
float exp10f(float x)
{
......
#define _GNU_SOURCE
#include <float.h>
#include <math.h>
#include "libc.h"
#include "libm.h"
#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
......
......@@ -79,7 +79,6 @@
*/
#include "libm.h"
#include "libc.h"
static const double
pi = 3.14159265358979311600e+00, /* 0x400921FB, 0x54442D18 */
......
......@@ -14,7 +14,6 @@
*/
#include "libm.h"
#include "libc.h"
static const float
pi = 3.1415927410e+00, /* 0x40490fdb */
......
......@@ -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)
......
#include <math.h>
#include "libc.h"
double remainder(double x, double y)
{
......
#include <math.h>
#include "libc.h"
float remainderf(float x, float y)
{
......
#include <math.h>
#include "libm.h"
#include "libc.h"
int __signgam = 0;
......
#include <string.h>
#include <libgen.h>
#include "libc.h"
char *basename(char *s)
{
......
......@@ -3,7 +3,6 @@
#include <string.h>
#include <limits.h>
#include <stdlib.h>
#include "libc.h"
#include "locale_impl.h"
#include "stdio_impl.h"
......
......@@ -3,7 +3,6 @@
#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
#include "libc.h"
#include "syscall.h"
int posix_openpt(int flags)
......
#include <sys/mman.h>
#include "syscall.h"
#include "libc.h"
int __madvise(void *addr, size_t len, int advice)
{
......
......@@ -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);
......
#include <sys/mman.h>
#include "syscall.h"
#include "libc.h"
static void dummy(void) { }
weak_alias(dummy, __vm_wait);
......
#define bittab __fsmu8
#include <stdint.h>
#include "libc.h"
#include <features.h>
extern hidden const uint32_t bittab[];
......
#include <sys/socket.h>
#include "syscall.h"
#include "libc.h"
int accept(int fd, struct sockaddr *restrict addr, socklen_t *restrict len)
{
......
......@@ -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)
{
......
#include <sys/socket.h>
#include "syscall.h"
#include "libc.h"
int connect(int fd, const struct sockaddr *addr, socklen_t len)
{
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册