From 2df82db48506e5a2044a28f147fdb42f662d37b9 Mon Sep 17 00:00:00 2001 From: Zachary Ware Date: Thu, 29 Dec 2022 16:13:28 -0600 Subject: [PATCH] gh-100540: Remove obsolete Modules/_ctypes/darwin/ dlfcn shim (GH-100541) As far as I can tell, this hasn't been actually used since Mac OS X 10.2. --- Makefile.pre.in | 2 +- ...-12-26-14-52-37.gh-issue-100540.kYZLtX.rst | 2 + Modules/_ctypes/_ctypes.c | 10 +- Modules/_ctypes/callproc.c | 12 +- Modules/_ctypes/ctypes_dlfcn.h | 27 -- Modules/_ctypes/darwin/LICENSE | 31 -- Modules/_ctypes/darwin/README | 95 ------ Modules/_ctypes/darwin/README.ctypes | 11 - Modules/_ctypes/darwin/dlfcn.h | 84 ------ Modules/_ctypes/darwin/dlfcn_simple.c | 272 ------------------ PCbuild/_ctypes.vcxproj | 1 - PCbuild/_ctypes.vcxproj.filters | 3 - Tools/c-analyzer/cpython/_parser.py | 1 - configure | 3 +- configure.ac | 1 - 15 files changed, 15 insertions(+), 540 deletions(-) create mode 100644 Misc/NEWS.d/next/macOS/2022-12-26-14-52-37.gh-issue-100540.kYZLtX.rst delete mode 100644 Modules/_ctypes/ctypes_dlfcn.h delete mode 100644 Modules/_ctypes/darwin/LICENSE delete mode 100644 Modules/_ctypes/darwin/README delete mode 100644 Modules/_ctypes/darwin/README.ctypes delete mode 100644 Modules/_ctypes/darwin/dlfcn.h delete mode 100644 Modules/_ctypes/darwin/dlfcn_simple.c diff --git a/Makefile.pre.in b/Makefile.pre.in index dd6c3fbd1c6..1f8bd561f61 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -2591,7 +2591,7 @@ MODULE_MATH_DEPS=$(srcdir)/Modules/_math.h MODULE_PYEXPAT_DEPS=@LIBEXPAT_INTERNAL@ MODULE_UNICODEDATA_DEPS=$(srcdir)/Modules/unicodedata_db.h $(srcdir)/Modules/unicodename_db.h MODULE__BLAKE2_DEPS=$(srcdir)/Modules/_blake2/impl/blake2-config.h $(srcdir)/Modules/_blake2/impl/blake2-impl.h $(srcdir)/Modules/_blake2/impl/blake2.h $(srcdir)/Modules/_blake2/impl/blake2b-load-sse2.h $(srcdir)/Modules/_blake2/impl/blake2b-load-sse41.h $(srcdir)/Modules/_blake2/impl/blake2b-ref.c $(srcdir)/Modules/_blake2/impl/blake2b-round.h $(srcdir)/Modules/_blake2/impl/blake2b.c $(srcdir)/Modules/_blake2/impl/blake2s-load-sse2.h $(srcdir)/Modules/_blake2/impl/blake2s-load-sse41.h $(srcdir)/Modules/_blake2/impl/blake2s-load-xop.h $(srcdir)/Modules/_blake2/impl/blake2s-ref.c $(srcdir)/Modules/_blake2/impl/blake2s-round.h $(srcdir)/Modules/_blake2/impl/blake2s.c $(srcdir)/Modules/_blake2/blake2module.h $(srcdir)/Modules/hashlib.h -MODULE__CTYPES_DEPS=$(srcdir)/Modules/_ctypes/ctypes.h $(srcdir)/Modules/_ctypes/darwin/dlfcn.h +MODULE__CTYPES_DEPS=$(srcdir)/Modules/_ctypes/ctypes.h MODULE__CTYPES_MALLOC_CLOSURE=@MODULE__CTYPES_MALLOC_CLOSURE@ MODULE__DECIMAL_DEPS=$(srcdir)/Modules/_decimal/docstrings.h @LIBMPDEC_INTERNAL@ MODULE__ELEMENTTREE_DEPS=$(srcdir)/Modules/pyexpat.c @LIBEXPAT_INTERNAL@ diff --git a/Misc/NEWS.d/next/macOS/2022-12-26-14-52-37.gh-issue-100540.kYZLtX.rst b/Misc/NEWS.d/next/macOS/2022-12-26-14-52-37.gh-issue-100540.kYZLtX.rst new file mode 100644 index 00000000000..a42814e1861 --- /dev/null +++ b/Misc/NEWS.d/next/macOS/2022-12-26-14-52-37.gh-issue-100540.kYZLtX.rst @@ -0,0 +1,2 @@ +Removed obsolete ``dlfcn.h`` shim from the ``_ctypes`` extension module, +which has not been necessary since Mac OS X 10.2. diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c index f69a3770996..4ce6433a2e4 100644 --- a/Modules/_ctypes/_ctypes.c +++ b/Modules/_ctypes/_ctypes.c @@ -120,7 +120,7 @@ bytes(cdata) #define IS_INTRESOURCE(x) (((size_t)(x) >> 16) == 0) #endif #else -#include "ctypes_dlfcn.h" +#include #endif #include "ctypes.h" @@ -768,7 +768,7 @@ CDataType_in_dll(PyObject *type, PyObject *args) return NULL; } #else - address = (void *)ctypes_dlsym(handle, name); + address = (void *)dlsym(handle, name); if (!address) { #ifdef __CYGWIN__ /* dlerror() isn't very helpful on cygwin */ @@ -776,7 +776,7 @@ CDataType_in_dll(PyObject *type, PyObject *args) "symbol '%s' not found", name); #else - PyErr_SetString(PyExc_ValueError, ctypes_dlerror()); + PyErr_SetString(PyExc_ValueError, dlerror()); #endif return NULL; } @@ -3560,7 +3560,7 @@ PyCFuncPtr_FromDll(PyTypeObject *type, PyObject *args, PyObject *kwds) return NULL; } #else - address = (PPROC)ctypes_dlsym(handle, name); + address = (PPROC)dlsym(handle, name); if (!address) { #ifdef __CYGWIN__ /* dlerror() isn't very helpful on cygwin */ @@ -3568,7 +3568,7 @@ PyCFuncPtr_FromDll(PyTypeObject *type, PyObject *args, PyObject *kwds) "function '%s' not found", name); #else - PyErr_SetString(PyExc_AttributeError, ctypes_dlerror()); + PyErr_SetString(PyExc_AttributeError, dlerror()); #endif Py_DECREF(ftuple); return NULL; diff --git a/Modules/_ctypes/callproc.c b/Modules/_ctypes/callproc.c index 28b7cd40697..1958758dd0c 100644 --- a/Modules/_ctypes/callproc.c +++ b/Modules/_ctypes/callproc.c @@ -67,7 +67,7 @@ #include #include #else -#include "ctypes_dlfcn.h" +#include #endif #ifdef __APPLE__ @@ -1537,10 +1537,10 @@ static PyObject *py_dl_open(PyObject *self, PyObject *args) if (PySys_Audit("ctypes.dlopen", "O", name) < 0) { return NULL; } - handle = ctypes_dlopen(name_str, mode); + handle = dlopen(name_str, mode); Py_XDECREF(name2); if (!handle) { - const char *errmsg = ctypes_dlerror(); + const char *errmsg = dlerror(); if (!errmsg) errmsg = "dlopen() error"; PyErr_SetString(PyExc_OSError, @@ -1558,7 +1558,7 @@ static PyObject *py_dl_close(PyObject *self, PyObject *args) return NULL; if (dlclose(handle)) { PyErr_SetString(PyExc_OSError, - ctypes_dlerror()); + dlerror()); return NULL; } Py_RETURN_NONE; @@ -1576,10 +1576,10 @@ static PyObject *py_dl_sym(PyObject *self, PyObject *args) if (PySys_Audit("ctypes.dlsym/handle", "O", args) < 0) { return NULL; } - ptr = ctypes_dlsym((void*)handle, name); + ptr = dlsym((void*)handle, name); if (!ptr) { PyErr_SetString(PyExc_OSError, - ctypes_dlerror()); + dlerror()); return NULL; } return PyLong_FromVoidPtr(ptr); diff --git a/Modules/_ctypes/ctypes_dlfcn.h b/Modules/_ctypes/ctypes_dlfcn.h deleted file mode 100644 index 54cdde9a4fd..00000000000 --- a/Modules/_ctypes/ctypes_dlfcn.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef _CTYPES_DLFCN_H_ -#define _CTYPES_DLFCN_H_ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#ifndef MS_WIN32 - -#include - -#ifndef CTYPES_DARWIN_DLFCN - -#define ctypes_dlsym dlsym -#define ctypes_dlerror dlerror -#define ctypes_dlopen dlopen -#define ctypes_dlclose dlclose -#define ctypes_dladdr dladdr - -#endif /* !CTYPES_DARWIN_DLFCN */ - -#endif /* !MS_WIN32 */ - -#ifdef __cplusplus -} -#endif /* __cplusplus */ -#endif /* _CTYPES_DLFCN_H_ */ diff --git a/Modules/_ctypes/darwin/LICENSE b/Modules/_ctypes/darwin/LICENSE deleted file mode 100644 index 786fb50258e..00000000000 --- a/Modules/_ctypes/darwin/LICENSE +++ /dev/null @@ -1,31 +0,0 @@ -Copyright (c) 2002 Jorge Acereda & - Peter O'Gorman - -Portions may be copyright others, see the AUTHORS file included with this -distribution. - -Maintained by Peter O'Gorman - -Bug Reports and other queries should go to - - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - diff --git a/Modules/_ctypes/darwin/README b/Modules/_ctypes/darwin/README deleted file mode 100644 index 4d63f3dfa5e..00000000000 --- a/Modules/_ctypes/darwin/README +++ /dev/null @@ -1,95 +0,0 @@ -dlcompat for Darwin -========================= - -This is dlcompat, a small library that emulates the dlopen() -interface on top of Darwin's dyld API. - -dlcompat allows loading a ".dylib" library (as long as the RTLD_LOCAL -flag isn't passed to dlopen()). It can be configured to yield a warning -when trying to close it (dynamic libraries cannot currently be unloaded). - -It automatically searches for modules in several directories when no -absolute path is specified and the module is not found in the current -directory. - -The paths searched are those specified in the environment variables -LD_LIBRARY_PATH and DYLD_LIBRARY_PATH plus /lib, /usr/local/lib and -/usr/lib or the path specified in the environment variable -DYLD_FALLBACK_LIBRARY_PATH. - -In the default install the behavior of dlsym is to automatically prepend -an underscore to passed in symbol names, this allows easier porting of -applications which were written specifically for ELF based lifeforms. - -Installation --------------- -Type: - ./configure - make - sudo make install - -This will compile the source file, generate both a static and shared -library called libdl and install it into /usr/local/lib. The header -file dlfcn.h will be installed in /usr/local/include. - -If you want to place the files somewhere else, run - - make clean - ./configure --prefix= - make - sudo make install - -where is the hierarchy you want to install into, e.g. /usr -for /usr/lib and /usr/include (_NOT_ recommended!). - -To enable debugging output (useful for me), run - - make clean - ./configure --enable-debug - make - sudo make install - -If you want old dlcompat style behavior of not prepending the underscore -on calls to dlsym then type: - - make clean - ./configure --enable-fink - make - sudo make install - -Usage -------- -Software that uses GNU autoconf will likely check for a library called -libdl, that's why I named it that way. For software that doesn't find -the library on its own, you must add a '-ldl' to the appropriate -Makefile (or environment) variable, usually LIBS. - -If you installed dlcompat into a directory other than /usr/local/lib, -you must tell the compiler where to find it. Add '-L/lib' to -LDFLAGS (or CFLAGS) and '-I/include' to CPPFLAGS (or CFLAGS). - -Notes ------ -If you are writing new software and plan to have Mac OX X compatibility you -should look at the dyld api's in /usr/include/mach-o/dyld.h, rather than -using dlcompat, using the native api's is the supported method of loading -dynamically on Mac OS X, if you want an small example, look at dlfcn_simple.c, -which should help get you started. - -Also note that the functions in dlcompat are not thread safe, and while it is not -POSIX spec compliant, it is about as close to compliance as it is going to get though. - -You can always get the latest version from opendarwin cvs: - - cvs -d :pserver:anonymous@anoncvs.opendarwin.org:/cvs/od login - cvs -z3 -d :pserver:anonymous@anoncvs.opendarwin.org:/cvs/od \ - co -d dlcompat proj/dlcompat - - -It is hoped that this library will be useful, and as bug free as possible, if you find -any bugs please let us know about them so they can be fixed. - -Please send bug reports to Peter O'Gorman - -Thanks. - diff --git a/Modules/_ctypes/darwin/README.ctypes b/Modules/_ctypes/darwin/README.ctypes deleted file mode 100644 index 8520b01f49d..00000000000 --- a/Modules/_ctypes/darwin/README.ctypes +++ /dev/null @@ -1,11 +0,0 @@ -The files in this directory are taken from -http://www.opendarwin.org/cgi-bin/cvsweb.cgi/~checkout~/proj/dlcompat/ - -The LICENSE in this directory applies to these files. - -Thomas Heller, Jan 2003 - -These files have been modified so they fall back to the system -dlfcn calls if available in libSystem. - -Bob Ippolito, Feb 2006 diff --git a/Modules/_ctypes/darwin/dlfcn.h b/Modules/_ctypes/darwin/dlfcn.h deleted file mode 100644 index a2afc3eeb84..00000000000 --- a/Modules/_ctypes/darwin/dlfcn.h +++ /dev/null @@ -1,84 +0,0 @@ -/* -Copyright (c) 2002 Jorge Acereda & - Peter O'Gorman - -Portions may be copyright others, see the AUTHORS file included with this -distribution. - -Maintained by Peter O'Gorman - -Bug Reports and other queries should go to - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ -#ifndef _DLFCN_H_ -#define _DLFCN_H_ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - - -/* - * Structure filled in by dladdr(). - */ - -typedef struct dl_info { - const char *dli_fname; /* Pathname of shared object */ - void *dli_fbase; /* Base address of shared object */ - const char *dli_sname; /* Name of nearest symbol */ - void *dli_saddr; /* Address of nearest symbol */ -} Dl_info; - - -#if MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_2 -#warning CTYPES_DARWIN_DLFCN -#define CTYPES_DARWIN_DLFCN -extern void * (*ctypes_dlopen)(const char *path, int mode); -extern void * (*ctypes_dlsym)(void * handle, const char *symbol); -extern const char * (*ctypes_dlerror)(void); -extern int (*ctypes_dlclose)(void * handle); -extern int (*ctypes_dladdr)(const void *, Dl_info *); -#else -extern void * dlopen(const char *path, int mode); -extern void * dlsym(void * handle, const char *symbol); -extern const char * dlerror(void); -extern int dlclose(void * handle); -extern int dladdr(const void *, Dl_info *); -#endif - -#define RTLD_LAZY 0x1 -#define RTLD_NOW 0x2 -#define RTLD_LOCAL 0x4 -#define RTLD_GLOBAL 0x8 -#define RTLD_NOLOAD 0x10 -#define RTLD_NODELETE 0x80 - -/* These are from the Mac OS X 10.4 headers */ -#define RTLD_NEXT ((void *) -1) /* Search subsequent objects. */ -#define RTLD_DEFAULT ((void *) -2) /* Use default search algorithm. */ - -#ifdef __cplusplus -} -#endif - -#endif /* _DLFCN_H_ */ diff --git a/Modules/_ctypes/darwin/dlfcn_simple.c b/Modules/_ctypes/darwin/dlfcn_simple.c deleted file mode 100644 index 2b293bb8695..00000000000 --- a/Modules/_ctypes/darwin/dlfcn_simple.c +++ /dev/null @@ -1,272 +0,0 @@ -/* -Copyright (c) 2002 Peter O'Gorman - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - - -/* Just to prove that it isn't that hard to add Mac calls to your code :) - This works with pretty much everything, including kde3 xemacs and the gimp, - I'd guess that it'd work in at least 95% of cases, use this as your starting - point, rather than the mess that is dlfcn.c, assuming that your code does not - require ref counting or symbol lookups in dependent libraries -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "dlfcn.h" - -#ifdef CTYPES_DARWIN_DLFCN - -#define ERR_STR_LEN 256 - -#ifndef MAC_OS_X_VERSION_10_3 -#define MAC_OS_X_VERSION_10_3 1030 -#endif - -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3 -#define DARWIN_HAS_DLOPEN -extern void * dlopen(const char *path, int mode) __attribute__((weak_import)); -extern void * dlsym(void * handle, const char *symbol) __attribute__((weak_import)); -extern const char * dlerror(void) __attribute__((weak_import)); -extern int dlclose(void * handle) __attribute__((weak_import)); -extern int dladdr(const void *, Dl_info *) __attribute__((weak_import)); -#endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3 */ - -#ifndef DARWIN_HAS_DLOPEN -#define dlopen darwin_dlopen -#define dlsym darwin_dlsym -#define dlerror darwin_dlerror -#define dlclose darwin_dlclose -#define dladdr darwin_dladdr -#endif - -void * (*ctypes_dlopen)(const char *path, int mode); -void * (*ctypes_dlsym)(void * handle, const char *symbol); -const char * (*ctypes_dlerror)(void); -int (*ctypes_dlclose)(void * handle); -int (*ctypes_dladdr)(const void *, Dl_info *); - -#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_3 -/* Mac OS X 10.3+ has dlopen, so strip all this dead code to avoid warnings */ - -static void *dlsymIntern(void *handle, const char *symbol); - -static const char *error(int setget, const char *str, ...); - -/* Set and get the error string for use by dlerror */ -static const char *error(int setget, const char *str, ...) -{ - static char errstr[ERR_STR_LEN]; - static int err_filled = 0; - const char *retval; - va_list arg; - if (setget == 0) - { - va_start(arg, str); - strncpy(errstr, "dlcompat: ", ERR_STR_LEN); - vsnprintf(errstr + 10, ERR_STR_LEN - 10, str, arg); - va_end(arg); - err_filled = 1; - retval = NULL; - } - else - { - if (!err_filled) - retval = NULL; - else - retval = errstr; - err_filled = 0; - } - return retval; -} - -/* darwin_dlopen */ -static void *darwin_dlopen(const char *path, int mode) -{ - void *module = 0; - NSObjectFileImage ofi = 0; - NSObjectFileImageReturnCode ofirc; - - /* If we got no path, the app wants the global namespace, use -1 as the marker - in this case */ - if (!path) - return (void *)-1; - - /* Create the object file image, works for things linked with the -bundle arg to ld */ - ofirc = NSCreateObjectFileImageFromFile(path, &ofi); - switch (ofirc) - { - case NSObjectFileImageSuccess: - /* It was okay, so use NSLinkModule to link in the image */ - module = NSLinkModule(ofi, path, - NSLINKMODULE_OPTION_RETURN_ON_ERROR - | (mode & RTLD_GLOBAL) ? 0 : NSLINKMODULE_OPTION_PRIVATE - | (mode & RTLD_LAZY) ? 0 : NSLINKMODULE_OPTION_BINDNOW); - NSDestroyObjectFileImage(ofi); - break; - case NSObjectFileImageInappropriateFile: - /* It may have been a dynamic library rather than a bundle, try to load it */ - module = (void *)NSAddImage(path, NSADDIMAGE_OPTION_RETURN_ON_ERROR); - break; - default: - /* God knows what we got */ - error(0, "Can not open \"%s\"", path); - return 0; - } - if (!module) - error(0, "Can not open \"%s\"", path); - return module; - -} - -/* dlsymIntern is used by dlsym to find the symbol */ -static void *dlsymIntern(void *handle, const char *symbol) -{ - NSSymbol nssym = 0; - /* If the handle is -1, if is the app global context */ - if (handle == (void *)-1) - { - /* Global context, use NSLookupAndBindSymbol */ - if (NSIsSymbolNameDefined(symbol)) - { - nssym = NSLookupAndBindSymbol(symbol); - } - - } - /* Now see if the handle is a struch mach_header* or not, use NSLookupSymbol in image - for libraries, and NSLookupSymbolInModule for bundles */ - else - { - /* Check for both possible magic numbers depending on x86/ppc byte order */ - if ((((struct mach_header *)handle)->magic == MH_MAGIC) || - (((struct mach_header *)handle)->magic == MH_CIGAM)) - { - if (NSIsSymbolNameDefinedInImage((struct mach_header *)handle, symbol)) - { - nssym = NSLookupSymbolInImage((struct mach_header *)handle, - symbol, - NSLOOKUPSYMBOLINIMAGE_OPTION_BIND - | NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR); - } - - } - else - { - nssym = NSLookupSymbolInModule(handle, symbol); - } - } - if (!nssym) - { - error(0, "Symbol \"%s\" Not found", symbol); - return NULL; - } - return NSAddressOfSymbol(nssym); -} - -static const char *darwin_dlerror(void) -{ - return error(1, (char *)NULL); -} - -static int darwin_dlclose(void *handle) -{ - if ((((struct mach_header *)handle)->magic == MH_MAGIC) || - (((struct mach_header *)handle)->magic == MH_CIGAM)) - { - error(0, "Can't remove dynamic libraries on darwin"); - return 0; - } - if (!NSUnLinkModule(handle, 0)) - { - error(0, "unable to unlink module %s", NSNameOfModule(handle)); - return 1; - } - return 0; -} - - -/* dlsym, prepend the underscore and call dlsymIntern */ -static void *darwin_dlsym(void *handle, const char *symbol) -{ - static char undersym[257]; /* Saves calls to malloc(3) */ - int sym_len = strlen(symbol); - void *value = NULL; - char *malloc_sym = NULL; - - if (sym_len < 256) - { - snprintf(undersym, 256, "_%s", symbol); - value = dlsymIntern(handle, undersym); - } - else - { - malloc_sym = malloc(sym_len + 2); - if (malloc_sym) - { - sprintf(malloc_sym, "_%s", symbol); - value = dlsymIntern(handle, malloc_sym); - free(malloc_sym); - } - else - { - error(0, "Unable to allocate memory"); - } - } - return value; -} - -static int darwin_dladdr(const void *handle, Dl_info *info) { - return 0; -} -#endif /* MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_3 */ - -#if __GNUC__ < 4 -#pragma CALL_ON_LOAD ctypes_dlfcn_init -#else -static void __attribute__ ((constructor)) ctypes_dlfcn_init(void); -static -#endif -void ctypes_dlfcn_init(void) { - if (dlopen != NULL) { - ctypes_dlsym = dlsym; - ctypes_dlopen = dlopen; - ctypes_dlerror = dlerror; - ctypes_dlclose = dlclose; - ctypes_dladdr = dladdr; - } else { -#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_3 - ctypes_dlsym = darwin_dlsym; - ctypes_dlopen = darwin_dlopen; - ctypes_dlerror = darwin_dlerror; - ctypes_dlclose = darwin_dlclose; - ctypes_dladdr = darwin_dladdr; -#endif /* MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_3 */ - } -} - -#endif /* CTYPES_DARWIN_DLFCN */ diff --git a/PCbuild/_ctypes.vcxproj b/PCbuild/_ctypes.vcxproj index 6ac26f1916c..253da31e9ce 100644 --- a/PCbuild/_ctypes.vcxproj +++ b/PCbuild/_ctypes.vcxproj @@ -102,7 +102,6 @@ - diff --git a/PCbuild/_ctypes.vcxproj.filters b/PCbuild/_ctypes.vcxproj.filters index 118c4f0698c..a38473e3e81 100644 --- a/PCbuild/_ctypes.vcxproj.filters +++ b/PCbuild/_ctypes.vcxproj.filters @@ -15,9 +15,6 @@ Header Files - - Header Files - diff --git a/Tools/c-analyzer/cpython/_parser.py b/Tools/c-analyzer/cpython/_parser.py index ac1721c061f..ab1d6257f1b 100644 --- a/Tools/c-analyzer/cpython/_parser.py +++ b/Tools/c-analyzer/cpython/_parser.py @@ -51,7 +51,6 @@ def clean_lines(text): # @begin=conf@ # OSX -#Modules/_ctypes/darwin/*.c Modules/_scproxy.c # SystemConfiguration/SystemConfiguration.h # Windows diff --git a/configure b/configure index 6afd1e9c367..946218fd8d8 100755 --- a/configure +++ b/configure @@ -12802,8 +12802,7 @@ if test "x$have_libffi" = xyes; then : case $ac_sys_system in #( Darwin) : - as_fn_append LIBFFI_CFLAGS " -I\$(srcdir)/Modules/_ctypes/darwin" - ctypes_malloc_closure=yes + ctypes_malloc_closure=yes ;; #( sunos5) : as_fn_append LIBFFI_LIBS " -mimpure-text" diff --git a/configure.ac b/configure.ac index 48736649a98..22028972cb3 100644 --- a/configure.ac +++ b/configure.ac @@ -3741,7 +3741,6 @@ AS_VAR_IF([have_libffi], [yes], [ AS_CASE([$ac_sys_system], [Darwin], [ dnl when do we need USING_APPLE_OS_LIBFFI? - AS_VAR_APPEND([LIBFFI_CFLAGS], [" -I\$(srcdir)/Modules/_ctypes/darwin"]) ctypes_malloc_closure=yes ], [sunos5], [AS_VAR_APPEND([LIBFFI_LIBS], [" -mimpure-text"])]