1 /* Copyright (C) 2002-2024 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 int do_test (void);
27 #define TEST_FUNCTION do_test ()
28 #include "../test-skeleton.c"
46 static void (*fcts
[N
]) (void *) =
56 pthread_key_t
*key
= (pthread_key_t
*) arg
;
58 /* Use an arbitrary but valid pointer to avoid GCC warnings. */
59 if (pthread_setspecific (*key
, arg
) != 0)
61 write_message ("setspecific failed\n");
72 pthread_key_t keys
[N
];
75 for (i
= 0; i
< N
; ++i
)
76 if (pthread_key_create (&keys
[i
], fcts
[i
]) != 0)
78 write_message ("key_create failed\n");
83 if (pthread_create (&th
, NULL
, tf
, &keys
[1]) != 0)
85 write_message ("create failed\n");
89 if (pthread_join (th
, NULL
) != 0)
91 write_message ("join failed\n");
97 write_message ("cnt0 != 0\n");
103 write_message ("cnt1 != 1\n");
107 for (i
= 0; i
< N
; ++i
)
108 if (pthread_key_delete (keys
[i
]) != 0)
110 write_message ("key_delete failed\n");