]> granicus.if.org Git - python/commitdiff
Expose RTLD_LOCAL and RTLD_GLOBAL always from the _ctypes extension module.
authorThomas Heller <theller@ctypes.org>
Thu, 6 Apr 2006 15:23:16 +0000 (15:23 +0000)
committerThomas Heller <theller@ctypes.org>
Thu, 6 Apr 2006 15:23:16 +0000 (15:23 +0000)
If RTLD_LOCAL is not #defined in any header file (Windows), set it to 0.
If RTLD_GLOBAL is not #defined, set it equal to RTLD_LOCAL.

This should fix ctypes on cygwin.

Lib/ctypes/__init__.py
Lib/ctypes/_loader.py
Modules/_ctypes/_ctypes.c

index a005594d66bb77693dd0b24c0c86c1b4b670f225..28ac1807be23b2eed77fa25b34fc950a10b784ec 100644 (file)
@@ -9,11 +9,7 @@ from _ctypes import Union, Structure, Array
 from _ctypes import _Pointer
 from _ctypes import CFuncPtr as _CFuncPtr
 from _ctypes import __version__ as _ctypes_version
-try:
-    from _ctypes import RTLD_LOCAL, RTLD_GLOBAL
-except (ImportError, AttributeError):
-    RTLD_GLOBAL = RTLD_LOCAL = None
-
+from _ctypes import RTLD_LOCAL, RTLD_GLOBAL
 from _ctypes import ArgumentError
 
 from struct import calcsize as _calcsize
index 6ab02961a18422151b486e392f9a9ae05f2be25f..7a48c1c4ba49b371971a042d2b4f6d7ff326c5a0 100644 (file)
@@ -1,14 +1,11 @@
-# WORK IN PROGRESS!  DO NOT (yet) USE!
 import sys, os
 import ctypes
 
-__all__ = ["LibraryLoader", "RTLD_LOCAL", "RTLD_GLOBAL"]
-
 if os.name in ("nt", "ce"):
     from _ctypes import LoadLibrary as dlopen
-    RTLD_LOCAL = RTLD_GLOBAL = None
 else:
-    from _ctypes import dlopen, RTLD_LOCAL, RTLD_GLOBAL
+    from _ctypes import dlopen
+from _ctypes import RTLD_LOCAL, RTLD_GLOBAL
 
 # _findLib(name) returns an iterable of possible names for a library.
 if os.name in ("nt", "ce"):
index 0743ec9c2df0fa0c5a45007bcadc70b7cfdc7e33..b9cac399c918cb5b8298497274142d389af6daa0 100644 (file)
@@ -4575,10 +4575,20 @@ init_ctypes(void)
        PyModule_AddObject(m, "_wstring_at_addr", PyLong_FromVoidPtr(wstring_at));
 #endif
 
-#ifdef RTLD_LOCAL
+/* If RTLD_LOCAL is not defined (Windows!), set it to zero. */
+#ifndef RTLD_LOCAL
+#define RTLD_LOCAL 0
+#endif
+
+/* If RTLD_GLOBAL is not defined (cygwin), set it to the same value as
+   RTLD_LOCAL.
+*/
+#ifndef RTLD_GLOBAL
+#define RTLD_GLOBAL RTLD_LOCAL
+#endif
+
        PyModule_AddObject(m, "RTLD_LOCAL", PyInt_FromLong(RTLD_LOCAL));
        PyModule_AddObject(m, "RTLD_GLOBAL", PyInt_FromLong(RTLD_GLOBAL));
-#endif
        
        PyExc_ArgError = PyErr_NewException("ctypes.ArgumentError", NULL, NULL);
        if (PyExc_ArgError) {