1 #ifndef _PTHREAD_IMPL_H
2 #define _PTHREAD_IMPL_H
13 #define pthread __pthread
17 void **dtv
, *unused1
, *unused2
;
19 uintptr_t canary
, canary2
;
21 int tsd_used
, errno_val
;
22 volatile int cancel
, canceldisable
, cancelasync
;
24 unsigned char *map_base
;
29 void *(*start
)(void *);
31 struct __ptcb
*cancelbuf
;
36 volatile void *volatile head
;
38 volatile void *volatile pending
;
41 volatile int timer_id
;
43 volatile int killlock
[2];
44 volatile int exitlock
[2];
45 volatile int startlock
[2];
46 unsigned long sigmask
[_NSIG
/8/sizeof(long)];
50 uintptr_t canary_at_end
;
59 #define __SU (sizeof(size_t)/sizeof(int))
61 #define _a_stacksize __u.__s[0]
62 #define _a_guardsize __u.__s[1]
63 #define _a_stackaddr __u.__s[2]
64 #define _a_detach __u.__i[3*__SU+0]
65 #define _a_sched __u.__i[3*__SU+1]
66 #define _a_policy __u.__i[3*__SU+2]
67 #define _a_prio __u.__i[3*__SU+3]
68 #define _m_type __u.__i[0]
69 #define _m_lock __u.__vi[1]
70 #define _m_waiters __u.__vi[2]
71 #define _m_prev __u.__p[3]
72 #define _m_next __u.__p[4]
73 #define _m_count __u.__i[5]
74 #define _c_shared __u.__p[0]
75 #define _c_seq __u.__vi[2]
76 #define _c_waiters __u.__vi[3]
77 #define _c_clock __u.__i[4]
78 #define _c_lock __u.__vi[8]
79 #define _c_head __u.__p[1]
80 #define _c_tail __u.__p[5]
81 #define _rw_lock __u.__vi[0]
82 #define _rw_waiters __u.__vi[1]
83 #define _rw_shared __u.__i[2]
84 #define _b_lock __u.__vi[0]
85 #define _b_waiters __u.__vi[1]
86 #define _b_limit __u.__i[2]
87 #define _b_count __u.__vi[3]
88 #define _b_waiters2 __u.__vi[4]
89 #define _b_inst __u.__p[3]
91 #include "pthread_arch.h"
103 #define SIGSYNCCALL 34
105 #define SIGALL_SET ((sigset_t *)(const unsigned long long [2]){ -1,-1 })
107 ((sigset_t *)(const unsigned long [_NSIG/8/sizeof(long)]){ \
108 [sizeof(long)==4] = 3UL<<(32*(sizeof(long)>4)) })
109 #define SIGTIMER_SET \
110 ((sigset_t *)(const unsigned long [_NSIG/8/sizeof(long)]){ \
113 pthread_t
__pthread_self_init(void);
115 int __clone(int (*)(void *), void *, int, void *, ...);
116 int __set_thread_area(void *);
117 int __libc_sigaction(int, const struct sigaction
*, struct sigaction
*);
118 int __libc_sigprocmask(int, const sigset_t
*, sigset_t
*);
119 void __lock(volatile int *);
120 void __unmapself(void *, size_t);
122 void __vm_wait(void);
123 void __vm_lock(void);
124 void __vm_unlock(void);
126 int __timedwait(volatile int *, int, clockid_t
, const struct timespec
*, int);
127 int __timedwait_cp(volatile int *, int, clockid_t
, const struct timespec
*, int);
128 void __wait(volatile int *, volatile int *, int, int);
129 static inline void __wake(volatile void *addr
, int cnt
, int priv
)
131 if (priv
) priv
= 128;
132 if (cnt
<0) cnt
= INT_MAX
;
133 __syscall(SYS_futex
, addr
, FUTEX_WAKE
|priv
, cnt
) != -ENOSYS
||
134 __syscall(SYS_futex
, addr
, FUTEX_WAKE
, cnt
);
137 void __acquire_ptc(void);
138 void __release_ptc(void);
139 void __inhibit_ptc(void);
141 void __block_all_sigs(void *);
142 void __block_app_sigs(void *);
143 void __restore_sigs(void *);
145 #define DEFAULT_STACK_SIZE 81920
146 #define DEFAULT_GUARD_SIZE PAGE_SIZE
148 #define __ATTRP_C11_THREAD ((void*)(uintptr_t)-1)