diff options
author | 2016-04-12 18:14:02 +0000 | |
---|---|---|
committer | 2016-04-12 18:14:02 +0000 | |
commit | 0af269bd86cee94b4542af99da3c803ac9ef436b (patch) | |
tree | 9a2f8a39c6692f4ca4ff58c9c2f4d2a306964c4a /lib/libc/stdlib | |
parent | documents "mcast" promise (diff) | |
download | wireguard-openbsd-0af269bd86cee94b4542af99da3c803ac9ef436b.tar.xz wireguard-openbsd-0af269bd86cee94b4542af99da3c803ac9ef436b.zip |
two times a define to an inline function, from Michael McConville; ok djm@
Diffstat (limited to 'lib/libc/stdlib')
-rw-r--r-- | lib/libc/stdlib/malloc.c | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/lib/libc/stdlib/malloc.c b/lib/libc/stdlib/malloc.c index fe010f18d8e..b9f692ebb78 100644 --- a/lib/libc/stdlib/malloc.c +++ b/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 <otto@drijf.net> * Copyright (c) 2012 Matthew Dempsky <matthew@openbsd.org> @@ -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) { |