Commit | Line | Data |
---|---|---|
959f3c4c JH |
1 | ?RCS: $Id: d_pthrattrj.U,v $ |
2 | ?RCS: | |
3 | ?RCS: Copyright (c) 1998 Jarkko Hietaniemi | |
4 | ?RCS: | |
5 | ?RCS: You may distribute under the terms of either the GNU General Public | |
6 | ?RCS: License or the Artistic License, as specified in the README file. | |
7 | ?RCS: | |
8 | ?MAKE:d_old_pthread_create_joinable old_pthread_create_joinable: \ | |
2cb64bf6 | 9 | cat Compile rm_try Setvar usethreads i_pthread |
959f3c4c JH |
10 | ?MAKE: -pick add $@ %< |
11 | ?S:d_old_pthread_create_joinable: | |
12 | ?S: This variable conditionally defines pthread_create_joinable. | |
13 | ?S: undef if pthread.h defines PTHREAD_CREATE_JOINABLE. | |
14 | ?S:. | |
15 | ?S:old_pthread_create_joinable: | |
16 | ?S: This variable defines the constant to use for creating joinable | |
17 | ?S: (aka undetached) pthreads. Unused if pthread.h defines | |
18 | ?S: PTHREAD_CREATE_JOINABLE. If used, possible values are | |
19 | ?S: PTHREAD_CREATE_UNDETACHED and __UNDETACHED. | |
20 | ?S:. | |
21 | ?C:OLD_PTHREAD_CREATE_JOINABLE: | |
22 | ?C: This symbol, if defined, indicates how to create pthread | |
23 | ?C: in joinable (aka undetached) state. NOTE: not defined | |
24 | ?C: if pthread.h already has defined PTHREAD_CREATE_JOINABLE | |
25 | ?C: (the new version of the constant). | |
26 | ?C: If defined, known values are PTHREAD_CREATE_UNDETACHED | |
27 | ?C: and __UNDETACHED. | |
28 | ?C:. | |
29 | ?H:#$d_old_pthread_create_joinable OLD_PTHREAD_CREATE_JOINABLE $old_pthread_create_joinable /**/ | |
30 | ?H:. | |
959f3c4c JH |
31 | : how to create joinable pthreads |
32 | if test "X$usethreads" = "X$define" -a "X$i_pthread" = "X$define"; then | |
33 | echo " " | |
2cb64bf6 | 34 | echo "Checking what constant to use for creating joinable pthreads..." >&4 |
959f3c4c JH |
35 | $cat >try.c <<'EOCP' |
36 | #include <pthread.h> | |
37 | int main() { | |
38 | int detachstate = JOINABLE; | |
39 | } | |
40 | EOCP | |
41 | set try -DJOINABLE=PTHREAD_CREATE_JOINABLE | |
42 | if eval $compile; then | |
43 | echo "You seem to use PTHREAD_CREATE_JOINABLE." >&4 | |
44 | val="$undef" # Yes, undef. | |
45 | set d_old_pthread_create_joinable | |
46 | eval $setvar | |
47 | val="" | |
48 | set old_pthread_create_joinable | |
49 | eval $setvar | |
50 | else | |
51 | set try -DJOINABLE=PTHREAD_CREATE_UNDETACHED | |
52 | if eval $compile; then | |
53 | echo "You seem to use PTHREAD_CREATE_UNDETACHED." >&4 | |
54 | val="$define" | |
55 | set d_old_pthread_create_joinable | |
56 | eval $setvar | |
57 | val=PTHREAD_CREATE_UNDETACHED | |
58 | set old_pthread_create_joinable | |
59 | eval $setvar | |
2cb64bf6 | 60 | else |
959f3c4c JH |
61 | set try -DJOINABLE=__UNDETACHED |
62 | if eval $compile; then | |
63 | echo "You seem to use __UNDETACHED." >&4 | |
64 | val="$define" | |
65 | set d_old_pthread_create_joinable | |
66 | eval $setvar | |
67 | val=__UNDETACHED | |
68 | set old_pthread_create_joinable | |
69 | eval $setvar | |
70 | else | |
71 | echo "Egads, nothing obvious found. Guessing that you use 0." >&4 | |
72 | val="$define" | |
73 | set d_old_pthread_create_joinable | |
74 | eval $setvar | |
75 | val=0 | |
76 | set old_pthread_create_joinable | |
77 | eval $setvar | |
78 | fi | |
79 | fi | |
80 | fi | |
2cb64bf6 | 81 | $rm_try |
959f3c4c JH |
82 | else |
83 | d_old_pthread_create_joinable="$undef" | |
84 | old_pthread_create_joinable="" | |
85 | fi | |
86 |