summaryrefslogtreecommitdiffstats
path: root/Modules/_ctypes
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2022-02-07 00:46:51 (GMT)
committerGitHub <noreply@github.com>2022-02-07 00:46:51 (GMT)
commitb556f53785cb9ad8cc088ad8c10efee91fe3da58 (patch)
tree7f2cfe2176fcaa50254a755801f3506d5f3aa569 /Modules/_ctypes
parent097f74a5a37e2a8a26d529cede456ede7011b66f (diff)
downloadcpython-b556f53785cb9ad8cc088ad8c10efee91fe3da58.zip
cpython-b556f53785cb9ad8cc088ad8c10efee91fe3da58.tar.gz
cpython-b556f53785cb9ad8cc088ad8c10efee91fe3da58.tar.bz2
bpo-46670: Test if a macro is defined, not its value (GH-31178)
* audioop.c: #ifdef WORDS_BIGENDIAN * ctypes.h: #ifdef USING_MALLOC_CLOSURE_DOT_C * _ctypes/malloc_closure.c: #ifdef HAVE_FFI_CLOSURE_ALLOC and #ifdef USING_APPLE_OS_LIBFFI * pytime.c: #ifdef __APPLE__ * unicodeobject.c: #ifdef HAVE_NON_UNICODE_WCHAR_T_REPRESENTATION
Diffstat (limited to 'Modules/_ctypes')
-rw-r--r--Modules/_ctypes/callbacks.c4
-rw-r--r--Modules/_ctypes/callproc.c2
-rw-r--r--Modules/_ctypes/ctypes.h2
-rw-r--r--Modules/_ctypes/malloc_closure.c12
4 files changed, 10 insertions, 10 deletions
diff --git a/Modules/_ctypes/callbacks.c b/Modules/_ctypes/callbacks.c
index 01d7037..b4079ee 100644
--- a/Modules/_ctypes/callbacks.c
+++ b/Modules/_ctypes/callbacks.c
@@ -418,7 +418,7 @@ CThunkObject *_ctypes_alloc_callback(PyObject *callable,
goto error;
}
#if HAVE_FFI_PREP_CLOSURE_LOC
-# if USING_APPLE_OS_LIBFFI
+# ifdef USING_APPLE_OS_LIBFFI
# define HAVE_FFI_PREP_CLOSURE_LOC_RUNTIME __builtin_available(macos 10.15, ios 13, watchos 6, tvos 13, *)
# else
# define HAVE_FFI_PREP_CLOSURE_LOC_RUNTIME 1
@@ -430,7 +430,7 @@ CThunkObject *_ctypes_alloc_callback(PyObject *callable,
} else
#endif
{
-#if USING_APPLE_OS_LIBFFI && defined(__arm64__)
+#if defined(USING_APPLE_OS_LIBFFI) && defined(__arm64__)
PyErr_Format(PyExc_NotImplementedError, "ffi_prep_closure_loc() is missing");
goto error;
#else
diff --git a/Modules/_ctypes/callproc.c b/Modules/_ctypes/callproc.c
index e220496..928737e 100644
--- a/Modules/_ctypes/callproc.c
+++ b/Modules/_ctypes/callproc.c
@@ -826,7 +826,7 @@ static int _call_function_pointer(int flags,
cc = FFI_STDCALL;
#endif
-# if USING_APPLE_OS_LIBFFI
+# ifdef USING_APPLE_OS_LIBFFI
# define HAVE_FFI_PREP_CIF_VAR_RUNTIME __builtin_available(macos 10.15, ios 13, watchos 6, tvos 13, *)
# elif HAVE_FFI_PREP_CIF_VAR
# define HAVE_FFI_PREP_CIF_VAR_RUNTIME true
diff --git a/Modules/_ctypes/ctypes.h b/Modules/_ctypes/ctypes.h
index 9600ddc..9e82ce8 100644
--- a/Modules/_ctypes/ctypes.h
+++ b/Modules/_ctypes/ctypes.h
@@ -362,7 +362,7 @@ PyObject *_ctypes_get_errobj(int **pspace);
extern PyObject *ComError;
#endif
-#if USING_MALLOC_CLOSURE_DOT_C
+#ifdef USING_MALLOC_CLOSURE_DOT_C
void Py_ffi_closure_free(void *p);
void *Py_ffi_closure_alloc(size_t size, void** codeloc);
#else
diff --git a/Modules/_ctypes/malloc_closure.c b/Modules/_ctypes/malloc_closure.c
index 788bae6..38edc90 100644
--- a/Modules/_ctypes/malloc_closure.c
+++ b/Modules/_ctypes/malloc_closure.c
@@ -91,13 +91,13 @@ static void more_core(void)
/* put the item back into the free list */
void Py_ffi_closure_free(void *p)
{
-#if HAVE_FFI_CLOSURE_ALLOC
-#if USING_APPLE_OS_LIBFFI
+#ifdef HAVE_FFI_CLOSURE_ALLOC
+#ifdef USING_APPLE_OS_LIBFFI
if (__builtin_available(macos 10.15, ios 13, watchos 6, tvos 13, *)) {
#endif
ffi_closure_free(p);
return;
-#if USING_APPLE_OS_LIBFFI
+#ifdef USING_APPLE_OS_LIBFFI
}
#endif
#endif
@@ -109,12 +109,12 @@ void Py_ffi_closure_free(void *p)
/* return one item from the free list, allocating more if needed */
void *Py_ffi_closure_alloc(size_t size, void** codeloc)
{
-#if HAVE_FFI_CLOSURE_ALLOC
-#if USING_APPLE_OS_LIBFFI
+#ifdef HAVE_FFI_CLOSURE_ALLOC
+#ifdef USING_APPLE_OS_LIBFFI
if (__builtin_available(macos 10.15, ios 13, watchos 6, tvos 13, *)) {
#endif
return ffi_closure_alloc(size, codeloc);
-#if USING_APPLE_OS_LIBFFI
+#ifdef USING_APPLE_OS_LIBFFI
}
#endif
#endif