1 //===- Unix/DynamicLibrary.cpp - Generic UNIX Dynamic Library ---*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by Reid Spencer and is distributed under the
6 // University of Illinois Open Source License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file implements the generic UNIX variant of DynamicLibrary
12 //===----------------------------------------------------------------------===//
20 DynamicLibrary::DynamicLibrary() : handle(0) {
21 #if defined (HAVE_DLOPEN)
22 if ((handle = dlopen(0, RTLD_NOW | RTLD_GLOBAL)) == 0)
23 throw std::string( dlerror() );
25 assert(!"Dynamic object linking not implemented for this platform");
29 DynamicLibrary::DynamicLibrary(const char *filename) : handle(0) {
30 #if defined (HAVE_DLOPEN)
31 if ((handle = dlopen (filename, RTLD_NOW | RTLD_GLOBAL)) == 0)
32 throw std::string( dlerror() );
34 assert (!"Dynamic object linking not implemented for this platform");
38 DynamicLibrary::~DynamicLibrary() {
39 assert(handle != 0 && "Invalid DynamicLibrary handle");
40 #if defined (HAVE_DLOPEN)
43 assert (!"Dynamic object linking not implemented for this platform");
47 void *DynamicLibrary::GetAddressOfSymbol(const char *symbolName) {
48 assert(handle != 0 && "Invalid DynamicLibrary handle");
49 #if defined(HAVE_DLOPEN)
50 return dlsym (handle, symbolName);
52 assert (0 && "Dynamic symbol lookup not implemented for this platform");