Blob


1 // Linux NPTL 2.3.2
2 complex list_head {
3 'X' 0 next;
4 'X' 4 prev;
5 };
6 complex nptl_pthread {
7 'X' 0 loopback;
8 'X' 0x48 tid;
9 };
11 // cannot be done at load time -- need shared library symbols
12 defn guessnptl() {
13 if var("nptl_version") then {
14 pthreadlibrary = "nptl";
15 isnptl = 1;
16 } else {
17 pthreadlibrary = "linuxclone";
18 isnptl = 0;
19 }
20 }
22 defn pthread2tid(p) {
23 guessnptl();
24 if p == 0 then
25 return 0;
26 if isnptl then {
27 complex nptl_pthread p;
28 if p.loopback != p then
29 error("bad pthread "+itoa(p, "%x"));
30 return p.tid;
31 }else {
32 return p\X;
33 }
34 }
36 defn pthreadlist() {
37 local all, p, n, l;
39 if isnptl then {
40 all = {};
41 l = (list_head)stack_used;
42 l = (list_head)l.next;
43 while l != stack_used do {
44 p = l - *_thread_db_pthread_list;
45 all = append all, p;
46 l = (list_head)l.next;
47 }
48 } else {
49 all = {};
50 }
51 return all;
52 }