summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane2002-02-12 23:41:25 +0000
committerTom Lane2002-02-12 23:41:25 +0000
commitfa046b6a92431a91f91a981bb2995e7091552477 (patch)
tree8048a4ce16e41b2d344ed468457d55e3b9989e5f
parentbaa0bb97b0a6f40993a8e340b55b14c9317f60a1 (diff)
Use RTLD_NOW, not RTLD_LAZY, as binding mode for dlopen() on all platforms.
This restores the Linux behavior to what it was in PG 7.0 and 7.1, and causes other platforms to agree. (Other well-tested platforms like HPUX were doing it this way already.) Per pghackers discussion over the past month or so.
-rw-r--r--src/backend/port/dynloader/README.dlfcn.aix4
-rw-r--r--src/backend/port/dynloader/aix.h4
-rw-r--r--src/backend/port/dynloader/bsdi.h23
-rw-r--r--src/backend/port/dynloader/dgux.h19
-rw-r--r--src/backend/port/dynloader/freebsd.h19
-rw-r--r--src/backend/port/dynloader/irix5.h22
-rw-r--r--src/backend/port/dynloader/linux.h20
-rw-r--r--src/backend/port/dynloader/netbsd.h23
-rw-r--r--src/backend/port/dynloader/openbsd.h22
-rw-r--r--src/backend/port/dynloader/osf.h19
-rw-r--r--src/backend/port/dynloader/sco.h24
-rw-r--r--src/backend/port/dynloader/solaris.h36
-rw-r--r--src/backend/port/dynloader/sunos4.h22
-rw-r--r--src/backend/port/dynloader/svr4.h28
-rw-r--r--src/backend/port/dynloader/univel.h20
-rw-r--r--src/backend/port/dynloader/unixware.h20
-rw-r--r--src/backend/port/dynloader/win.h20
17 files changed, 266 insertions, 79 deletions
diff --git a/src/backend/port/dynloader/README.dlfcn.aix b/src/backend/port/dynloader/README.dlfcn.aix
index f64446d49b5..e7519086d11 100644
--- a/src/backend/port/dynloader/README.dlfcn.aix
+++ b/src/backend/port/dynloader/README.dlfcn.aix
@@ -39,8 +39,8 @@ table. If the path does not contain a '/' character, dlopen will search
for the module using the LIBPATH environment variable. It returns an
opaque handle to the module or NULL on error. The mode parameter can be
either RTLD_LAZY (for lazy function binding) or RTLD_NOW for immediate
-function binding. The AIX implementation currently does treat RTLD_NOW
-the same as RTLD_LAZY. The flag RTLD_GLOBAL might be or'ed into the
+function binding. The AIX implementation currently behaves as RTLD_NOW
+even if RTLD_LAZY is specified. The flag RTLD_GLOBAL might be or'ed into the
mode parameter to allow loaded modules to bind to global variables or
functions in other loaded modules loaded by dlopen(). If RTLD_GLOBAL is
not specified, only globals from the main part of the executable or
diff --git a/src/backend/port/dynloader/aix.h b/src/backend/port/dynloader/aix.h
index 69b5881ec48..3aee79731a2 100644
--- a/src/backend/port/dynloader/aix.h
+++ b/src/backend/port/dynloader/aix.h
@@ -1,5 +1,5 @@
/*
- * $Id: aix.h,v 1.10 2001/11/08 20:37:52 momjian Exp $
+ * $Id: aix.h,v 1.11 2002/02/12 23:39:46 tgl Exp $
*
* @(#)dlfcn.h 1.4 revision of 95/04/25 09:36:52
* This is an unpublished work copyright (c) 1992 HELIOS Software GmbH
@@ -57,7 +57,7 @@ int dlclose();
#include "utils/dynamic_loader.h"
-#define pg_dlopen(f) dlopen((f), RTLD_LAZY | RTLD_GLOBAL)
+#define pg_dlopen(f) dlopen((f), RTLD_NOW | RTLD_GLOBAL)
#define pg_dlsym dlsym
#define pg_dlclose dlclose
#define pg_dlerror dlerror
diff --git a/src/backend/port/dynloader/bsdi.h b/src/backend/port/dynloader/bsdi.h
index 1af6d3d3f5a..29c2e0e8546 100644
--- a/src/backend/port/dynloader/bsdi.h
+++ b/src/backend/port/dynloader/bsdi.h
@@ -1,12 +1,12 @@
/*-------------------------------------------------------------------------
*
- * Dynamic loader interface for BSD/OS
- *
+ * bsdi.h
+ * Dynamic loader interface for BSD/OS
*
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * port_protos.h,v 1.2 1995/05/25 22:51:03 andrew Exp
+ * $Id: bsdi.h,v 1.15 2002/02/12 23:39:57 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -19,7 +19,21 @@
#ifdef HAVE_DLOPEN
#include <dlfcn.h>
-#define pg_dlopen(f) dlopen((f), RTLD_LAZY | RTLD_GLOBAL)
+
+/*
+ * 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
@@ -32,6 +46,7 @@ do { \
dld_unlink_by_file(handle, 1); \
free(handle); \
} while (0)
+
#endif /* not HAVE_DLOPEN */
#endif /* PORT_PROTOS_H */
diff --git a/src/backend/port/dynloader/dgux.h b/src/backend/port/dynloader/dgux.h
index 2cdde7574f7..b53245858a9 100644
--- a/src/backend/port/dynloader/dgux.h
+++ b/src/backend/port/dynloader/dgux.h
@@ -5,7 +5,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: dgux.h,v 1.13 2001/11/05 17:46:27 momjian Exp $
+ * $Id: dgux.h,v 1.14 2002/02/12 23:40:03 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -21,9 +21,22 @@
* this dynamic loader uses the system dynamic loading interface for shared
* libraries (ie. dlopen/dlsym/dlclose). The user must specify a shared
* library as the file to be dynamically loaded.
- *
*/
-#define pg_dlopen(f) dlopen((f), RTLD_LAZY | RTLD_GLOBAL)
+
+/*
+ * 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
diff --git a/src/backend/port/dynloader/freebsd.h b/src/backend/port/dynloader/freebsd.h
index 4437bff089d..065451f8c6e 100644
--- a/src/backend/port/dynloader/freebsd.h
+++ b/src/backend/port/dynloader/freebsd.h
@@ -1,13 +1,12 @@
/*-------------------------------------------------------------------------
*
- * port_protos.h
- * port-specific prototypes for NetBSD 1.0
- *
+ * freebsd.h
+ * port-specific prototypes for FreeBSD
*
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: freebsd.h,v 1.14 2002/02/11 21:38:11 petere Exp $
+ * $Id: freebsd.h,v 1.15 2002/02/12 23:40:12 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -21,7 +20,6 @@
#include "utils/dynamic_loader.h"
-/* dynloader.c */
/*
* Dynamic Loader on NetBSD 1.0.
*
@@ -35,11 +33,20 @@
* NetBSD (like 1.0, and 1.0A pre June 1995) have no dlerror.)
*/
+/*
+ * 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) BSD44_derived_dlopen((f), RTLD_LAZY | RTLD_GLOBAL)
+#define pg_dlopen(f) BSD44_derived_dlopen((f), RTLD_NOW | RTLD_GLOBAL)
#define pg_dlsym BSD44_derived_dlsym
#define pg_dlclose BSD44_derived_dlclose
#define pg_dlerror BSD44_derived_dlerror
diff --git a/src/backend/port/dynloader/irix5.h b/src/backend/port/dynloader/irix5.h
index 87efa317f77..2d6dfac8a09 100644
--- a/src/backend/port/dynloader/irix5.h
+++ b/src/backend/port/dynloader/irix5.h
@@ -1,13 +1,13 @@
/*-------------------------------------------------------------------------
*
- * port_protos.h
+ * irix5.h
* port-specific prototypes for Irix 5
*
*
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * port_protos.h,v 1.2 1995/03/17 06:40:18 andrew Exp
+ * $Id: irix5.h,v 1.12 2002/02/12 23:40:24 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -17,16 +17,28 @@
#include <dlfcn.h>
#include "utils/dynamic_loader.h"
-/* dynloader.c */
/*
* Dynamic Loader on SunOS 4.
*
* this dynamic loader uses the system dynamic loading interface for shared
* libraries (ie. dlopen/dlsym/dlclose). The user must specify a shared
* library as the file to be dynamically loaded.
- *
*/
-#define pg_dlopen(f) dlopen((f), RTLD_LAZY | RTLD_GLOBAL)
+
+/*
+ * 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
diff --git a/src/backend/port/dynloader/linux.h b/src/backend/port/dynloader/linux.h
index 3db2436597b..de096c60373 100644
--- a/src/backend/port/dynloader/linux.h
+++ b/src/backend/port/dynloader/linux.h
@@ -1,12 +1,13 @@
/*-------------------------------------------------------------------------
*
- * Dynamic loader interface for Linux
+ * linux.h
+ * Port-specific prototypes for Linux
*
*
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: linux.h,v 1.16 2001/11/05 17:46:27 momjian Exp $
+ * $Id: linux.h,v 1.17 2002/02/12 23:40:29 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -35,7 +36,20 @@ do { \
#else /* HAVE_DLOPEN */
-#define pg_dlopen(f) dlopen((f), RTLD_LAZY | RTLD_GLOBAL)
+/*
+ * 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
diff --git a/src/backend/port/dynloader/netbsd.h b/src/backend/port/dynloader/netbsd.h
index 8310de4db2a..e01fd8f3334 100644
--- a/src/backend/port/dynloader/netbsd.h
+++ b/src/backend/port/dynloader/netbsd.h
@@ -1,13 +1,13 @@
/*-------------------------------------------------------------------------
*
- * port_protos.h
- * port-specific prototypes for NetBSD 1.0
+ * netbsd.h
+ * port-specific prototypes for NetBSD
*
*
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: netbsd.h,v 1.8 2001/11/05 17:46:27 momjian Exp $
+ * $Id: netbsd.h,v 1.9 2002/02/12 23:40:37 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -21,7 +21,6 @@
#include "utils/dynamic_loader.h"
-/* dynloader.c */
/*
* Dynamic Loader on NetBSD 1.0.
*
@@ -34,7 +33,21 @@
* begin with an underscore is fairly tricky, and some versions of
* NetBSD (like 1.0, and 1.0A pre June 1995) have no dlerror.)
*/
-#define pg_dlopen(f) BSD44_derived_dlopen((f), RTLD_LAZY | RTLD_GLOBAL)
+
+/*
+ * 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) BSD44_derived_dlopen((f), RTLD_NOW | RTLD_GLOBAL)
#define pg_dlsym BSD44_derived_dlsym
#define pg_dlclose BSD44_derived_dlclose
#define pg_dlerror BSD44_derived_dlerror
diff --git a/src/backend/port/dynloader/openbsd.h b/src/backend/port/dynloader/openbsd.h
index 644b149b804..b68bb9d5873 100644
--- a/src/backend/port/dynloader/openbsd.h
+++ b/src/backend/port/dynloader/openbsd.h
@@ -1,11 +1,12 @@
/*-------------------------------------------------------------------------
*
- * Dynamic loader for OpenBSD
+ * openbsd.h
+ * port-specific prototypes for OpenBSD
*
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: openbsd.h,v 1.9 2001/11/05 17:46:27 momjian Exp $
+ * $Id: openbsd.h,v 1.10 2002/02/12 23:40:40 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -19,7 +20,6 @@
#include "utils/dynamic_loader.h"
-/* dynloader.c */
/*
* Dynamic Loader on NetBSD 1.0.
*
@@ -32,7 +32,21 @@
* begin with an underscore is fairly tricky, and some versions of
* NetBSD (like 1.0, and 1.0A pre June 1995) have no dlerror.)
*/
-#define pg_dlopen(f) BSD44_derived_dlopen((f), RTLD_LAZY)
+
+/*
+ * 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) BSD44_derived_dlopen((f), RTLD_NOW | RTLD_GLOBAL)
#define pg_dlsym BSD44_derived_dlsym
#define pg_dlclose BSD44_derived_dlclose
#define pg_dlerror BSD44_derived_dlerror
diff --git a/src/backend/port/dynloader/osf.h b/src/backend/port/dynloader/osf.h
index f505ad1dff8..71028d9b240 100644
--- a/src/backend/port/dynloader/osf.h
+++ b/src/backend/port/dynloader/osf.h
@@ -1,13 +1,13 @@
/*-------------------------------------------------------------------------
*
- * alpha.h
+ * osf.h
* prototypes for OSF/1-specific routines
*
*
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: osf.h,v 1.7 2001/11/15 16:08:15 petere Exp $
+ * $Id: osf.h,v 1.8 2002/02/12 23:40:43 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -18,23 +18,28 @@
#include <dlfcn.h>
#include "utils/dynamic_loader.h"
-/* dynloader.c */
-
/*
* Dynamic Loader on Alpha OSF/1.x
*
* this dynamic loader uses the system dynamic loading interface for shared
* libraries (ie. dlopen/dlsym/dlclose). The user must specify a shared
* library as the file to be dynamically loaded.
- *
*/
-/* RTLD_GLOBAL is not available in <5.x */
+/*
+ * 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_LAZY | RTLD_GLOBAL)
+#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()
diff --git a/src/backend/port/dynloader/sco.h b/src/backend/port/dynloader/sco.h
index 171c9e4c4d2..dccca881f2b 100644
--- a/src/backend/port/dynloader/sco.h
+++ b/src/backend/port/dynloader/sco.h
@@ -1,13 +1,13 @@
/*-------------------------------------------------------------------------
*
- * port_protos.h
+ * sco.h
* port-specific prototypes for SCO 3.2v5.2
*
*
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: sco.h,v 1.11 2001/11/05 17:46:27 momjian Exp $
+ * $Id: sco.h,v 1.12 2002/02/12 23:40:47 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -17,20 +17,30 @@
#include <dlfcn.h>
#include "utils/dynamic_loader.h"
-/* dynloader.c */
/*
* Dynamic Loader on SCO 3.2v5.0.2
*
* this dynamic loader uses the system dynamic loading interface for shared
* libraries (ie. dlopen/dlsym/dlclose). The user must specify a shared
* library as the file to be dynamically loaded.
- *
*/
-#define pg_dlopen(f) dlopen((f), RTLD_LAZY | RTLD_GLOBAL)
+
+/*
+ * 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
-/* port.c */
-
#endif /* PORT_PROTOS_H */
diff --git a/src/backend/port/dynloader/solaris.h b/src/backend/port/dynloader/solaris.h
index ddb6b965b95..2f0c00e97b6 100644
--- a/src/backend/port/dynloader/solaris.h
+++ b/src/backend/port/dynloader/solaris.h
@@ -1,14 +1,38 @@
-/* $Header: /cvsroot/pgsql/src/backend/port/dynloader/solaris.h,v 1.7 2001/11/05 17:46:27 momjian Exp $ */
-
-#ifndef DYNLOADER_SOLARIS_H
-#define DYNLOADER_SOLARIS_H
+/*-------------------------------------------------------------------------
+ *
+ * solaris.h
+ * port-specific prototypes for Solaris
+ *
+ *
+ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1994, Regents of the University of California
+ *
+ * $Id: solaris.h,v 1.8 2002/02/12 23:40:53 tgl Exp $
+ *
+ *-------------------------------------------------------------------------
+ */
+#ifndef PORT_PROTOS_H
+#define PORT_PROTOS_H
#include <dlfcn.h>
#include "utils/dynamic_loader.h"
-#define pg_dlopen(f) dlopen((f), RTLD_LAZY | RTLD_GLOBAL)
+/*
+ * 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 /* DYNLOADER_SOLARIS_H */
+#endif /* PORT_PROTOS_H */
diff --git a/src/backend/port/dynloader/sunos4.h b/src/backend/port/dynloader/sunos4.h
index 0bd685be7dc..60d434586a2 100644
--- a/src/backend/port/dynloader/sunos4.h
+++ b/src/backend/port/dynloader/sunos4.h
@@ -1,13 +1,13 @@
/*-------------------------------------------------------------------------
*
- * port_protos.h
+ * sunos4.h
* port-specific prototypes for SunOS 4
*
*
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: sunos4.h,v 1.12 2001/12/05 02:03:59 ishii Exp $
+ * $Id: sunos4.h,v 1.13 2002/02/12 23:40:55 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -17,16 +17,28 @@
#include <dlfcn.h>
#include "utils/dynamic_loader.h"
-/* dynloader.c */
/*
* Dynamic Loader on SunOS 4.
*
* this dynamic loader uses the system dynamic loading interface for shared
* libraries (ie. dlopen/dlsym/dlclose). The user must specify a shared
* library as the file to be dynamically loaded.
- *
*/
-#define pg_dlopen(f) dlopen((f),1)
+
+/*
+ * 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
diff --git a/src/backend/port/dynloader/svr4.h b/src/backend/port/dynloader/svr4.h
index 191f81b42e9..33b36692bf4 100644
--- a/src/backend/port/dynloader/svr4.h
+++ b/src/backend/port/dynloader/svr4.h
@@ -1,34 +1,46 @@
/*-------------------------------------------------------------------------
*
- * dynloader.h
+ * svr4.h
* port-specific prototypes for Intel x86/Intel SVR4
*
*
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: svr4.h,v 1.11 2001/11/05 17:46:27 momjian Exp $
+ * $Id: svr4.h,v 1.12 2002/02/12 23:41:01 tgl Exp $
*
*-------------------------------------------------------------------------
*/
-#ifndef DYNLOADER_H
-#define DYNLOADER_H
+#ifndef PORT_PROTOS_H
+#define PORT_PROTOS_H
#include <dlfcn.h>
#include "utils/dynamic_loader.h"
-/* dynloader.h */
/*
* Dynamic Loader on Intel x86/Intel SVR4.
*
* this dynamic loader uses the system dynamic loading interface for shared
* libraries (ie. dlopen/dlsym/dlclose). The user must specify a shared
* library as the file to be dynamically loaded.
- *
*/
-#define pg_dlopen(f) dlopen((f), RTLD_LAZY | RTLD_GLOBAL)
+
+/*
+ * 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 /* DYNLOADER_H */
+#endif /* PORT_PROTOS_H */
diff --git a/src/backend/port/dynloader/univel.h b/src/backend/port/dynloader/univel.h
index c8a652f733a..aef381712d2 100644
--- a/src/backend/port/dynloader/univel.h
+++ b/src/backend/port/dynloader/univel.h
@@ -17,16 +17,28 @@
#include <dlfcn.h>
#include "utils/dynamic_loader.h"
- /* dynloader.c */
/*
* Dynamic Loader on Intel x86/Intel SVR4.
*
* this dynamic loader uses the system dynamic loading interface for shared
* libraries (ie. dlopen/dlsym/dlclose). The user must specify a shared
* library as the file to be dynamically loaded.
- *
- */
-#define pg_dlopen(f) dlopen((f), RTLD_LAZY | RTLD_GLOBAL)
+ */
+
+/*
+ * 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
diff --git a/src/backend/port/dynloader/unixware.h b/src/backend/port/dynloader/unixware.h
index 691273fdbdc..2edea13cf87 100644
--- a/src/backend/port/dynloader/unixware.h
+++ b/src/backend/port/dynloader/unixware.h
@@ -17,16 +17,28 @@
#include <dlfcn.h>
#include "utils/dynamic_loader.h"
- /* dynloader.c */
/*
* Dynamic Loader on Intel x86/Intel SVR4.
*
* this dynamic loader uses the system dynamic loading interface for shared
* libraries (ie. dlopen/dlsym/dlclose). The user must specify a shared
* library as the file to be dynamically loaded.
- *
- */
-#define pg_dlopen(f) dlopen((f), RTLD_LAZY | RTLD_GLOBAL)
+ */
+
+/*
+ * 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
diff --git a/src/backend/port/dynloader/win.h b/src/backend/port/dynloader/win.h
index 01ee8761c7f..4f76d20f0d7 100644
--- a/src/backend/port/dynloader/win.h
+++ b/src/backend/port/dynloader/win.h
@@ -17,16 +17,28 @@
#include <dlfcn.h>
#include "utils/dynamic_loader.h"
- /* dynloader.c */
/*
* Dynamic Loader on Intel x86/Windows NT
*
* this dynamic loader uses the system dynamic loading interface for shared
* libraries (ie. dlopen/dlsym/dlclose). The user must specify a shared
* library as the file to be dynamically loaded.
- *
- */
-#define pg_dlopen(f) dlopen((f), RTLD_LAZY | RTLD_GLOBAL)
+ */
+
+/*
+ * 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