diff options
Diffstat (limited to 'lib/libc')
104 files changed, 455 insertions, 370 deletions
diff --git a/lib/libc/Makefile.depend b/lib/libc/Makefile.depend index 05b44c8..02168e8 100644 --- a/lib/libc/Makefile.depend +++ b/lib/libc/Makefile.depend @@ -126,6 +126,9 @@ jemalloc_mb.po: jemalloc_mb.c jemalloc_mutex.So: jemalloc_mutex.c jemalloc_mutex.o: jemalloc_mutex.c jemalloc_mutex.po: jemalloc_mutex.c +jemalloc_pages.So: jemalloc_pages.c +jemalloc_pages.o: jemalloc_pages.c +jemalloc_pages.po: jemalloc_pages.c jemalloc_prof.So: jemalloc_prof.c jemalloc_prof.o: jemalloc_prof.c jemalloc_prof.po: jemalloc_prof.c diff --git a/lib/libc/aarch64/gen/_set_tp.c b/lib/libc/aarch64/gen/_set_tp.c index a587b2e..871acb3 100644 --- a/lib/libc/aarch64/gen/_set_tp.c +++ b/lib/libc/aarch64/gen/_set_tp.c @@ -33,6 +33,7 @@ __FBSDID("$FreeBSD$"); #include <machine/sysarch.h> #include <stdlib.h> +#include "libc_private.h" void _set_tp(void *tp) diff --git a/lib/libc/amd64/gen/_set_tp.c b/lib/libc/amd64/gen/_set_tp.c index 02e5e14..d5526fa 100644 --- a/lib/libc/amd64/gen/_set_tp.c +++ b/lib/libc/amd64/gen/_set_tp.c @@ -29,6 +29,7 @@ #include <string.h> #include <stdint.h> #include <machine/sysarch.h> +#include "libc_private.h" void _set_tp(void *tp) diff --git a/lib/libc/arm/gen/_set_tp.c b/lib/libc/arm/gen/_set_tp.c index 97cabec..2332f59 100644 --- a/lib/libc/arm/gen/_set_tp.c +++ b/lib/libc/arm/gen/_set_tp.c @@ -30,6 +30,7 @@ #include <sys/types.h> #include <machine/sysarch.h> +#include "libc_private.h" void _set_tp(void *tp) diff --git a/lib/libc/compat-43/creat.c b/lib/libc/compat-43/creat.c index 4545482..983ff92 100644 --- a/lib/libc/compat-43/creat.c +++ b/lib/libc/compat-43/creat.c @@ -41,6 +41,8 @@ __FBSDID("$FreeBSD$"); __weak_reference(__creat, creat); __weak_reference(__creat, _creat); +int __creat(const char *path, mode_t mode); + #pragma weak creat int __creat(const char *path, mode_t mode) diff --git a/lib/libc/gdtoa/_ldtoa.c b/lib/libc/gdtoa/_ldtoa.c index 60c6b22..00d7601 100644 --- a/lib/libc/gdtoa/_ldtoa.c +++ b/lib/libc/gdtoa/_ldtoa.c @@ -32,6 +32,7 @@ __FBSDID("$FreeBSD$"); #include <limits.h> #include <math.h> #include <stdlib.h> +#include "../stdio/floatio.h" #include "fpmath.h" #include "gdtoaimp.h" diff --git a/lib/libc/gen/alarm.c b/lib/libc/gen/alarm.c index 318be4c..439a9e1 100644 --- a/lib/libc/gen/alarm.c +++ b/lib/libc/gen/alarm.c @@ -40,8 +40,7 @@ __FBSDID("$FreeBSD$"); #include <unistd.h> unsigned int -alarm(secs) - unsigned int secs; +alarm(unsigned int secs) { struct itimerval it, oitv; struct itimerval *itp = ⁢ diff --git a/lib/libc/gen/assert.c b/lib/libc/gen/assert.c index 73e199c..ccbc7a4 100644 --- a/lib/libc/gen/assert.c +++ b/lib/libc/gen/assert.c @@ -38,10 +38,7 @@ __FBSDID("$FreeBSD$"); #include <stdlib.h> void -__assert(func, file, line, failedexpr) - const char *func, *file; - int line; - const char *failedexpr; +__assert(const char *func, const char *file, int line, const char *failedexpr) { if (func == NULL) (void)fprintf(stderr, diff --git a/lib/libc/gen/dlfcn.c b/lib/libc/gen/dlfcn.c index 7d28797..53c9d67 100644 --- a/lib/libc/gen/dlfcn.c +++ b/lib/libc/gen/dlfcn.c @@ -41,6 +41,10 @@ __FBSDID("$FreeBSD$"); static char sorry[] = "Service unavailable"; +void _rtld_thread_init(void *); +void _rtld_atfork_pre(int *); +void _rtld_atfork_post(int *); + /* * For ELF, the dynamic linker directly resolves references to its * services to functions inside the dynamic linker itself. These diff --git a/lib/libc/gen/dup3.c b/lib/libc/gen/dup3.c index ac8877c..ff3431a 100644 --- a/lib/libc/gen/dup3.c +++ b/lib/libc/gen/dup3.c @@ -35,6 +35,8 @@ __FBSDID("$FreeBSD$"); #include <errno.h> #include "un-namespace.h" +int __dup3(int, int, int); + int __dup3(int oldfd, int newfd, int flags) { diff --git a/lib/libc/gen/elf_utils.c b/lib/libc/gen/elf_utils.c index 7bd7511..069f62e 100644 --- a/lib/libc/gen/elf_utils.c +++ b/lib/libc/gen/elf_utils.c @@ -33,6 +33,9 @@ #include <link.h> #include <stddef.h> +int __elf_phdr_match_addr(struct dl_phdr_info *, void *); +void __pthread_map_stacks_exec(void); + int __elf_phdr_match_addr(struct dl_phdr_info *phdr_info, void *addr) { diff --git a/lib/libc/gen/err.c b/lib/libc/gen/err.c index 0ba584c..a536e5a 100644 --- a/lib/libc/gen/err.c +++ b/lib/libc/gen/err.c @@ -79,10 +79,7 @@ _err(int eval, const char *fmt, ...) } void -verr(eval, fmt, ap) - int eval; - const char *fmt; - va_list ap; +verr(int eval, const char *fmt, va_list ap) { verrc(eval, errno, fmt, ap); } diff --git a/lib/libc/gen/exec.c b/lib/libc/gen/exec.c index 4998ee8..c6731f7 100644 --- a/lib/libc/gen/exec.c +++ b/lib/libc/gen/exec.c @@ -131,9 +131,7 @@ execlp(const char *name, const char *arg, ...) } int -execv(name, argv) - const char *name; - char * const *argv; +execv(const char *name, char * const *argv) { (void)_execve(name, argv, environ); return (-1); diff --git a/lib/libc/gen/feature_present.c b/lib/libc/gen/feature_present.c index 7a2c282..a230c8a 100644 --- a/lib/libc/gen/feature_present.c +++ b/lib/libc/gen/feature_present.c @@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$"); #include <sys/sysctl.h> #include <stdio.h> #include <stdlib.h> +#include <unistd.h> /* * Returns true if the named feature is present in the currently diff --git a/lib/libc/gen/fmtcheck.c b/lib/libc/gen/fmtcheck.c index 5b3f2c4..7929f1f 100644 --- a/lib/libc/gen/fmtcheck.c +++ b/lib/libc/gen/fmtcheck.c @@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$"); #include <ctype.h> __weak_reference(__fmtcheck, fmtcheck); +const char * __fmtcheck(const char *, const char *); enum __e_fmtcheck_types { FMTCHECK_START, diff --git a/lib/libc/gen/fnmatch.c b/lib/libc/gen/fnmatch.c index 47d0a41..173592a 100644 --- a/lib/libc/gen/fnmatch.c +++ b/lib/libc/gen/fnmatch.c @@ -76,9 +76,7 @@ static int fnmatch1(const char *, const char *, const char *, int, mbstate_t, mbstate_t); int -fnmatch(pattern, string, flags) - const char *pattern, *string; - int flags; +fnmatch(const char *pattern, const char *string, int flags) { static const mbstate_t initial; @@ -86,10 +84,8 @@ fnmatch(pattern, string, flags) } static int -fnmatch1(pattern, string, stringstart, flags, patmbs, strmbs) - const char *pattern, *string, *stringstart; - int flags; - mbstate_t patmbs, strmbs; +fnmatch1(const char *pattern, const char *string, const char *stringstart, + int flags, mbstate_t patmbs, mbstate_t strmbs) { char *newp; char c; @@ -214,12 +210,8 @@ fnmatch1(pattern, string, stringstart, flags, patmbs, strmbs) } static int -rangematch(pattern, test, flags, newp, patmbs) - const char *pattern; - wchar_t test; - int flags; - char **newp; - mbstate_t *patmbs; +rangematch(const char *pattern, wchar_t test, int flags, char **newp, + mbstate_t *patmbs) { int negate, ok; wchar_t c, c2; diff --git a/lib/libc/gen/ftok.c b/lib/libc/gen/ftok.c index 4269e37..2fad66e 100644 --- a/lib/libc/gen/ftok.c +++ b/lib/libc/gen/ftok.c @@ -33,9 +33,7 @@ __FBSDID("$FreeBSD$"); #include <sys/ipc.h> key_t -ftok(path, id) - const char *path; - int id; +ftok(const char *path, int id) { struct stat st; diff --git a/lib/libc/gen/fts-compat.c b/lib/libc/gen/fts-compat.c index 105b064..313431a 100644 --- a/lib/libc/gen/fts-compat.c +++ b/lib/libc/gen/fts-compat.c @@ -120,10 +120,8 @@ static const char *ufslike_filesystems[] = { }; FTS * -__fts_open_44bsd(argv, options, compar) - char * const *argv; - int options; - int (*compar)(const FTSENT * const *, const FTSENT * const *); +__fts_open_44bsd(char * const *argv, int options, + int (*compar)(const FTSENT * const *, const FTSENT * const *)) { struct _fts_private *priv; FTS *sp; @@ -234,9 +232,7 @@ mem1: free(sp); } static void -fts_load(sp, p) - FTS *sp; - FTSENT *p; +fts_load(FTS *sp, FTSENT *p) { int len; char *cp; @@ -260,8 +256,7 @@ fts_load(sp, p) } int -__fts_close_44bsd(sp) - FTS *sp; +__fts_close_44bsd(FTS *sp) { FTSENT *freep, *p; int saved_errno; @@ -315,8 +310,7 @@ __fts_close_44bsd(sp) ? p->fts_pathlen - 1 : p->fts_pathlen) FTSENT * -__fts_read_44bsd(sp) - FTS *sp; +__fts_read_44bsd(FTS *sp) { FTSENT *p, *tmp; int instr; @@ -510,10 +504,7 @@ name: t = sp->fts_path + NAPPEND(p->fts_parent); */ /* ARGSUSED */ int -__fts_set_44bsd(sp, p, instr) - FTS *sp; - FTSENT *p; - int instr; +__fts_set_44bsd(FTS *sp, FTSENT *p, int instr) { if (instr != 0 && instr != FTS_AGAIN && instr != FTS_FOLLOW && instr != FTS_NOINSTR && instr != FTS_SKIP) { @@ -525,9 +516,7 @@ __fts_set_44bsd(sp, p, instr) } FTSENT * -__fts_children_44bsd(sp, instr) - FTS *sp; - int instr; +__fts_children_44bsd(FTS *sp, int instr) { FTSENT *p; int fd; diff --git a/lib/libc/gen/fts.c b/lib/libc/gen/fts.c index 8083a88..03ef5c8 100644 --- a/lib/libc/gen/fts.c +++ b/lib/libc/gen/fts.c @@ -110,10 +110,8 @@ static const char *ufslike_filesystems[] = { }; FTS * -fts_open(argv, options, compar) - char * const *argv; - int options; - int (*compar)(const FTSENT * const *, const FTSENT * const *); +fts_open(char * const *argv, int options, + int (*compar)(const FTSENT * const *, const FTSENT * const *)) { struct _fts_private *priv; FTS *sp; @@ -1105,8 +1103,7 @@ fts_padjust(FTS *sp, FTSENT *head) } static size_t -fts_maxarglen(argv) - char * const *argv; +fts_maxarglen(char * const *argv) { size_t len, max; diff --git a/lib/libc/gen/getbsize.c b/lib/libc/gen/getbsize.c index 7e88e3f..bbf5b1e 100644 --- a/lib/libc/gen/getbsize.c +++ b/lib/libc/gen/getbsize.c @@ -39,9 +39,7 @@ __FBSDID("$FreeBSD$"); #include <string.h> char * -getbsize(headerlenp, blocksizep) - int *headerlenp; - long *blocksizep; +getbsize(int *headerlenp, long *blocksizep) { static char header[20]; long n, max, mul, blocksize; diff --git a/lib/libc/gen/getcwd.c b/lib/libc/gen/getcwd.c index da76d56..6884897 100644 --- a/lib/libc/gen/getcwd.c +++ b/lib/libc/gen/getcwd.c @@ -55,9 +55,7 @@ __FBSDID("$FreeBSD$"); extern int __getcwd(char *, size_t); char * -getcwd(pt, size) - char *pt; - size_t size; +getcwd(char *pt, size_t size) { struct dirent *dp; DIR *dir = NULL; diff --git a/lib/libc/gen/getdomainname.c b/lib/libc/gen/getdomainname.c index 21eb66d..5a38857 100644 --- a/lib/libc/gen/getdomainname.c +++ b/lib/libc/gen/getdomainname.c @@ -39,9 +39,7 @@ __FBSDID("$FreeBSD$"); #include <unistd.h> int -getdomainname(name, namelen) - char *name; - int namelen; +getdomainname(char *name, int namelen) { int mib[2]; size_t size; diff --git a/lib/libc/gen/getgrent.c b/lib/libc/gen/getgrent.c index 93a82c2..31d2af1 100644 --- a/lib/libc/gen/getgrent.c +++ b/lib/libc/gen/getgrent.c @@ -75,6 +75,7 @@ static const ns_src defaultsrc[] = { { NULL, 0 } }; +int __getgroupmembership(const char *, gid_t, gid_t *, int, int *); int __gr_match_entry(const char *, size_t, enum nss_lookup_type, const char *, gid_t); int __gr_parse_entry(char *, size_t, struct group *, char *, size_t, diff --git a/lib/libc/gen/gethostname.c b/lib/libc/gen/gethostname.c index c83805e..dc2b372 100644 --- a/lib/libc/gen/gethostname.c +++ b/lib/libc/gen/gethostname.c @@ -40,9 +40,7 @@ __FBSDID("$FreeBSD$"); #include <unistd.h> int -gethostname(name, namelen) - char *name; - size_t namelen; +gethostname(char *name, size_t namelen) { int mib[2]; diff --git a/lib/libc/gen/getpagesize.c b/lib/libc/gen/getpagesize.c index f4b8128..da2eb69 100644 --- a/lib/libc/gen/getpagesize.c +++ b/lib/libc/gen/getpagesize.c @@ -51,7 +51,7 @@ __FBSDID("$FreeBSD$"); */ int -getpagesize() +getpagesize(void) { int mib[2]; static int value; diff --git a/lib/libc/gen/getusershell.c b/lib/libc/gen/getusershell.c index 53536e1..6e78286 100644 --- a/lib/libc/gen/getusershell.c +++ b/lib/libc/gen/getusershell.c @@ -102,10 +102,7 @@ static int _local_initshells(void *, void *, va_list); /*ARGSUSED*/ static int -_local_initshells(rv, cb_data, ap) - void *rv; - void *cb_data; - va_list ap; +_local_initshells(void *rv, void *cb_data, va_list ap) { char *sp, *cp; FILE *fp; @@ -139,10 +136,7 @@ static int _dns_initshells(void *, void *, va_list); /*ARGSUSED*/ static int -_dns_initshells(rv, cb_data, ap) - void *rv; - void *cb_data; - va_list ap; +_dns_initshells(void *rv, void *cb_data, va_list ap) { char shellname[] = "shells-XXXXX"; int hsindex, hpi, r; @@ -183,10 +177,7 @@ static int _nis_initshells(void *, void *, va_list); /*ARGSUSED*/ static int -_nis_initshells(rv, cb_data, ap) - void *rv; - void *cb_data; - va_list ap; +_nis_initshells(void *rv, void *cb_data, va_list ap) { static char *ypdomain; char *key, *data; @@ -239,7 +230,7 @@ _nis_initshells(rv, cb_data, ap) #endif /* YP */ static const char *const * -initshells() +initshells(void) { static const ns_dtab dtab[] = { NS_FILES_CB(_local_initshells, NULL) diff --git a/lib/libc/gen/getvfsbyname.c b/lib/libc/gen/getvfsbyname.c index 0d896bb..c90c5ee 100644 --- a/lib/libc/gen/getvfsbyname.c +++ b/lib/libc/gen/getvfsbyname.c @@ -45,9 +45,7 @@ __FBSDID("$FreeBSD$"); * and if it is resident, return its xvfsconf structure. */ int -getvfsbyname(fsname, vfcp) - const char *fsname; - struct xvfsconf *vfcp; +getvfsbyname(const char *fsname, struct xvfsconf *vfcp) { struct xvfsconf *xvfsp; size_t buflen; diff --git a/lib/libc/gen/initgroups.c b/lib/libc/gen/initgroups.c index aacaf7e..d6a644c 100644 --- a/lib/libc/gen/initgroups.c +++ b/lib/libc/gen/initgroups.c @@ -44,9 +44,7 @@ __FBSDID("$FreeBSD$"); #include <unistd.h> int -initgroups(uname, agroup) - const char *uname; - gid_t agroup; +initgroups(const char *uname, gid_t agroup) { int ngroups, ret; long ngroups_max; diff --git a/lib/libc/gen/isatty.c b/lib/libc/gen/isatty.c index 076b824..02b0ffd 100644 --- a/lib/libc/gen/isatty.c +++ b/lib/libc/gen/isatty.c @@ -37,8 +37,7 @@ __FBSDID("$FreeBSD$"); #include <unistd.h> int -isatty(fd) - int fd; +isatty(int fd) { int retval; struct termios t; diff --git a/lib/libc/gen/nlist.c b/lib/libc/gen/nlist.c index 88254cd..e93f89b 100644 --- a/lib/libc/gen/nlist.c +++ b/lib/libc/gen/nlist.c @@ -61,6 +61,7 @@ __FBSDID("$FreeBSD$"); int __fdnlist(int, struct nlist *); int __aout_fdnlist(int, struct nlist *); int __elf_fdnlist(int, struct nlist *); +int __elf_is_okay__(Elf_Ehdr *); int nlist(const char *name, struct nlist *list) diff --git a/lib/libc/gen/pause.c b/lib/libc/gen/pause.c index ef48c1c..8e7a638 100644 --- a/lib/libc/gen/pause.c +++ b/lib/libc/gen/pause.c @@ -38,6 +38,8 @@ __FBSDID("$FreeBSD$"); #include "libc_private.h" +int __pause(void); + /* * Backwards compatible pause. */ diff --git a/lib/libc/gen/popen.c b/lib/libc/gen/popen.c index e54bb5c..a7a9708 100644 --- a/lib/libc/gen/popen.c +++ b/lib/libc/gen/popen.c @@ -67,8 +67,7 @@ static pthread_mutex_t pidlist_mutex = PTHREAD_MUTEX_INITIALIZER; #define THREAD_UNLOCK() if (__isthreaded) _pthread_mutex_unlock(&pidlist_mutex) FILE * -popen(command, type) - const char *command, *type; +popen(const char *command, const char *type) { struct pid *cur; FILE *iop; @@ -179,8 +178,7 @@ popen(command, type) * if already `pclosed', or waitpid returns an error. */ int -pclose(iop) - FILE *iop; +pclose(FILE *iop) { struct pid *cur, *last = NULL; int pstat; diff --git a/lib/libc/gen/psignal.c b/lib/libc/gen/psignal.c index 6fca4b1..5c5aada 100644 --- a/lib/libc/gen/psignal.c +++ b/lib/libc/gen/psignal.c @@ -44,9 +44,7 @@ __FBSDID("$FreeBSD$"); #include "un-namespace.h" void -psignal(sig, s) - unsigned int sig; - const char *s; +psignal(unsigned int sig, const char *s) { const char *c; diff --git a/lib/libc/gen/raise.c b/lib/libc/gen/raise.c index 994fea5..4bc895e 100644 --- a/lib/libc/gen/raise.c +++ b/lib/libc/gen/raise.c @@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$"); __weak_reference(__raise, raise); __weak_reference(__raise, _raise); +int __raise(int); int __raise(int s) diff --git a/lib/libc/gen/readdir.c b/lib/libc/gen/readdir.c index c6f5d3f..b5162ed 100644 --- a/lib/libc/gen/readdir.c +++ b/lib/libc/gen/readdir.c @@ -49,9 +49,7 @@ __FBSDID("$FreeBSD$"); * get next entry in a directory. */ struct dirent * -_readdir_unlocked(dirp, skip) - DIR *dirp; - int skip; +_readdir_unlocked(DIR *dirp, int skip) { struct dirent *dp; long initial_seek; @@ -91,8 +89,7 @@ _readdir_unlocked(dirp, skip) } struct dirent * -readdir(dirp) - DIR *dirp; +readdir(DIR *dirp) { struct dirent *dp; @@ -107,10 +104,7 @@ readdir(dirp) } int -readdir_r(dirp, entry, result) - DIR *dirp; - struct dirent *entry; - struct dirent **result; +readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result) { struct dirent *dp; int saved_errno; diff --git a/lib/libc/gen/rewinddir.c b/lib/libc/gen/rewinddir.c index e157cd6..2421c47 100644 --- a/lib/libc/gen/rewinddir.c +++ b/lib/libc/gen/rewinddir.c @@ -45,8 +45,7 @@ __FBSDID("$FreeBSD$"); #include "telldir.h" void -rewinddir(dirp) - DIR *dirp; +rewinddir(DIR *dirp) { if (__isthreaded) diff --git a/lib/libc/gen/seekdir.c b/lib/libc/gen/seekdir.c index e9851a7..699de46 100644 --- a/lib/libc/gen/seekdir.c +++ b/lib/libc/gen/seekdir.c @@ -48,9 +48,7 @@ __FBSDID("$FreeBSD$"); * _seekdir is in telldir.c so that it can share opaque data structures. */ void -seekdir(dirp, loc) - DIR *dirp; - long loc; +seekdir(DIR *dirp, long loc) { if (__isthreaded) _pthread_mutex_lock(&dirp->dd_lock); diff --git a/lib/libc/gen/semctl.c b/lib/libc/gen/semctl.c index 156d18c..c68734d 100644 --- a/lib/libc/gen/semctl.c +++ b/lib/libc/gen/semctl.c @@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$"); int __semctl(int semid, int semnum, int cmd, union semun *arg); int freebsd7___semctl(int semid, int semnum, int cmd, union semun_old *arg); +int freebsd7_semctl(int semid, int semnum, int cmd, ...); int semctl(int semid, int semnum, int cmd, ...) diff --git a/lib/libc/gen/setjmperr.c b/lib/libc/gen/setjmperr.c index 3cfeb55..90fa4aa 100644 --- a/lib/libc/gen/setjmperr.c +++ b/lib/libc/gen/setjmperr.c @@ -46,7 +46,7 @@ __FBSDID("$FreeBSD$"); #include "un-namespace.h" void -longjmperror() +longjmperror(void) { #define ERRMSG "longjmp botch.\n" (void)_write(STDERR_FILENO, ERRMSG, sizeof(ERRMSG) - 1); diff --git a/lib/libc/gen/sigsetops.c b/lib/libc/gen/sigsetops.c index cf7e688..cbcbfec 100644 --- a/lib/libc/gen/sigsetops.c +++ b/lib/libc/gen/sigsetops.c @@ -39,9 +39,7 @@ __FBSDID("$FreeBSD$"); #include <signal.h> int -sigaddset(set, signo) - sigset_t *set; - int signo; +sigaddset(sigset_t *set, int signo) { if (signo <= 0 || signo > _SIG_MAXSIG) { @@ -53,9 +51,7 @@ sigaddset(set, signo) } int -sigdelset(set, signo) - sigset_t *set; - int signo; +sigdelset(sigset_t *set, int signo) { if (signo <= 0 || signo > _SIG_MAXSIG) { @@ -67,8 +63,7 @@ sigdelset(set, signo) } int -sigemptyset(set) - sigset_t *set; +sigemptyset(sigset_t *set) { int i; @@ -78,8 +73,7 @@ sigemptyset(set) } int -sigfillset(set) - sigset_t *set; +sigfillset(sigset_t *set) { int i; @@ -89,9 +83,7 @@ sigfillset(set) } int -sigismember(set, signo) - const sigset_t *set; - int signo; +sigismember(const sigset_t *set, int signo) { if (signo <= 0 || signo > _SIG_MAXSIG) { diff --git a/lib/libc/gen/sleep.c b/lib/libc/gen/sleep.c index 6bb4ecd..6c33c35 100644 --- a/lib/libc/gen/sleep.c +++ b/lib/libc/gen/sleep.c @@ -42,6 +42,8 @@ __FBSDID("$FreeBSD$"); #include "libc_private.h" +unsigned int __sleep(unsigned int); + unsigned int __sleep(unsigned int seconds) { diff --git a/lib/libc/gen/sysconf.c b/lib/libc/gen/sysconf.c index 2b3acfb..be3d4af 100644 --- a/lib/libc/gen/sysconf.c +++ b/lib/libc/gen/sysconf.c @@ -69,8 +69,7 @@ __FBSDID("$FreeBSD$"); * less useful than returning up-to-date values, however. */ long -sysconf(name) - int name; +sysconf(int name) { struct rlimit rl; size_t len; diff --git a/lib/libc/gen/telldir.c b/lib/libc/gen/telldir.c index 19cd6ee..3e5678c 100644 --- a/lib/libc/gen/telldir.c +++ b/lib/libc/gen/telldir.c @@ -50,8 +50,7 @@ __FBSDID("$FreeBSD$"); * return a pointer into a directory */ long -telldir(dirp) - DIR *dirp; +telldir(DIR *dirp) { struct ddloc *lp; long idx; @@ -86,9 +85,7 @@ telldir(dirp) * Only values returned by "telldir" should be passed to seekdir. */ void -_seekdir(dirp, loc) - DIR *dirp; - long loc; +_seekdir(DIR *dirp, long loc) { struct ddloc *lp; struct dirent *dp; @@ -152,8 +149,7 @@ _fixtelldir(DIR *dirp, long oldseek, long oldloc) * Reclaim memory for telldir cookies which weren't used. */ void -_reclaim_telldir(dirp) - DIR *dirp; +_reclaim_telldir(DIR *dirp) { struct ddloc *lp; struct ddloc *templp; diff --git a/lib/libc/gen/tls.c b/lib/libc/gen/tls.c index 73eb9a2..ca4d696 100644 --- a/lib/libc/gen/tls.c +++ b/lib/libc/gen/tls.c @@ -270,7 +270,7 @@ __libc_free_tls(void *tcb __unused, size_t tcbsize __unused, extern char **environ; void -_init_tls() +_init_tls(void) { #ifndef PIC Elf_Addr *sp; diff --git a/lib/libc/gen/ttyslot.c b/lib/libc/gen/ttyslot.c index 1de0837..397e3ad 100644 --- a/lib/libc/gen/ttyslot.c +++ b/lib/libc/gen/ttyslot.c @@ -33,6 +33,8 @@ static char sccsid[] = "@(#)ttyslot.c 8.1 (Berkeley) 6/4/93"; #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); +int __ttyslot(void); + int __ttyslot(void) { diff --git a/lib/libc/gen/ualarm.c b/lib/libc/gen/ualarm.c index bf75775..6a1dca7 100644 --- a/lib/libc/gen/ualarm.c +++ b/lib/libc/gen/ualarm.c @@ -44,9 +44,7 @@ __FBSDID("$FreeBSD$"); * every ``reload'' microseconds after the first signal. */ useconds_t -ualarm(usecs, reload) - useconds_t usecs; - useconds_t reload; +ualarm(useconds_t usecs, useconds_t reload) { struct itimerval new, old; diff --git a/lib/libc/gen/uname.c b/lib/libc/gen/uname.c index 5a7baf7..499f761 100644 --- a/lib/libc/gen/uname.c +++ b/lib/libc/gen/uname.c @@ -40,6 +40,8 @@ __FBSDID("$FreeBSD$"); #include <errno.h> #undef uname +int uname(struct utsname *); + int uname(struct utsname *name) { diff --git a/lib/libc/gen/unvis-compat.c b/lib/libc/gen/unvis-compat.c index 080143e..5fa5ca9 100644 --- a/lib/libc/gen/unvis-compat.c +++ b/lib/libc/gen/unvis-compat.c @@ -34,6 +34,8 @@ #define _UNVIS_END 1 +int __unvis_44bsd(char *, int, int *, int); + int __unvis_44bsd(char *cp, int c, int *astate, int flag) { diff --git a/lib/libc/gen/usleep.c b/lib/libc/gen/usleep.c index 7c35f6c..90be6d4 100644 --- a/lib/libc/gen/usleep.c +++ b/lib/libc/gen/usleep.c @@ -40,6 +40,8 @@ __FBSDID("$FreeBSD$"); #include "libc_private.h" +int __usleep(useconds_t); + int __usleep(useconds_t useconds) { diff --git a/lib/libc/gen/utime.c b/lib/libc/gen/utime.c index 97bf878..0250a7a 100644 --- a/lib/libc/gen/utime.c +++ b/lib/libc/gen/utime.c @@ -38,9 +38,7 @@ __FBSDID("$FreeBSD$"); #include <utime.h> int -utime(path, times) - const char *path; - const struct utimbuf *times; +utime(const char *path, const struct utimbuf *times) { struct timeval tv[2], *tvp; diff --git a/lib/libc/gen/wait.c b/lib/libc/gen/wait.c index 46a3fdd..7cede6e 100644 --- a/lib/libc/gen/wait.c +++ b/lib/libc/gen/wait.c @@ -42,6 +42,8 @@ __FBSDID("$FreeBSD$"); #include "libc_private.h" +pid_t __wait(int *); + pid_t __wait(int *istat) { diff --git a/lib/libc/gen/wait3.c b/lib/libc/gen/wait3.c index 965effe..b50e3dd 100644 --- a/lib/libc/gen/wait3.c +++ b/lib/libc/gen/wait3.c @@ -42,6 +42,8 @@ __FBSDID("$FreeBSD$"); #include "libc_private.h" +pid_t __wait3(int *, int, struct rusage *); + pid_t __wait3(int *istat, int options, struct rusage *rup) { diff --git a/lib/libc/gen/waitid.c b/lib/libc/gen/waitid.c index 17a2dd6..8bdd652 100644 --- a/lib/libc/gen/waitid.c +++ b/lib/libc/gen/waitid.c @@ -39,6 +39,8 @@ __FBSDID("$FreeBSD$"); #include "un-namespace.h" #include "libc_private.h" +int __waitid(idtype_t, id_t, siginfo_t *, int); + int __waitid(idtype_t idtype, id_t id, siginfo_t *info, int flags) { diff --git a/lib/libc/gen/waitpid.c b/lib/libc/gen/waitpid.c index 5177591..5dc4fa8 100644 --- a/lib/libc/gen/waitpid.c +++ b/lib/libc/gen/waitpid.c @@ -42,6 +42,8 @@ __FBSDID("$FreeBSD$"); #include "libc_private.h" +pid_t __waitpid(pid_t, int *, int); + pid_t __waitpid(pid_t pid, int *istat, int options) { diff --git a/lib/libc/gmon/gmon.c b/lib/libc/gmon/gmon.c index b17a18f..eebce0a 100644 --- a/lib/libc/gmon/gmon.c +++ b/lib/libc/gmon/gmon.c @@ -68,6 +68,7 @@ static int s_scale; void moncontrol(int); static int hertz(void); +void _mcleanup(void); void monstartup(u_long lowpc, u_long highpc) diff --git a/lib/libc/mips/gen/_set_tp.c b/lib/libc/mips/gen/_set_tp.c index 0bf04b52..a1a30c5 100644 --- a/lib/libc/mips/gen/_set_tp.c +++ b/lib/libc/mips/gen/_set_tp.c @@ -30,6 +30,7 @@ #include <stdint.h> #include <machine/sysarch.h> +#include "libc_private.h" void _set_tp(void *tp) diff --git a/lib/libc/net/getaddrinfo.3 b/lib/libc/net/getaddrinfo.3 index 570fc2e..e13c667 100644 --- a/lib/libc/net/getaddrinfo.3 +++ b/lib/libc/net/getaddrinfo.3 @@ -18,7 +18,7 @@ .\" .\" $FreeBSD$ .\" -.Dd February 14, 2013 +.Dd September 20, 2015 .Dt GETADDRINFO 3 .Os .Sh NAME @@ -40,7 +40,6 @@ The .Fn getaddrinfo function is used to get a list of -.Tn IP addresses and port numbers for host .Fa hostname and service @@ -59,7 +58,9 @@ arguments are either pointers to NUL-terminated strings or the null pointer. An acceptable value for .Fa hostname is either a valid host name or a numeric host address string consisting -of a dotted decimal IPv4 address or an IPv6 address. +of a dotted decimal IPv4 address, +an IPv6 address, +or a UNIX-domain address. The .Fa servname is either a decimal port number or a service name listed in @@ -105,6 +106,7 @@ operating system. Denotes the type of socket that is wanted: .Dv SOCK_STREAM , .Dv SOCK_DGRAM , +.Dv SOCK_SEQPACKET , or .Dv SOCK_RAW . When @@ -112,9 +114,11 @@ When is zero the caller will accept any socket type. .It Fa ai_protocol Indicates which transport protocol is desired, -.Dv IPPROTO_UDP +.Dv IPPROTO_UDP , +.Dv IPPROTO_TCP , +.Dv IPPROTO_SCTP , or -.Dv IPPROTO_TCP . +.Dv IPPROTO_UDPLITE . If .Fa ai_protocol is zero the caller will accept any protocol. @@ -131,6 +135,9 @@ or be the bitwise-inclusive OR of one or more of the values .Dv AI_NUMERICSERV and .Dv AI_PASSIVE . +For a UNIX-domain address, +.Fa ai_flags +is ignored. .Bl -tag -width "AI_CANONNAMEXX" .It Dv AI_ADDRCONFIG If the @@ -419,6 +426,9 @@ freeaddrinfo(res0); .Xr getnameinfo 3 , .Xr getservbyname 3 , .Xr resolver 3 , +.Xr inet 4 , +.Xr inet6 4 , +.Xr unix 4 , .Xr hosts 5 , .Xr resolv.conf 5 , .Xr services 5 , diff --git a/lib/libc/net/getaddrinfo.c b/lib/libc/net/getaddrinfo.c index 17c9b65..8b47aef 100644 --- a/lib/libc/net/getaddrinfo.c +++ b/lib/libc/net/getaddrinfo.c @@ -137,13 +137,20 @@ static const struct afd { offsetof(struct sockaddr_in6, sin6_addr), in6_addrany, in6_loopback, 1}, #define N_INET 1 +#define N_LOCAL 2 #else #define N_INET 0 +#define N_LOCAL 1 #endif {PF_INET, sizeof(struct in_addr), sizeof(struct sockaddr_in), offsetof(struct sockaddr_in, sin_addr), in_addrany, in_loopback, 0}, +#define sizeofmember(type, member) (sizeof(((type *)0)->member)) + {PF_LOCAL, sizeofmember(struct sockaddr_un, sun_path), + sizeof(struct sockaddr_un), + offsetof(struct sockaddr_un, sun_path), + NULL, NULL, 0}, {0, 0, 0, 0, NULL, NULL, 0}, }; @@ -152,29 +159,47 @@ struct explore { int e_socktype; int e_protocol; int e_wild; -#define WILD_AF(ex) ((ex)->e_wild & 0x01) -#define WILD_SOCKTYPE(ex) ((ex)->e_wild & 0x02) -#define WILD_PROTOCOL(ex) ((ex)->e_wild & 0x04) +#define AF_ANY 0x01 +#define SOCKTYPE_ANY 0x02 +#define PROTOCOL_ANY 0x04 +#define WILD_AF(ex) ((ex)->e_wild & AF_ANY) +#define WILD_SOCKTYPE(ex) ((ex)->e_wild & SOCKTYPE_ANY) +#define WILD_PROTOCOL(ex) ((ex)->e_wild & PROTOCOL_ANY) }; static const struct explore explore[] = { -#if 0 - { PF_LOCAL, ANY, ANY, 0x01 }, -#endif + { PF_LOCAL, SOCK_DGRAM, ANY, + AF_ANY | PROTOCOL_ANY }, + { PF_LOCAL, SOCK_STREAM, ANY, + AF_ANY | PROTOCOL_ANY }, + { PF_LOCAL, SOCK_SEQPACKET, ANY, + AF_ANY | PROTOCOL_ANY }, #ifdef INET6 - { PF_INET6, SOCK_DGRAM, IPPROTO_UDP, 0x07 }, - { PF_INET6, SOCK_STREAM, IPPROTO_TCP, 0x07 }, - { PF_INET6, SOCK_STREAM, IPPROTO_SCTP, 0x03 }, - { PF_INET6, SOCK_SEQPACKET, IPPROTO_SCTP, 0x07 }, - { PF_INET6, SOCK_DGRAM, IPPROTO_UDPLITE, 0x03 }, - { PF_INET6, SOCK_RAW, ANY, 0x05 }, + { PF_INET6, SOCK_DGRAM, IPPROTO_UDP, + AF_ANY | SOCKTYPE_ANY | PROTOCOL_ANY }, + { PF_INET6, SOCK_STREAM, IPPROTO_TCP, + AF_ANY | SOCKTYPE_ANY | PROTOCOL_ANY }, + { PF_INET6, SOCK_STREAM, IPPROTO_SCTP, + AF_ANY | SOCKTYPE_ANY }, + { PF_INET6, SOCK_SEQPACKET, IPPROTO_SCTP, + AF_ANY | SOCKTYPE_ANY | PROTOCOL_ANY }, + { PF_INET6, SOCK_DGRAM, IPPROTO_UDPLITE, + AF_ANY | SOCKTYPE_ANY }, + { PF_INET6, SOCK_RAW, ANY, + AF_ANY | PROTOCOL_ANY }, #endif - { PF_INET, SOCK_DGRAM, IPPROTO_UDP, 0x07 }, - { PF_INET, SOCK_STREAM, IPPROTO_TCP, 0x07 }, - { PF_INET, SOCK_STREAM, IPPROTO_SCTP, 0x03 }, - { PF_INET, SOCK_SEQPACKET, IPPROTO_SCTP, 0x07 }, - { PF_INET, SOCK_DGRAM, IPPROTO_UDPLITE, 0x03 }, - { PF_INET, SOCK_RAW, ANY, 0x05 }, + { PF_INET, SOCK_DGRAM, IPPROTO_UDP, + AF_ANY | SOCKTYPE_ANY | PROTOCOL_ANY }, + { PF_INET, SOCK_STREAM, IPPROTO_TCP, + AF_ANY | SOCKTYPE_ANY | PROTOCOL_ANY }, + { PF_INET, SOCK_STREAM, IPPROTO_SCTP, + AF_ANY | SOCKTYPE_ANY }, + { PF_INET, SOCK_SEQPACKET, IPPROTO_SCTP, + AF_ANY | SOCKTYPE_ANY | PROTOCOL_ANY }, + { PF_INET, SOCK_DGRAM, IPPROTO_UDPLITE, + AF_ANY | SOCKTYPE_ANY }, + { PF_INET, SOCK_RAW, ANY, + AF_ANY | PROTOCOL_ANY }, { -1, 0, 0, 0 }, }; @@ -408,6 +433,7 @@ getaddrinfo(const char *hostname, const char *servname, ERR(EAI_BADFLAGS); switch (hints->ai_family) { case PF_UNSPEC: + case PF_LOCAL: case PF_INET: #ifdef INET6 case PF_INET6: @@ -1130,6 +1156,9 @@ explore_null(const struct addrinfo *pai, const char *servname, *res = NULL; ai = NULL; + if (pai->ai_family == PF_LOCAL) + return (0); + /* * filter out AFs that are not supported by the kernel * XXX errno? @@ -1172,8 +1201,11 @@ explore_numeric(const struct addrinfo *pai, const char *hostname, const struct afd *afd; struct addrinfo *ai; int error; - char pton[PTON_MAX]; + char pton[PTON_MAX], path[PATH_MAX], *p; +#ifdef CTASSERT + CTASSERT(sizeofmember(struct sockaddr_un, sun_path) <= PATH_MAX); +#endif *res = NULL; ai = NULL; @@ -1182,6 +1214,15 @@ explore_numeric(const struct addrinfo *pai, const char *hostname, return 0; switch (afd->a_af) { + case AF_LOCAL: + if (hostname[0] != '/') + ERR(EAI_NONAME); + if (strlen(hostname) > afd->a_addrlen) + ERR(EAI_MEMORY); + /* NUL-termination does not need to be guaranteed. */ + strncpy(path, hostname, afd->a_addrlen); + p = &path[0]; + break; case AF_INET: /* * RFC3493 requires getaddrinfo() to accept AF_INET formats @@ -1192,15 +1233,17 @@ explore_numeric(const struct addrinfo *pai, const char *hostname, */ if (inet_aton(hostname, (struct in_addr *)pton) != 1) return 0; + p = pton; break; default: if (inet_pton(afd->a_af, hostname, pton) != 1) return 0; + p = pton; break; } if (pai->ai_family == afd->a_af) { - GET_AI(ai, afd, pton); + GET_AI(ai, afd, p); GET_PORT(ai, servname); if ((pai->ai_flags & AI_CANONNAME)) { /* @@ -1320,6 +1363,12 @@ get_ai(const struct addrinfo *pai, const struct afd *afd, const char *addr) memset(ai->ai_addr, 0, (size_t)afd->a_socklen); ai->ai_addr->sa_len = afd->a_socklen; ai->ai_addrlen = afd->a_socklen; + if (ai->ai_family == PF_LOCAL) { + size_t n = strnlen(addr, afd->a_addrlen); + + ai->ai_addrlen -= afd->a_addrlen - n; + ai->ai_addr->sa_len -= afd->a_addrlen - n; + } ai->ai_addr->sa_family = ai->ai_family = afd->a_af; p = (char *)(void *)(ai->ai_addr); memcpy(p + afd->a_off, addr, (size_t)afd->a_addrlen); @@ -1378,6 +1427,9 @@ get_port(struct addrinfo *ai, const char *servname, int matchonly) if (servname == NULL) return 0; switch (ai->ai_family) { + case AF_LOCAL: + /* AF_LOCAL ignores servname silently. */ + return (0); case AF_INET: #ifdef AF_INET6 case AF_INET6: diff --git a/lib/libc/net/gethostnamadr.c b/lib/libc/net/gethostnamadr.c index 2dc9d02..6bbe270 100644 --- a/lib/libc/net/gethostnamadr.c +++ b/lib/libc/net/gethostnamadr.c @@ -48,13 +48,6 @@ __FBSDID("$FreeBSD$"); #include "nscache.h" #endif -extern int _ht_gethostbyname(void *, void *, va_list); -extern int _dns_gethostbyname(void *, void *, va_list); -extern int _nis_gethostbyname(void *, void *, va_list); -extern int _ht_gethostbyaddr(void *, void *, va_list); -extern int _dns_gethostbyaddr(void *, void *, va_list); -extern int _nis_gethostbyaddr(void *, void *, va_list); - static int gethostbyname_internal(const char *, int, struct hostent *, char *, size_t, struct hostent **, int *, res_state); diff --git a/lib/libc/net/getnameinfo.3 b/lib/libc/net/getnameinfo.3 index 0549ccd..ff227fd 100644 --- a/lib/libc/net/getnameinfo.3 +++ b/lib/libc/net/getnameinfo.3 @@ -18,7 +18,7 @@ .\" .\" $FreeBSD$ .\" -.Dd February 14, 2013 +.Dd September 20, 2015 .Dt GETNAMEINFO 3 .Os .Sh NAME @@ -47,7 +47,7 @@ functions and is the converse of the .Xr getaddrinfo 3 function. .Pp -If a link-layer address is passed to +If a link-layer address or UNIX-domain address is passed to .Fn getnameinfo , its ASCII representation will be stored in .Fa host . @@ -56,7 +56,8 @@ The string pointed to by will be set to the empty string if non-NULL; .Fa flags will always be ignored. -This is intended as a replacement for the legacy +For a link-layer address, +this can be used as a replacement of the legacy .Xr link_ntoa 3 function. .Pp @@ -66,10 +67,17 @@ structure .Fa sa should point to either a .Li sockaddr_in , -.Li sockaddr_in6 +.Li sockaddr_in6 , +.Li sockaddr_dl , or -.Li sockaddr_dl -structure (for IPv4, IPv6 or link-layer respectively) that is +.Li sockaddr_un +structure +.Po for IPv4 , +IPv6, +link-layer, +or UNIX-domain respectively +.Pc +that is .Fa salen bytes long. .Pp @@ -182,6 +190,9 @@ printf("host=%s\en", hbuf); .Xr inet_ntop 3 , .Xr link_ntoa 3 , .Xr resolver 3 , +.Xr inet 4 , +.Xr inet6 4 , +.Xr unix 4 , .Xr hosts 5 , .Xr resolv.conf 5 , .Xr services 5 , diff --git a/lib/libc/net/getnameinfo.c b/lib/libc/net/getnameinfo.c index d7e7971..c813189 100644 --- a/lib/libc/net/getnameinfo.c +++ b/lib/libc/net/getnameinfo.c @@ -49,6 +49,7 @@ __FBSDID("$FreeBSD$"); #include <sys/types.h> #include <sys/socket.h> +#include <sys/un.h> #include <net/if.h> #include <net/if_dl.h> #include <net/if_types.h> @@ -62,67 +63,102 @@ __FBSDID("$FreeBSD$"); #include <stddef.h> #include <errno.h> -static int getnameinfo_inet(const struct sockaddr *, socklen_t, char *, +static const struct afd *find_afd(int); +static int getnameinfo_inet(const struct afd *, + const struct sockaddr *, socklen_t, char *, size_t, char *, size_t, int); #ifdef INET6 static int ip6_parsenumeric(const struct sockaddr *, const char *, char *, size_t, int); static int ip6_sa2str(const struct sockaddr_in6 *, char *, size_t, int); #endif -static int getnameinfo_link(const struct sockaddr *, socklen_t, char *, +static int getnameinfo_link(const struct afd *, + const struct sockaddr *, socklen_t, char *, + size_t, char *, size_t, int); +static int hexname(const u_int8_t *, size_t, char *, size_t); +static int getnameinfo_un(const struct afd *, + const struct sockaddr *, socklen_t, char *, size_t, char *, size_t, int); -static int hexname(const u_int8_t *, size_t, char *, size_t); - -int -getnameinfo(const struct sockaddr *sa, socklen_t salen, - char *host, size_t hostlen, char *serv, size_t servlen, - int flags) -{ - if (sa == NULL) - return (EAI_FAIL); - - switch (sa->sa_family) { - case AF_INET: -#ifdef INET6 - case AF_INET6: -#endif - return getnameinfo_inet(sa, salen, host, hostlen, serv, - servlen, flags); - case AF_LINK: - return getnameinfo_link(sa, salen, host, hostlen, serv, - servlen, flags); - default: - return EAI_FAMILY; - } -} static const struct afd { int a_af; size_t a_addrlen; socklen_t a_socklen; int a_off; + int (*a_func)(const struct afd *, + const struct sockaddr *, socklen_t, char *, + size_t, char *, size_t, int); } afdl [] = { #ifdef INET6 {PF_INET6, sizeof(struct in6_addr), sizeof(struct sockaddr_in6), - offsetof(struct sockaddr_in6, sin6_addr)}, + offsetof(struct sockaddr_in6, sin6_addr), + getnameinfo_inet}, #endif {PF_INET, sizeof(struct in_addr), sizeof(struct sockaddr_in), - offsetof(struct sockaddr_in, sin_addr)}, + offsetof(struct sockaddr_in, sin_addr), + getnameinfo_inet}, +#define sizeofmember(type, member) (sizeof(((type *)0)->member)) + {PF_LOCAL, sizeofmember(struct sockaddr_un, sun_path), + sizeof(struct sockaddr_un), + offsetof(struct sockaddr_un, sun_path), + getnameinfo_un}, + {PF_LINK, sizeofmember(struct sockaddr_dl, sdl_data), + sizeof(struct sockaddr_dl), + offsetof(struct sockaddr_dl, sdl_data), + getnameinfo_link}, {0, 0, 0}, }; -struct sockinet { - u_char si_len; - u_char si_family; - u_short si_port; -}; +int +getnameinfo(const struct sockaddr *sa, socklen_t salen, + char *host, size_t hostlen, char *serv, size_t servlen, + int flags) +{ + const struct afd *afd; + + if (sa == NULL) + return (EAI_FAIL); + + afd = find_afd(sa->sa_family); + if (afd == NULL) + return (EAI_FAMILY); + if (sa->sa_family == PF_LOCAL) { + /* + * PF_LOCAL uses variable sa->sa_len depending on the + * content length of sun_path. Require 1 byte in + * sun_path at least. + */ + if (salen > afd->a_socklen || + salen <= afd->a_socklen - + sizeofmember(struct sockaddr_un, sun_path)) + return (EAI_FAIL); + } else if (salen != afd->a_socklen) + return (EAI_FAIL); + + return ((*afd->a_func)(afd, sa, salen, host, hostlen, + serv, servlen, flags)); +} + +static const struct afd * +find_afd(int af) +{ + const struct afd *afd; + + if (af == PF_UNSPEC) + return (NULL); + for (afd = &afdl[0]; afd->a_af > 0; afd++) { + if (afd->a_af == af) + return (afd); + } + return (NULL); +} static int -getnameinfo_inet(const struct sockaddr *sa, socklen_t salen, +getnameinfo_inet(const struct afd *afd, + const struct sockaddr *sa, socklen_t salen, char *host, size_t hostlen, char *serv, size_t servlen, int flags) { - const struct afd *afd; struct servent *sp; struct hostent *hp; u_short port; @@ -132,18 +168,8 @@ getnameinfo_inet(const struct sockaddr *sa, socklen_t salen, char numserv[512]; char numaddr[512]; - for (afd = &afdl[0]; afd->a_af > 0; afd++) { - if (afd->a_af == sa->sa_family) - break; - } - if (afd->a_af == 0) - return (EAI_FAMILY); - - if (salen != afd->a_socklen) - return EAI_FAIL; - /* network byte order */ - port = ((const struct sockinet *)sa)->si_port; + port = ((const struct sockaddr_in *)sa)->sin_port; addr = (const char *)sa + afd->a_off; if (serv == NULL || servlen == 0) { @@ -377,7 +403,8 @@ ip6_sa2str(const struct sockaddr_in6 *sa6, char *buf, size_t bufsiz, int flags) */ /* ARGSUSED */ static int -getnameinfo_link(const struct sockaddr *sa, socklen_t salen, +getnameinfo_link(const struct afd *afd, + const struct sockaddr *sa, socklen_t salen, char *host, size_t hostlen, char *serv, size_t servlen, int flags) { const struct sockaddr_dl *sdl = @@ -465,3 +492,30 @@ hexname(const u_int8_t *cp, size_t len, char *host, size_t hostlen) } return 0; } + +/* + * getnameinfo_un(): + * Format a UNIX IPC domain address (pathname). + */ +/* ARGSUSED */ +static int +getnameinfo_un(const struct afd *afd, + const struct sockaddr *sa, socklen_t salen, + char *host, size_t hostlen, char *serv, size_t servlen, int flags) +{ + size_t pathlen; + + if (serv != NULL && servlen > 0) + *serv = '\0'; + if (host != NULL && hostlen > 0) { + pathlen = sa->sa_len - afd->a_off; + + if (pathlen + 1 > hostlen) { + *host = '\0'; + return (EAI_MEMORY); + } + strlcpy(host, (const char *)sa + afd->a_off, pathlen + 1); + } + + return (0); +} diff --git a/lib/libc/net/getnetnamadr.c b/lib/libc/net/getnetnamadr.c index 9aa4d51..4d2fb38 100644 --- a/lib/libc/net/getnetnamadr.c +++ b/lib/libc/net/getnetnamadr.c @@ -46,13 +46,6 @@ __FBSDID("$FreeBSD$"); #include "nscache.h" #endif -extern int _ht_getnetbyname(void *, void *, va_list); -extern int _dns_getnetbyname(void *, void *, va_list); -extern int _nis_getnetbyname(void *, void *, va_list); -extern int _ht_getnetbyaddr(void *, void *, va_list); -extern int _dns_getnetbyaddr(void *, void *, va_list); -extern int _nis_getnetbyaddr(void *, void *, va_list); - /* Network lookup order if nsswitch.conf is broken or nonexistant */ static const ns_src default_src[] = { { NSSRC_FILES, NS_SUCCESS }, diff --git a/lib/libc/net/getproto.c b/lib/libc/net/getproto.c index b923edf..36eeb90 100644 --- a/lib/libc/net/getproto.c +++ b/lib/libc/net/getproto.c @@ -47,12 +47,6 @@ static const ns_src defaultsrc[] = { { NULL, 0 } }; -#ifdef NS_CACHING -extern int __proto_id_func(char *, size_t *, va_list, void *); -extern int __proto_marshal_func(char *, size_t *, void *, va_list, void *); -extern int __proto_unmarshal_func(char *, size_t, void *, va_list, void *); -#endif - static int files_getprotobynumber(void *retval, void *mdata, va_list ap) { diff --git a/lib/libc/net/map_v4v6.c b/lib/libc/net/map_v4v6.c index dbc7e70..09b035b 100644 --- a/lib/libc/net/map_v4v6.c +++ b/lib/libc/net/map_v4v6.c @@ -68,6 +68,7 @@ __FBSDID("$FreeBSD$"); #include <resolv.h> #include <ctype.h> #include <syslog.h> +#include "netdb_private.h" typedef union { int32_t al; diff --git a/lib/libc/net/netdb_private.h b/lib/libc/net/netdb_private.h index b48dd7b..0eedb3c 100644 --- a/lib/libc/net/netdb_private.h +++ b/lib/libc/net/netdb_private.h @@ -142,4 +142,23 @@ void _sethosthtent(int, struct hostent_data *); void _setnetdnsent(int); void _setnethtent(int, struct netent_data *); +struct hostent *__dns_getanswer(const char *, int, const char *, int); +int _dns_gethostbyaddr(void *, void *, va_list); +int _dns_gethostbyname(void *, void *, va_list); +int _dns_getnetbyaddr(void *, void *, va_list); +int _dns_getnetbyname(void *, void *, va_list); +int _ht_gethostbyaddr(void *, void *, va_list); +int _ht_gethostbyname(void *, void *, va_list); +int _ht_getnetbyaddr(void *, void *, va_list); +int _ht_getnetbyname(void *, void *, va_list); +int _nis_gethostbyaddr(void *, void *, va_list); +int _nis_gethostbyname(void *, void *, va_list); +int _nis_getnetbyaddr(void *, void *, va_list); +int _nis_getnetbyname(void *, void *, va_list); +#ifdef NS_CACHING +int __proto_id_func(char *, size_t *, va_list, void *); +int __proto_marshal_func(char *, size_t *, void *, va_list, void *); +int __proto_unmarshal_func(char *, size_t, void *, va_list, void *); +#endif + #endif /* _NETDB_PRIVATE_H_ */ diff --git a/lib/libc/net/nscache.c b/lib/libc/net/nscache.c index 68cec21..88a115b 100644 --- a/lib/libc/net/nscache.c +++ b/lib/libc/net/nscache.c @@ -29,6 +29,7 @@ __FBSDID("$FreeBSD$"); #include "namespace.h" +#define _NS_PRIVATE #include <nsswitch.h> #include <stdlib.h> #include <string.h> diff --git a/lib/libc/net/nss_compat.c b/lib/libc/net/nss_compat.c index 09a2d4f..ba1e951 100644 --- a/lib/libc/net/nss_compat.c +++ b/lib/libc/net/nss_compat.c @@ -79,6 +79,16 @@ do { \ DECLARE_TERMINATOR(group); +int __nss_compat_getgrnam_r(void *retval, void *mdata, va_list ap); +int __nss_compat_getgrgid_r(void *retval, void *mdata, va_list ap); +int __nss_compat_getgrent_r(void *retval, void *mdata, va_list ap); +int __nss_compat_setgrent(void *retval, void *mdata, va_list ap); +int __nss_compat_endgrent(void *retval, void *mdata, va_list ap); +int __nss_compat_getpwnam_r(void *retval, void *mdata, va_list ap); +int __nss_compat_getpwuid_r(void *retval, void *mdata, va_list ap); +int __nss_compat_getpwent_r(void *retval, void *mdata, va_list ap); +int __nss_compat_setpwent(void *retval, void *mdata, va_list ap); +int __nss_compat_endpwent(void *retval, void *mdata, va_list ap); int __nss_compat_getgrnam_r(void *retval, void *mdata, va_list ap) diff --git a/lib/libc/net/ntoh.c b/lib/libc/net/ntoh.c index 738d8c7..d658c90 100644 --- a/lib/libc/net/ntoh.c +++ b/lib/libc/net/ntoh.c @@ -28,6 +28,8 @@ __FBSDID("$FreeBSD$"); #include <sys/endian.h> +#define _BYTEORDER_FUNC_DEFINED +#include <arpa/inet.h> uint32_t htonl(uint32_t hl) diff --git a/lib/libc/net/sockatmark.c b/lib/libc/net/sockatmark.c index e416de8..9337da5 100644 --- a/lib/libc/net/sockatmark.c +++ b/lib/libc/net/sockatmark.c @@ -24,13 +24,16 @@ * * $FreeBSD$ */ +#include "namespace.h" #include <sys/ioctl.h> +#include <sys/socket.h> +#include "un-namespace.h" int sockatmark(int s) { int atmark; - if (ioctl(s, SIOCATMARK, &atmark) == -1) + if (_ioctl(s, SIOCATMARK, &atmark) == -1) return -1; return atmark; } diff --git a/lib/libc/posix1e/acl_compat.c b/lib/libc/posix1e/acl_compat.c index c433920..ab1bdf6 100644 --- a/lib/libc/posix1e/acl_compat.c +++ b/lib/libc/posix1e/acl_compat.c @@ -29,6 +29,10 @@ __FBSDID("$FreeBSD$"); #include <sys/acl.h> +int __oldacl_get_perm_np(acl_permset_t, oldacl_perm_t); +int __oldacl_add_perm(acl_permset_t, oldacl_perm_t); +int __oldacl_delete_perm(acl_permset_t, oldacl_perm_t); + /* * Compatibility wrappers for applications compiled against libc from before * NFSv4 ACLs were added. diff --git a/lib/libc/posix1e/acl_support.h b/lib/libc/posix1e/acl_support.h index 11fa29b..e7f35d5 100644 --- a/lib/libc/posix1e/acl_support.h +++ b/lib/libc/posix1e/acl_support.h @@ -45,6 +45,8 @@ int _acl_brand_may_be(const acl_t acl, int brand); int _entry_brand_may_be(const acl_entry_t entry, int brand); void _acl_brand_as(acl_t acl, int brand); void _entry_brand_as(const acl_entry_t entry, int brand); +int _nfs4_acl_entry_from_text(acl_t, char *); +char *_nfs4_acl_to_text_np(const acl_t, ssize_t *, int); int _nfs4_format_flags(char *str, size_t size, acl_flag_t var, int verbose); int _nfs4_format_access_mask(char *str, size_t size, acl_perm_t var, int verbose); int _nfs4_parse_flags(const char *str, acl_flag_t *var); diff --git a/lib/libc/powerpc/gen/_set_tp.c b/lib/libc/powerpc/gen/_set_tp.c index aa1150a..eeb062f 100644 --- a/lib/libc/powerpc/gen/_set_tp.c +++ b/lib/libc/powerpc/gen/_set_tp.c @@ -25,6 +25,7 @@ * * $FreeBSD$ */ +#include "libc_private.h" void _set_tp(void *tpval) diff --git a/lib/libc/powerpc64/gen/_set_tp.c b/lib/libc/powerpc64/gen/_set_tp.c index 32137e5..26009dc 100644 --- a/lib/libc/powerpc64/gen/_set_tp.c +++ b/lib/libc/powerpc64/gen/_set_tp.c @@ -25,6 +25,7 @@ * * $FreeBSD$ */ +#include "libc_private.h" void _set_tp(void *tpval) diff --git a/lib/libc/resolv/h_errno.c b/lib/libc/resolv/h_errno.c index 88d15ae..8ced708 100644 --- a/lib/libc/resolv/h_errno.c +++ b/lib/libc/resolv/h_errno.c @@ -33,6 +33,9 @@ #undef h_errno extern int h_errno; +int *__h_errno(void); +void __h_errno_set(res_state res, int err); + int * __h_errno(void) { diff --git a/lib/libc/rpc/svc.c b/lib/libc/rpc/svc.c index 8203bd9..38cbb79 100644 --- a/lib/libc/rpc/svc.c +++ b/lib/libc/rpc/svc.c @@ -97,8 +97,7 @@ static void __xprt_do_unregister (SVCXPRT *xprt, bool_t dolock); * Activate a transport handle. */ void -xprt_register(xprt) - SVCXPRT *xprt; +xprt_register(SVCXPRT *xprt) { int sock; @@ -140,9 +139,7 @@ __xprt_unregister_unlocked(SVCXPRT *xprt) * De-activate a transport handle. */ static void -__xprt_do_unregister(xprt, dolock) - SVCXPRT *xprt; - bool_t dolock; +__xprt_do_unregister(SVCXPRT *xprt, bool_t dolock) { int sock; @@ -171,12 +168,9 @@ __xprt_do_unregister(xprt, dolock) * program number comes in. */ bool_t -svc_reg(xprt, prog, vers, dispatch, nconf) - SVCXPRT *xprt; - const rpcprog_t prog; - const rpcvers_t vers; - void (*dispatch)(struct svc_req *, SVCXPRT *); - const struct netconfig *nconf; +svc_reg(SVCXPRT *xprt, const rpcprog_t prog, const rpcvers_t vers, + void (*dispatch)(struct svc_req *, SVCXPRT *), + const struct netconfig *nconf) { bool_t dummy; struct svc_callout *prev; @@ -245,9 +239,7 @@ rpcb_it: * Remove a service program from the callout list. */ void -svc_unreg(prog, vers) - const rpcprog_t prog; - const rpcvers_t vers; +svc_unreg(const rpcprog_t prog, const rpcvers_t vers) { struct svc_callout *prev; struct svc_callout *s; @@ -278,12 +270,9 @@ svc_unreg(prog, vers) * program number comes in. */ bool_t -svc_register(xprt, prog, vers, dispatch, protocol) - SVCXPRT *xprt; - u_long prog; - u_long vers; - void (*dispatch)(struct svc_req *, SVCXPRT *); - int protocol; +svc_register(SVCXPRT *xprt, u_long prog, u_long vers, + void (*dispatch)(struct svc_req *, SVCXPRT *), + int protocol) { struct svc_callout *prev; struct svc_callout *s; @@ -318,9 +307,7 @@ pmap_it: * Remove a service program from the callout list. */ void -svc_unregister(prog, vers) - u_long prog; - u_long vers; +svc_unregister(u_long prog, u_long vers) { struct svc_callout *prev; struct svc_callout *s; @@ -345,11 +332,8 @@ svc_unregister(prog, vers) * struct. */ static struct svc_callout * -svc_find(prog, vers, prev, netid) - rpcprog_t prog; - rpcvers_t vers; - struct svc_callout **prev; - char *netid; +svc_find(rpcprog_t prog, rpcvers_t vers, struct svc_callout **prev, + char *netid) { struct svc_callout *s, *p; @@ -373,10 +357,8 @@ svc_find(prog, vers, prev, netid) * Send a reply to an rpc request */ bool_t -svc_sendreply(xprt, xdr_results, xdr_location) - SVCXPRT *xprt; - xdrproc_t xdr_results; - void * xdr_location; +svc_sendreply(SVCXPRT *xprt, xdrproc_t xdr_results, + void * xdr_location) { struct rpc_msg rply; @@ -395,8 +377,7 @@ svc_sendreply(xprt, xdr_results, xdr_location) * No procedure error reply */ void -svcerr_noproc(xprt) - SVCXPRT *xprt; +svcerr_noproc(SVCXPRT *xprt) { struct rpc_msg rply; @@ -413,8 +394,7 @@ svcerr_noproc(xprt) * Can't decode args error reply */ void -svcerr_decode(xprt) - SVCXPRT *xprt; +svcerr_decode(SVCXPRT *xprt) { struct rpc_msg rply; @@ -431,8 +411,7 @@ svcerr_decode(xprt) * Some system error */ void -svcerr_systemerr(xprt) - SVCXPRT *xprt; +svcerr_systemerr(SVCXPRT *xprt) { struct rpc_msg rply; @@ -453,31 +432,27 @@ svcerr_systemerr(xprt) * protocol: the portmapper (or rpc binder). */ void -__svc_versquiet_on(xprt) - SVCXPRT *xprt; +__svc_versquiet_on(SVCXPRT *xprt) { SVC_EXT(xprt)->xp_flags |= SVC_VERSQUIET; } void -__svc_versquiet_off(xprt) - SVCXPRT *xprt; +__svc_versquiet_off(SVCXPRT *xprt) { SVC_EXT(xprt)->xp_flags &= ~SVC_VERSQUIET; } void -svc_versquiet(xprt) - SVCXPRT *xprt; +svc_versquiet(SVCXPRT *xprt) { __svc_versquiet_on(xprt); } int -__svc_versquiet_get(xprt) - SVCXPRT *xprt; +__svc_versquiet_get(SVCXPRT *xprt) { return (SVC_EXT(xprt)->xp_flags & SVC_VERSQUIET); @@ -488,9 +463,7 @@ __svc_versquiet_get(xprt) * Authentication error reply */ void -svcerr_auth(xprt, why) - SVCXPRT *xprt; - enum auth_stat why; +svcerr_auth(SVCXPRT *xprt, enum auth_stat why) { struct rpc_msg rply; @@ -507,8 +480,7 @@ svcerr_auth(xprt, why) * Auth too weak error reply */ void -svcerr_weakauth(xprt) - SVCXPRT *xprt; +svcerr_weakauth(SVCXPRT *xprt) { assert(xprt != NULL); @@ -520,8 +492,7 @@ svcerr_weakauth(xprt) * Program unavailable error reply */ void -svcerr_noprog(xprt) - SVCXPRT *xprt; +svcerr_noprog(SVCXPRT *xprt) { struct rpc_msg rply; @@ -538,10 +509,7 @@ svcerr_noprog(xprt) * Program version mismatch error reply */ void -svcerr_progvers(xprt, low_vers, high_vers) - SVCXPRT *xprt; - rpcvers_t low_vers; - rpcvers_t high_vers; +svcerr_progvers(SVCXPRT *xprt, rpcvers_t low_vers, rpcvers_t high_vers) { struct rpc_msg rply; @@ -563,7 +531,7 @@ svcerr_progvers(xprt, low_vers, high_vers) * parameters. */ SVCXPRT * -svc_xprt_alloc() +svc_xprt_alloc(void) { SVCXPRT *xprt; SVCXPRT_EXT *ext; @@ -588,8 +556,7 @@ svc_xprt_alloc() * Free a server transport structure. */ void -svc_xprt_free(xprt) - SVCXPRT *xprt; +svc_xprt_free(SVCXPRT *xprt) { mem_free(xprt->xp_p3, sizeof(SVCXPRT_EXT)); @@ -615,8 +582,7 @@ svc_xprt_free(xprt) */ void -svc_getreq(rdfds) - int rdfds; +svc_getreq(int rdfds) { fd_set readfds; @@ -626,8 +592,7 @@ svc_getreq(rdfds) } void -svc_getreqset(readfds) - fd_set *readfds; +svc_getreqset(fd_set *readfds) { int bit, fd; fd_mask mask, *maskp; @@ -647,8 +612,7 @@ svc_getreqset(readfds) } void -svc_getreq_common(fd) - int fd; +svc_getreq_common(int fd) { SVCXPRT *xprt; struct svc_req r; @@ -743,9 +707,7 @@ call_done: void -svc_getreq_poll(pfdp, pollretval) - struct pollfd *pfdp; - int pollretval; +svc_getreq_poll(struct pollfd *pfdp, int pollretval) { int i; int fds_found; diff --git a/lib/libc/sparc64/gen/_set_tp.c b/lib/libc/sparc64/gen/_set_tp.c index cf9db26..7632951 100644 --- a/lib/libc/sparc64/gen/_set_tp.c +++ b/lib/libc/sparc64/gen/_set_tp.c @@ -25,6 +25,7 @@ * * $FreeBSD$ */ +#include "libc_private.h" void _set_tp(void *tpval) diff --git a/lib/libc/stdio/_flock_stub.c b/lib/libc/stdio/_flock_stub.c index 0b61315..f53df35 100644 --- a/lib/libc/stdio/_flock_stub.c +++ b/lib/libc/stdio/_flock_stub.c @@ -55,6 +55,9 @@ __weak_reference(_flockfile_debug_stub, _flockfile_debug); __weak_reference(_ftrylockfile, ftrylockfile); __weak_reference(_funlockfile, funlockfile); +void _flockfile_debug_stub(FILE *, char *, int); +int _ftrylockfile(FILE *); + void _flockfile(FILE *fp) { diff --git a/lib/libc/stdio/fgetwln.c b/lib/libc/stdio/fgetwln.c index 6d9087b..8439496 100644 --- a/lib/libc/stdio/fgetwln.c +++ b/lib/libc/stdio/fgetwln.c @@ -40,6 +40,8 @@ __FBSDID("$FreeBSD$"); #include "local.h" #include "xlocale_private.h" +wchar_t *fgetwln_l(FILE * __restrict, size_t *, locale_t); + wchar_t * fgetwln_l(FILE * __restrict fp, size_t *lenp, locale_t locale) { diff --git a/lib/libc/stdio/findfp.c b/lib/libc/stdio/findfp.c index be196b7..0eabe82 100644 --- a/lib/libc/stdio/findfp.c +++ b/lib/libc/stdio/findfp.c @@ -113,7 +113,7 @@ moreglue(int n) * Find a free FILE for fopen et al. */ FILE * -__sfp() +__sfp(void) { FILE *fp; int n; @@ -164,6 +164,7 @@ found: */ __warn_references(f_prealloc, "warning: this program uses f_prealloc(), which is not recommended."); +void f_prealloc(void); void f_prealloc(void) @@ -195,7 +196,7 @@ f_prealloc(void) * The name `_cleanup' is, alas, fairly well known outside stdio. */ void -_cleanup() +_cleanup(void) { /* (void) _fwalk(fclose); */ (void) _fwalk(__sflush); /* `cheating' */ @@ -205,7 +206,7 @@ _cleanup() * __sinit() is called whenever stdio's internal variables must be set up. */ void -__sinit() +__sinit(void) { /* Make sure we clean up on exit. */ diff --git a/lib/libc/stdio/getchar.c b/lib/libc/stdio/getchar.c index 21040bc..2815072 100644 --- a/lib/libc/stdio/getchar.c +++ b/lib/libc/stdio/getchar.c @@ -49,7 +49,7 @@ __FBSDID("$FreeBSD$"); #undef getchar_unlocked int -getchar() +getchar(void) { int retval; FLOCKFILE(stdin); diff --git a/lib/libc/stdio/vfscanf.c b/lib/libc/stdio/vfscanf.c index 50f0690..b537263 100644 --- a/lib/libc/stdio/vfscanf.c +++ b/lib/libc/stdio/vfscanf.c @@ -814,9 +814,7 @@ match_failure: * considered part of the scanset. */ static const u_char * -__sccl(tab, fmt) - char *tab; - const u_char *fmt; +__sccl(char *tab, const u_char *fmt) { int c, n, v, i; struct xlocale_collate *table = diff --git a/lib/libc/stdlib/abort.c b/lib/libc/stdlib/abort.c index 022c6aa..2335c40 100644 --- a/lib/libc/stdlib/abort.c +++ b/lib/libc/stdlib/abort.c @@ -44,7 +44,7 @@ __FBSDID("$FreeBSD$"); #include "libc_private.h" void -abort() +abort(void) { struct sigaction act; diff --git a/lib/libc/stdlib/abs.c b/lib/libc/stdlib/abs.c index 8758947..367b114 100644 --- a/lib/libc/stdlib/abs.c +++ b/lib/libc/stdlib/abs.c @@ -36,8 +36,7 @@ __FBSDID("$FreeBSD$"); #include <stdlib.h> int -abs(j) - int j; +abs(int j) { return(j < 0 ? -j : j); } diff --git a/lib/libc/stdlib/atexit.c b/lib/libc/stdlib/atexit.c index 0a5048a..eda5703 100644 --- a/lib/libc/stdlib/atexit.c +++ b/lib/libc/stdlib/atexit.c @@ -82,6 +82,9 @@ struct atexit { static struct atexit *__atexit; /* points to head of LIFO stack */ typedef DECLARE_BLOCK(void, atexit_block, void); +int atexit_b(atexit_block); +int __cxa_atexit(void (*)(void *), void *, void *); + /* * Register the function described by 'fptr' to be called at application * exit or owning shared object unload time. This is a helper function diff --git a/lib/libc/stdlib/atof.c b/lib/libc/stdlib/atof.c index 3514ae3..0458eb9 100644 --- a/lib/libc/stdlib/atof.c +++ b/lib/libc/stdlib/atof.c @@ -42,16 +42,13 @@ __FBSDID("$FreeBSD$"); #include <xlocale.h> double -atof(ascii) - const char *ascii; +atof(const char *ascii) { return strtod(ascii, (char **)NULL); } double -atof_l(ascii, locale) - const char *ascii; - locale_t locale; +atof_l(const char *ascii, locale_t locale) { return strtod_l(ascii, (char **)NULL, locale); } diff --git a/lib/libc/stdlib/atoi.c b/lib/libc/stdlib/atoi.c index 564273e..9f92fcd 100644 --- a/lib/libc/stdlib/atoi.c +++ b/lib/libc/stdlib/atoi.c @@ -42,16 +42,13 @@ __FBSDID("$FreeBSD$"); #include <xlocale.h> int -atoi(str) - const char *str; +atoi(const char *str) { return (int)strtol(str, (char **)NULL, 10); } int -atoi_l(str, locale) - const char *str; - locale_t locale; +atoi_l(const char *str, locale_t locale) { return (int)strtol_l(str, (char **)NULL, 10, locale); } diff --git a/lib/libc/stdlib/atol.c b/lib/libc/stdlib/atol.c index d30aa18..bd8ef07 100644 --- a/lib/libc/stdlib/atol.c +++ b/lib/libc/stdlib/atol.c @@ -42,16 +42,13 @@ __FBSDID("$FreeBSD$"); #include <xlocale.h> long -atol(str) - const char *str; +atol(const char *str) { return strtol(str, (char **)NULL, 10); } long -atol_l(str, locale) - const char *str; - locale_t locale; +atol_l(const char *str, locale_t locale) { return strtol_l(str, (char **)NULL, 10, locale); } diff --git a/lib/libc/stdlib/atoll.c b/lib/libc/stdlib/atoll.c index af52838..093fde5 100644 --- a/lib/libc/stdlib/atoll.c +++ b/lib/libc/stdlib/atoll.c @@ -39,16 +39,13 @@ __FBSDID("$FreeBSD$"); #include <xlocale.h> long long -atoll(str) - const char *str; +atoll(const char *str) { return strtoll(str, (char **)NULL, 10); } long long -atoll_l(str, locale) - const char *str; - locale_t locale; +atoll_l(const char *str, locale_t locale) { return strtoll_l(str, (char **)NULL, 10, locale); } diff --git a/lib/libc/stdlib/bsearch.c b/lib/libc/stdlib/bsearch.c index 4a1dd52..8303f97 100644 --- a/lib/libc/stdlib/bsearch.c +++ b/lib/libc/stdlib/bsearch.c @@ -61,20 +61,12 @@ __FBSDID("$FreeBSD$"); */ #ifdef I_AM_BSEARCH_B void * -bsearch_b(key, base0, nmemb, size, compar) - const void *key; - const void *base0; - size_t nmemb; - size_t size; - DECLARE_BLOCK(int, compar, const void *, const void *); +bsearch_b(const void *key, const void *base0, size_t nmemb, size_t size, + DECLARE_BLOCK(int, compar, const void *, const void *)) #else void * -bsearch(key, base0, nmemb, size, compar) - const void *key; - const void *base0; - size_t nmemb; - size_t size; - int (*compar)(const void *, const void *); +bsearch(const void *key, const void *base0, size_t nmemb, size_t size, + int (*compar)(const void *, const void *)) #endif { const char *base = base0; diff --git a/lib/libc/stdlib/exit.c b/lib/libc/stdlib/exit.c index 145eb9d..a656e04 100644 --- a/lib/libc/stdlib/exit.c +++ b/lib/libc/stdlib/exit.c @@ -56,8 +56,7 @@ int __isthreaded = 0; * Exit, flushing stdio buffers if necessary. */ void -exit(status) - int status; +exit(int status) { /* Ensure that the auto-initialization routine is linked in: */ extern int _thread_autoinit_dummy_decl; diff --git a/lib/libc/stdlib/heapsort.c b/lib/libc/stdlib/heapsort.c index 16c1bfe..a7a4a26 100644 --- a/lib/libc/stdlib/heapsort.c +++ b/lib/libc/stdlib/heapsort.c @@ -138,6 +138,12 @@ typedef DECLARE_BLOCK(int, heapsort_block, const void *, const void *); } \ } +#ifdef I_AM_HEAPSORT_B +int heapsort_b(void *, size_t, size_t, heapsort_block); +#else +int heapsort(void *, size_t, size_t, + int (*)(const void *, const void *)); +#endif /* * Heapsort -- Knuth, Vol. 3, page 145. Runs in O (N lg N), both average * and worst. While heapsort is faster than the worst case of quicksort, diff --git a/lib/libc/stdlib/labs.c b/lib/libc/stdlib/labs.c index 816370e..ef06882 100644 --- a/lib/libc/stdlib/labs.c +++ b/lib/libc/stdlib/labs.c @@ -36,8 +36,7 @@ __FBSDID("$FreeBSD$"); #include <stdlib.h> long -labs(j) - long j; +labs(long j) { return(j < 0 ? -j : j); } diff --git a/lib/libc/stdlib/merge.c b/lib/libc/stdlib/merge.c index 17f07eb..55b3a0c 100644 --- a/lib/libc/stdlib/merge.c +++ b/lib/libc/stdlib/merge.c @@ -99,6 +99,12 @@ static void insertionsort(u_char *, size_t, size_t, cmp_t); ((u_char *)0 + \ (((u_char *)p + PSIZE - 1 - (u_char *) 0) & ~(PSIZE - 1))) +#ifdef I_AM_MERGESORT_B +int mergesort_b(void *, size_t, size_t, cmp_t); +#else +int mergesort(void *, size_t, size_t, cmp_t); +#endif + /* * Arguments are as for qsort. */ diff --git a/lib/libc/stdlib/qsort.c b/lib/libc/stdlib/qsort.c index e97ea92..0881688 100644 --- a/lib/libc/stdlib/qsort.c +++ b/lib/libc/stdlib/qsort.c @@ -64,9 +64,7 @@ static inline void swapfunc(char *, char *, int, int, int); es % sizeof(TYPE) ? 2 : es == sizeof(TYPE) ? 0 : 1; static inline void -swapfunc(a, b, n, swaptype_long, swaptype_int) - char *a, *b; - int n, swaptype_long, swaptype_int; +swapfunc( char *a, char *b, int n, int swaptype_long, int swaptype_int) { if (swaptype_long <= 1) swapcode(long, a, b, n) diff --git a/lib/libc/stdlib/rand.c b/lib/libc/stdlib/rand.c index 4f4aa8d..b8871a2 100644 --- a/lib/libc/stdlib/rand.c +++ b/lib/libc/stdlib/rand.c @@ -111,14 +111,13 @@ static u_long next = #endif int -rand() +rand(void) { return (do_rand(&next)); } void -srand(seed) -u_int seed; +srand(u_int seed) { next = seed; #ifndef USE_WEAK_SEEDING @@ -136,7 +135,7 @@ u_int seed; * data from the kernel. */ void -sranddev() +sranddev(void) { int mib[2]; size_t len; diff --git a/lib/libc/stdlib/tfind.c b/lib/libc/stdlib/tfind.c index c5d66cf..0ad391e 100644 --- a/lib/libc/stdlib/tfind.c +++ b/lib/libc/stdlib/tfind.c @@ -23,12 +23,15 @@ __FBSDID("$FreeBSD$"); #include <stdlib.h> #include <search.h> -/* find a node, or return 0 */ +/* + * find a node, or return 0 + * + * vkey - key to be found + * vrootp - address of the tree root + */ void * -tfind(vkey, vrootp, compar) - const void *vkey; /* key to be found */ - void * const *vrootp; /* address of the tree root */ - int (*compar)(const void *, const void *); +tfind(const void *vkey, void * const *vrootp, + int (*compar)(const void *, const void *)) { node_t **rootp = (node_t **)vrootp; diff --git a/lib/libc/string/strchrnul.c b/lib/libc/string/strchrnul.c index 98e652d..893468c 100644 --- a/lib/libc/string/strchrnul.c +++ b/lib/libc/string/strchrnul.c @@ -33,6 +33,8 @@ __FBSDID("$FreeBSD$"); __weak_reference(__strchrnul, strchrnul); +char *__strchrnul(const char *, int); + char * __strchrnul(const char *p, int ch) { diff --git a/lib/libc/sys/__error.c b/lib/libc/sys/__error.c index 28cc31d..8a065bf7 100644 --- a/lib/libc/sys/__error.c +++ b/lib/libc/sys/__error.c @@ -30,6 +30,8 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); +#include "libc_private.h" + extern int errno; static int * diff --git a/lib/libc/sys/close.c b/lib/libc/sys/close.c index 02e74c6..f7b36f8 100644 --- a/lib/libc/sys/close.c +++ b/lib/libc/sys/close.c @@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$"); #include <sys/types.h> #include <sys/fcntl.h> +#include <unistd.h> #include "libc_private.h" __weak_reference(__sys_close, __close); diff --git a/lib/libc/sys/fsync.c b/lib/libc/sys/fsync.c index 3fff428..5f15129 100644 --- a/lib/libc/sys/fsync.c +++ b/lib/libc/sys/fsync.c @@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$"); #include <sys/types.h> #include <sys/fcntl.h> +#include <unistd.h> #include "libc_private.h" __weak_reference(__sys_fsync, __fsync); diff --git a/lib/libc/sys/msync.c b/lib/libc/sys/msync.c index 3c6879f..d86cc04 100644 --- a/lib/libc/sys/msync.c +++ b/lib/libc/sys/msync.c @@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$"); #include <sys/types.h> #include <sys/fcntl.h> +#include <sys/mman.h> #include "libc_private.h" __weak_reference(__sys_msync, __msync); diff --git a/lib/libc/sys/readv.c b/lib/libc/sys/readv.c index 8c82040..5672927 100644 --- a/lib/libc/sys/readv.c +++ b/lib/libc/sys/readv.c @@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$"); #include <sys/types.h> #include <sys/syscall.h> +#include <sys/uio.h> #include <unistd.h> #include "libc_private.h" diff --git a/lib/libc/sys/reboot.2 b/lib/libc/sys/reboot.2 index caaba58..df4a0ec 100644 --- a/lib/libc/sys/reboot.2 +++ b/lib/libc/sys/reboot.2 @@ -28,7 +28,7 @@ .\" @(#)reboot.2 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd June 4, 1993 +.Dd September 18, 2015 .Dt REBOOT 2 .Os .Sh NAME @@ -113,6 +113,13 @@ Normally, the disks are sync'd (see before the processor is halted or rebooted. This option may be useful if file system changes have been made manually or if the processor is on fire. +.It Dv RB_REROOT +Instead of rebooting, unmount all filesystems except the one containing +currently-running executable, and mount root filesystem using the same +mechanism which is used during normal boot, based on +vfs.root.mountfrom +.Xr kenv 8 +variable. .It Dv RB_RDONLY Initially mount the root file system read-only. This is currently the default, and this option has been deprecated. @@ -159,8 +166,3 @@ The .Fn reboot system call appeared in .Bx 4.0 . -.Sh BUGS -The HP300 implementation supports neither -.Dv RB_DFLTROOT -nor -.Dv RB_KDB . diff --git a/lib/libc/sys/writev.c b/lib/libc/sys/writev.c index 6be74b3..20b1005 100644 --- a/lib/libc/sys/writev.c +++ b/lib/libc/sys/writev.c @@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$"); #include <sys/types.h> #include <sys/syscall.h> +#include <sys/uio.h> #include <unistd.h> #include "libc_private.h" |