1 /* Copyright (C) 2003-2015 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
26 static pthread_key_t key
;
37 if (pthread_setspecific (key
, (void *) 1l) != 0)
39 puts ("destr: setspecific failed");
48 if (pthread_setspecific (key
, (void *) 1l) != 0)
50 puts ("tf: setspecific failed");
58 /* This test check non-standard behavior. The standard does not
59 require that the implementation has to stop calling TSD destructors
60 when they are set over and over again. But NPTL does. */
64 /* Allocate two keys, both with destructors. */
65 if (pthread_key_create (&key
, destr
) != 0)
67 puts ("key_create failed");
72 if (pthread_create (&th
, NULL
, tf
, NULL
) != 0)
74 puts ("create failed");
78 if (pthread_join (th
, NULL
) != 0)
84 if (rounds
< PTHREAD_DESTRUCTOR_ITERATIONS
)
86 printf ("rounds == %d, PTHREAD_DESTRUCTOR_ITERATIONS = %d\n",
87 rounds
, PTHREAD_DESTRUCTOR_ITERATIONS
);
91 if (pthread_getspecific (key
) != NULL
)
93 puts ("key data != NULL");
101 #define TEST_FUNCTION do_test ()
102 #include "../test-skeleton.c"