summaryrefslogtreecommitdiffstats
path: root/lib/libc/include
diff options
context:
space:
mode:
authorotto <otto@openbsd.org>2016-09-01 10:41:02 +0000
committerotto <otto@openbsd.org>2016-09-01 10:41:02 +0000
commitca609fedb3fd4858a72ea88c8ada5319b57e8bd9 (patch)
tree872a70745e6f18c07e2ef6dd37ccb0a1163460a0 /lib/libc/include
parentDo not busy loop in the rsa engine callback waiting for the ca. Instead use (diff)
downloadwireguard-openbsd-ca609fedb3fd4858a72ea88c8ada5319b57e8bd9.tar.xz
wireguard-openbsd-ca609fedb3fd4858a72ea88c8ada5319b57e8bd9.zip
Less lock contention by using more pools for mult-threaded programs.
tested by many (thanks!) ok tedu, guenther@
Diffstat (limited to 'lib/libc/include')
-rw-r--r--lib/libc/include/thread_private.h21
1 files changed, 12 insertions, 9 deletions
diff --git a/lib/libc/include/thread_private.h b/lib/libc/include/thread_private.h
index c2e0cf0b3fd..81caaaae68a 100644
--- a/lib/libc/include/thread_private.h
+++ b/lib/libc/include/thread_private.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: thread_private.h,v 1.27 2016/05/07 19:05:22 guenther Exp $ */
+/* $OpenBSD: thread_private.h,v 1.28 2016/09/01 10:41:02 otto Exp $ */
/* PUBLIC DOMAIN: No Rights Reserved. Marco S Hyman <marc@snafu.org> */
@@ -7,6 +7,9 @@
#include <stdio.h> /* for FILE and __isthreaded */
+#define _MALLOC_MUTEXES 4
+void _malloc_init(int);
+
/*
* The callbacks needed by libc to handle the threaded case.
* NOTE: Bump the version when you change the struct contents!
@@ -72,8 +75,8 @@ struct thread_callbacks {
void (*tc_flockfile)(FILE *);
int (*tc_ftrylockfile)(FILE *);
void (*tc_funlockfile)(FILE *);
- void (*tc_malloc_lock)(void);
- void (*tc_malloc_unlock)(void);
+ void (*tc_malloc_lock)(int);
+ void (*tc_malloc_unlock)(int);
void (*tc_atexit_lock)(void);
void (*tc_atexit_unlock)(void);
void (*tc_atfork_lock)(void);
@@ -137,8 +140,8 @@ extern void *__THREAD_NAME(serv_mutex);
#define _MUTEX_LOCK(mutex) do {} while (0)
#define _MUTEX_UNLOCK(mutex) do {} while (0)
#define _MUTEX_DESTROY(mutex) do {} while (0)
-#define _MALLOC_LOCK() do {} while (0)
-#define _MALLOC_UNLOCK() do {} while (0)
+#define _MALLOC_LOCK(n) do {} while (0)
+#define _MALLOC_UNLOCK(n) do {} while (0)
#define _ATEXIT_LOCK() do {} while (0)
#define _ATEXIT_UNLOCK() do {} while (0)
#define _ATFORK_LOCK() do {} while (0)
@@ -184,15 +187,15 @@ extern void *__THREAD_NAME(serv_mutex);
/*
* malloc lock/unlock prototypes and definitions
*/
-#define _MALLOC_LOCK() \
+#define _MALLOC_LOCK(n) \
do { \
if (__isthreaded) \
- _thread_cb.tc_malloc_lock(); \
+ _thread_cb.tc_malloc_lock(n); \
} while (0)
-#define _MALLOC_UNLOCK() \
+#define _MALLOC_UNLOCK(n) \
do { \
if (__isthreaded) \
- _thread_cb.tc_malloc_unlock(); \
+ _thread_cb.tc_malloc_unlock(n); \
} while (0)
#define _ATEXIT_LOCK() \