1 /* Copyright (C) 2002-2014 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/>. */
27 static pthread_once_t once
= PTHREAD_ONCE_INIT
;
40 nanosleep (&ts
, NULL
);
47 pthread_once (&once
, once_handler
);
51 printf ("thread %ld: global == %d\n", (long int) arg
, global
);
66 if (pthread_attr_init (&at
) != 0)
68 puts ("attr_init failed");
72 if (pthread_attr_setstacksize (&at
, 1 * 1024 * 1024) != 0)
74 puts ("attr_setstacksize failed");
78 for (cnt
= 0; cnt
< N
; ++cnt
)
79 if (pthread_create (&th
[cnt
], &at
, tf
, (void *) (long int) cnt
) != 0)
81 printf ("creation of thread %d failed\n", cnt
);
85 if (pthread_attr_destroy (&at
) != 0)
87 puts ("attr_destroy failed");
91 for (cnt
= 0; cnt
< N
; ++cnt
)
92 if (pthread_join (th
[cnt
], NULL
) != 0)
94 printf ("join of thread %d failed\n", cnt
);
101 #define TEST_FUNCTION do_test ()
103 #include "../test-skeleton.c"