123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376 |
- #ifndef _DESCR_H
- #define _DESCR_H 1
- #include <limits.h>
- #include <sched.h>
- #include <setjmp.h>
- #include <stdbool.h>
- #include <sys/types.h>
- #include <hp-timing.h>
- #include <list.h>
- #include <lowlevellock.h>
- #include <pthreaddef.h>
- #include "../nptl_db/thread_db.h"
- #include <tls.h>
- #ifdef HAVE_FORCED_UNWIND
- # include <unwind.h>
- #endif
- #define __need_res_state
- #include <resolv.h>
- #include <bits/kernel-features.h>
- #ifndef TCB_ALIGNMENT
- # define TCB_ALIGNMENT sizeof (double)
- #endif
- #define PTHREAD_KEY_2NDLEVEL_SIZE 32
- #define PTHREAD_KEY_1STLEVEL_SIZE \
- ((PTHREAD_KEYS_MAX + PTHREAD_KEY_2NDLEVEL_SIZE - 1) \
- / PTHREAD_KEY_2NDLEVEL_SIZE)
- struct pthread_unwind_buf
- {
- struct
- {
- __jmp_buf jmp_buf;
- int mask_was_saved;
- } cancel_jmp_buf[1];
- union
- {
-
- void *pad[4];
- struct
- {
-
- struct pthread_unwind_buf *prev;
-
- struct _pthread_cleanup_buffer *cleanup;
-
- int canceltype;
- } data;
- } priv;
- };
- struct xid_command
- {
- int syscall_no;
- long int id[3];
- volatile int cntr;
- };
- struct robust_list_head
- {
- void *list;
- long int futex_offset;
- void *list_op_pending;
- };
- struct priority_protection_data
- {
- int priomax;
- unsigned int priomap[];
- };
- struct pthread
- {
- union
- {
- #if !defined(TLS_DTV_AT_TP)
-
- tcbhead_t header;
- #else
- struct
- {
- int multiple_threads;
- int gscope_flag;
- # ifndef __ASSUME_PRIVATE_FUTEX
- int private_futex;
- # endif
- } header;
- #endif
-
- void *__padding[24];
- };
-
- list_t list;
-
- pid_t tid;
-
- pid_t pid;
-
- #ifdef __PTHREAD_MUTEX_HAVE_PREV
- void *robust_prev;
- struct robust_list_head robust_head;
-
- # define QUEUE_PTR_ADJUST (offsetof (__pthread_list_t, __next))
- # define ENQUEUE_MUTEX_BOTH(mutex, val) \
- do { \
- __pthread_list_t *next = (__pthread_list_t *) \
- ((((uintptr_t) THREAD_GETMEM (THREAD_SELF, robust_head.list)) & ~1ul) \
- - QUEUE_PTR_ADJUST); \
- next->__prev = (void *) &mutex->__data.__list.__next; \
- mutex->__data.__list.__next = THREAD_GETMEM (THREAD_SELF, \
- robust_head.list); \
- mutex->__data.__list.__prev = (void *) &THREAD_SELF->robust_head; \
- THREAD_SETMEM (THREAD_SELF, robust_head.list, \
- (void *) (((uintptr_t) &mutex->__data.__list.__next) \
- | val)); \
- } while (0)
- # define DEQUEUE_MUTEX(mutex) \
- do { \
- __pthread_list_t *next = (__pthread_list_t *) \
- ((char *) (((uintptr_t) mutex->__data.__list.__next) & ~1ul) \
- - QUEUE_PTR_ADJUST); \
- next->__prev = mutex->__data.__list.__prev; \
- __pthread_list_t *prev = (__pthread_list_t *) \
- ((char *) (((uintptr_t) mutex->__data.__list.__prev) & ~1ul) \
- - QUEUE_PTR_ADJUST); \
- prev->__next = mutex->__data.__list.__next; \
- mutex->__data.__list.__prev = NULL; \
- mutex->__data.__list.__next = NULL; \
- } while (0)
- #else
- union
- {
- __pthread_slist_t robust_list;
- struct robust_list_head robust_head;
- };
- # define ENQUEUE_MUTEX_BOTH(mutex, val) \
- do { \
- mutex->__data.__list.__next \
- = THREAD_GETMEM (THREAD_SELF, robust_list.__next); \
- THREAD_SETMEM (THREAD_SELF, robust_list.__next, \
- (void *) (((uintptr_t) &mutex->__data.__list) | val)); \
- } while (0)
- # define DEQUEUE_MUTEX(mutex) \
- do { \
- __pthread_slist_t *runp = (__pthread_slist_t *) \
- (((uintptr_t) THREAD_GETMEM (THREAD_SELF, robust_list.__next)) & ~1ul); \
- if (runp == &mutex->__data.__list) \
- THREAD_SETMEM (THREAD_SELF, robust_list.__next, runp->__next); \
- else \
- { \
- __pthread_slist_t *next = (__pthread_slist_t *) \
- (((uintptr_t) runp->__next) & ~1ul); \
- while (next != &mutex->__data.__list) \
- { \
- runp = next; \
- next = (__pthread_slist_t *) (((uintptr_t) runp->__next) & ~1ul); \
- } \
- \
- runp->__next = next->__next; \
- mutex->__data.__list.__next = NULL; \
- } \
- } while (0)
- #endif
- #define ENQUEUE_MUTEX(mutex) ENQUEUE_MUTEX_BOTH (mutex, 0)
- #define ENQUEUE_MUTEX_PI(mutex) ENQUEUE_MUTEX_BOTH (mutex, 1)
-
- struct _pthread_cleanup_buffer *cleanup;
-
- struct pthread_unwind_buf *cleanup_jmp_buf;
- #define HAVE_CLEANUP_JMP_BUF
-
- int cancelhandling;
-
- #define CANCELSTATE_BIT 0
- #define CANCELSTATE_BITMASK (0x01 << CANCELSTATE_BIT)
-
- #define CANCELTYPE_BIT 1
- #define CANCELTYPE_BITMASK (0x01 << CANCELTYPE_BIT)
-
- #define CANCELING_BIT 2
- #define CANCELING_BITMASK (0x01 << CANCELING_BIT)
-
- #define CANCELED_BIT 3
- #define CANCELED_BITMASK (0x01 << CANCELED_BIT)
-
- #define EXITING_BIT 4
- #define EXITING_BITMASK (0x01 << EXITING_BIT)
-
- #define TERMINATED_BIT 5
- #define TERMINATED_BITMASK (0x01 << TERMINATED_BIT)
-
- #define SETXID_BIT 6
- #define SETXID_BITMASK (0x01 << SETXID_BIT)
-
- #define CANCEL_RESTMASK 0xffffff80
- #define CANCEL_ENABLED_AND_CANCELED(value) \
- (((value) & (CANCELSTATE_BITMASK | CANCELED_BITMASK | EXITING_BITMASK \
- | CANCEL_RESTMASK | TERMINATED_BITMASK)) == CANCELED_BITMASK)
- #define CANCEL_ENABLED_AND_CANCELED_AND_ASYNCHRONOUS(value) \
- (((value) & (CANCELSTATE_BITMASK | CANCELTYPE_BITMASK | CANCELED_BITMASK \
- | EXITING_BITMASK | CANCEL_RESTMASK | TERMINATED_BITMASK)) \
- == (CANCELTYPE_BITMASK | CANCELED_BITMASK))
-
- int flags;
-
- struct pthread_key_data
- {
-
- uintptr_t seq;
-
- void *data;
- } specific_1stblock[PTHREAD_KEY_2NDLEVEL_SIZE];
-
- struct pthread_key_data *specific[PTHREAD_KEY_1STLEVEL_SIZE];
-
- bool specific_used;
-
- bool report_events;
-
- bool user_stack;
-
- bool stopped_start;
-
- int parent_cancelhandling;
-
- int lock;
-
- int setxid_futex;
- #if HP_TIMING_AVAIL
-
- hp_timing_t cpuclock_offset;
- #endif
-
- struct pthread *joinid;
-
- #define IS_DETACHED(pd) ((pd)->joinid == (pd))
-
- void *result;
-
- struct sched_param schedparam;
- int schedpolicy;
-
- void *(*start_routine) (void *);
- void *arg;
-
- td_eventbuf_t eventbuf;
-
- struct pthread *nextevent;
- #ifdef HAVE_FORCED_UNWIND
-
- struct _Unwind_Exception exc;
- #endif
-
- void *stackblock;
- size_t stackblock_size;
-
- size_t guardsize;
-
- size_t reported_guardsize;
-
- struct priority_protection_data *tpp;
-
- struct __res_state res;
-
- char end_padding[];
- #define PTHREAD_STRUCT_END_PADDING \
- (sizeof (struct pthread) - offsetof (struct pthread, end_padding))
- } __attribute ((aligned (TCB_ALIGNMENT)));
- #endif
|