diff --git a/src/lib/libc/stdlib/malloc.c b/src/lib/libc/stdlib/malloc.c index fe010f18..b9f692eb 100644 --- a/src/lib/libc/stdlib/malloc.c +++ b/src/lib/libc/stdlib/malloc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: malloc.c,v 1.187 2016/04/09 14:08:40 otto Exp $ */ +/* $OpenBSD: malloc.c,v 1.188 2016/04/12 18:14:02 otto Exp $ */ /* * Copyright (c) 2008, 2010, 2011 Otto Moerbeek * Copyright (c) 2012 Matthew Dempsky @@ -93,15 +93,6 @@ #define MQUERY(a, sz) mquery((a), (size_t)(sz), PROT_READ | PROT_WRITE, \ MAP_ANON | MAP_PRIVATE | MAP_FIXED, -1, (off_t)0) -#define _MALLOC_LEAVE(d) do { if (__isthreaded) { \ - (d)->active--; \ - _MALLOC_UNLOCK(); } \ -} while (0) -#define _MALLOC_ENTER(d) do { if (__isthreaded) { \ - _MALLOC_LOCK(); \ - (d)->active++; } \ -} while (0) - struct region_info { void *p; /* page; low bits used to mark chunks */ uintptr_t size; /* size for pages, or chunk_info pointer */ @@ -224,6 +215,24 @@ static void malloc_exit(void); (sz) = (uintptr_t)(r)->p & MALLOC_PAGEMASK, \ (sz) = ((sz) == 0 ? (r)->size : ((sz) == 1 ? 0 : (1 << ((sz)-1)))) +static inline void +_MALLOC_LEAVE(struct dir_info *d) +{ + if (__isthreaded) { + d->active--; + _MALLOC_UNLOCK(); + } +} + +static inline void +_MALLOC_ENTER(struct dir_info *d) +{ + if (__isthreaded) { + _MALLOC_LOCK(); + d->active++; + } +} + static inline size_t hash(void *p) {