]> granicus.if.org Git - postgresql/commitdiff
Modernize dlopen interface code for FreeBSD and OpenBSD.
authorTom Lane <tgl@sss.pgh.pa.us>
Thu, 7 Apr 2011 19:14:44 +0000 (15:14 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Thu, 7 Apr 2011 19:14:44 +0000 (15:14 -0400)
Remove the hard-wired assumption that __mips__ (and only __mips__) lacks
dlopen in FreeBSD and OpenBSD.  This assumption is outdated at least for
OpenBSD, as per report from an anonymous 9.1 tester.  We can perfectly well
use HAVE_DLOPEN instead to decide which code to use.

Some other cosmetic adjustments to make freebsd.c, netbsd.c, and openbsd.c
exactly alike.

src/backend/port/dynloader/freebsd.c
src/backend/port/dynloader/netbsd.c
src/backend/port/dynloader/openbsd.c

index cb678cd696c6c600f698b9f120301380faaa2798..29114e87ac362914b469c1072ed678d3e701b9cb 100644 (file)
@@ -57,7 +57,7 @@ BSD44_derived_dlerror(void)
 void *
 BSD44_derived_dlopen(const char *file, int num)
 {
-#if defined(__mips__)
+#if !defined(HAVE_DLOPEN)
        snprintf(error_message, sizeof(error_message),
                         "dlopen (%s) not supported", file);
        return NULL;
@@ -74,7 +74,7 @@ BSD44_derived_dlopen(const char *file, int num)
 void *
 BSD44_derived_dlsym(void *handle, const char *name)
 {
-#if defined(__mips__)
+#if !defined(HAVE_DLOPEN)
        snprintf(error_message, sizeof(error_message),
                         "dlsym (%s) failed", name);
        return NULL;
@@ -89,7 +89,7 @@ BSD44_derived_dlsym(void *handle, const char *name)
                snprintf(buf, sizeof(buf), "_%s", name);
                name = buf;
        }
-#endif
+#endif /* !__ELF__ */
        if ((vp = dlsym(handle, (char *) name)) == NULL)
                snprintf(error_message, sizeof(error_message),
                                 "dlsym (%s) failed", name);
@@ -100,8 +100,7 @@ BSD44_derived_dlsym(void *handle, const char *name)
 void
 BSD44_derived_dlclose(void *handle)
 {
-#if defined(__mips__)
-#else
+#if defined(HAVE_DLOPEN)
        dlclose(handle);
 #endif
 }
index b8dcfafec628f527d68521f19f7697fb06a213f2..569624373ee5618fd248622e5d2927ad8bad1da7 100644 (file)
@@ -78,10 +78,10 @@ BSD44_derived_dlsym(void *handle, const char *name)
        snprintf(error_message, sizeof(error_message),
                         "dlsym (%s) failed", name);
        return NULL;
-#elif defined(__ELF__)
-       return dlsym(handle, name);
 #else
        void       *vp;
+
+#ifndef __ELF__
        char            buf[BUFSIZ];
 
        if (*name != '_')
@@ -89,6 +89,7 @@ BSD44_derived_dlsym(void *handle, const char *name)
                snprintf(buf, sizeof(buf), "_%s", name);
                name = buf;
        }
+#endif /* !__ELF__ */
        if ((vp = dlsym(handle, (char *) name)) == NULL)
                snprintf(error_message, sizeof(error_message),
                                 "dlsym (%s) failed", name);
index f25239e740d61e7e5fcb994f97f5acec3686a328..bbfb3171e6ef188d1f92ac0a1767e0f94db0eabe 100644 (file)
@@ -57,7 +57,7 @@ BSD44_derived_dlerror(void)
 void *
 BSD44_derived_dlopen(const char *file, int num)
 {
-#if defined(__mips__)
+#if !defined(HAVE_DLOPEN)
        snprintf(error_message, sizeof(error_message),
                         "dlopen (%s) not supported", file);
        return NULL;
@@ -74,14 +74,14 @@ BSD44_derived_dlopen(const char *file, int num)
 void *
 BSD44_derived_dlsym(void *handle, const char *name)
 {
-#if defined(__mips__)
+#if !defined(HAVE_DLOPEN)
        snprintf(error_message, sizeof(error_message),
                         "dlsym (%s) failed", name);
        return NULL;
-#elif defined(__ELF__)
-       return dlsym(handle, name);
 #else
        void       *vp;
+
+#ifndef __ELF__
        char            buf[BUFSIZ];
 
        if (*name != '_')
@@ -89,6 +89,7 @@ BSD44_derived_dlsym(void *handle, const char *name)
                snprintf(buf, sizeof(buf), "_%s", name);
                name = buf;
        }
+#endif /* !__ELF__ */
        if ((vp = dlsym(handle, (char *) name)) == NULL)
                snprintf(error_message, sizeof(error_message),
                                 "dlsym (%s) failed", name);
@@ -99,8 +100,7 @@ BSD44_derived_dlsym(void *handle, const char *name)
 void
 BSD44_derived_dlclose(void *handle)
 {
-#if defined(__mips__)
-#else
+#if defined(HAVE_DLOPEN)
        dlclose(handle);
 #endif
 }