]> 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:39 +0000 (15:14 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Thu, 7 Apr 2011 19:14:39 +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 58cf979df57bc5e4b10df24b65516dcad3a6ed79..373d6aaec84338b7242100acfb476975225a1a6e 100644 (file)
@@ -1,10 +1,10 @@
-/* src/backend/port/dynloader/freebsd.c */
-
 /*
  * Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
  * Portions Copyright (c) 1990 The Regents of the University of California.
  * All rights reserved.
  *
+ * src/backend/port/dynloader/freebsd.c
+ *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
@@ -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 7aecf170c5823b9dca00d9396161596c12b5daa3..d12065614140fd335d82cb873f88e6e08d7c5cae 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 d099ec376026f6980e27153d0e3f6e6e9f7b6245..2d061efb1e8ecb4c8e217e6e173221cbc10d3fba 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
 }