2011-02-12 00:22:29 -05:00
|
|
|
#ifndef _PTHREAD_IMPL_H
|
|
|
|
#define _PTHREAD_IMPL_H
|
|
|
|
|
|
|
|
#include <pthread.h>
|
|
|
|
#include <sched.h>
|
|
|
|
#include <signal.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <sys/mman.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <limits.h>
|
|
|
|
#include <inttypes.h>
|
|
|
|
#include <setjmp.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <time.h>
|
|
|
|
#include "libc.h"
|
|
|
|
#include "syscall.h"
|
|
|
|
#include "atomic.h"
|
|
|
|
#include "futex.h"
|
|
|
|
|
|
|
|
#define pthread __pthread
|
|
|
|
|
|
|
|
struct pthread {
|
2011-02-15 03:24:58 -05:00
|
|
|
struct pthread *self;
|
|
|
|
unsigned long tlsdesc[4];
|
2011-02-12 00:22:29 -05:00
|
|
|
pid_t tid, pid;
|
2011-02-15 03:24:58 -05:00
|
|
|
int tsd_used, errno_val, *errno_ptr;
|
2011-04-17 11:43:03 -04:00
|
|
|
volatile uintptr_t cp_sp, cp_ip;
|
|
|
|
volatile int cancel, canceldisable, cancelasync;
|
2011-02-12 00:22:29 -05:00
|
|
|
unsigned char *map_base;
|
|
|
|
size_t map_size;
|
|
|
|
void *start_arg;
|
|
|
|
void *(*start)(void *);
|
|
|
|
void *result;
|
|
|
|
int detached;
|
|
|
|
int exitlock;
|
|
|
|
struct __ptcb *cancelbuf;
|
|
|
|
void **tsd;
|
|
|
|
pthread_attr_t attr;
|
2011-03-10 18:31:37 -05:00
|
|
|
volatile int dead;
|
2011-03-17 20:41:37 -04:00
|
|
|
struct {
|
|
|
|
void **head;
|
|
|
|
long off;
|
|
|
|
void *pending;
|
|
|
|
} robust_list;
|
2011-03-29 12:58:22 -04:00
|
|
|
int unblock_cancel;
|
2011-04-09 02:23:33 -04:00
|
|
|
int delete_timer;
|
2011-02-12 00:22:29 -05:00
|
|
|
};
|
|
|
|
|
2011-03-29 10:05:57 -04:00
|
|
|
struct __timer {
|
2011-03-29 12:58:22 -04:00
|
|
|
int timerid;
|
|
|
|
pthread_t thread;
|
2011-03-29 10:05:57 -04:00
|
|
|
};
|
|
|
|
|
2011-02-17 17:16:20 -05:00
|
|
|
#define __SU (sizeof(size_t)/sizeof(int))
|
|
|
|
|
|
|
|
#define _a_stacksize __u.__s[0]
|
|
|
|
#define _a_guardsize __u.__s[1]
|
|
|
|
#define _a_detach __u.__i[2*__SU+0]
|
|
|
|
#define _m_type __u.__i[0]
|
|
|
|
#define _m_lock __u.__i[1]
|
|
|
|
#define _m_waiters __u.__i[2]
|
2011-03-17 13:17:15 -04:00
|
|
|
#define _m_prev __u.__p[3]
|
|
|
|
#define _m_next __u.__p[4]
|
|
|
|
#define _m_count __u.__i[5]
|
2011-02-17 17:16:20 -05:00
|
|
|
#define _c_block __u.__i[0]
|
2011-03-07 17:39:13 -05:00
|
|
|
#define _c_clock __u.__i[1]
|
2011-02-17 17:16:20 -05:00
|
|
|
#define _rw_wrlock __u.__i[0]
|
|
|
|
#define _rw_readers __u.__i[1]
|
|
|
|
#define _rw_waiters __u.__i[2]
|
|
|
|
#define _rw_owner __u.__i[3]
|
2011-05-06 20:00:59 -04:00
|
|
|
#define _b_inst __u.__p[0]
|
|
|
|
#define _b_limit __u.__i[2]
|
|
|
|
#define _b_lock __u.__i[3]
|
|
|
|
#define _b_waiters __u.__i[4]
|
2011-02-17 17:16:20 -05:00
|
|
|
|
2011-02-15 03:56:52 -05:00
|
|
|
#include "pthread_arch.h"
|
2011-02-12 00:22:29 -05:00
|
|
|
|
|
|
|
#define SIGCANCEL 32
|
|
|
|
#define SIGSYSCALL 33
|
2011-04-14 12:51:00 -04:00
|
|
|
#define SIGTIMER 34
|
2011-02-12 00:22:29 -05:00
|
|
|
|
2011-02-15 03:56:52 -05:00
|
|
|
int __set_thread_area(void *);
|
2011-02-12 00:22:29 -05:00
|
|
|
int __libc_sigaction(int, const struct sigaction *, struct sigaction *);
|
|
|
|
int __libc_sigprocmask(int, const sigset_t *, sigset_t *);
|
|
|
|
void __lock(volatile int *);
|
|
|
|
void __unmapself(void *, size_t);
|
|
|
|
|
|
|
|
int __timedwait(volatile int *, int, clockid_t, const struct timespec *, int);
|
2011-04-17 11:43:03 -04:00
|
|
|
int __timedwait_cp(volatile int *, int, clockid_t, const struct timespec *, int);
|
2011-02-12 00:22:29 -05:00
|
|
|
void __wait(volatile int *, volatile int *, int, int);
|
|
|
|
void __wake(volatile int *, int, int);
|
|
|
|
|
2011-04-06 20:27:07 -04:00
|
|
|
void __rsyscall_lock();
|
|
|
|
void __rsyscall_unlock();
|
|
|
|
|
2011-02-12 00:22:29 -05:00
|
|
|
#define DEFAULT_STACK_SIZE (16384-PAGE_SIZE)
|
|
|
|
#define DEFAULT_GUARD_SIZE PAGE_SIZE
|
|
|
|
|
|
|
|
#endif
|