1 /* Copyright (C) 2003-2023 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <https://www.gnu.org/licenses/>. */
25 static pthread_key_t key1
;
26 static pthread_key_t key2
;
39 /* Use an arbitrary but valid pointer to avoid GCC warnings. */
40 if (pthread_setspecific (key2
, (void *) &left
) != 0)
42 puts ("destr1: setspecific failed");
56 /* Use an arbitrary but valid pointer to avoid GCC warnings. */
57 if (pthread_setspecific (key1
, (void *) &left
) != 0)
59 puts ("destr2: setspecific failed");
69 /* Let the destructors work. */
72 /* Use an arbitrary but valid pointer to avoid GCC warnings. */
73 if (pthread_setspecific (key1
, (void *) &left
) != 0
74 || pthread_setspecific (key2
, (void *) &left
) != 0)
76 puts ("tf: setspecific failed");
87 /* Allocate two keys, both with destructors. */
88 if (pthread_key_create (&key1
, destr1
) != 0
89 || pthread_key_create (&key2
, destr2
) != 0)
91 puts ("key_create failed");
96 if (pthread_create (&th
, NULL
, tf
, NULL
) != 0)
98 puts ("create failed");
102 if (pthread_join (th
, NULL
) != 0)
104 puts ("join failed");
110 printf ("left == %d\n", left
);
114 if (pthread_getspecific (key1
) != NULL
)
116 puts ("key1 data != NULL");
119 if (pthread_getspecific (key2
) != NULL
)
121 puts ("key2 data != NULL");
129 #define TEST_FUNCTION do_test ()
130 #include "../test-skeleton.c"