tech-userlevel archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: Increase PTHREAD_KEYS_MAX
On Wed, May 20, 2015 at 09:26:49AM +0000, Emmanuel Dreyfus wrote:
> This is quickly getting ugly: malloc() calls pthread_key_create(),
There is a way out, though. Is it reasonable?
Index: pthread.c
===================================================================
RCS file: /cvsroot/src/lib/libpthread/pthread.c,v
retrieving revision 1.145
diff -U 8 -r1.145 pthread.c
--- pthread.c 16 Dec 2014 20:05:54 -0000 1.145
+++ pthread.c 20 May 2015 09:40:12 -0000
@@ -160,16 +160,26 @@
void
pthread__init(void)
{
pthread_t first;
char *p;
int i;
extern int __isthreaded;
+ /*
+ * Allocate pthread_keys descriptors before
+ * reseting __uselibcstub because otherwise
+ * malloc() will call pthread_keys_create()
+ * while pthread_keys descriptors are not
+ * yet allocated.
+ */
+ if (pthread_tsd_init() != 0)
+ err(1, "Cannot allocate pthread_keys descriptors");
+
__uselibcstub = 0;
pthread__pagesize = (size_t)sysconf(_SC_PAGESIZE);
pthread__concurrency = (int)sysconf(_SC_NPROCESSORS_CONF);
/* Initialize locks first; they're needed elsewhere. */
pthread__lockprim_init();
for (i = 0; i < NHASHLOCK; i++) {
--
Emmanuel Dreyfus
manu%netbsd.org@localhost
Home |
Main Index |
Thread Index |
Old Index