2008-03-31 19:10:00 +04:00
|
|
|
/*
|
|
|
|
* Copyright 2003-2008, Axel Dörfler, axeld@pinc-software.de.
|
2007-09-22 20:30:22 +04:00
|
|
|
* Copyright 2007, Ryan Leavengood, leavengood@gmail.com.
|
|
|
|
* All rights reserved. Distributed under the terms of the MIT License.
|
|
|
|
*/
|
2008-03-31 19:10:00 +04:00
|
|
|
#ifndef _PTHREAD_PRIVATE_H_
|
|
|
|
#define _PTHREAD_PRIVATE_H_
|
|
|
|
|
|
|
|
|
|
|
|
#include <pthread.h>
|
2003-04-20 22:48:54 +04:00
|
|
|
|
|
|
|
#include <OS.h>
|
|
|
|
|
|
|
|
// The public *_t types are only pointers to these structures
|
|
|
|
// This way, we are completely free to change them, which might be
|
|
|
|
// necessary in the future (not only due to the incomplete implementation
|
|
|
|
// at this point).
|
|
|
|
|
2007-09-22 20:30:22 +04:00
|
|
|
typedef struct _pthread_condattr {
|
|
|
|
bool process_shared;
|
|
|
|
} pthread_condattr;
|
|
|
|
|
|
|
|
typedef struct _pthread_cond {
|
|
|
|
sem_id sem;
|
|
|
|
pthread_mutex_t *mutex;
|
|
|
|
int32 waiter_count;
|
2007-09-23 06:48:30 +04:00
|
|
|
int32 event_counter;
|
2007-09-22 20:30:22 +04:00
|
|
|
pthread_condattr attr;
|
|
|
|
} pthread_cond;
|
|
|
|
|
2003-04-20 22:48:54 +04:00
|
|
|
typedef struct _pthread_mutexattr {
|
|
|
|
int32 type;
|
|
|
|
bool process_shared;
|
|
|
|
} pthread_mutexattr;
|
|
|
|
|
|
|
|
typedef struct _pthread_mutex {
|
|
|
|
vint32 count;
|
|
|
|
sem_id sem;
|
|
|
|
thread_id owner;
|
|
|
|
int32 owner_count;
|
|
|
|
pthread_mutexattr attr;
|
|
|
|
} pthread_mutex;
|
|
|
|
|
2006-06-20 15:05:58 +04:00
|
|
|
typedef struct _pthread_attr {
|
|
|
|
int32 detach_state;
|
|
|
|
int32 sched_priority;
|
|
|
|
} pthread_attr;
|
|
|
|
|
2008-04-17 17:44:39 +04:00
|
|
|
typedef void (*pthread_key_destructor)(void *data);
|
|
|
|
|
|
|
|
struct pthread_key {
|
|
|
|
vint32 sequence;
|
|
|
|
pthread_key_destructor destructor;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct pthread_key_data {
|
|
|
|
vint32 sequence;
|
|
|
|
void *value;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define PTHREAD_KEYS_MAX 256
|
|
|
|
#define PTHREAD_UNUSED_SEQUENCE 0
|
2006-06-21 18:07:34 +04:00
|
|
|
|
2008-03-31 19:10:00 +04:00
|
|
|
// This structure is used internally only, it has no public equivalent
|
|
|
|
struct pthread_thread {
|
|
|
|
void *(*entry)(void*);
|
|
|
|
void *entry_argument;
|
2008-03-31 22:49:19 +04:00
|
|
|
int cancel_state;
|
|
|
|
int cancel_type;
|
|
|
|
bool cancelled;
|
2008-04-17 17:44:39 +04:00
|
|
|
struct pthread_key_data specific[PTHREAD_KEYS_MAX];
|
2008-03-31 19:10:00 +04:00
|
|
|
struct __pthread_cleanup_handler *cleanup_handlers;
|
|
|
|
// TODO: move pthread keys in here, too
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2008-04-17 17:44:39 +04:00
|
|
|
void __pthread_key_call_destructors(struct pthread_thread *thread);
|
2008-03-31 19:10:00 +04:00
|
|
|
struct pthread_thread *__get_pthread(void);
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
2006-06-21 18:07:34 +04:00
|
|
|
|
2003-04-20 22:48:54 +04:00
|
|
|
#endif /* _PTHREAD_PRIVATE_H_ */
|