added posix thread specific data functions
added a pthread_detach skeleton git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17880 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
a23efdfa79
commit
1f11178f97
|
@ -127,6 +127,12 @@ extern pthread_t pthread_self(void);
|
|||
|
||||
extern int pthread_kill(pthread_t thread, int sig);
|
||||
|
||||
/* thread specific data functions */
|
||||
extern int pthread_key_create(pthread_key_t *key, void (*destructor)(void*));
|
||||
extern int pthread_key_delete(pthread_key_t key);
|
||||
extern void *pthread_getspecific(pthread_key_t key);
|
||||
extern int pthread_setspecific(pthread_key_t key, const void *value);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -6,6 +6,7 @@ MergeObject posix_pthread.o :
|
|||
pthread.c
|
||||
pthread_atfork.c
|
||||
pthread_attr.c
|
||||
pthread_key.c
|
||||
pthread_mutex.c
|
||||
pthread_mutexattr.c
|
||||
;
|
||||
|
|
|
@ -73,3 +73,10 @@ pthread_kill(pthread_t thread, int sig)
|
|||
return kill(thread, sig);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
pthread_detach(pthread_t thread)
|
||||
{
|
||||
return B_NOT_ALLOWED;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
** Copyright 2006, Jérôme Duval. All rights reserved.
|
||||
** Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
|
||||
#include <TLS.h>
|
||||
#include <pthread.h>
|
||||
#include "pthread_private.h"
|
||||
|
||||
int
|
||||
pthread_key_create(pthread_key_t *key, void (*destructor)(void*))
|
||||
{
|
||||
if (key == NULL)
|
||||
return B_BAD_VALUE;
|
||||
*key = tls_allocate();
|
||||
if (*key > 0)
|
||||
return B_OK;
|
||||
return *key;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
pthread_key_delete(pthread_key_t key)
|
||||
{
|
||||
// we don't check if the key is valid
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
void *
|
||||
pthread_getspecific(pthread_key_t key)
|
||||
{
|
||||
return tls_get(key);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
pthread_setspecific(pthread_key_t key, const void *value)
|
||||
{
|
||||
// we don't check if the key is valid
|
||||
tls_set(key, (void *)value);
|
||||
return B_OK;
|
||||
}
|
||||
|
Loading…
Reference in New Issue