summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane2006-10-08 19:31:03 +0000
committerTom Lane2006-10-08 19:31:03 +0000
commitc50b36d215cad0b48114f3bef108ab851a93b2bf (patch)
treee5b8080c6767b63923a0174495c694f779b56e06
parent92fb5edbc1ba2b3cc2fbf0a203c2bb511a42dba3 (diff)
Update Darwin dlopen() support to avoid deprecation warnings with latest
Apple developer tools. We now use dlopen directly if available, and fall back to the older code if not. Chris Campbell
-rw-r--r--src/backend/port/dynloader/darwin.c51
1 files changed, 46 insertions, 5 deletions
diff --git a/src/backend/port/dynloader/darwin.c b/src/backend/port/dynloader/darwin.c
index 72e9598dc1..8d01c554a0 100644
--- a/src/backend/port/dynloader/darwin.c
+++ b/src/backend/port/dynloader/darwin.c
@@ -1,19 +1,58 @@
/*
- * These routines were taken from the Apache source, but were made
- * available with a PostgreSQL-compatible license. Kudos Wilfredo
- * S�nchez <[email protected]>.
+ * Dynamic loading support for Darwin
*
- * $PostgreSQL: pgsql/src/backend/port/dynloader/darwin.c,v 1.10 2004/01/07 18:56:27 neilc Exp $
+ * If dlopen() is available (Darwin 10.3 and later), we just use it.
+ * Otherwise we emulate it with the older, now deprecated, NSLinkModule API.
+ *
+ * $PostgreSQL: pgsql/src/backend/port/dynloader/darwin.c,v 1.11 2006/10/08 19:31:03 tgl Exp $
*/
#include "postgres.h"
+#ifdef HAVE_DLOPEN
+#include <dlfcn.h>
+#else
#include <mach-o/dyld.h>
+#endif
#include "dynloader.h"
-static NSObjectFileImageReturnCode cofiff_result = NSObjectFileImageFailure;
+#ifdef HAVE_DLOPEN
+
+void *
+pg_dlopen(char *filename)
+{
+ return dlopen(filename, RTLD_NOW | RTLD_GLOBAL);
+}
+
+void
+pg_dlclose(void *handle)
+{
+ dlclose(handle);
+}
+
+PGFunction
+pg_dlsym(void *handle, char *funcname)
+{
+ /* Do not prepend an underscore: see dlopen(3) */
+ return dlsym(handle, funcname);
+}
+char *
+pg_dlerror(void)
+{
+ return dlerror();
+}
+
+#else /* !HAVE_DLOPEN */
+
+/*
+ * These routines were taken from the Apache source, but were made
+ * available with a PostgreSQL-compatible license. Kudos Wilfredo
+ * S�nchez <[email protected]>.
+ */
+
+static NSObjectFileImageReturnCode cofiff_result = NSObjectFileImageFailure;
void *
pg_dlopen(char *filename)
@@ -92,3 +131,5 @@ pg_dlerror(void)
return (char *) errorString;
}
+
+#endif /* HAVE_DLOPEN */