/* ********************************* PTHREAD IMPLEMENTATION ************************************ */
#ifdef HAVE_PTHREAD_H
-#include <pthread.h>
#include <semaphore.h>
#ifdef HAVE_MUTEX_TIMEDLOCK
THROWF(system_error, errcode,
"pthread_setspecific failed for xbt_self_thread_key");
- void *res = (*(t->start_routine)) (t->param);
+ void *res = t->start_routine(t->param);
if (t->detached)
xbt_os_thread_free_thread_data(t);
return res;
if ((res->ps == (sem_t *) SEM_FAILED) && (errno == ENAMETOOLONG)) {
/* Old darwins only allow 13 chars. Did you create *that* amount of semaphores? */
res->name[13] = '\0';
- res->ps = sem_open(res->name, O_CREAT, 0644, 1);
+ res->ps = sem_open(res->name, O_CREAT, 0644, value);
}
if ((res->ps == (sem_t *) SEM_FAILED))
THROWF(system_error, errno, "sem_open() failed: %s", strerror(errno));
CloseHandle(thread->handle);
- if (thread->name)
- free(thread->name);
+ free(thread->name);
free(thread);
}
xbt_os_rmutex_t xbt_os_rmutex_init(void)
{
- xbt_os_rmutex_t rmutex = xbt_new0(struct xbt_os_rmutex_, 0);
+ xbt_os_rmutex_t rmutex = xbt_new0(struct xbt_os_rmutex_, 1);
rmutex->mutex = xbt_os_mutex_init();
rmutex->owner = NULL;
rmutex->count = 0;