about summary refs log tree commit diff stats
path: root/src/include/threads.h
blob: 7a77657f6f4b9d4769c90f2b0a4111c78db9b75b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#ifndef _THREADS_H_
#define _THREADS_H_

typedef struct box64context_s box64context_t;
typedef struct x64emu_s x64emu_t;

typedef struct emuthread_s {
	uintptr_t 	fnc;
	void*		arg;
	x64emu_t*	emu;
	int			join;
	int			is32bits;
	uintptr_t	self;
	ulong_t 	hself;
	int			cancel_cap, cancel_size;
	void**		cancels;
} emuthread_t;

void CleanStackSize(box64context_t* context);

void init_pthread_helper(void);
void fini_pthread_helper(box64context_t* context);
void clean_current_emuthread(void);
#ifdef BOX32
void init_pthread_helper_32(void);
void fini_pthread_helper_32(box64context_t* context);
#endif

// prepare an "emuthread structure" in pet and return address of function pointer for a "thread creation routine"
void* my_prepare_thread(x64emu_t *emu, void* f, void* arg, int ssize, void** pet);

//check and unlock if a mutex is locked by current thread (works only for PTHREAD_MUTEX_ERRORCHECK typed mutex)
int checkUnlockMutex(void* m);

#endif //_THREADS_H_