File: threads.h

package info (click to toggle)
njamd 0.9.3pre2-4
  • links: PTS
  • area: main
  • in suites: woody
  • size: 1,704 kB
  • ctags: 1,056
  • sloc: ansic: 9,367; sh: 7,921; makefile: 121; perl: 52
file content (49 lines) | stat: -rw-r--r-- 1,206 bytes parent folder | download
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/**
 * @file threads.h
 *
 * Handles pthreads
 *
 */
#ifndef __NJ_LIB_THREADS_H__
#define __NJ_LIB_THREADS_H__
#include <config.h>

#ifdef _THREAD_SAFE
# include <pthread.h>
#endif

#include <lib/libc_syms.h>
#include <unistd.h>

/** Passed to the real pthread_create so we know all thread's starting
 * points.
 * @see pthread_create() __nj_pthread_launch() */
struct pthread_arg_wrapper
{
	void *(*start)(void *); /**< Always __nj_pthread_launch() */
	void *real_arg;			/**< The user's actual arg */
	struct nj_threads *threads;
};

struct nj_threads
{
	void (*libc_pthread_exit)(void *);
#ifdef _THREAD_SAFE
	int  (*libc_pthread_create)(pthread_t  *  thread, pthread_attr_t *attr,
			void * (*start_routine)(void *), void *);
	pthread_mutex_t 			launch_lock;
#endif

};

void __nj_threads_bootstrap_init(struct nj_threads *, struct nj_libc_syms *);
void __nj_threads_user_init(struct nj_threads *);
void __nj_threads_fini(struct nj_threads *);
#ifdef _THREAD_SAFE
int __nj_threads_create_thread(struct nj_threads *, pthread_t  *, pthread_attr_t *, void * (*start_routine)(void *), void *);
#endif
void *__nj_threads_launch(void *);
void __nj_threads_launch_end(void);

#endif /* output.h */
// vim:ts=4