1133066Sdfr/*- 2133066Sdfr * Copyright (C) 2004 NVIDIA Corporation. 3133066Sdfr * All rights reserved. 4133066Sdfr * 5133066Sdfr * Redistribution and use in source and binary forms, with or without 6133066Sdfr * modification, are permitted provided that the following conditions 7133066Sdfr * are met: 8133066Sdfr * 1. Redistributions of source code must retain the above copyright 9133066Sdfr * notice, this list of conditions and the following disclaimer. 10133066Sdfr * 2. Redistributions in binary form must reproduce the above copyright 11133066Sdfr * notice, this list of conditions and the following disclaimer in the 12133066Sdfr * documentation and/or other materials provided with the distribution. 13133066Sdfr * 14133066Sdfr * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15133066Sdfr * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16133066Sdfr * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17133066Sdfr * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18133066Sdfr * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19133066Sdfr * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20133066Sdfr * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21133066Sdfr * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22133066Sdfr * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23133066Sdfr * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24133066Sdfr * SUCH DAMAGE. 25133066Sdfr * 26133066Sdfr * $FreeBSD: releng/10.3/tools/regression/tls/ttls3/tls-test.c 133066 2004-08-03 09:04:01Z dfr $ 27133066Sdfr */ 28133066Sdfr 29133066Sdfr#include <stdio.h> 30133066Sdfr#include <dlfcn.h> 31133066Sdfr 32133066Sdfrint main(int argc, char **argv) 33133066Sdfr{ 34133066Sdfr void *handle; 35133066Sdfr void (*__gl_tls_test)(void); 36133066Sdfr const char *error; 37133066Sdfr 38133066Sdfr handle = dlopen("libtls-test.so.1", RTLD_NOW); 39133066Sdfr if (!handle) { 40133066Sdfr error = dlerror(); 41133066Sdfr printf("dlopen failed (%s)!\n", error); 42133066Sdfr exit(1); 43133066Sdfr } 44133066Sdfr 45133066Sdfr dlerror(); 46133066Sdfr __gl_tls_test = dlsym(handle, "__gl_tls_test"); 47133066Sdfr error = dlerror(); 48133066Sdfr 49133066Sdfr if (error) { 50133066Sdfr dlclose(handle); 51133066Sdfr printf("dlsym failed (%s)!\n", error); 52133066Sdfr exit(1); 53133066Sdfr } 54133066Sdfr 55133066Sdfr __gl_tls_test(); /* print TLS values */ 56133066Sdfr dlclose(handle); 57133066Sdfr 58133066Sdfr return 0; 59133066Sdfr} 60