summaryrefslogtreecommitdiff
path: root/lib/Support/Unix/DynamicLibrary.inc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Support/Unix/DynamicLibrary.inc')
-rw-r--r--lib/Support/Unix/DynamicLibrary.inc7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/Support/Unix/DynamicLibrary.inc b/lib/Support/Unix/DynamicLibrary.inc
index a0526fa2c1b80..aad77f19c35a5 100644
--- a/lib/Support/Unix/DynamicLibrary.inc
+++ b/lib/Support/Unix/DynamicLibrary.inc
@@ -15,7 +15,8 @@
#include <dlfcn.h>
DynamicLibrary::HandleSet::~HandleSet() {
- for (void *Handle : Handles)
+ // Close the libraries in reverse order.
+ for (void *Handle : llvm::reverse(Handles))
::dlclose(Handle);
if (Process)
::dlclose(Process);
@@ -101,10 +102,10 @@ static void *DoSearch(const char* SymbolName) {
#define EXPLICIT_SYMBOL(SYM) \
if (!strcmp(SymbolName, #SYM)) return &SYM
-// On linux we have a weird situation. The stderr/out/in symbols are both
+// Under glibc we have a weird situation. The stderr/out/in symbols are both
// macros and global variables because of standards requirements. So, we
// boldly use the EXPLICIT_SYMBOL macro without checking for a #define first.
-#if defined(__linux__) and !defined(__ANDROID__)
+#if defined(__GLIBC__)
{
EXPLICIT_SYMBOL(stderr);
EXPLICIT_SYMBOL(stdout);