xref: /netbsd-src/tests/lib/libc/tls_dso/h_tls_dynamic.c (revision 7ce95f3734d22fa47d15afed09ff5d05902f5a74)
1*7ce95f37Sjoerg /*	$NetBSD: h_tls_dynamic.c,v 1.5 2013/10/21 19:11:17 joerg Exp $	*/
2aad59997Sjoerg /*-
3aad59997Sjoerg  * Copyright (c) 2011 The NetBSD Foundation, Inc.
4aad59997Sjoerg  * All rights reserved.
5aad59997Sjoerg  *
6aad59997Sjoerg  * This code is derived from software contributed to The NetBSD Foundation
7aad59997Sjoerg  * by Joerg Sonnenberger.
8aad59997Sjoerg  *
9aad59997Sjoerg  * Redistribution and use in source and binary forms, with or without
10aad59997Sjoerg  * modification, are permitted provided that the following conditions
11aad59997Sjoerg  * are met:
12aad59997Sjoerg  *
13aad59997Sjoerg  * 1. Redistributions of source code must retain the above copyright
14aad59997Sjoerg  *    notice, this list of conditions and the following disclaimer.
15aad59997Sjoerg  * 2. Redistributions in binary form must reproduce the above copyright
16aad59997Sjoerg  *    notice, this list of conditions and the following disclaimer in
17aad59997Sjoerg  *    the documentation and/or other materials provided with the
18aad59997Sjoerg  *    distribution.
19aad59997Sjoerg  *
20aad59997Sjoerg  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21aad59997Sjoerg  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22aad59997Sjoerg  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23aad59997Sjoerg  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
24aad59997Sjoerg  * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25aad59997Sjoerg  * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
26aad59997Sjoerg  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27aad59997Sjoerg  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
28aad59997Sjoerg  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29aad59997Sjoerg  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
30aad59997Sjoerg  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31aad59997Sjoerg  * SUCH DAMAGE.
32aad59997Sjoerg  */
33aad59997Sjoerg 
34aad59997Sjoerg #include <sys/cdefs.h>
35*7ce95f37Sjoerg __RCSID("$NetBSD: h_tls_dynamic.c,v 1.5 2013/10/21 19:11:17 joerg Exp $");
36aad59997Sjoerg 
37cc2f98ecSjoerg #include <unistd.h>
38aad59997Sjoerg #include <sys/tls.h>
39aad59997Sjoerg 
4071d0bcc6Sjoerg #ifdef __HAVE_NO___THREAD
41aad59997Sjoerg #define	__thread
42aad59997Sjoerg #endif
43aad59997Sjoerg 
44aad59997Sjoerg __thread int var1 = 1;
45aad59997Sjoerg __thread int var2;
46aad59997Sjoerg 
47cc2f98ecSjoerg __thread pid_t (*dso_var1)(void) = getpid;
48cc2f98ecSjoerg 
49aad59997Sjoerg void testf_dso_helper(int x, int y);
50aad59997Sjoerg 
51aad59997Sjoerg void
testf_dso_helper(int x,int y)52aad59997Sjoerg testf_dso_helper(int x, int y)
53aad59997Sjoerg {
54aad59997Sjoerg 	var1 = x;
55aad59997Sjoerg 	var2 = y;
56aad59997Sjoerg }
57