xref: /minix3/minix/lib/libmthread/proto.h (revision 433d6423c39e34ec4b79c950597bb2d236f886be)
1*433d6423SLionel Sambuc #ifndef __MTHREAD_PROTO_H__
2*433d6423SLionel Sambuc #define __MTHREAD_PROTO_H__
3*433d6423SLionel Sambuc 
4*433d6423SLionel Sambuc /* allocate.c */
5*433d6423SLionel Sambuc mthread_tcb_t * mthread_find_tcb(mthread_thread_t thread);
6*433d6423SLionel Sambuc void mthread_thread_reset(mthread_thread_t thread);
7*433d6423SLionel Sambuc 
8*433d6423SLionel Sambuc /* attribute.c */
9*433d6423SLionel Sambuc void mthread_init_valid_attributes(void);
10*433d6423SLionel Sambuc #ifdef MDEBUG
11*433d6423SLionel Sambuc int mthread_attr_verify(void);
12*433d6423SLionel Sambuc #endif
13*433d6423SLionel Sambuc 
14*433d6423SLionel Sambuc /* cond.c */
15*433d6423SLionel Sambuc void mthread_init_valid_conditions(void);
16*433d6423SLionel Sambuc #ifdef MDEBUG
17*433d6423SLionel Sambuc int mthread_cond_verify(void);
18*433d6423SLionel Sambuc #endif
19*433d6423SLionel Sambuc 
20*433d6423SLionel Sambuc /* key.c */
21*433d6423SLionel Sambuc void mthread_init_keys(void);
22*433d6423SLionel Sambuc void mthread_cleanup_values(void);
23*433d6423SLionel Sambuc 
24*433d6423SLionel Sambuc /* misc.c */
25*433d6423SLionel Sambuc #ifdef MDEBUG
26*433d6423SLionel Sambuc #define mthread_panic(m) mthread_panic_f(__FILE__, __LINE__, (m))
27*433d6423SLionel Sambuc void mthread_panic_f(const char *file, int line, const char *msg);
28*433d6423SLionel Sambuc #define mthread_debug(m) mthread_debug_f(__FILE__, __LINE__, (m))
29*433d6423SLionel Sambuc void mthread_debug_f(const char *file, int line, const char *msg);
30*433d6423SLionel Sambuc #else
31*433d6423SLionel Sambuc __dead void mthread_panic_s(void);
32*433d6423SLionel Sambuc # define mthread_panic(m) mthread_panic_s()
33*433d6423SLionel Sambuc # define mthread_debug(m)
34*433d6423SLionel Sambuc #endif
35*433d6423SLionel Sambuc 
36*433d6423SLionel Sambuc /* mutex.c */
37*433d6423SLionel Sambuc void mthread_init_valid_mutexes(void);
38*433d6423SLionel Sambuc 
39*433d6423SLionel Sambuc #ifdef MTHREAD_STRICT
40*433d6423SLionel Sambuc int mthread_mutex_valid(mthread_mutex_t *mutex);
41*433d6423SLionel Sambuc #else
42*433d6423SLionel Sambuc # define mthread_mutex_valid(x) ((*x)->mm_magic == MTHREAD_INIT_MAGIC)
43*433d6423SLionel Sambuc #endif
44*433d6423SLionel Sambuc 
45*433d6423SLionel Sambuc #ifdef MDEBUG
46*433d6423SLionel Sambuc int mthread_mutex_verify(void);
47*433d6423SLionel Sambuc #endif
48*433d6423SLionel Sambuc 
49*433d6423SLionel Sambuc /* schedule.c */
50*433d6423SLionel Sambuc int mthread_getcontext(ucontext_t *ctxt);
51*433d6423SLionel Sambuc void mthread_init_scheduler(void);
52*433d6423SLionel Sambuc void mthread_schedule(void);
53*433d6423SLionel Sambuc void mthread_suspend(mthread_state_t state);
54*433d6423SLionel Sambuc void mthread_unsuspend(mthread_thread_t thread);
55*433d6423SLionel Sambuc 
56*433d6423SLionel Sambuc /* queue.c */
57*433d6423SLionel Sambuc #ifdef MDEBUG
58*433d6423SLionel Sambuc void mthread_dump_queue(mthread_queue_t *queue);
59*433d6423SLionel Sambuc #endif
60*433d6423SLionel Sambuc void mthread_queue_init(mthread_queue_t *queue);
61*433d6423SLionel Sambuc void mthread_queue_add(mthread_queue_t *queue, mthread_thread_t thread);
62*433d6423SLionel Sambuc mthread_thread_t mthread_queue_remove(mthread_queue_t *queue);
63*433d6423SLionel Sambuc int mthread_queue_isempty(mthread_queue_t *queue);
64*433d6423SLionel Sambuc 
65*433d6423SLionel Sambuc #endif
66