LIBS_including_readline="$LIBS"
LIBS=`echo "$LIBS" | sed -e 's/-ledit//g' -e 's/-lreadline//g'`
-for ac_func in cbrt clock_gettime dlopen fdatasync getifaddrs getpeerucred getrlimit mbstowcs_l memmove poll posix_fallocate pstat pthread_is_threaded_np readlink setproctitle setproctitle_fast setsid shm_open symlink sync_file_range utime utimes wcstombs_l
+for ac_func in cbrt clock_gettime fdatasync getifaddrs getpeerucred getrlimit mbstowcs_l memmove poll posix_fallocate pstat pthread_is_threaded_np readlink setproctitle setproctitle_fast setsid shm_open symlink sync_file_range utime utimes wcstombs_l
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
_ACEOF
+ac_fn_c_check_decl "$LINENO" "RTLD_GLOBAL" "ac_cv_have_decl_RTLD_GLOBAL" "#include <dlfcn.h>
+"
+if test "x$ac_cv_have_decl_RTLD_GLOBAL" = xyes; then :
+ ac_have_decl=1
+else
+ ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_RTLD_GLOBAL $ac_have_decl
+_ACEOF
+ac_fn_c_check_decl "$LINENO" "RTLD_NOW" "ac_cv_have_decl_RTLD_NOW" "#include <dlfcn.h>
+"
+if test "x$ac_cv_have_decl_RTLD_NOW" = xyes; then :
+ ac_have_decl=1
+else
+ ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_RTLD_NOW $ac_have_decl
+_ACEOF
+
+
HAVE_IPV6=no
ac_fn_c_check_type "$LINENO" "struct sockaddr_in6" "ac_cv_type_struct_sockaddr_in6" "$ac_includes_default
#include <netinet/in.h>
fi
+ac_fn_c_check_func "$LINENO" "dlopen" "ac_cv_func_dlopen"
+if test "x$ac_cv_func_dlopen" = xyes; then :
+ $as_echo "#define HAVE_DLOPEN 1" >>confdefs.h
+
+else
+ case " $LIBOBJS " in
+ *" dlopen.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS dlopen.$ac_objext"
+ ;;
+esac
+
+fi
+
ac_fn_c_check_func "$LINENO" "fls" "ac_cv_func_fls"
if test "x$ac_cv_func_fls" = xyes; then :
$as_echo "#define HAVE_FLS 1" >>confdefs.h
ac_config_files="$ac_config_files GNUmakefile src/Makefile.global"
-ac_config_links="$ac_config_links src/backend/port/dynloader.c:src/backend/port/dynloader/${template}.c src/backend/port/pg_sema.c:${SEMA_IMPLEMENTATION} src/backend/port/pg_shmem.c:${SHMEM_IMPLEMENTATION} src/include/dynloader.h:src/backend/port/dynloader/${template}.h src/include/pg_config_os.h:src/include/port/${template}.h src/Makefile.port:src/makefiles/Makefile.${template}"
+ac_config_links="$ac_config_links src/backend/port/pg_sema.c:${SEMA_IMPLEMENTATION} src/backend/port/pg_shmem.c:${SHMEM_IMPLEMENTATION} src/include/pg_config_os.h:src/include/port/${template}.h src/Makefile.port:src/makefiles/Makefile.${template}"
if test "$PORTNAME" = "win32"; then
"src/backend/port/tas.s") CONFIG_LINKS="$CONFIG_LINKS src/backend/port/tas.s:src/backend/port/tas/${tas_file}" ;;
"GNUmakefile") CONFIG_FILES="$CONFIG_FILES GNUmakefile" ;;
"src/Makefile.global") CONFIG_FILES="$CONFIG_FILES src/Makefile.global" ;;
- "src/backend/port/dynloader.c") CONFIG_LINKS="$CONFIG_LINKS src/backend/port/dynloader.c:src/backend/port/dynloader/${template}.c" ;;
"src/backend/port/pg_sema.c") CONFIG_LINKS="$CONFIG_LINKS src/backend/port/pg_sema.c:${SEMA_IMPLEMENTATION}" ;;
"src/backend/port/pg_shmem.c") CONFIG_LINKS="$CONFIG_LINKS src/backend/port/pg_shmem.c:${SHMEM_IMPLEMENTATION}" ;;
- "src/include/dynloader.h") CONFIG_LINKS="$CONFIG_LINKS src/include/dynloader.h:src/backend/port/dynloader/${template}.h" ;;
"src/include/pg_config_os.h") CONFIG_LINKS="$CONFIG_LINKS src/include/pg_config_os.h:src/include/port/${template}.h" ;;
"src/Makefile.port") CONFIG_LINKS="$CONFIG_LINKS src/Makefile.port:src/makefiles/Makefile.${template}" ;;
"check_win32_symlinks") CONFIG_COMMANDS="$CONFIG_COMMANDS check_win32_symlinks" ;;
LIBS_including_readline="$LIBS"
LIBS=`echo "$LIBS" | sed -e 's/-ledit//g' -e 's/-lreadline//g'`
-AC_CHECK_FUNCS([cbrt clock_gettime dlopen fdatasync getifaddrs getpeerucred getrlimit mbstowcs_l memmove poll posix_fallocate pstat pthread_is_threaded_np readlink setproctitle setproctitle_fast setsid shm_open symlink sync_file_range utime utimes wcstombs_l])
+AC_CHECK_FUNCS([cbrt clock_gettime fdatasync getifaddrs getpeerucred getrlimit mbstowcs_l memmove poll posix_fallocate pstat pthread_is_threaded_np readlink setproctitle setproctitle_fast setsid shm_open symlink sync_file_range utime utimes wcstombs_l])
AC_REPLACE_FUNCS(fseeko)
case $host_os in
# This is probably only present on macOS, but may as well check always
AC_CHECK_DECLS(F_FULLFSYNC, [], [], [#include <fcntl.h>])
+AC_CHECK_DECLS([RTLD_GLOBAL, RTLD_NOW], [], [], [#include <dlfcn.h>])
+
HAVE_IPV6=no
AC_CHECK_TYPE([struct sockaddr_in6],
[AC_DEFINE(HAVE_IPV6, 1, [Define to 1 if you have support for IPv6.])
AC_CHECK_FUNCS([fpclass fp_class fp_class_d class], [break])
fi
-AC_REPLACE_FUNCS([crypt fls getopt getrusage inet_aton mkdtemp random rint srandom strerror strlcat strlcpy strnlen])
+AC_REPLACE_FUNCS([crypt dlopen fls getopt getrusage inet_aton mkdtemp random rint srandom strerror strlcat strlcpy strnlen])
case $host_os in
AC_CONFIG_FILES([GNUmakefile src/Makefile.global])
AC_CONFIG_LINKS([
- src/backend/port/dynloader.c:src/backend/port/dynloader/${template}.c
src/backend/port/pg_sema.c:${SEMA_IMPLEMENTATION}
src/backend/port/pg_shmem.c:${SHMEM_IMPLEMENTATION}
- src/include/dynloader.h:src/backend/port/dynloader/${template}.h
src/include/pg_config_os.h:src/include/port/${template}.h
src/Makefile.port:src/makefiles/Makefile.${template}
])
endif
distclean: clean
- rm -f port/tas.s port/dynloader.c port/pg_sema.c port/pg_shmem.c
+ rm -f port/tas.s port/pg_sema.c port/pg_shmem.c
maintainer-clean: distclean
$(MAKE) -C catalog $@
-/dynloader.c
/pg_sema.c
/pg_shmem.c
/tas.s
top_builddir = ../../..
include $(top_builddir)/src/Makefile.global
-OBJS = atomics.o dynloader.o pg_sema.o pg_shmem.o $(TAS)
+OBJS = atomics.o pg_sema.o pg_shmem.o $(TAS)
ifeq ($(PORTNAME), win32)
SUBDIRS += win32
+++ /dev/null
-/*
- * src/backend/port/dynloader/aix.c
- *
- * Dummy file used for nothing at this point
- *
- * see aix.h
- */
+++ /dev/null
-/*-------------------------------------------------------------------------
- *
- * aix.h
- * prototypes for AIX-specific routines
- *
- *
- * Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group
- * Portions Copyright (c) 1994, Regents of the University of California
- *
- * src/backend/port/dynloader/aix.h
- *
- *-------------------------------------------------------------------------
- */
-
-#ifndef PORT_PROTOS_H
-#define PORT_PROTOS_H
-
-#include <dlfcn.h>
-#include "utils/dynamic_loader.h" /* pgrminclude ignore */
-
-/*
- * In some older systems, the RTLD_NOW flag isn't defined and the mode
- * argument to dlopen must always be 1. 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.
- */
-#ifndef RTLD_NOW
-#define RTLD_NOW 1
-#endif
-#ifndef RTLD_GLOBAL
-#define RTLD_GLOBAL 0
-#endif
-
-#define pg_dlopen(f) dlopen((f), RTLD_NOW | RTLD_GLOBAL)
-#define pg_dlsym(h, f) ((PGFunction) dlsym(h, f))
-#define pg_dlclose(h) dlclose(h)
-#define pg_dlerror() dlerror()
-
-#endif /* PORT_PROTOS_H */
+++ /dev/null
-/* src/backend/port/dynloader/cygwin.c */
-
-/* Dummy file used for nothing at this point; see cygwin.h */
+++ /dev/null
-/*-------------------------------------------------------------------------
- *
- * Dynamic loader declarations for Cygwin
- *
- * Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group
- * Portions Copyright (c) 1994, Regents of the University of California
- *
- * src/backend/port/dynloader/cygwin.h
- *
- *-------------------------------------------------------------------------
- */
-#ifndef PORT_PROTOS_H
-#define PORT_PROTOS_H
-
-#include <dlfcn.h>
-#include "utils/dynamic_loader.h" /* pgrminclude ignore */
-
-/*
- * In some older systems, the RTLD_NOW flag isn't defined and the mode
- * argument to dlopen must always be 1. 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.
- */
-#ifndef RTLD_NOW
-#define RTLD_NOW 1
-#endif
-#ifndef RTLD_GLOBAL
-#define RTLD_GLOBAL 0
-#endif
-
-#define pg_dlopen(f) dlopen((f), RTLD_NOW | RTLD_GLOBAL)
-#define pg_dlsym dlsym
-#define pg_dlclose dlclose
-#define pg_dlerror dlerror
-
-#endif /* PORT_PROTOS_H */
+++ /dev/null
-/*
- * Dynamic loading support for macOS (Darwin)
- *
- * src/backend/port/dynloader/darwin.c
- */
-#include "postgres.h"
-
-#include <dlfcn.h>
-
-#include "dynloader.h"
-
-
-void *
-pg_dlopen(const char *filename)
-{
- return dlopen(filename, RTLD_NOW | RTLD_GLOBAL);
-}
-
-void
-pg_dlclose(void *handle)
-{
- dlclose(handle);
-}
-
-PGFunction
-pg_dlsym(void *handle, const char *funcname)
-{
- return dlsym(handle, funcname);
-}
-
-char *
-pg_dlerror(void)
-{
- return dlerror();
-}
+++ /dev/null
-/* src/backend/port/dynloader/darwin.h */
-
-#include "fmgr.h"
-
-void *pg_dlopen(const char *filename);
-PGFunction pg_dlsym(void *handle, const char *funcname);
-void pg_dlclose(void *handle);
-char *pg_dlerror(void);
+++ /dev/null
-/*
- * src/backend/port/dynloader/freebsd.c
- *
- * Dummy file used for nothing at this point
- *
- * see freebsd.h
- */
+++ /dev/null
-/*-------------------------------------------------------------------------
- *
- * freebsd.h
- * port-specific prototypes for FreeBSD
- *
- * Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group
- * Portions Copyright (c) 1994, Regents of the University of California
- *
- * src/backend/port/dynloader/freebsd.h
- *
- *-------------------------------------------------------------------------
- */
-#ifndef PORT_PROTOS_H
-#define PORT_PROTOS_H
-
-#include <dlfcn.h>
-
-#include "utils/dynamic_loader.h" /* pgrminclude ignore */
-
-/*
- * In some older systems, the RTLD_NOW flag isn't defined and the mode
- * argument to dlopen must always be 1. 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.
- */
-#ifndef RTLD_NOW
-#define RTLD_NOW 1
-#endif
-#ifndef RTLD_GLOBAL
-#define RTLD_GLOBAL 0
-#endif
-
-#define pg_dlopen(f) dlopen((f), RTLD_NOW | RTLD_GLOBAL)
-#define pg_dlsym dlsym
-#define pg_dlclose dlclose
-#define pg_dlerror dlerror
-
-#endif /* PORT_PROTOS_H */
+++ /dev/null
-/*-------------------------------------------------------------------------
- *
- * dynloader.c
- * dynamic loader for HP-UX using the shared library mechanism
- *
- * Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group
- * Portions Copyright (c) 1994, Regents of the University of California
- *
- *
- * IDENTIFICATION
- * src/backend/port/dynloader/hpux.c
- *
- * NOTES
- * all functions are defined here -- it's impossible to trace the
- * shl_* routines from the bundled HP-UX debugger.
- *
- *-------------------------------------------------------------------------
- */
-#include "postgres.h"
-
-/* System includes */
-#include <a.out.h>
-#include <dl.h>
-
-#include "dynloader.h"
-#include "utils/dynamic_loader.h"
-
-void *
-pg_dlopen(const char *filename)
-{
- /*
- * Use BIND_IMMEDIATE so that undefined symbols cause a failure return
- * from shl_load(), rather than an abort() later on when we attempt to
- * call the library!
- */
- shl_t handle = shl_load(filename,
- BIND_IMMEDIATE | BIND_VERBOSE | DYNAMIC_PATH,
- 0L);
-
- return (void *) handle;
-}
-
-PGFunction
-pg_dlsym(void *handle, const char *funcname)
-{
- PGFunction f;
-
- if (shl_findsym((shl_t *) & handle, funcname, TYPE_PROCEDURE, &f) == -1)
- f = (PGFunction) NULL;
- return f;
-}
-
-void
-pg_dlclose(void *handle)
-{
- shl_unload((shl_t) handle);
-}
-
-char *
-pg_dlerror(void)
-{
- static char errmsg[] = "shl_load failed";
-
- if (errno)
- return strerror(errno);
-
- return errmsg;
-}
+++ /dev/null
-/*-------------------------------------------------------------------------
- *
- * dynloader.h
- * dynamic loader for HP-UX using the shared library mechanism
- *
- * Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group
- * Portions Copyright (c) 1994, Regents of the University of California
- *
- *
- * IDENTIFICATION
- * src/backend/port/dynloader/hpux.h
- *
- * NOTES
- * all functions are defined here -- it's impossible to trace the
- * shl_* routines from the bundled HP-UX debugger.
- *
- *-------------------------------------------------------------------------
- */
-/* System includes */
-#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);
+++ /dev/null
-/*
- * src/backend/port/dynloader/linux.c
- *
- * Dummy file used for nothing at this point
- *
- * see linux.h
- */
+++ /dev/null
-/*-------------------------------------------------------------------------
- *
- * linux.h
- * Port-specific prototypes for Linux
- *
- *
- * Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group
- * Portions Copyright (c) 1994, Regents of the University of California
- *
- * src/backend/port/dynloader/linux.h
- *
- *-------------------------------------------------------------------------
- */
-#ifndef PORT_PROTOS_H
-#define PORT_PROTOS_H
-
-#include "utils/dynamic_loader.h" /* pgrminclude ignore */
-#include <dlfcn.h>
-
-/*
- * In some older systems, the RTLD_NOW flag isn't defined and the mode
- * argument to dlopen must always be 1. 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.
- */
-#ifndef RTLD_NOW
-#define RTLD_NOW 1
-#endif
-#ifndef RTLD_GLOBAL
-#define RTLD_GLOBAL 0
-#endif
-
-#define pg_dlopen(f) dlopen((f), RTLD_NOW | RTLD_GLOBAL)
-#define pg_dlsym dlsym
-#define pg_dlclose dlclose
-#define pg_dlerror dlerror
-
-#endif /* PORT_PROTOS_H */
+++ /dev/null
-/*
- * src/backend/port/dynloader/netbsd.c
- *
- * Dummy file used for nothing at this point
- *
- * see netbsd.h
- */
+++ /dev/null
-/*-------------------------------------------------------------------------
- *
- * netbsd.h
- * port-specific prototypes for NetBSD
- *
- * Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group
- * Portions Copyright (c) 1994, Regents of the University of California
- *
- * src/backend/port/dynloader/netbsd.h
- *
- *-------------------------------------------------------------------------
- */
-#ifndef PORT_PROTOS_H
-#define PORT_PROTOS_H
-
-#include <dlfcn.h>
-
-#include "utils/dynamic_loader.h" /* pgrminclude ignore */
-
-/*
- * In some older systems, the RTLD_NOW flag isn't defined and the mode
- * argument to dlopen must always be 1. 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.
- */
-#ifndef RTLD_NOW
-#define RTLD_NOW 1
-#endif
-#ifndef RTLD_GLOBAL
-#define RTLD_GLOBAL 0
-#endif
-
-#define pg_dlopen(f) dlopen((f), RTLD_NOW | RTLD_GLOBAL)
-#define pg_dlsym dlsym
-#define pg_dlclose dlclose
-#define pg_dlerror dlerror
-
-#endif /* PORT_PROTOS_H */
+++ /dev/null
-/*
- * src/backend/port/dynloader/openbsd.c
- *
- * Dummy file used for nothing at this point
- *
- * see openbsd.h
- */
+++ /dev/null
-/*-------------------------------------------------------------------------
- *
- * openbsd.h
- * port-specific prototypes for OpenBSD
- *
- * Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group
- * Portions Copyright (c) 1994, Regents of the University of California
- *
- * src/backend/port/dynloader/openbsd.h
- *
- *-------------------------------------------------------------------------
- */
-#ifndef PORT_PROTOS_H
-#define PORT_PROTOS_H
-
-#include <dlfcn.h>
-
-#include "utils/dynamic_loader.h" /* pgrminclude ignore */
-
-/*
- * In some older systems, the RTLD_NOW flag isn't defined and the mode
- * argument to dlopen must always be 1. 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.
- */
-#ifndef RTLD_NOW
-#define RTLD_NOW 1
-#endif
-#ifndef RTLD_GLOBAL
-#define RTLD_GLOBAL 0
-#endif
-
-#define pg_dlopen(f) dlopen((f), RTLD_NOW | RTLD_GLOBAL)
-#define pg_dlsym dlsym
-#define pg_dlclose dlclose
-#define pg_dlerror dlerror
-
-#endif /* PORT_PROTOS_H */
+++ /dev/null
-/*
- * src/backend/port/dynloader/solaris.c
- *
- * Dummy file used for nothing at this point
- *
- * see solaris.h
- */
+++ /dev/null
-/*-------------------------------------------------------------------------
- *
- * solaris.h
- * port-specific prototypes for Solaris
- *
- *
- * Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group
- * Portions Copyright (c) 1994, Regents of the University of California
- *
- * src/backend/port/dynloader/solaris.h
- *
- *-------------------------------------------------------------------------
- */
-#ifndef PORT_PROTOS_H
-#define PORT_PROTOS_H
-
-#include <dlfcn.h>
-#include "utils/dynamic_loader.h" /* pgrminclude ignore */
-
-/*
- * In some older systems, the RTLD_NOW flag isn't defined and the mode
- * argument to dlopen must always be 1. 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.
- */
-#ifndef RTLD_NOW
-#define RTLD_NOW 1
-#endif
-#ifndef RTLD_GLOBAL
-#define RTLD_GLOBAL 0
-#endif
-
-#define pg_dlopen(f) dlopen((f), RTLD_NOW | RTLD_GLOBAL)
-#define pg_dlsym dlsym
-#define pg_dlclose dlclose
-#define pg_dlerror dlerror
-
-#endif /* PORT_PROTOS_H */
+++ /dev/null
-/*
- * src/backend/port/dynloader/win32.h
- */
-#ifndef PORT_PROTOS_H
-#define PORT_PROTOS_H
-
-#include "utils/dynamic_loader.h" /* pgrminclude ignore */
-
-#define pg_dlopen(f) dlopen((f), 1)
-#define pg_dlsym dlsym
-#define pg_dlclose dlclose
-#define pg_dlerror dlerror
-
-char *dlerror(void);
-int dlclose(void *handle);
-void *dlsym(void *handle, const char *symbol);
-void *dlopen(const char *path, int mode);
-
-#endif /* PORT_PROTOS_H */
#include "tcop/tcopprot.h"
#include "utils/builtins.h"
#include "utils/datetime.h"
-#include "utils/dynamic_loader.h"
#include "utils/memutils.h"
#include "utils/pidfile.h"
#include "utils/ps_status.h"
#include <sys/stat.h>
-#include "dynloader.h"
+#ifdef HAVE_DLOPEN
+#include <dlfcn.h>
+#endif
+
+#include "fmgr.h"
#include "lib/stringinfo.h"
#include "miscadmin.h"
#include "storage/shmem.h"
-#include "utils/dynamic_loader.h"
#include "utils/hsearch.h"
* should declare its second argument as "const char *", but older
* platforms might not, so for the time being we just cast away const.
*/
- retval = (PGFunction) pg_dlsym(lib_handle, (char *) funcname);
+ retval = (PGFunction) dlsym(lib_handle, (char *) funcname);
if (retval == NULL && signalNotFound)
ereport(ERROR,
lookup_external_function(void *filehandle, const char *funcname)
{
/* as above, cast away const for the time being */
- return (PGFunction) pg_dlsym(filehandle, (char *) funcname);
+ return (PGFunction) dlsym(filehandle, (char *) funcname);
}
#endif
file_scanner->next = NULL;
- file_scanner->handle = pg_dlopen(file_scanner->filename);
+ file_scanner->handle = dlopen(file_scanner->filename, RTLD_NOW | RTLD_GLOBAL);
if (file_scanner->handle == NULL)
{
- load_error = (char *) pg_dlerror();
+ load_error = dlerror();
free((char *) file_scanner);
/* errcode_for_file_access might not be appropriate here? */
ereport(ERROR,
/* Check the magic function to determine compatibility */
magic_func = (PGModuleMagicFunction)
- pg_dlsym(file_scanner->handle, PG_MAGIC_FUNCTION_NAME_STRING);
+ dlsym(file_scanner->handle, PG_MAGIC_FUNCTION_NAME_STRING);
if (magic_func)
{
const Pg_magic_struct *magic_data_ptr = (*magic_func) ();
/* copy data block before unlinking library */
Pg_magic_struct module_magic_data = *magic_data_ptr;
- /* try to unlink library */
- pg_dlclose(file_scanner->handle);
+ /* try to close library */
+ dlclose(file_scanner->handle);
free((char *) file_scanner);
/* issue suitable complaint */
}
else
{
- /* try to unlink library */
- pg_dlclose(file_scanner->handle);
+ /* try to close library */
+ dlclose(file_scanner->handle);
free((char *) file_scanner);
/* complain */
ereport(ERROR,
/*
* If the library has a _PG_init() function, call it.
*/
- PG_init = (PG_init_t) pg_dlsym(file_scanner->handle, "_PG_init");
+ PG_init = (PG_init_t) dlsym(file_scanner->handle, "_PG_init");
if (PG_init)
(*PG_init) ();
/*
* If the library has a _PG_fini() function, call it.
*/
- PG_fini = (PG_fini_t) pg_dlsym(file_scanner->handle, "_PG_fini");
+ PG_fini = (PG_fini_t) dlsym(file_scanner->handle, "_PG_fini");
if (PG_fini)
(*PG_fini) ();
clear_external_function_hash(file_scanner->handle);
- pg_dlclose(file_scanner->handle);
+ dlclose(file_scanner->handle);
free((char *) file_scanner);
/* prv does not change */
}
/pg_config.h
/pg_config_ext.h
/pg_config_os.h
-/dynloader.h
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
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
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
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
#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);
+++ /dev/null
-/*-------------------------------------------------------------------------
- *
- * 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 */
-/* src/backend/port/dynloader/win32.c */
+/*-------------------------------------------------------------------------
+ *
+ * dlopen.c
+ * dynamic loader for platforms without dlopen()
+ *
+ * Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1994, Regents of the University of California
+ *
+ *
+ * IDENTIFICATION
+ * src/port/dlopen.c
+ *
+ *-------------------------------------------------------------------------
+ */
-#include "postgres.h"
+#include "c.h"
-char *dlerror(void);
-int dlclose(void *handle);
-void *dlsym(void *handle, const char *symbol);
-void *dlopen(const char *path, int mode);
+#if defined(__hpux)
+
+/* System includes */
+#include <a.out.h>
+#include <dl.h>
+
+void *
+dlopen(const char *file, int mode)
+{
+ int flags = 0;
+
+ if (mode & RTLD_NOW)
+ flags |= BIND_IMMEDIATE;
+#ifdef NOT_USED
+ if (mode & RTLD_LAZY)
+ flags |= BIND_DEFERRED;
+#endif
+
+ return shl_load(filename, flags | BIND_VERBOSE, 0L);
+}
+
+void *
+dlsym(void *handle, const char *symbol)
+{
+ void *value;
+
+ if (shl_findsym((shl_t *) & handle, symbol, TYPE_PROCEDURE, &value) == -1)
+ return NULL;
+ return value;
+}
+
+int
+dlclose(void *handle)
+{
+ return shl_unload((shl_t) handle);
+}
+
+char *
+dlerror(void)
+{
+ static char errmsg[] = "shl_load failed";
+
+ if (errno)
+ return strerror(errno);
+
+ return errmsg;
+}
+
+#elif defined(WIN32)
static char last_dyn_error[512];
last_dyn_error[0] = 0;
return (void *) h;
}
+
+#endif
'Public headers', $target . '/include/',
'src/include/', 'postgres_ext.h',
'pg_config.h', 'pg_config_ext.h',
- 'pg_config_os.h', 'dynloader.h',
+ 'pg_config_os.h',
'pg_config_manual.h');
lcopy('src/include/libpq/libpq-fs.h', $target . '/include/libpq/')
|| croak 'Could not copy libpq-fs.h';
CopyFiles(
'Server headers',
$target . '/include/server/',
- 'src/include/', 'pg_config.h', 'pg_config_ext.h', 'pg_config_os.h',
- 'dynloader.h');
+ 'src/include/', 'pg_config.h', 'pg_config_ext.h', 'pg_config_os.h');
CopyFiles(
'Grammar header',
$target . '/include/server/parser/',
erand48.c snprintf.c strlcat.c strlcpy.c dirmod.c noblock.c path.c
pg_strong_random.c pgcheckdir.c pgmkdirp.c pgsleep.c pgstrcasecmp.c
pqsignal.c mkdtemp.c qsort.c qsort_arg.c quotes.c system.c
- sprompt.c tar.c thread.c getopt.c getopt_long.c dirent.c
+ sprompt.c tar.c thread.c getopt.c getopt_long.c dirent.c dlopen.c
win32env.c win32error.c win32security.c win32setlocale.c);
push(@pgportfiles, 'rint.c') if ($vsVersion < '12.00');
$postgres->AddIncludeDir('src/backend');
$postgres->AddDir('src/backend/port/win32');
$postgres->AddFile('src/backend/utils/fmgrtab.c');
- $postgres->ReplaceFile(
- 'src/backend/port/dynloader.c',
- 'src/backend/port/dynloader/win32.c');
$postgres->ReplaceFile('src/backend/port/pg_sema.c',
'src/backend/port/win32_sema.c');
$postgres->ReplaceFile('src/backend/port/pg_shmem.c',
'src/include/storage/lwlocknames.h');
}
- if (IsNewer(
- 'src/include/dynloader.h', 'src/backend/port/dynloader/win32.h'))
- {
- copyFile('src/backend/port/dynloader/win32.h',
- 'src/include/dynloader.h');
- }
-
if (IsNewer('src/include/utils/probes.h', 'src/backend/utils/probes.d'))
{
print "Generating probes.h...\n";
if exist src\include\pg_config.h del /q src\include\pg_config.h
if exist src\include\pg_config_ext.h del /q src\include\pg_config_ext.h
if exist src\include\pg_config_os.h del /q src\include\pg_config_os.h
-if exist src\include\dynloader.h del /q src\include\dynloader.h
if %DIST%==1 if exist src\backend\parser\gram.h del /q src\backend\parser\gram.h
if exist src\include\utils\errcodes.h del /q src\include\utils\errcodes.h
if exist src\include\utils\fmgroids.h del /q src\include\utils\fmgroids.h