1112918Sjeff/*
2112918Sjeff * Copyright (c) 2002 Alfred Perlstein <alfred@freebsd.org>.
3112918Sjeff * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>.
4112918Sjeff * All rights reserved.
5112918Sjeff *
6112918Sjeff * Redistribution and use in source and binary forms, with or without
7112918Sjeff * modification, are permitted provided that the following conditions
8112918Sjeff * are met:
9112918Sjeff * 1. Redistributions of source code must retain the above copyright
10112918Sjeff *    notice, this list of conditions and the following disclaimer.
11112918Sjeff * 2. Redistributions in binary form must reproduce the above copyright
12112918Sjeff *    notice, this list of conditions and the following disclaimer in the
13112918Sjeff *    documentation and/or other materials provided with the distribution.
14112918Sjeff * 3. All advertising materials mentioning features or use of this software
15112918Sjeff *    must display the following acknowledgement:
16112918Sjeff *	This product includes software developed by John Birrell.
17112918Sjeff * 4. Neither the name of the author nor the names of any co-contributors
18112918Sjeff *    may be used to endorse or promote products derived from this software
19112918Sjeff *    without specific prior written permission.
20112918Sjeff *
21112918Sjeff * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND
22112918Sjeff * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23112918Sjeff * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24112918Sjeff * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
25112918Sjeff * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26112918Sjeff * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27112918Sjeff * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28112918Sjeff * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29112918Sjeff * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30112918Sjeff * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31112918Sjeff * SUCH DAMAGE.
32112918Sjeff *
33112918Sjeff * $FreeBSD: releng/10.3/lib/libthr/thread/thr_autoinit.c 115260 2003-05-23 09:48:20Z mtm $
34112918Sjeff */
35112918Sjeff
36115260Smtm#include <pthread.h>
37115260Smtm
38115260Smtm#include "thr_private.h"
39115260Smtm
40112918Sjeff/*
41112918Sjeff * This module uses GCC extentions to initialize the
42112918Sjeff * threads package at program start-up time.
43112918Sjeff */
44112918Sjeff
45112918Sjeffvoid	_thread_init_hack(void) __attribute__ ((constructor));
46112918Sjeff
47112918Sjeffvoid
48112918Sjeff_thread_init_hack(void)
49112918Sjeff{
50112918Sjeff
51112918Sjeff	_thread_init();
52112918Sjeff}
53112918Sjeff
54112918Sjeff/*
55112918Sjeff * For the shared version of the threads library, the above is sufficient.
56112918Sjeff * But for the archive version of the library, we need a little bit more.
57112918Sjeff * Namely, we must arrange for this particular module to be pulled in from
58112918Sjeff * the archive library at link time.  To accomplish that, we define and
59112918Sjeff * initialize a variable, "_thread_autoinit_dummy_decl".  This variable is
60112918Sjeff * referenced (as an extern) from libc/stdlib/exit.c. This will always
61112918Sjeff * create a need for this module, ensuring that it is present in the
62112918Sjeff * executable.
63112918Sjeff */
64112918Sjeffextern int _thread_autoinit_dummy_decl;
65112918Sjeffint _thread_autoinit_dummy_decl = 0;
66