Thu Jan 12 02:00:42 2017 UTC ()
Avoid sysconf: __sysconf -> sysctlgetmibinfo -> strtoimax -> locale, etc.


(christos)
diff -r1.57 -r1.58 src/lib/libc/stdlib/malloc.c

cvs diff -r1.57 -r1.58 src/lib/libc/stdlib/malloc.c (expand / switch to unified diff)

--- src/lib/libc/stdlib/malloc.c 2017/01/12 01:02:09 1.57
+++ src/lib/libc/stdlib/malloc.c 2017/01/12 02:00:42 1.58
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: malloc.c,v 1.57 2017/01/12 01:02:09 christos Exp $ */ 1/* $NetBSD: malloc.c,v 1.58 2017/01/12 02:00:42 christos Exp $ */
2 2
3/* 3/*
4 * ---------------------------------------------------------------------------- 4 * ----------------------------------------------------------------------------
5 * "THE BEER-WARE LICENSE" (Revision 42): 5 * "THE BEER-WARE LICENSE" (Revision 42):
6 * <phk@FreeBSD.ORG> wrote this file. As long as you retain this notice you 6 * <phk@FreeBSD.ORG> wrote this file. As long as you retain this notice you
7 * can do whatever you want with this stuff. If we meet some day, and you think 7 * can do whatever you want with this stuff. If we meet some day, and you think
8 * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp 8 * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
9 * ---------------------------------------------------------------------------- 9 * ----------------------------------------------------------------------------
10 * 10 *
11 * From FreeBSD: malloc.c,v 1.91 2006/01/12 07:28:20 jasone 11 * From FreeBSD: malloc.c,v 1.91 2006/01/12 07:28:20 jasone
12 * 12 *
13 */ 13 */
14 14
@@ -83,27 +83,27 @@ void utrace(struct ut *, int); @@ -83,27 +83,27 @@ void utrace(struct ut *, int);
83#endif /* __FreeBSD__ */ 83#endif /* __FreeBSD__ */
84 84
85#include <sys/types.h> 85#include <sys/types.h>
86#if defined(__NetBSD__) 86#if defined(__NetBSD__)
87# define malloc_minsize 16U 87# define malloc_minsize 16U
88# ifdef _LIBC 88# ifdef _LIBC
89# define HAS_UTRACE 89# define HAS_UTRACE
90# define UTRACE_LABEL "malloc", 90# define UTRACE_LABEL "malloc",
91int utrace(const char *, void *, size_t); 91int utrace(const char *, void *, size_t);
92# endif 92# endif
93# include <sys/cdefs.h> 93# include <sys/cdefs.h>
94# include "extern.h" 94# include "extern.h"
95# if defined(LIBC_SCCS) && !defined(lint) 95# if defined(LIBC_SCCS) && !defined(lint)
96__RCSID("$NetBSD: malloc.c,v 1.57 2017/01/12 01:02:09 christos Exp $"); 96__RCSID("$NetBSD: malloc.c,v 1.58 2017/01/12 02:00:42 christos Exp $");
97# endif /* LIBC_SCCS and not lint */ 97# endif /* LIBC_SCCS and not lint */
98# include <reentrant.h> 98# include <reentrant.h>
99# ifdef _REENTRANT 99# ifdef _REENTRANT
100extern int __isthreaded; 100extern int __isthreaded;
101static mutex_t thread_lock = MUTEX_INITIALIZER; 101static mutex_t thread_lock = MUTEX_INITIALIZER;
102# define _MALLOC_LOCK() if (__isthreaded) mutex_lock(&thread_lock); 102# define _MALLOC_LOCK() if (__isthreaded) mutex_lock(&thread_lock);
103# define _MALLOC_UNLOCK() if (__isthreaded) mutex_unlock(&thread_lock); 103# define _MALLOC_UNLOCK() if (__isthreaded) mutex_unlock(&thread_lock);
104# else 104# else
105# define _MALLOC_LOCK()  105# define _MALLOC_LOCK()
106# define _MALLOC_UNLOCK() 106# define _MALLOC_UNLOCK()
107# endif 107# endif
108#endif /* __NetBSD__ */ 108#endif /* __NetBSD__ */
109 109
@@ -448,27 +448,31 @@ extend_pgdir(size_t idx) @@ -448,27 +448,31 @@ extend_pgdir(size_t idx)
448 */ 448 */
449static void 449static void
450malloc_init(void) 450malloc_init(void)
451{ 451{
452 const char *p; 452 const char *p;
453 char b[64]; 453 char b[64];
454 size_t i; 454 size_t i;
455 ssize_t j; 455 ssize_t j;
456 int serrno = errno; 456 int serrno = errno;
457 457
458 /* 458 /*
459 * Compute page-size related variables. 459 * Compute page-size related variables.
460 */ 460 */
 461#ifdef _LIBC
461 malloc_pagesize = (size_t)sysconf(_SC_PAGESIZE); 462 malloc_pagesize = (size_t)sysconf(_SC_PAGESIZE);
 463#else
 464 malloc_pagesize = 4096;
 465#endif
462 malloc_pagemask = malloc_pagesize - 1; 466 malloc_pagemask = malloc_pagesize - 1;
463 for (malloc_pageshift = 0; 467 for (malloc_pageshift = 0;
464 (1UL << malloc_pageshift) != malloc_pagesize; 468 (1UL << malloc_pageshift) != malloc_pagesize;
465 malloc_pageshift++) 469 malloc_pageshift++)
466 /* nothing */ ; 470 /* nothing */ ;
467 471
468 INIT_MMAP(); 472 INIT_MMAP();
469 473
470#ifdef MALLOC_EXTRA_SANITY 474#ifdef MALLOC_EXTRA_SANITY
471 malloc_junk = 1; 475 malloc_junk = 1;
472#endif /* MALLOC_EXTRA_SANITY */ 476#endif /* MALLOC_EXTRA_SANITY */
473 477
474 for (i = 0; i < 3; i++) { 478 for (i = 0; i < 3; i++) {