summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lib/libc/stdlib/malloc.c29
1 files changed, 19 insertions, 10 deletions
diff --git a/src/lib/libc/stdlib/malloc.c b/src/lib/libc/stdlib/malloc.c
index fe010f18d8..b9f692ebb7 100644
--- a/src/lib/libc/stdlib/malloc.c
+++ b/src/lib/libc/stdlib/malloc.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: malloc.c,v 1.187 2016/04/09 14:08:40 otto Exp $ */ 1/* $OpenBSD: malloc.c,v 1.188 2016/04/12 18:14:02 otto Exp $ */
2/* 2/*
3 * Copyright (c) 2008, 2010, 2011 Otto Moerbeek <otto@drijf.net> 3 * Copyright (c) 2008, 2010, 2011 Otto Moerbeek <otto@drijf.net>
4 * Copyright (c) 2012 Matthew Dempsky <matthew@openbsd.org> 4 * Copyright (c) 2012 Matthew Dempsky <matthew@openbsd.org>
@@ -93,15 +93,6 @@
93#define MQUERY(a, sz) mquery((a), (size_t)(sz), PROT_READ | PROT_WRITE, \ 93#define MQUERY(a, sz) mquery((a), (size_t)(sz), PROT_READ | PROT_WRITE, \
94 MAP_ANON | MAP_PRIVATE | MAP_FIXED, -1, (off_t)0) 94 MAP_ANON | MAP_PRIVATE | MAP_FIXED, -1, (off_t)0)
95 95
96#define _MALLOC_LEAVE(d) do { if (__isthreaded) { \
97 (d)->active--; \
98 _MALLOC_UNLOCK(); } \
99} while (0)
100#define _MALLOC_ENTER(d) do { if (__isthreaded) { \
101 _MALLOC_LOCK(); \
102 (d)->active++; } \
103} while (0)
104
105struct region_info { 96struct region_info {
106 void *p; /* page; low bits used to mark chunks */ 97 void *p; /* page; low bits used to mark chunks */
107 uintptr_t size; /* size for pages, or chunk_info pointer */ 98 uintptr_t size; /* size for pages, or chunk_info pointer */
@@ -224,6 +215,24 @@ static void malloc_exit(void);
224 (sz) = (uintptr_t)(r)->p & MALLOC_PAGEMASK, \ 215 (sz) = (uintptr_t)(r)->p & MALLOC_PAGEMASK, \
225 (sz) = ((sz) == 0 ? (r)->size : ((sz) == 1 ? 0 : (1 << ((sz)-1)))) 216 (sz) = ((sz) == 0 ? (r)->size : ((sz) == 1 ? 0 : (1 << ((sz)-1))))
226 217
218static inline void
219_MALLOC_LEAVE(struct dir_info *d)
220{
221 if (__isthreaded) {
222 d->active--;
223 _MALLOC_UNLOCK();
224 }
225}
226
227static inline void
228_MALLOC_ENTER(struct dir_info *d)
229{
230 if (__isthreaded) {
231 _MALLOC_LOCK();
232 d->active++;
233 }
234}
235
227static inline size_t 236static inline size_t
228hash(void *p) 237hash(void *p)
229{ 238{