}
retry:
- __libc_rwlock_wrlock (GL (dl_pthread_threads_lock));
+ __mach_rwlock_wrlock (GL (dl_pthread_threads_lock));
if (GL (dl_pthread_num_threads) < __pthread_max_threads)
{
new->thread = 1 + GL (dl_pthread_num_threads)++;
GL (dl_pthread_threads)[new->thread - 1] = NULL;
- __libc_rwlock_unlock (GL (dl_pthread_threads_lock));
+ __mach_rwlock_unlock (GL (dl_pthread_threads_lock));
*pthread = new;
return 0;
else if (GL (dl_pthread_num_threads) >= PTHREAD_THREADS_MAX)
{
/* We have reached the limit on the number of threads per process. */
- __libc_rwlock_unlock (GL (dl_pthread_threads_lock));
+ __mach_rwlock_unlock (GL (dl_pthread_threads_lock));
free (new);
return EAGAIN;
memory allocation, since that's a potentially blocking operation. */
max_threads = __pthread_max_threads;
- __libc_rwlock_unlock (GL (dl_pthread_threads_lock));
+ __mach_rwlock_unlock (GL (dl_pthread_threads_lock));
/* Allocate a new lookup table that's twice as large. */
new_max_threads
return ENOMEM;
}
- __libc_rwlock_wrlock (GL (dl_pthread_threads_lock));
+ __mach_rwlock_wrlock (GL (dl_pthread_threads_lock));
/* Check if nobody else has already enlarged the table. */
if (max_threads != __pthread_max_threads)
{
/* Yep, they did. */
- __libc_rwlock_unlock (GL (dl_pthread_threads_lock));
+ __mach_rwlock_unlock (GL (dl_pthread_threads_lock));
/* Free the newly allocated table and try again to allocate a slot. */
free (threads);
new->thread = 1 + GL (dl_pthread_num_threads)++;
GL (dl_pthread_threads)[new->thread - 1] = NULL;
- __libc_rwlock_unlock (GL (dl_pthread_threads_lock));
+ __mach_rwlock_unlock (GL (dl_pthread_threads_lock));
free (old_threads);
{
int i;
- __libc_rwlock_wrlock (GL (dl_pthread_threads_lock));
+ __mach_rwlock_wrlock (GL (dl_pthread_threads_lock));
for (i = 0; i < GL (dl_pthread_num_threads); ++i)
{
struct __pthread *t = GL (dl_pthread_threads)[i];
memset (__mempcpy (dest, map->l_tls_initimage, map->l_tls_initimage_size),
'\0', map->l_tls_blocksize - map->l_tls_initimage_size);
}
- __libc_rwlock_unlock (GL (dl_pthread_threads_lock));
+ __mach_rwlock_unlock (GL (dl_pthread_threads_lock));
}
libc_hidden_def (__pthread_init_static_tls)
could use __thread_setid, however, we only lock for reading as no
other thread should be using this entry (we also assume that the
store is atomic). */
- __libc_rwlock_rdlock (GL (dl_pthread_threads_lock));
+ __mach_rwlock_rdlock (GL (dl_pthread_threads_lock));
GL (dl_pthread_threads)[pthread->thread - 1] = pthread;
- __libc_rwlock_unlock (GL (dl_pthread_threads_lock));
+ __mach_rwlock_unlock (GL (dl_pthread_threads_lock));
/* At this point it is possible to guess our pthread ID. We have to
make sure that all functions taking a pthread_t argument can
#define __pthread_getid(thread) \
({ struct __pthread *__t = NULL; \
- __libc_rwlock_rdlock (GL (dl_pthread_threads_lock)); \
+ __mach_rwlock_rdlock (GL (dl_pthread_threads_lock)); \
if (thread <= __pthread_max_threads) \
__t = GL (dl_pthread_threads)[thread - 1]; \
- __libc_rwlock_unlock (GL (dl_pthread_threads_lock)); \
+ __mach_rwlock_unlock (GL (dl_pthread_threads_lock)); \
__t; })
#define __pthread_setid(thread, pthread) \
- __libc_rwlock_wrlock (GL (dl_pthread_threads_lock)); \
+ __mach_rwlock_wrlock (GL (dl_pthread_threads_lock)); \
GL (dl_pthread_threads)[thread - 1] = pthread; \
- __libc_rwlock_unlock (GL (dl_pthread_threads_lock));
+ __mach_rwlock_unlock (GL (dl_pthread_threads_lock));
/* Similar to pthread_self, but returns the thread descriptor instead
of the thread ID. */
/* Array of __pthread structures and its lock. */
EXTERN struct __pthread **_dl_pthread_threads;
- __libc_rwlock_define (EXTERN, _dl_pthread_threads_lock)
+ __mach_rwlock_define (EXTERN, _dl_pthread_threads_lock)
#endif
#ifdef SHARED
};
int _dl_pthread_num_threads;
struct __pthread **_dl_pthread_threads;
-__libc_rwlock_define_initialized (, _dl_pthread_threads_lock)
+__mach_rwlock_define_initialized (, _dl_pthread_threads_lock)
struct __pthread *t;
int *gscope_flagp;
- __libc_rwlock_rdlock (GL (dl_pthread_threads_lock));
+ __mach_rwlock_rdlock (GL (dl_pthread_threads_lock));
/* Iterate over the list of threads. */
for (i = 0; i < GL (dl_pthread_num_threads); ++i)
while (*gscope_flagp == THREAD_GSCOPE_FLAG_WAIT);
}
- __libc_rwlock_unlock (GL (dl_pthread_threads_lock));
+ __mach_rwlock_unlock (GL (dl_pthread_threads_lock));
}
__pthread_key_destructors[key] = PTHREAD_KEY_INVALID;
__pthread_key_invalid_count++;
- __libc_rwlock_rdlock (GL (dl_pthread_threads_lock));
+ __mach_rwlock_rdlock (GL (dl_pthread_threads_lock));
for (i = 0; i < GL (dl_pthread_num_threads); ++i)
{
struct __pthread *t;
t->thread_specifics[key] = 0;
}
}
- __libc_rwlock_unlock (GL (dl_pthread_threads_lock));
+ __mach_rwlock_unlock (GL (dl_pthread_threads_lock));
}
__pthread_mutex_unlock (&__pthread_key_lock);
#include <sys/random.h>
#include <fcntl.h>
-__libc_rwlock_define_initialized (static, lock);
+__mach_rwlock_define_initialized (static, lock);
static file_t random_server, random_server_nonblock,
urandom_server, urandom_server_nonblock;
return length;
again:
- __libc_rwlock_rdlock (lock);
+ __mach_rwlock_rdlock (lock);
server = *cached_server;
if (MACH_PORT_VALID (server))
/* Attempt to read some random data using this port. */
err = __io_read (server, &data, &nread, -1, length);
else
err = MACH_SEND_INVALID_DEST;
- __libc_rwlock_unlock (lock);
+ __mach_rwlock_unlock (lock);
if (err == MACH_SEND_INVALID_DEST || err == MIG_SERVER_DIED)
{
/* Slow path: the cached port didn't work, or there was no
cached port in the first place. */
- __libc_rwlock_wrlock (lock);
+ __mach_rwlock_wrlock (lock);
server = *cached_server;
if (server != oldserver)
{
/* Someone else must have refetched the port while we were
waiting for the lock. */
- __libc_rwlock_unlock (lock);
+ __mach_rwlock_unlock (lock);
goto again;
}
MACH_PORT_RIGHT_SEND, &urefs);
if (!err && urefs > 0)
{
- __libc_rwlock_unlock (lock);
+ __mach_rwlock_unlock (lock);
goto again;
}
server = *cached_server = __file_name_lookup (random_source,
open_flags, 0);
- __libc_rwlock_unlock (lock);
+ __mach_rwlock_unlock (lock);
if (!MACH_PORT_VALID (server))
{
if (errno == ENOENT)
#define __rtld_lock_unlock_recursive(NAME) \
__libc_lock_unlock_recursive (NAME)
-/* XXX for now */
+/* XXX for now, waiting for a futex-based pthread_rwlock implementation */
+#define __mach_rwlock_define __libc_lock_define
+#define __mach_rwlock_define_initialized __libc_lock_define_initialized
+#define __mach_rwlock_init __libc_lock_init
+#define __mach_rwlock_fini __libc_lock_fini
+#define __mach_rwlock_rdlock __libc_lock_lock
+#define __mach_rwlock_wrlock __libc_lock_lock
+#define __mach_rwlock_tryrdlock __libc_lock_trylock
+#define __mach_rwlock_trywrlock __libc_lock_trylock
+#define __mach_rwlock_unlock __libc_lock_unlock
+
#define __libc_rwlock_define __libc_lock_define
#define __libc_rwlock_define_initialized __libc_lock_define_initialized
#define __libc_rwlock_init __libc_lock_init