Revert "Roll NDK to r11c and extract it into its own repository."
[android_tools.git] / ndk / platforms / android-21 / arch-x86 / usr / include / thread_db.h
blob1b36cb2b421839d41bf313abd4ec7bc423a15cf3
1 /*
2 * Copyright 2006 The Android Open Source Project
3 */
5 #ifndef _LIBTHREAD_DB__THREAD_DB_H
6 #define _LIBTHREAD_DB__THREAD_DB_H
8 #include <pthread.h>
9 #include <signal.h>
10 #include <stdint.h>
11 #include <sys/types.h>
13 typedef void *psaddr_t;
14 typedef pid_t lwpid_t;
16 #define TD_THR_ANY_USER_FLAGS 0xffffffff
17 #define TD_THR_LOWEST_PRIORITY -20
18 #define TD_SIGNO_MASK NULL
20 /* td_err_e values */
21 enum {
22 TD_OK,
23 TD_ERR,
24 TD_NOTHR,
25 TD_NOSV,
26 TD_NOLWP,
27 TD_BADPH,
28 TD_BADTH,
29 TD_BADSH,
30 TD_BADTA,
31 TD_BADKEY,
32 TD_NOMSG,
33 TD_NOFPREGS,
34 TD_NOLIBTHREAD,
35 TD_NOEVENT,
36 TD_NOCAPAB,
37 TD_DBERR,
38 TD_NOAPLIC,
39 TD_NOTSD,
40 TD_MALLOC,
41 TD_PARTIALREG,
42 TD_NOXREGS,
43 TD_VERSION
47 * td_event_e values
48 * NOTE: There is a max of 32 events
50 enum {
51 TD_CREATE,
52 TD_DEATH
55 /* td_thr_state_e values */
56 enum {
57 TD_THR_ANY_STATE,
58 TD_THR_UNKNOWN,
59 TD_THR_SLEEP,
60 TD_THR_ZOMBIE
63 typedef int32_t td_err_e;
64 typedef uint32_t td_event_e;
65 typedef uint32_t td_notify_e;
66 typedef uint32_t td_thr_state_e;
67 typedef pthread_t thread_t;
69 typedef struct
71 pid_t pid;
72 struct ps_prochandle *ph;
73 } td_thragent_t;
75 typedef struct
77 pid_t pid;
78 pid_t tid;
79 } td_thrhandle_t;
81 typedef struct
83 td_event_e event;
84 td_thrhandle_t const * th_p;
85 union {
86 void * data;
87 } msg;
88 } td_event_msg_t;
90 typedef struct
92 uint32_t events;
93 } td_thr_events_t;
95 typedef struct
97 union {
98 void * bptaddr;
99 } u;
100 } td_notify_t;
102 typedef struct
104 td_thr_state_e ti_state;
105 thread_t ti_tid; // pthread's id for the thread
106 int32_t ti_lid; // the kernel's id for the thread
107 } td_thrinfo_t;
110 #define td_event_emptyset(set) \
111 (set)->events = 0
113 #define td_event_fillset(set) \
114 (set)->events = 0xffffffff
116 #define td_event_addset(set, n) \
117 (set)->events |= (1 << n)
120 typedef int td_thr_iter_f(td_thrhandle_t const *, void *);
123 struct ps_prochandle;
125 #ifdef __cplusplus
126 extern "C"{
127 #endif
129 extern td_err_e td_ta_new(struct ps_prochandle * proc_handle, td_thragent_t ** thread_agent);
131 extern td_err_e td_ta_delete(td_thragent_t * ta);
133 extern td_err_e td_ta_set_event(td_thragent_t const * agent, td_thr_events_t * event);
135 extern td_err_e td_ta_event_addr(td_thragent_t const * agent, td_event_e event, td_notify_t * notify);
137 extern td_err_e td_ta_clear_event(const td_thragent_t * ta_arg,
138 td_thr_events_t * event);
140 extern td_err_e td_ta_event_getmsg(td_thragent_t const * agent, td_event_msg_t * event);
142 extern td_err_e td_ta_map_lwp2thr(td_thragent_t const * agent, lwpid_t lwpid,
143 td_thrhandle_t *th);
145 extern td_err_e td_thr_get_info(td_thrhandle_t const * handle,
146 td_thrinfo_t * info);
148 extern td_err_e td_thr_event_enable(td_thrhandle_t const * handle,
149 td_event_e event);
151 extern td_err_e td_ta_thr_iter(td_thragent_t const * agent, td_thr_iter_f * func, void * cookie,
152 td_thr_state_e state, int32_t prio, sigset_t * sigmask, uint32_t user_flags);
154 extern char const ** td_symbol_list(void);
156 extern td_err_e td_thr_tls_get_addr(const td_thrhandle_t * th,
157 psaddr_t map_address, size_t offset,
158 psaddr_t * address);
160 #ifdef __cplusplus
162 #endif
164 #endif