version 1.34.2.3, 2016/05/10 09:10:11 |
version 1.44.4.1, 2019/06/10 22:05:21 |
Line 143 __RCSID("$NetBSD$"); |
|
Line 143 __RCSID("$NetBSD$"); |
|
#ifdef __FreeBSD__ |
#ifdef __FreeBSD__ |
#include <machine/atomic.h> |
#include <machine/atomic.h> |
#include <machine/cpufunc.h> |
#include <machine/cpufunc.h> |
#endif |
|
#include <machine/vmparam.h> |
#include <machine/vmparam.h> |
|
#endif |
|
|
#include <errno.h> |
#include <errno.h> |
#include <limits.h> |
#include <limits.h> |
Line 163 __RCSID("$NetBSD$"); |
|
Line 163 __RCSID("$NetBSD$"); |
|
# include <reentrant.h> |
# include <reentrant.h> |
# include "extern.h" |
# include "extern.h" |
|
|
#define STRERROR_R(a, b, c) __strerror_r(a, b, c); |
#define STRERROR_R(a, b, c) strerror_r_ss(a, b, c); |
/* |
|
* A non localized version of strerror, that avoids bringing in |
|
* stdio and the locale code. All the malloc messages are in English |
|
* so why bother? |
|
*/ |
|
static int |
|
__strerror_r(int e, char *s, size_t l) |
|
{ |
|
int rval; |
|
size_t slen; |
|
|
|
if (e >= 0 && e < sys_nerr) { |
|
slen = strlcpy(s, sys_errlist[e], l); |
|
rval = 0; |
|
} else { |
|
slen = snprintf_ss(s, l, "Unknown error %u", e); |
|
rval = EINVAL; |
|
} |
|
return slen >= l ? ERANGE : rval; |
|
} |
|
#endif |
#endif |
|
|
#ifdef __FreeBSD__ |
#ifdef __FreeBSD__ |
Line 275 __strerror_r(int e, char *s, size_t l) |
|
Line 255 __strerror_r(int e, char *s, size_t l) |
|
# define SIZEOF_PTR_2POW 2 |
# define SIZEOF_PTR_2POW 2 |
# define USE_BRK |
# define USE_BRK |
#endif |
#endif |
|
#ifdef __or1k__ |
|
# define QUANTUM_2POW_MIN 4 |
|
# define SIZEOF_PTR_2POW 2 |
|
# define USE_BRK |
|
#endif |
#ifdef __vax__ |
#ifdef __vax__ |
# define QUANTUM_2POW_MIN 4 |
# define QUANTUM_2POW_MIN 4 |
# define SIZEOF_PTR_2POW 2 |
# define SIZEOF_PTR_2POW 2 |
Line 290 __strerror_r(int e, char *s, size_t l) |
|
Line 275 __strerror_r(int e, char *s, size_t l) |
|
# define SIZEOF_PTR_2POW 2 |
# define SIZEOF_PTR_2POW 2 |
# define USE_BRK |
# define USE_BRK |
#endif |
#endif |
#ifdef __mips__ |
#if defined(__mips__) || defined(__riscv__) |
|
# ifdef _LP64 |
|
# define SIZEOF_PTR_2POW 3 |
|
# define TINY_MIN_2POW 3 |
|
# else |
|
# define SIZEOF_PTR_2POW 2 |
|
# endif |
# define QUANTUM_2POW_MIN 4 |
# define QUANTUM_2POW_MIN 4 |
# define SIZEOF_PTR_2POW 2 |
|
# define USE_BRK |
# define USE_BRK |
#endif |
#endif |
#ifdef __hppa__ |
#ifdef __hppa__ |
# define QUANTUM_2POW_MIN 4 |
# define QUANTUM_2POW_MIN 4 |
# define SIZEOF_PTR_2POW 2 |
# define TINY_MIN_2POW 4 |
|
# define SIZEOF_PTR_2POW 2 |
# define USE_BRK |
# define USE_BRK |
#endif |
#endif |
|
|
Line 713 static chunk_tree_t huge; |
|
Line 704 static chunk_tree_t huge; |
|
* base_pages_alloc() also uses sbrk(), but cannot lock chunks_mtx (doing so |
* base_pages_alloc() also uses sbrk(), but cannot lock chunks_mtx (doing so |
* could cause recursive lock acquisition). |
* could cause recursive lock acquisition). |
*/ |
*/ |
|
#ifdef _REENTRANT |
static malloc_mutex_t brk_mtx; |
static malloc_mutex_t brk_mtx; |
|
#endif |
/* Result of first sbrk(0) call. */ |
/* Result of first sbrk(0) call. */ |
static void *brk_base; |
static void *brk_base; |
/* Current end of brk, or ((void *)-1) if brk is exhausted. */ |
/* Current end of brk, or ((void *)-1) if brk is exhausted. */ |
Line 1713 arena_run_reg_alloc(arena_run_t *run, ar |
|
Line 1706 arena_run_reg_alloc(arena_run_t *run, ar |
|
+ (bin->reg_size * regind)); |
+ (bin->reg_size * regind)); |
|
|
/* Clear bit. */ |
/* Clear bit. */ |
mask ^= (1 << bit); |
mask ^= (1U << bit); |
run->regs_mask[i] = mask; |
run->regs_mask[i] = mask; |
|
|
return (ret); |
return (ret); |
Line 1730 arena_run_reg_alloc(arena_run_t *run, ar |
|
Line 1723 arena_run_reg_alloc(arena_run_t *run, ar |
|
+ (bin->reg_size * regind)); |
+ (bin->reg_size * regind)); |
|
|
/* Clear bit. */ |
/* Clear bit. */ |
mask ^= (1 << bit); |
mask ^= (1U << bit); |
run->regs_mask[i] = mask; |
run->regs_mask[i] = mask; |
|
|
/* |
/* |
Line 1845 arena_run_reg_dalloc(arena_run_t *run, a |
|
Line 1838 arena_run_reg_dalloc(arena_run_t *run, a |
|
if (elm < run->regs_minelm) |
if (elm < run->regs_minelm) |
run->regs_minelm = elm; |
run->regs_minelm = elm; |
bit = regind - (elm << (SIZEOF_INT_2POW + 3)); |
bit = regind - (elm << (SIZEOF_INT_2POW + 3)); |
assert((run->regs_mask[elm] & (1 << bit)) == 0); |
assert((run->regs_mask[elm] & (1U << bit)) == 0); |
run->regs_mask[elm] |= (1 << bit); |
run->regs_mask[elm] |= (1U << bit); |
#undef SIZE_INV |
#undef SIZE_INV |
#undef SIZE_INV_SHIFT |
#undef SIZE_INV_SHIFT |
} |
} |