mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-09-28 00:31:51 +02:00
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
This commit is contained in:
parent
ac27c74def
commit
842cb9fa62
43
configure
vendored
43
configure
vendored
@ -15060,7 +15060,7 @@ fi
|
|||||||
LIBS_including_readline="$LIBS"
|
LIBS_including_readline="$LIBS"
|
||||||
LIBS=`echo "$LIBS" | sed -e 's/-ledit//g' -e 's/-lreadline//g'`
|
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 :
|
do :
|
||||||
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
|
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
|
||||||
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
|
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
|
||||||
@ -15252,6 +15252,30 @@ cat >>confdefs.h <<_ACEOF
|
|||||||
_ACEOF
|
_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
|
HAVE_IPV6=no
|
||||||
ac_fn_c_check_type "$LINENO" "struct sockaddr_in6" "ac_cv_type_struct_sockaddr_in6" "$ac_includes_default
|
ac_fn_c_check_type "$LINENO" "struct sockaddr_in6" "ac_cv_type_struct_sockaddr_in6" "$ac_includes_default
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
@ -15461,6 +15485,19 @@ esac
|
|||||||
|
|
||||||
fi
|
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"
|
ac_fn_c_check_func "$LINENO" "fls" "ac_cv_func_fls"
|
||||||
if test "x$ac_cv_func_fls" = xyes; then :
|
if test "x$ac_cv_func_fls" = xyes; then :
|
||||||
$as_echo "#define HAVE_FLS 1" >>confdefs.h
|
$as_echo "#define HAVE_FLS 1" >>confdefs.h
|
||||||
@ -19016,7 +19053,7 @@ fi
|
|||||||
ac_config_files="$ac_config_files GNUmakefile src/Makefile.global"
|
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
|
if test "$PORTNAME" = "win32"; then
|
||||||
@ -19737,10 +19774,8 @@ do
|
|||||||
"src/backend/port/tas.s") CONFIG_LINKS="$CONFIG_LINKS src/backend/port/tas.s:src/backend/port/tas/${tas_file}" ;;
|
"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" ;;
|
"GNUmakefile") CONFIG_FILES="$CONFIG_FILES GNUmakefile" ;;
|
||||||
"src/Makefile.global") CONFIG_FILES="$CONFIG_FILES src/Makefile.global" ;;
|
"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_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/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/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}" ;;
|
"src/Makefile.port") CONFIG_LINKS="$CONFIG_LINKS src/Makefile.port:src/makefiles/Makefile.${template}" ;;
|
||||||
"check_win32_symlinks") CONFIG_COMMANDS="$CONFIG_COMMANDS check_win32_symlinks" ;;
|
"check_win32_symlinks") CONFIG_COMMANDS="$CONFIG_COMMANDS check_win32_symlinks" ;;
|
||||||
|
@ -1544,7 +1544,7 @@ PGAC_FUNC_WCSTOMBS_L
|
|||||||
LIBS_including_readline="$LIBS"
|
LIBS_including_readline="$LIBS"
|
||||||
LIBS=`echo "$LIBS" | sed -e 's/-ledit//g' -e 's/-lreadline//g'`
|
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)
|
AC_REPLACE_FUNCS(fseeko)
|
||||||
case $host_os in
|
case $host_os in
|
||||||
@ -1570,6 +1570,8 @@ AC_CHECK_DECLS([strlcat, strlcpy, strnlen])
|
|||||||
# This is probably only present on macOS, but may as well check always
|
# This is probably only present on macOS, but may as well check always
|
||||||
AC_CHECK_DECLS(F_FULLFSYNC, [], [], [#include <fcntl.h>])
|
AC_CHECK_DECLS(F_FULLFSYNC, [], [], [#include <fcntl.h>])
|
||||||
|
|
||||||
|
AC_CHECK_DECLS([RTLD_GLOBAL, RTLD_NOW], [], [], [#include <dlfcn.h>])
|
||||||
|
|
||||||
HAVE_IPV6=no
|
HAVE_IPV6=no
|
||||||
AC_CHECK_TYPE([struct sockaddr_in6],
|
AC_CHECK_TYPE([struct sockaddr_in6],
|
||||||
[AC_DEFINE(HAVE_IPV6, 1, [Define to 1 if you have support for IPv6.])
|
[AC_DEFINE(HAVE_IPV6, 1, [Define to 1 if you have support for IPv6.])
|
||||||
@ -1658,7 +1660,7 @@ else
|
|||||||
AC_CHECK_FUNCS([fpclass fp_class fp_class_d class], [break])
|
AC_CHECK_FUNCS([fpclass fp_class fp_class_d class], [break])
|
||||||
fi
|
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
|
case $host_os in
|
||||||
|
|
||||||
@ -2382,10 +2384,8 @@ AC_SUBST(vpath_build)
|
|||||||
AC_CONFIG_FILES([GNUmakefile src/Makefile.global])
|
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_sema.c:${SEMA_IMPLEMENTATION}
|
||||||
src/backend/port/pg_shmem.c:${SHMEM_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/include/pg_config_os.h:src/include/port/${template}.h
|
||||||
src/Makefile.port:src/makefiles/Makefile.${template}
|
src/Makefile.port:src/makefiles/Makefile.${template}
|
||||||
])
|
])
|
||||||
|
@ -293,7 +293,7 @@ ifeq ($(PORTNAME), win32)
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
distclean: clean
|
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
|
maintainer-clean: distclean
|
||||||
$(MAKE) -C catalog $@
|
$(MAKE) -C catalog $@
|
||||||
|
1
src/backend/port/.gitignore
vendored
1
src/backend/port/.gitignore
vendored
@ -1,4 +1,3 @@
|
|||||||
/dynloader.c
|
|
||||||
/pg_sema.c
|
/pg_sema.c
|
||||||
/pg_shmem.c
|
/pg_shmem.c
|
||||||
/tas.s
|
/tas.s
|
||||||
|
@ -21,7 +21,7 @@ subdir = src/backend/port
|
|||||||
top_builddir = ../../..
|
top_builddir = ../../..
|
||||||
include $(top_builddir)/src/Makefile.global
|
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)
|
ifeq ($(PORTNAME), win32)
|
||||||
SUBDIRS += win32
|
SUBDIRS += win32
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
/*
|
|
||||||
* src/backend/port/dynloader/aix.c
|
|
||||||
*
|
|
||||||
* Dummy file used for nothing at this point
|
|
||||||
*
|
|
||||||
* see aix.h
|
|
||||||
*/
|
|
@ -1,39 +0,0 @@
|
|||||||
/*-------------------------------------------------------------------------
|
|
||||||
*
|
|
||||||
* 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 */
|
|
@ -1,3 +0,0 @@
|
|||||||
/* src/backend/port/dynloader/cygwin.c */
|
|
||||||
|
|
||||||
/* Dummy file used for nothing at this point; see cygwin.h */
|
|
@ -1,36 +0,0 @@
|
|||||||
/*-------------------------------------------------------------------------
|
|
||||||
*
|
|
||||||
* 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 */
|
|
@ -1,35 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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();
|
|
||||||
}
|
|
@ -1,8 +0,0 @@
|
|||||||
/* 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);
|
|
@ -1,7 +0,0 @@
|
|||||||
/*
|
|
||||||
* src/backend/port/dynloader/freebsd.c
|
|
||||||
*
|
|
||||||
* Dummy file used for nothing at this point
|
|
||||||
*
|
|
||||||
* see freebsd.h
|
|
||||||
*/
|
|
@ -1,38 +0,0 @@
|
|||||||
/*-------------------------------------------------------------------------
|
|
||||||
*
|
|
||||||
* 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 */
|
|
@ -1,68 +0,0 @@
|
|||||||
/*-------------------------------------------------------------------------
|
|
||||||
*
|
|
||||||
* 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;
|
|
||||||
}
|
|
@ -1,25 +0,0 @@
|
|||||||
/*-------------------------------------------------------------------------
|
|
||||||
*
|
|
||||||
* 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);
|
|
@ -1,7 +0,0 @@
|
|||||||
/*
|
|
||||||
* src/backend/port/dynloader/linux.c
|
|
||||||
*
|
|
||||||
* Dummy file used for nothing at this point
|
|
||||||
*
|
|
||||||
* see linux.h
|
|
||||||
*/
|
|
@ -1,38 +0,0 @@
|
|||||||
/*-------------------------------------------------------------------------
|
|
||||||
*
|
|
||||||
* 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 */
|
|
@ -1,7 +0,0 @@
|
|||||||
/*
|
|
||||||
* src/backend/port/dynloader/netbsd.c
|
|
||||||
*
|
|
||||||
* Dummy file used for nothing at this point
|
|
||||||
*
|
|
||||||
* see netbsd.h
|
|
||||||
*/
|
|
@ -1,38 +0,0 @@
|
|||||||
/*-------------------------------------------------------------------------
|
|
||||||
*
|
|
||||||
* 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 */
|
|
@ -1,7 +0,0 @@
|
|||||||
/*
|
|
||||||
* src/backend/port/dynloader/openbsd.c
|
|
||||||
*
|
|
||||||
* Dummy file used for nothing at this point
|
|
||||||
*
|
|
||||||
* see openbsd.h
|
|
||||||
*/
|
|
@ -1,38 +0,0 @@
|
|||||||
/*-------------------------------------------------------------------------
|
|
||||||
*
|
|
||||||
* 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 */
|
|
@ -1,7 +0,0 @@
|
|||||||
/*
|
|
||||||
* src/backend/port/dynloader/solaris.c
|
|
||||||
*
|
|
||||||
* Dummy file used for nothing at this point
|
|
||||||
*
|
|
||||||
* see solaris.h
|
|
||||||
*/
|
|
@ -1,38 +0,0 @@
|
|||||||
/*-------------------------------------------------------------------------
|
|
||||||
*
|
|
||||||
* 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 */
|
|
@ -1,19 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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 */
|
|
@ -124,7 +124,6 @@
|
|||||||
#include "tcop/tcopprot.h"
|
#include "tcop/tcopprot.h"
|
||||||
#include "utils/builtins.h"
|
#include "utils/builtins.h"
|
||||||
#include "utils/datetime.h"
|
#include "utils/datetime.h"
|
||||||
#include "utils/dynamic_loader.h"
|
|
||||||
#include "utils/memutils.h"
|
#include "utils/memutils.h"
|
||||||
#include "utils/pidfile.h"
|
#include "utils/pidfile.h"
|
||||||
#include "utils/ps_status.h"
|
#include "utils/ps_status.h"
|
||||||
|
@ -16,11 +16,14 @@
|
|||||||
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#include "dynloader.h"
|
#ifdef HAVE_DLOPEN
|
||||||
|
#include <dlfcn.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "fmgr.h"
|
||||||
#include "lib/stringinfo.h"
|
#include "lib/stringinfo.h"
|
||||||
#include "miscadmin.h"
|
#include "miscadmin.h"
|
||||||
#include "storage/shmem.h"
|
#include "storage/shmem.h"
|
||||||
#include "utils/dynamic_loader.h"
|
|
||||||
#include "utils/hsearch.h"
|
#include "utils/hsearch.h"
|
||||||
|
|
||||||
|
|
||||||
@ -113,7 +116,7 @@ load_external_function(const char *filename, const char *funcname,
|
|||||||
* should declare its second argument as "const char *", but older
|
* should declare its second argument as "const char *", but older
|
||||||
* platforms might not, so for the time being we just cast away const.
|
* 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)
|
if (retval == NULL && signalNotFound)
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
@ -162,7 +165,7 @@ PGFunction
|
|||||||
lookup_external_function(void *filehandle, const char *funcname)
|
lookup_external_function(void *filehandle, const char *funcname)
|
||||||
{
|
{
|
||||||
/* as above, cast away const for the time being */
|
/* as above, cast away const for the time being */
|
||||||
return (PGFunction) pg_dlsym(filehandle, (char *) funcname);
|
return (PGFunction) dlsym(filehandle, (char *) funcname);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -228,10 +231,10 @@ internal_load_library(const char *libname)
|
|||||||
#endif
|
#endif
|
||||||
file_scanner->next = NULL;
|
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)
|
if (file_scanner->handle == NULL)
|
||||||
{
|
{
|
||||||
load_error = (char *) pg_dlerror();
|
load_error = dlerror();
|
||||||
free((char *) file_scanner);
|
free((char *) file_scanner);
|
||||||
/* errcode_for_file_access might not be appropriate here? */
|
/* errcode_for_file_access might not be appropriate here? */
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
@ -242,7 +245,7 @@ internal_load_library(const char *libname)
|
|||||||
|
|
||||||
/* Check the magic function to determine compatibility */
|
/* Check the magic function to determine compatibility */
|
||||||
magic_func = (PGModuleMagicFunction)
|
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)
|
if (magic_func)
|
||||||
{
|
{
|
||||||
const Pg_magic_struct *magic_data_ptr = (*magic_func) ();
|
const Pg_magic_struct *magic_data_ptr = (*magic_func) ();
|
||||||
@ -253,8 +256,8 @@ internal_load_library(const char *libname)
|
|||||||
/* copy data block before unlinking library */
|
/* copy data block before unlinking library */
|
||||||
Pg_magic_struct module_magic_data = *magic_data_ptr;
|
Pg_magic_struct module_magic_data = *magic_data_ptr;
|
||||||
|
|
||||||
/* try to unlink library */
|
/* try to close library */
|
||||||
pg_dlclose(file_scanner->handle);
|
dlclose(file_scanner->handle);
|
||||||
free((char *) file_scanner);
|
free((char *) file_scanner);
|
||||||
|
|
||||||
/* issue suitable complaint */
|
/* issue suitable complaint */
|
||||||
@ -263,8 +266,8 @@ internal_load_library(const char *libname)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* try to unlink library */
|
/* try to close library */
|
||||||
pg_dlclose(file_scanner->handle);
|
dlclose(file_scanner->handle);
|
||||||
free((char *) file_scanner);
|
free((char *) file_scanner);
|
||||||
/* complain */
|
/* complain */
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
@ -276,7 +279,7 @@ internal_load_library(const char *libname)
|
|||||||
/*
|
/*
|
||||||
* If the library has a _PG_init() function, call it.
|
* 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)
|
if (PG_init)
|
||||||
(*PG_init) ();
|
(*PG_init) ();
|
||||||
|
|
||||||
@ -436,12 +439,12 @@ internal_unload_library(const char *libname)
|
|||||||
/*
|
/*
|
||||||
* If the library has a _PG_fini() function, call it.
|
* 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)
|
if (PG_fini)
|
||||||
(*PG_fini) ();
|
(*PG_fini) ();
|
||||||
|
|
||||||
clear_external_function_hash(file_scanner->handle);
|
clear_external_function_hash(file_scanner->handle);
|
||||||
pg_dlclose(file_scanner->handle);
|
dlclose(file_scanner->handle);
|
||||||
free((char *) file_scanner);
|
free((char *) file_scanner);
|
||||||
/* prv does not change */
|
/* prv does not change */
|
||||||
}
|
}
|
||||||
|
1
src/include/.gitignore
vendored
1
src/include/.gitignore
vendored
@ -3,4 +3,3 @@
|
|||||||
/pg_config.h
|
/pg_config.h
|
||||||
/pg_config_ext.h
|
/pg_config_ext.h
|
||||||
/pg_config_os.h
|
/pg_config_os.h
|
||||||
/dynloader.h
|
|
||||||
|
@ -54,7 +54,7 @@ install: all installdirs
|
|||||||
cp $(srcdir)/$$dir/*.h '$(DESTDIR)$(includedir_server)'/$$dir/ || exit; \
|
cp $(srcdir)/$$dir/*.h '$(DESTDIR)$(includedir_server)'/$$dir/ || exit; \
|
||||||
done
|
done
|
||||||
ifeq ($(vpath_build),yes)
|
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; \
|
cp $$file '$(DESTDIR)$(includedir_server)'/$$file || exit; \
|
||||||
done
|
done
|
||||||
endif
|
endif
|
||||||
@ -82,4 +82,4 @@ clean:
|
|||||||
rm -f catalog/schemapg.h catalog/pg_*_d.h catalog/header-stamp
|
rm -f catalog/schemapg.h catalog/pg_*_d.h catalog/header-stamp
|
||||||
|
|
||||||
distclean maintainer-clean: clean
|
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
|
||||||
|
@ -158,6 +158,14 @@
|
|||||||
don't. */
|
don't. */
|
||||||
#undef HAVE_DECL_POSIX_FADVISE
|
#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
|
/* Define to 1 if you have the declaration of `snprintf', and to 0 if you
|
||||||
don't. */
|
don't. */
|
||||||
#undef HAVE_DECL_SNPRINTF
|
#undef HAVE_DECL_SNPRINTF
|
||||||
|
@ -127,6 +127,14 @@
|
|||||||
to 0 if you don't. */
|
to 0 if you don't. */
|
||||||
#define HAVE_DECL_LLVMORCGETSYMBOLADDRESSIN 0
|
#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
|
/* Define to 1 if you have the declaration of `snprintf', and to 0 if you
|
||||||
don't. */
|
don't. */
|
||||||
#define HAVE_DECL_SNPRINTF 1
|
#define HAVE_DECL_SNPRINTF 1
|
||||||
|
@ -403,6 +403,29 @@ extern void srandom(unsigned int seed);
|
|||||||
#define SSL_get_current_compression(x) 0
|
#define SSL_get_current_compression(x) 0
|
||||||
#endif
|
#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 */
|
/* thread.h */
|
||||||
extern char *pqStrerror(int errnum, char *strerrbuf, size_t buflen);
|
extern char *pqStrerror(int errnum, char *strerrbuf, size_t buflen);
|
||||||
|
|
||||||
|
@ -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 */
|
|
@ -1,11 +1,69 @@
|
|||||||
/* 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);
|
#if defined(__hpux)
|
||||||
int dlclose(void *handle);
|
|
||||||
void *dlsym(void *handle, const char *symbol);
|
/* System includes */
|
||||||
void *dlopen(const char *path, int mode);
|
#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];
|
static char last_dyn_error[512];
|
||||||
|
|
||||||
@ -83,3 +141,5 @@ dlopen(const char *path, int mode)
|
|||||||
last_dyn_error[0] = 0;
|
last_dyn_error[0] = 0;
|
||||||
return (void *) h;
|
return (void *) h;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
@ -654,7 +654,7 @@ sub CopyIncludeFiles
|
|||||||
'Public headers', $target . '/include/',
|
'Public headers', $target . '/include/',
|
||||||
'src/include/', 'postgres_ext.h',
|
'src/include/', 'postgres_ext.h',
|
||||||
'pg_config.h', 'pg_config_ext.h',
|
'pg_config.h', 'pg_config_ext.h',
|
||||||
'pg_config_os.h', 'dynloader.h',
|
'pg_config_os.h',
|
||||||
'pg_config_manual.h');
|
'pg_config_manual.h');
|
||||||
lcopy('src/include/libpq/libpq-fs.h', $target . '/include/libpq/')
|
lcopy('src/include/libpq/libpq-fs.h', $target . '/include/libpq/')
|
||||||
|| croak 'Could not copy libpq-fs.h';
|
|| croak 'Could not copy libpq-fs.h';
|
||||||
@ -678,8 +678,7 @@ sub CopyIncludeFiles
|
|||||||
CopyFiles(
|
CopyFiles(
|
||||||
'Server headers',
|
'Server headers',
|
||||||
$target . '/include/server/',
|
$target . '/include/server/',
|
||||||
'src/include/', 'pg_config.h', 'pg_config_ext.h', 'pg_config_os.h',
|
'src/include/', 'pg_config.h', 'pg_config_ext.h', 'pg_config_os.h');
|
||||||
'dynloader.h');
|
|
||||||
CopyFiles(
|
CopyFiles(
|
||||||
'Grammar header',
|
'Grammar header',
|
||||||
$target . '/include/server/parser/',
|
$target . '/include/server/parser/',
|
||||||
|
@ -98,7 +98,7 @@ sub mkvcbuild
|
|||||||
erand48.c snprintf.c strlcat.c strlcpy.c dirmod.c noblock.c path.c
|
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
|
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
|
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);
|
win32env.c win32error.c win32security.c win32setlocale.c);
|
||||||
|
|
||||||
push(@pgportfiles, 'rint.c') if ($vsVersion < '12.00');
|
push(@pgportfiles, 'rint.c') if ($vsVersion < '12.00');
|
||||||
@ -155,9 +155,6 @@ sub mkvcbuild
|
|||||||
$postgres->AddIncludeDir('src/backend');
|
$postgres->AddIncludeDir('src/backend');
|
||||||
$postgres->AddDir('src/backend/port/win32');
|
$postgres->AddDir('src/backend/port/win32');
|
||||||
$postgres->AddFile('src/backend/utils/fmgrtab.c');
|
$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',
|
$postgres->ReplaceFile('src/backend/port/pg_sema.c',
|
||||||
'src/backend/port/win32_sema.c');
|
'src/backend/port/win32_sema.c');
|
||||||
$postgres->ReplaceFile('src/backend/port/pg_shmem.c',
|
$postgres->ReplaceFile('src/backend/port/pg_shmem.c',
|
||||||
|
@ -321,13 +321,6 @@ sub GenerateFiles
|
|||||||
'src/include/storage/lwlocknames.h');
|
'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'))
|
if (IsNewer('src/include/utils/probes.h', 'src/backend/utils/probes.d'))
|
||||||
{
|
{
|
||||||
print "Generating probes.h...\n";
|
print "Generating probes.h...\n";
|
||||||
|
@ -40,7 +40,6 @@ REM Delete files created with GenerateFiles() in Solution.pm
|
|||||||
if exist src\include\pg_config.h del /q src\include\pg_config.h
|
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_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\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 %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\errcodes.h del /q src\include\utils\errcodes.h
|
||||||
if exist src\include\utils\fmgroids.h del /q src\include\utils\fmgroids.h
|
if exist src\include\utils\fmgroids.h del /q src\include\utils\fmgroids.h
|
||||||
|
Loading…
Reference in New Issue
Block a user