12546665aSDoug Rabson /*-
22546665aSDoug Rabson * Copyright (C) 2004 NVIDIA Corporation.
32546665aSDoug Rabson * All rights reserved.
42546665aSDoug Rabson *
52546665aSDoug Rabson * Redistribution and use in source and binary forms, with or without
62546665aSDoug Rabson * modification, are permitted provided that the following conditions
72546665aSDoug Rabson * are met:
82546665aSDoug Rabson * 1. Redistributions of source code must retain the above copyright
92546665aSDoug Rabson * notice, this list of conditions and the following disclaimer.
102546665aSDoug Rabson * 2. Redistributions in binary form must reproduce the above copyright
112546665aSDoug Rabson * notice, this list of conditions and the following disclaimer in the
122546665aSDoug Rabson * documentation and/or other materials provided with the distribution.
132546665aSDoug Rabson *
142546665aSDoug Rabson * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
152546665aSDoug Rabson * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
162546665aSDoug Rabson * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
172546665aSDoug Rabson * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
182546665aSDoug Rabson * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
192546665aSDoug Rabson * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
202546665aSDoug Rabson * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
212546665aSDoug Rabson * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
222546665aSDoug Rabson * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
232546665aSDoug Rabson * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
242546665aSDoug Rabson * SUCH DAMAGE.
252546665aSDoug Rabson */
262546665aSDoug Rabson
272546665aSDoug Rabson #include <stdio.h>
282546665aSDoug Rabson #include <dlfcn.h>
292546665aSDoug Rabson
main(int argc,char ** argv)302546665aSDoug Rabson int main(int argc, char **argv)
312546665aSDoug Rabson {
322546665aSDoug Rabson void *handle;
332546665aSDoug Rabson void (*__gl_tls_test)(void);
342546665aSDoug Rabson const char *error;
352546665aSDoug Rabson
362546665aSDoug Rabson handle = dlopen("libtls-test.so.1", RTLD_NOW);
372546665aSDoug Rabson if (!handle) {
382546665aSDoug Rabson error = dlerror();
392546665aSDoug Rabson printf("dlopen failed (%s)!\n", error);
402546665aSDoug Rabson exit(1);
412546665aSDoug Rabson }
422546665aSDoug Rabson
432546665aSDoug Rabson dlerror();
442546665aSDoug Rabson __gl_tls_test = dlsym(handle, "__gl_tls_test");
452546665aSDoug Rabson error = dlerror();
462546665aSDoug Rabson
472546665aSDoug Rabson if (error) {
482546665aSDoug Rabson dlclose(handle);
492546665aSDoug Rabson printf("dlsym failed (%s)!\n", error);
502546665aSDoug Rabson exit(1);
512546665aSDoug Rabson }
522546665aSDoug Rabson
532546665aSDoug Rabson __gl_tls_test(); /* print TLS values */
542546665aSDoug Rabson dlclose(handle);
552546665aSDoug Rabson
562546665aSDoug Rabson return 0;
572546665aSDoug Rabson }
58