*
* @APPLE_LICENSE_HEADER_START@
*
- * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
- *
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
void (*destructor)(void *);
} _pthread_keys[_POSIX_THREAD_KEYS_MAX];
static pthread_lock_t tds_lock = LOCK_INITIALIZER;
+/*
+ * Partition _pthread_keys in a lower part that dyld can use, and an upper
+ * part for libSystem. The libSystem part starts at __pthread_tsd_first = 4.
+ * dyld will set this value to 1.
+ */
+__private_extern__ int __pthread_tsd_first = 4;
/*
* Create a new key for thread specific data
LOCK(tds_lock);
res = ENOMEM; /* No 'free' keys */
/* The first slot is reserved for pthread_self() */
- for (i = 1; i < _POSIX_THREAD_KEYS_MAX; i++)
+ for (i = __pthread_tsd_first; i < _POSIX_THREAD_KEYS_MAX; i++)
{
if (_pthread_keys[i].created == FALSE)
{
int res;
LOCK(tds_lock);
/* The first slot is reserved for pthread_self() */
- if ((key > 0) && (key < _POSIX_THREAD_KEYS_MAX))
+ if ((key >= __pthread_tsd_first) && (key < _POSIX_THREAD_KEYS_MAX))
{
if (_pthread_keys[key].created)
{
int res;
pthread_t self;
/* The first slot is reserved for pthread_self() */
- if ((key > 0) && (key < _POSIX_THREAD_KEYS_MAX))
+ if ((key >= __pthread_tsd_first) && (key < _POSIX_THREAD_KEYS_MAX))
{
if (_pthread_keys[key].created)
{
for (j = 0; j < PTHREAD_DESTRUCTOR_ITERATIONS; j++)
{
/* The first slot is reserved for pthread_self() */
- for (i = 1; i < _POSIX_THREAD_KEYS_MAX; i++)
+ for (i = __pthread_tsd_first; i < _POSIX_THREAD_KEYS_MAX; i++)
{
if (_pthread_keys[i].created && (param = self->tsd[i]))
{