summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorguenther <guenther@openbsd.org>2012-02-18 21:50:27 +0000
committerguenther <guenther@openbsd.org>2012-02-18 21:50:27 +0000
commit6918e75c4e8ee4d998959013260fd7c24a12a35e (patch)
tree85b2d341dcf741d7da6d34228750d2594a278ddb
parentid tag. (diff)
downloadwireguard-openbsd-6918e75c4e8ee4d998959013260fd7c24a12a35e.tar.xz
wireguard-openbsd-6918e75c4e8ee4d998959013260fd7c24a12a35e.zip
Before using _thread_pagesize, make sure _rthread_init() has been called
-rw-r--r--lib/librthread/rthread_attr.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/librthread/rthread_attr.c b/lib/librthread/rthread_attr.c
index dbef6b5acf1..7a4e3b31105 100644
--- a/lib/librthread/rthread_attr.c
+++ b/lib/librthread/rthread_attr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rthread_attr.c,v 1.12 2012/02/18 21:12:09 guenther Exp $ */
+/* $OpenBSD: rthread_attr.c,v 1.13 2012/02/18 21:50:27 guenther Exp $ */
/*
* Copyright (c) 2004,2005 Ted Unangst <tedu@openbsd.org>
* All Rights Reserved.
@@ -144,6 +144,8 @@ pthread_attr_getstacksize(const pthread_attr_t *attrp, size_t *stacksize)
int
pthread_attr_setstacksize(pthread_attr_t *attrp, size_t stacksize)
{
+ if (!_threads_ready)
+ _rthread_init();
if (stacksize < PTHREAD_STACK_MIN ||
stacksize > ROUND_TO_PAGE(stacksize))
return (EINVAL);
@@ -163,6 +165,8 @@ pthread_attr_getstackaddr(const pthread_attr_t *attrp, void **stackaddr)
int
pthread_attr_setstackaddr(pthread_attr_t *attrp, void *stackaddr)
{
+ if (!_threads_ready)
+ _rthread_init();
if (stackaddr == NULL || (uintptr_t)stackaddr & (_thread_pagesize - 1))
return EINVAL;
(*attrp)->stack_addr = stackaddr;