1*84d9c625SLionel Sambuc /* $NetBSD: h_tls_dlopen.c,v 1.5 2013/10/21 19:14:16 joerg Exp $ */
211be35a1SLionel Sambuc /*-
311be35a1SLionel Sambuc * Copyright (c) 2011 The NetBSD Foundation, Inc.
411be35a1SLionel Sambuc * All rights reserved.
511be35a1SLionel Sambuc *
611be35a1SLionel Sambuc * This code is derived from software contributed to The NetBSD Foundation
711be35a1SLionel Sambuc * by Joerg Sonnenberger.
811be35a1SLionel Sambuc *
911be35a1SLionel Sambuc * Redistribution and use in source and binary forms, with or without
1011be35a1SLionel Sambuc * modification, are permitted provided that the following conditions
1111be35a1SLionel Sambuc * are met:
1211be35a1SLionel Sambuc *
1311be35a1SLionel Sambuc * 1. Redistributions of source code must retain the above copyright
1411be35a1SLionel Sambuc * notice, this list of conditions and the following disclaimer.
1511be35a1SLionel Sambuc * 2. Redistributions in binary form must reproduce the above copyright
1611be35a1SLionel Sambuc * notice, this list of conditions and the following disclaimer in
1711be35a1SLionel Sambuc * the documentation and/or other materials provided with the
1811be35a1SLionel Sambuc * distribution.
1911be35a1SLionel Sambuc *
2011be35a1SLionel Sambuc * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
2111be35a1SLionel Sambuc * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
2211be35a1SLionel Sambuc * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
2311be35a1SLionel Sambuc * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
2411be35a1SLionel Sambuc * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
2511be35a1SLionel Sambuc * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
2611be35a1SLionel Sambuc * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
2711be35a1SLionel Sambuc * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
2811be35a1SLionel Sambuc * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
2911be35a1SLionel Sambuc * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
3011be35a1SLionel Sambuc * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3111be35a1SLionel Sambuc * SUCH DAMAGE.
3211be35a1SLionel Sambuc */
3311be35a1SLionel Sambuc
3411be35a1SLionel Sambuc #include <sys/cdefs.h>
35*84d9c625SLionel Sambuc __RCSID("$NetBSD: h_tls_dlopen.c,v 1.5 2013/10/21 19:14:16 joerg Exp $");
3611be35a1SLionel Sambuc
3711be35a1SLionel Sambuc #include <atf-c.h>
3811be35a1SLionel Sambuc #include <unistd.h>
3911be35a1SLionel Sambuc #include <sys/tls.h>
4011be35a1SLionel Sambuc
4111be35a1SLionel Sambuc #ifdef __HAVE_NO___THREAD
4211be35a1SLionel Sambuc #define __thread
4311be35a1SLionel Sambuc #endif
4411be35a1SLionel Sambuc
4511be35a1SLionel Sambuc extern __thread int var1;
4611be35a1SLionel Sambuc extern __thread int var2;
4711be35a1SLionel Sambuc extern __thread int *var3;
48*84d9c625SLionel Sambuc __thread int var5 = 1;
4911be35a1SLionel Sambuc static __thread pid_t (*local_var)(void) = getpid;
5011be35a1SLionel Sambuc
5111be35a1SLionel Sambuc void testf_dso_helper(int x, int y);
5211be35a1SLionel Sambuc
5311be35a1SLionel Sambuc void
testf_dso_helper(int x,int y)5411be35a1SLionel Sambuc testf_dso_helper(int x, int y)
5511be35a1SLionel Sambuc {
5611be35a1SLionel Sambuc var1 = x;
5711be35a1SLionel Sambuc var2 = y;
5811be35a1SLionel Sambuc var3 = &optind;
5911be35a1SLionel Sambuc ATF_CHECK_EQ(local_var, getpid);
6011be35a1SLionel Sambuc }
61