Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
233dbb1efd46015295f8db9ba17bea2428149e7a
[simgrid.git] / src / sthread / sthread.h
1 /* SimGrid's pthread interposer. Intercepts most of the pthread and semaphore calls to model-check them.
2  *
3  * Intercepting on pthread is somewhat complicated by the fact that pthread is used everywhere in the system headers.
4  * To reduce definition conflicts, our redefinitions of the pthread symbols (in sthread.c) load as little headers as
5  * possible. Thus, the actual implementations are separated in another file (sthread_impl.cpp) and are used as black
6  * boxes by our redefinitions.
7  *
8  * The sthread_* symbols are those actual implementations, used in the pthread_* redefinitions. */
9
10 #if defined(__cplusplus)
11 extern "C" {
12 #endif
13 extern volatile int sthread_inside_simgrid; // Only intercept pthread calls in user code
14
15 int sthread_main(int argc, char** argv, char** envp, int (*raw_main)(int, char**, char**));
16
17 typedef unsigned long int sthread_t;
18 int sthread_create(sthread_t* thread, const /*pthread_attr_t*/ void* attr, void* (*start_routine)(void*), void* arg);
19 int sthread_join(sthread_t thread, void** retval);
20
21 typedef struct {
22   void* mutex;
23 } sthread_mutex_t;
24 int sthread_mutex_init(sthread_mutex_t* mutex, const /*pthread_mutexattr_t*/ void* attr);
25 int sthread_mutex_lock(sthread_mutex_t* mutex);
26 int sthread_mutex_trylock(sthread_mutex_t* mutex);
27 int sthread_mutex_unlock(sthread_mutex_t* mutex);
28 int sthread_mutex_destroy(sthread_mutex_t* mutex);
29
30 #if defined(__cplusplus)
31 }
32 #endif