blob: d751f197fde08a22e323bb5a52ddbee1ec6ed1fd [file] [log] [blame]
Rich Felker0b44a032011-02-12 00:22:29 -05001#ifndef _PTHREAD_IMPL_H
2#define _PTHREAD_IMPL_H
3
4#include <pthread.h>
5#include <sched.h>
6#include <signal.h>
7#include <unistd.h>
8#include <sys/mman.h>
9#include <errno.h>
10#include <limits.h>
11#include <inttypes.h>
12#include <setjmp.h>
13#include <string.h>
14#include <time.h>
15#include "libc.h"
16#include "syscall.h"
17#include "atomic.h"
18#include "futex.h"
19
20#define pthread __pthread
21
22struct pthread {
Rich Felker0b2006c2011-02-15 03:24:58 -050023 struct pthread *self;
24 unsigned long tlsdesc[4];
Rich Felker0b44a032011-02-12 00:22:29 -050025 pid_t tid, pid;
Rich Felker0b2006c2011-02-15 03:24:58 -050026 int tsd_used, errno_val, *errno_ptr;
Rich Felker0b44a032011-02-12 00:22:29 -050027 volatile int canceldisable, cancelasync, cancelpoint, cancel;
28 unsigned char *map_base;
29 size_t map_size;
30 void *start_arg;
31 void *(*start)(void *);
32 void *result;
33 jmp_buf exit_jmp_buf;
34 int detached;
35 int exitlock;
Rich Felker0b44a032011-02-12 00:22:29 -050036 struct __ptcb *cancelbuf;
37 void **tsd;
Rich Felker0b44a032011-02-12 00:22:29 -050038 pthread_attr_t attr;
Rich Felker0b44a032011-02-12 00:22:29 -050039};
40
41static inline struct pthread *__pthread_self()
42{
43 struct pthread *self;
44 __asm__ ("movl %%gs:0,%0" : "=r" (self) );
45 return self;
46}
47
48#define SIGCANCEL 32
49#define SIGSYSCALL 33
50#define SIGTIMER 32 /* ?? */
51
52int __set_thread_area(unsigned long *);
53int __set_pthread_self(void *);
54int __libc_sigaction(int, const struct sigaction *, struct sigaction *);
55int __libc_sigprocmask(int, const sigset_t *, sigset_t *);
56void __lock(volatile int *);
57void __unmapself(void *, size_t);
58
59int __timedwait(volatile int *, int, clockid_t, const struct timespec *, int);
60void __wait(volatile int *, volatile int *, int, int);
61void __wake(volatile int *, int, int);
62
63#define DEFAULT_STACK_SIZE (16384-PAGE_SIZE)
64#define DEFAULT_GUARD_SIZE PAGE_SIZE
65
66#endif