diff options
author | Philip Guenther <guenther@cvs.openbsd.org> | 2016-03-20 02:32:41 +0000 |
---|---|---|
committer | Philip Guenther <guenther@cvs.openbsd.org> | 2016-03-20 02:32:41 +0000 |
commit | 3924b0c2475a56d000c0c5cae2ca1660a97b489b (patch) | |
tree | d5f23aa4e0c292f35123ecaf9761158d7c5d71e6 /lib/libc/gen | |
parent | 4621abcf30c5f4ecef9340db8259e51bfabf6529 (diff) |
Rearrange C runtime bits: now that ld.so exports environ and __progname,
move their definitions and initialization in static links to libc.a
Make crt0 always invoke a new func _csu_finish() in libc to process the auxv
and to either register the ld.so cleanup function (in dynamic links) or
initialize environ and __progname and do MC_DISABLE_KBIND (in static links).
In libc, get pagesize from auxv; cache that between getpagesize() and
sysconf(_SC_PAGESIZE)
ok mpi@ "good time" deraadt@
Diffstat (limited to 'lib/libc/gen')
-rw-r--r-- | lib/libc/gen/getpagesize.c | 12 | ||||
-rw-r--r-- | lib/libc/gen/sysconf.c | 4 |
2 files changed, 8 insertions, 8 deletions
diff --git a/lib/libc/gen/getpagesize.c b/lib/libc/gen/getpagesize.c index 3c81d64209e..aa2919032fa 100644 --- a/lib/libc/gen/getpagesize.c +++ b/lib/libc/gen/getpagesize.c @@ -1,4 +1,4 @@ -/* $OpenBSD: getpagesize.c,v 1.8 2015/09/12 14:56:50 guenther Exp $ */ +/* $OpenBSD: getpagesize.c,v 1.9 2016/03/20 02:32:40 guenther Exp $ */ /* * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. @@ -35,18 +35,16 @@ int getpagesize(void) { - static int pagsz; - - if (pagsz == 0) { + if (_pagesize == 0) { int mib[2]; size_t size; mib[0] = CTL_HW; mib[1] = HW_PAGESIZE; - size = sizeof pagsz; - if (sysctl(mib, 2, &pagsz, &size, NULL, 0) == -1) + size = sizeof _pagesize; + if (sysctl(mib, 2, &_pagesize, &size, NULL, 0) == -1) return (-1); } - return (pagsz); + return (_pagesize); } DEF_WEAK(getpagesize); diff --git a/lib/libc/gen/sysconf.c b/lib/libc/gen/sysconf.c index 3f39418f026..03becb59eec 100644 --- a/lib/libc/gen/sysconf.c +++ b/lib/libc/gen/sysconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sysconf.c,v 1.23 2015/09/12 14:56:50 guenther Exp $ */ +/* $OpenBSD: sysconf.c,v 1.24 2016/03/20 02:32:40 guenther Exp $ */ /*- * Copyright (c) 1993 * The Regents of the University of California. All rights reserved. @@ -131,6 +131,8 @@ sysconf(int name) /* 1003.1b */ case _SC_PAGESIZE: + if (_pagesize != 0) + return (_pagesize); mib[0] = CTL_HW; mib[1] = HW_PAGESIZE; break; |