Use RTLD_NOW, not RTLD_LAZY, as binding mode for dlopen() on all platforms.
authorTom Lane <tgl@sss.pgh.pa.us>
Tue, 12 Feb 2002 23:41:25 +0000 (23:41 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Tue, 12 Feb 2002 23:41:25 +0000 (23:41 +0000)
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.

17 files changed:
src/backend/port/dynloader/README.dlfcn.aix
src/backend/port/dynloader/aix.h
src/backend/port/dynloader/bsdi.h
src/backend/port/dynloader/dgux.h
src/backend/port/dynloader/freebsd.h
src/backend/port/dynloader/irix5.h
src/backend/port/dynloader/linux.h
src/backend/port/dynloader/netbsd.h
src/backend/port/dynloader/openbsd.h
src/backend/port/dynloader/osf.h
src/backend/port/dynloader/sco.h
src/backend/port/dynloader/solaris.h
src/backend/port/dynloader/sunos4.h
src/backend/port/dynloader/svr4.h
src/backend/port/dynloader/univel.h
src/backend/port/dynloader/unixware.h
src/backend/port/dynloader/win.h

index f64446d49b549bb4fe26eda88c4bb6f9c8ccbd43..e7519086d11d7f42a21514f3c8e4f38aba7810f1 100644 (file)
@@ -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
index 7131acd01985eb5bee146384fd439ecfe65c5e9a..3a47397dd1dab8be0f741e32c8e79c09e5fe6308 100644 (file)
@@ -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
index 1af6d3d3f5a67d35e6f0d3c6ff77ba7c67fb9a6f..8a3fc489facd23d6548d3f12c4e967fa69a5d5d3 100644 (file)
@@ -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$
  *
  *-------------------------------------------------------------------------
  */
 #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 */
index 31a854fb2e617c70b82eca6ef921d065f059116b..86b3d1b5b3cfcae1b8de5c64be2315ceb2df26f0 100644 (file)
  * 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
index 10275e8020f00359780c8b0af78bd45399d501b6..dcf3c3eb0ffec00181658ea46f29a2fe3fb13d9c 100644 (file)
@@ -1,8 +1,7 @@
 /*-------------------------------------------------------------------------
  *
- * 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
@@ -21,7 +20,6 @@
 
 #include "utils/dynamic_loader.h"
 
-/* dynloader.c */
 /*
  * Dynamic Loader on NetBSD 1.0.
  *
  * 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
index 87efa317f77f61492ad58f3365d59596bfaf4d6b..cf93b10e17762f649115aeb74e2973336b532c7b 100644 (file)
@@ -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$
  *
  *-------------------------------------------------------------------------
  */
 #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
index 938ef0724621537d645e21616f535131f81ab175..480d65f46eff38dc1af0039c27c8cebcd0fa9536 100644 (file)
@@ -1,6 +1,7 @@
 /*-------------------------------------------------------------------------
  *
- * Dynamic loader interface for Linux
+ * linux.h
+ *             Port-specific prototypes for Linux
  *
  *
  * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
@@ -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
index 04fad271a38ca1b2645d692dfe90fef47cfb79ff..bd5ce7d8d45fa586418010d12a43a8464413a29a 100644 (file)
@@ -1,7 +1,7 @@
 /*-------------------------------------------------------------------------
  *
- * 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
@@ -21,7 +21,6 @@
 
 #include "utils/dynamic_loader.h"
 
-/* dynloader.c */
 /*
  * Dynamic Loader on NetBSD 1.0.
  *
  * 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
index dcb94bd9ad0010977da8c90adf2c195f4757b132..534e4c59f80f265e199d6f49b4c8d7944f4cf324 100644 (file)
@@ -1,6 +1,7 @@
 /*-------------------------------------------------------------------------
  *
- * 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
@@ -19,7 +20,6 @@
 
 #include "utils/dynamic_loader.h"
 
-/* dynloader.c */
 /*
  * Dynamic Loader on NetBSD 1.0.
  *
  * 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
index b0c7f11c3e1cbfadc5da10dabe55037be1f69212..dcec4a5e091d210236bdd49b965010e7ee2c65db 100644 (file)
@@ -1,6 +1,6 @@
 /*-------------------------------------------------------------------------
  *
- * alpha.h
+ * osf.h
  *       prototypes for OSF/1-specific routines
  *
  *
 #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()
index aa88d74eaac6ae1e8a4aef1df33216b794b06972..8025a44fc2ba81c2cedac08a9fd8d8c6bd22ce74 100644 (file)
@@ -1,6 +1,6 @@
 /*-------------------------------------------------------------------------
  *
- * port_protos.h
+ * sco.h
  *       port-specific prototypes for SCO 3.2v5.2
  *
  *
 #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 */
index 94c9d79f8dd0d18bf089ed613acfdc98f6177916..77b8482947ec8217527ba452cc71cacb8853159d 100644 (file)
@@ -1,14 +1,38 @@
-/* $Header$ */
-
-#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$
+ *
+ *-------------------------------------------------------------------------
+ */
+#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 */
index a1ed67ddcf529495e3e0996efa7f6b4b850155c2..ad1727b4547f389175deab288302ba1dbc6d4709 100644 (file)
@@ -1,6 +1,6 @@
 /*-------------------------------------------------------------------------
  *
- * port_protos.h
+ * sunos4.h
  *       port-specific prototypes for SunOS 4
  *
  *
 #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
index 1ce24f57b3994ca5b3cb54009e0d64fbbe27f8bd..5df6fc1a5c9f5358d7f113f9e2a51c25743be00b 100644 (file)
@@ -1,6 +1,6 @@
 /*-------------------------------------------------------------------------
  *
- * dynloader.h
+ * svr4.h
  *       port-specific prototypes for Intel x86/Intel SVR4
  *
  *
  *
  *-------------------------------------------------------------------------
  */
-#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 */
index c8a652f733aae08216208802ba86369189f621cb..aef381712d2880527ee634c28c16851d9ba1e8d7 100644 (file)
 #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
index 691273fdbdcdb7038078e1e44aed8aeab0800f78..2edea13cf87b8b88d5b30b9dc2207d9f91090f0a 100644 (file)
 #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
index 01ee8761c7fd973aa9a58f4e37a1c82cfa19b60d..4f76d20f0d74625c300474d12a76ce243db927f3 100644 (file)
 #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