diff options
author | Otto Moerbeek <otto@cvs.openbsd.org> | 2016-04-12 18:14:03 +0000 |
---|---|---|
committer | Otto Moerbeek <otto@cvs.openbsd.org> | 2016-04-12 18:14:03 +0000 |
commit | db3ff3df8b6a21fd2e95c67af75725bec455d115 (patch) | |
tree | 82de9b279bb0ba2546e34e7f150c35cf81c769c5 /lib | |
parent | 1467cdacbdcade531e7df0712134fd38d7841557 (diff) |
two times a define to an inline function, from Michael McConville; ok djm@
Diffstat (limited to 'lib')
-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) { |