From 77b6f2fd22bd9e0b8c0f1a4b0b007971e7b84d35 Mon Sep 17 00:00:00 2001 From: Jordy Rose Date: Wed, 17 Aug 2011 18:23:17 +0000 Subject: [PATCH] Don't use NULL to represent an invalid library; Cygwin uses this for RTLD_DEFAULT. Caught by Takumi. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137841 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/DynamicLibrary.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/include/llvm/Support/DynamicLibrary.h b/include/llvm/Support/DynamicLibrary.h index 04100cd891a..11965292dd1 100644 --- a/include/llvm/Support/DynamicLibrary.h +++ b/include/llvm/Support/DynamicLibrary.h @@ -32,13 +32,18 @@ namespace sys { /// Note: there is currently no interface for temporarily loading a library, /// or for unloading libraries when the LLVM library is unloaded. class DynamicLibrary { + // Placeholder whose address represents an invalid library. + // We use this instead of NULL or a pointer-int pair because the OS library + // might define 0 or 1 to be "special" handles, such as "search all". + static const char Invalid; + // Opaque data used to interface with OS-specific dynamic library handling. void *Data; - explicit DynamicLibrary(void *data = 0) : Data(data) {} + explicit DynamicLibrary(void *data = &Invalid) : Data(data) {} public: /// Returns true if the object refers to a valid library. - bool isValid() { return Data != 0; } + bool isValid() { return Data != &Invalid; } /// Searches through the library for the symbol \p symbolName. If it is /// found, the address of that symbol is returned. If not, NULL is returned.