1df57947fSPedro F. Giffuni /*-
2df57947fSPedro F. Giffuni * SPDX-License-Identifier: BSD-4-Clause
3df57947fSPedro F. Giffuni *
4bb535300SJeff Roberson * Copyright (c) 2002 Alfred Perlstein <alfred@freebsd.org>.
5bb535300SJeff Roberson * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>.
6bb535300SJeff Roberson * All rights reserved.
7bb535300SJeff Roberson *
8bb535300SJeff Roberson * Redistribution and use in source and binary forms, with or without
9bb535300SJeff Roberson * modification, are permitted provided that the following conditions
10bb535300SJeff Roberson * are met:
11bb535300SJeff Roberson * 1. Redistributions of source code must retain the above copyright
12bb535300SJeff Roberson * notice, this list of conditions and the following disclaimer.
13bb535300SJeff Roberson * 2. Redistributions in binary form must reproduce the above copyright
14bb535300SJeff Roberson * notice, this list of conditions and the following disclaimer in the
15bb535300SJeff Roberson * documentation and/or other materials provided with the distribution.
16bb535300SJeff Roberson * 3. All advertising materials mentioning features or use of this software
17bb535300SJeff Roberson * must display the following acknowledgement:
18bb535300SJeff Roberson * This product includes software developed by John Birrell.
19bb535300SJeff Roberson * 4. Neither the name of the author nor the names of any co-contributors
20bb535300SJeff Roberson * may be used to endorse or promote products derived from this software
21bb535300SJeff Roberson * without specific prior written permission.
22bb535300SJeff Roberson *
23bb535300SJeff Roberson * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND
24bb535300SJeff Roberson * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25bb535300SJeff Roberson * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26bb535300SJeff Roberson * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
27bb535300SJeff Roberson * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28bb535300SJeff Roberson * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29bb535300SJeff Roberson * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30bb535300SJeff Roberson * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31bb535300SJeff Roberson * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32bb535300SJeff Roberson * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33bb535300SJeff Roberson * SUCH DAMAGE.
34bb535300SJeff Roberson */
35bb535300SJeff Roberson
367d9d7ca2SMike Makonnen #include <pthread.h>
377d9d7ca2SMike Makonnen
387d9d7ca2SMike Makonnen #include "thr_private.h"
397d9d7ca2SMike Makonnen
40bb535300SJeff Roberson /*
41*085a77a6SGordon Bergling * This module uses GCC extensions to initialize the
42bb535300SJeff Roberson * threads package at program start-up time.
43bb535300SJeff Roberson */
44bb535300SJeff Roberson
45bb535300SJeff Roberson void _thread_init_hack(void) __attribute__ ((constructor));
46bb535300SJeff Roberson
47bb535300SJeff Roberson void
_thread_init_hack(void)48bb535300SJeff Roberson _thread_init_hack(void)
49bb535300SJeff Roberson {
50bb535300SJeff Roberson
51bb535300SJeff Roberson _thread_init();
52bb535300SJeff Roberson }
53bb535300SJeff Roberson
54bb535300SJeff Roberson /*
55bb535300SJeff Roberson * For the shared version of the threads library, the above is sufficient.
56bb535300SJeff Roberson * But for the archive version of the library, we need a little bit more.
57bb535300SJeff Roberson * Namely, we must arrange for this particular module to be pulled in from
58bb535300SJeff Roberson * the archive library at link time. To accomplish that, we define and
59bb535300SJeff Roberson * initialize a variable, "_thread_autoinit_dummy_decl". This variable is
60bb535300SJeff Roberson * referenced (as an extern) from libc/stdlib/exit.c. This will always
61bb535300SJeff Roberson * create a need for this module, ensuring that it is present in the
62bb535300SJeff Roberson * executable.
63bb535300SJeff Roberson */
64bb535300SJeff Roberson extern int _thread_autoinit_dummy_decl;
65bb535300SJeff Roberson int _thread_autoinit_dummy_decl = 0;
66