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 //===----------------------------------------------------------------------===//
19 DynamicLibrary::DynamicLibrary() : handle(0) {
20 #if defined (HAVE_DLOPEN)
21 if ((handle = dlopen(0, RTLD_NOW | RTLD_GLOBAL)) == 0)
22 throw std::string( dlerror() );
24 assert(!"Dynamic object linking not implemented for this platform");
28 DynamicLibrary::DynamicLibrary(const char *filename) : handle(0) {
29 #if defined (HAVE_DLOPEN)
30 if ((handle = dlopen (filename, RTLD_NOW | RTLD_GLOBAL)) == 0)
31 throw std::string( dlerror() );
33 assert (!"Dynamic object linking not implemented for this platform");
37 DynamicLibrary::~DynamicLibrary() {
38 assert(handle != 0 && "Invalid DynamicLibrary handle");
39 #if defined (HAVE_DLOPEN)
42 assert (!"Dynamic object linking not implemented for this platform");
46 void *DynamicLibrary::GetAddressOfSymbol(const char *symbolName) {
47 assert(handle != 0 && "Invalid DynamicLibrary handle");
48 #if defined(HAVE_DLOPEN)
49 return dlsym (handle, symbolName);
51 assert (0 && "Dynamic symbol lookup not implemented for this platform");