summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorPeter Eisentraut2018-09-06 08:07:24 +0000
committerPeter Eisentraut2018-09-06 09:33:04 +0000
commit842cb9fa62fc99598086166bdeec9d6ae6e3c50f (patch)
treea1c3c19d6d8eb66fd1b162fcf616e711ea2cafd1 /src/include
parentac27c74def5d8544530b13d5901308a342f072ac (diff)
Refactor dlopen() support
Nowadays, all platforms except Windows and older HP-UX have standard dlopen() support. So having a separate implementation per platform under src/backend/port/dynloader/ is a bit excessive. Instead, treat dlopen() like other library functions that happen to be missing sometimes and put a replacement implementation under src/port/. Discussion: https://www.postgresql.org/message-id/flat/e11a49cb-570a-60b7-707d-7084c8de0e61%402ndquadrant.com#54e735ae37476a121abb4e33c2549b03
Diffstat (limited to 'src/include')
-rw-r--r--src/include/.gitignore1
-rw-r--r--src/include/Makefile4
-rw-r--r--src/include/pg_config.h.in8
-rw-r--r--src/include/pg_config.h.win328
-rw-r--r--src/include/port.h23
-rw-r--r--src/include/utils/dynamic_loader.h25
6 files changed, 41 insertions, 28 deletions
diff --git a/src/include/.gitignore b/src/include/.gitignore
index 49d108dbed3..51819fb4ddd 100644
--- a/src/include/.gitignore
+++ b/src/include/.gitignore
@@ -3,4 +3,3 @@
/pg_config.h
/pg_config_ext.h
/pg_config_os.h
-/dynloader.h
diff --git a/src/include/Makefile b/src/include/Makefile
index 901eddbd448..6bdfd7db911 100644
--- a/src/include/Makefile
+++ b/src/include/Makefile
@@ -54,7 +54,7 @@ install: all installdirs
cp $(srcdir)/$$dir/*.h '$(DESTDIR)$(includedir_server)'/$$dir/ || exit; \
done
ifeq ($(vpath_build),yes)
- for file in dynloader.h catalog/schemapg.h catalog/pg_*_d.h parser/gram.h storage/lwlocknames.h utils/probes.h; do \
+ for file in catalog/schemapg.h catalog/pg_*_d.h parser/gram.h storage/lwlocknames.h utils/probes.h; do \
cp $$file '$(DESTDIR)$(includedir_server)'/$$file || exit; \
done
endif
@@ -82,4 +82,4 @@ clean:
rm -f catalog/schemapg.h catalog/pg_*_d.h catalog/header-stamp
distclean maintainer-clean: clean
- rm -f pg_config.h pg_config_ext.h pg_config_os.h dynloader.h stamp-h stamp-ext-h
+ rm -f pg_config.h pg_config_ext.h pg_config_os.h stamp-h stamp-ext-h
diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in
index 347d5b56dcb..4094e22776c 100644
--- a/src/include/pg_config.h.in
+++ b/src/include/pg_config.h.in
@@ -158,6 +158,14 @@
don't. */
#undef HAVE_DECL_POSIX_FADVISE
+/* Define to 1 if you have the declaration of `RTLD_GLOBAL', and to 0 if you
+ don't. */
+#undef HAVE_DECL_RTLD_GLOBAL
+
+/* Define to 1 if you have the declaration of `RTLD_NOW', and to 0 if you
+ don't. */
+#undef HAVE_DECL_RTLD_NOW
+
/* Define to 1 if you have the declaration of `snprintf', and to 0 if you
don't. */
#undef HAVE_DECL_SNPRINTF
diff --git a/src/include/pg_config.h.win32 b/src/include/pg_config.h.win32
index 7a92d889996..6618b435874 100644
--- a/src/include/pg_config.h.win32
+++ b/src/include/pg_config.h.win32
@@ -127,6 +127,14 @@
to 0 if you don't. */
#define HAVE_DECL_LLVMORCGETSYMBOLADDRESSIN 0
+/* Define to 1 if you have the declaration of `RTLD_GLOBAL', and to 0 if you
+ don't. */
+#define HAVE_DECL_RTLD_GLOBAL 0
+
+/* Define to 1 if you have the declaration of `RTLD_NOW', and to 0 if you
+ don't. */
+#define HAVE_DECL_RTLD_NOW 0
+
/* Define to 1 if you have the declaration of `snprintf', and to 0 if you
don't. */
#define HAVE_DECL_SNPRINTF 1
diff --git a/src/include/port.h b/src/include/port.h
index 0ce72e50e5e..d92756111f2 100644
--- a/src/include/port.h
+++ b/src/include/port.h
@@ -403,6 +403,29 @@ extern void srandom(unsigned int seed);
#define SSL_get_current_compression(x) 0
#endif
+#ifndef HAVE_DLOPEN
+extern void *dlopen(const char *file, int mode);
+extern void *dlsym(void *handle, const char *symbol);
+extern int dlclose(void *handle);
+extern char *dlerror(void);
+#endif
+
+/*
+ * In some older systems, the RTLD_NOW flag isn't defined and the mode
+ * argument to dlopen must always be 1.
+ */
+#if !HAVE_DECL_RTLD_NOW
+#define RTLD_NOW 1
+#endif
+
+/*
+ * The RTLD_GLOBAL flag is wanted if available, but it doesn't exist
+ * everywhere. If it doesn't exist, set it to 0 so it has no effect.
+ */
+#if !HAVE_DECL_RTLD_GLOBAL
+#define RTLD_GLOBAL 0
+#endif
+
/* thread.h */
extern char *pqStrerror(int errnum, char *strerrbuf, size_t buflen);
diff --git a/src/include/utils/dynamic_loader.h b/src/include/utils/dynamic_loader.h
deleted file mode 100644
index e2455b52ca7..00000000000
--- a/src/include/utils/dynamic_loader.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/*-------------------------------------------------------------------------
- *
- * dynamic_loader.h
- *
- *
- *
- * Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group
- * Portions Copyright (c) 1994, Regents of the University of California
- *
- * src/include/utils/dynamic_loader.h
- *
- *-------------------------------------------------------------------------
- */
-#ifndef DYNAMIC_LOADER_H
-#define DYNAMIC_LOADER_H
-
-#include "fmgr.h"
-
-
-extern void *pg_dlopen(const char *filename);
-extern PGFunction pg_dlsym(void *handle, const char *funcname);
-extern void pg_dlclose(void *handle);
-extern char *pg_dlerror(void);
-
-#endif /* DYNAMIC_LOADER_H */