blob: b78921034ffa5e7be505c42aa7348bee2bc66fa3 [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 {
23 struct pthread *self, *join;
24 int errno_val;
25 pid_t tid, pid;
26 volatile int canceldisable, cancelasync, cancelpoint, cancel;
27 unsigned char *map_base;
28 size_t map_size;
29 void *start_arg;
30 void *(*start)(void *);
31 void *result;
32 jmp_buf exit_jmp_buf;
33 int detached;
34 int exitlock;
35 unsigned long tlsdesc[4];
36 struct __ptcb *cancelbuf;
37 void **tsd;
38 int tsd_used;
39 pthread_attr_t attr;
40 int *errno_ptr;
41};
42
43static inline struct pthread *__pthread_self()
44{
45 struct pthread *self;
46 __asm__ ("movl %%gs:0,%0" : "=r" (self) );
47 return self;
48}
49
50#define SIGCANCEL 32
51#define SIGSYSCALL 33
52#define SIGTIMER 32 /* ?? */
53
54int __set_thread_area(unsigned long *);
55int __set_pthread_self(void *);
56int __libc_sigaction(int, const struct sigaction *, struct sigaction *);
57int __libc_sigprocmask(int, const sigset_t *, sigset_t *);
58void __lock(volatile int *);
59void __unmapself(void *, size_t);
60
61int __timedwait(volatile int *, int, clockid_t, const struct timespec *, int);
62void __wait(volatile int *, volatile int *, int, int);
63void __wake(volatile int *, int, int);
64
65#define DEFAULT_STACK_SIZE (16384-PAGE_SIZE)
66#define DEFAULT_GUARD_SIZE PAGE_SIZE
67
68#endif