summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdlib/malloc.c
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2010-08-17 09:13:26 +0000
committerkib <kib@FreeBSD.org>2010-08-17 09:13:26 +0000
commit5a79777b4407edd39781e06216e4dc6ca68bb6a7 (patch)
tree2f639ad563c61b228d123038b15beca40d36a4ba /lib/libc/stdlib/malloc.c
parent680fe863d9e18febb130562fe69135f824b59b45 (diff)
downloadFreeBSD-src-5a79777b4407edd39781e06216e4dc6ca68bb6a7.zip
FreeBSD-src-5a79777b4407edd39781e06216e4dc6ca68bb6a7.tar.gz
Use aux vector to get values for SSP canary, pagesize, pagesizes array,
number of host CPUs and osreldate. This eliminates the last sysctl(2) calls from the dynamically linked image startup. No objections from: kan Tested by: marius (sparc64) MFC after: 1 month
Diffstat (limited to 'lib/libc/stdlib/malloc.c')
-rw-r--r--lib/libc/stdlib/malloc.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/lib/libc/stdlib/malloc.c b/lib/libc/stdlib/malloc.c
index 1b581d4..f1a13ef 100644
--- a/lib/libc/stdlib/malloc.c
+++ b/lib/libc/stdlib/malloc.c
@@ -180,6 +180,7 @@ __FBSDID("$FreeBSD$");
#include <errno.h>
#include <limits.h>
+#include <link.h>
#include <pthread.h>
#include <sched.h>
#include <stdarg.h>
@@ -194,6 +195,8 @@ __FBSDID("$FreeBSD$");
#include "un-namespace.h"
+#include "libc_private.h"
+
#define RB_COMPACT
#include "rb.h"
#if (defined(MALLOC_TCACHE) && defined(MALLOC_STATS))
@@ -5353,14 +5356,20 @@ small_size2bin_init_hard(void)
static unsigned
malloc_ncpus(void)
{
+ int mib[2];
unsigned ret;
- size_t retlen = sizeof(ret);
- int mib[] = {CTL_HW, HW_NCPU};
-
- if (sysctl(mib, sizeof(mib) / sizeof(int), &ret, &retlen,
- (void *)0, 0) == -1) {
- /* Error. */
- ret = 1;
+ int error;
+ size_t len;
+
+ error = _elf_aux_info(AT_NCPUS, &ret, sizeof(ret));
+ if (error != 0 || ret == 0) {
+ mib[0] = CTL_HW;
+ mib[1] = HW_NCPU;
+ len = sizeof(ret);
+ if (sysctl(mib, 2, &ret, &len, (void *)NULL, 0) == -1) {
+ /* Error. */
+ ret = 1;
+ }
}
return (ret);
OpenPOWER on IntegriCloud