1 /* Copyright (C) 2002-2017 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
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/>. */
33 err
= pthread_key_create (&key1
, NULL
);
36 printf ("1st key_create failed: %s\n", strerror (err
));
40 /* Initial value must be NULL. */
41 value
= pthread_getspecific (key1
);
44 puts ("1st getspecific != NULL");
48 err
= pthread_setspecific (key1
, (void *) -2l);
51 printf ("1st setspecific failed: %s\n", strerror (err
));
55 value
= pthread_getspecific (key1
);
58 puts ("2nd getspecific == NULL\n");
61 else if (value
!= (void *) -2l)
63 puts ("2nd getspecific != -2l\n");
67 err
= pthread_setspecific (key1
, (void *) -3l);
70 printf ("2nd setspecific failed: %s\n", strerror (err
));
74 value
= pthread_getspecific (key1
);
77 puts ("3rd getspecific == NULL\n");
80 else if (value
!= (void *) -3l)
82 puts ("3rd getspecific != -2l\n");
86 err
= pthread_key_delete (key1
);
89 printf ("key_delete failed: %s\n", strerror (err
));
94 err
= pthread_key_create (&key2
, NULL
);
97 printf ("2nd key_create failed: %s\n", strerror (err
));
102 puts ("key1 != key2; no more tests performed");
105 value
= pthread_getspecific (key2
);
108 puts ("4th getspecific != NULL");
116 #define TEST_FUNCTION do_test ()
117 #include "../test-skeleton.c"