8000 gh-125206: Bug in ctypes with old libffi is fixed by efimov-mikhail · Pull Request #125322 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-125206: Bug in ctypes with old libffi is fixed #125322

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
gh-125206: Py_FFI_TARGET_HAS_COMPLEX_TYPE -> Py_FFI_SUPPORT_C_COMPLEX
  • Loading branch information
efimov-mikhail committed Oct 11, 2024
commit f0f54e22d5567c67a7a4e3f41f573a12f76baa6e
2 changes: 1 addition & 1 deletion Modules/_ctypes/_ctypes.c
Original file line number Diff line number Diff line change
Expand Up @@ -1747,7 +1747,7 @@ class _ctypes.c_void_p "PyObject *" "clinic_state_sub()->PyCSimpleType_Type"
[clinic start generated code]*/
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=dd4d9646c56f43a9]*/

#if defined(Py_HAVE_C_COMPLEX) && defined(Py_FFI_TARGET_HAS_COMPLEX_TYPE)
#if defined(Py_HAVE_C_COMPLEX) && defined(Py_FFI_SUPPORT_C_COMPLEX)
static const char SIMPLE_TYPE_CHARS[] = "cbBhHiIlLdCEFfuzZqQPXOv?g";
#else
static const char SIMPLE_TYPE_CHARS[] = "cbBhHiIlLdfuzZqQPXOv?g";
Expand Down
4 changes: 2 additions & 2 deletions Modules/_ctypes/_ctypes_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

#include <Python.h>

#if defined(Py_HAVE_C_COMPLEX) && defined(Py_FFI_TARGET_HAS_COMPLEX_TYPE)
#if defined(Py_HAVE_C_COMPLEX) && defined(Py_FFI_SUPPORT_C_COMPLEX)
# include "../_complex.h" // csqrt()
# undef I // for _ctypes_test_generated.c.h
#endif
Expand Down Expand Up @@ -447,7 +447,7 @@ EXPORT(double) my_sqrt(double a)
return sqrt(a);
}

#if defined(Py_HAVE_C_COMPLEX) && defined(Py_FFI_TARGET_HAS_COMPLEX_TYPE)
#if defined(Py_HAVE_C_COMPLEX) && defined(Py_FFI_SUPPORT_C_COMPLEX)
EXPORT(double complex) my_csqrt(double complex a)
{
return csqrt(a);
Expand Down
4 changes: 2 additions & 2 deletions Modules/_ctypes/callproc.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ module _ctypes
#include "pycore_global_objects.h"// _Py_ID()
#include "pycore_traceback.h" // _PyTraceback_Add()

#if defined(Py_HAVE_C_COMPLEX) && defined(Py_FFI_TARGET_HAS_COMPLEX_TYPE)
#if defined(Py_HAVE_C_COMPLEX) && defined(Py_FFI_SUPPORT_C_COMPLEX)
#include "../_complex.h" // complex
#endif

Expand Down Expand Up @@ -655,7 +655,7 @@ union result {
double d;
float f;
void *p;
#if defined(Py_HAVE_C_COMPLEX) && defined(Py_FFI_TARGET_HAS_COMPLEX_TYPE)
#if defined(Py_HAVE_C_COMPLEX) && defined(Py_FFI_SUPPORT_C_COMPLEX)
double complex C;
float complex E;
long double complex F;
Expand Down
8 changes: 4 additions & 4 deletions Modules/_ctypes/cfield.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include <ffi.h>
#include "ctypes.h"

#if defined(Py_HAVE_C_COMPLEX) && defined(Py_FFI_TARGET_HAS_COMPLEX_TYPE)
#if defined(Py_HAVE_C_COMPLEX) && defined(Py_FFI_SUPPORT_C_COMPLEX)
# include "../_complex.h" // complex
#endif

8000 Expand Down Expand Up @@ -972,7 +972,7 @@ d_get(void *ptr, Py_ssize_t size)
return PyFloat_FromDouble(val);
}

#if defined(Py_HAVE_C_COMPLEX) && defined(Py_FFI_TARGET_HAS_COMPLEX_TYPE)
#if defined(Py_HAVE_C_COMPLEX) && defined(Py_FFI_SUPPORT_C_COMPLEX)
static PyObject *
C_set(void *ptr, PyObject *value, Py_ssize_t size)
{
Expand Down Expand Up @@ -1545,7 +1545,7 @@ static struct fielddesc formattable[] = {
{ 'B', B_set, B_get, NULL},
{ 'c', c_set, c_get, NULL},
{ 'd', d_set, d_get, NULL, d_set_sw, d_get_sw},
#if defined(Py_HAVE_C_COMPLEX) && defined(Py_FFI_TARGET_HAS_COMPLEX_TYPE)
#if defined(Py_HAVE_C_COMPLEX) && defined(Py_FFI_SUPPORT_C_COMPLEX)
{ 'C', C_set, C_get, NULL},
{ 'E', E_set, E_get, NULL},
{ 'F', F_set, F_get, NULL},
Expand Down Expand Up @@ -1600,7 +1600,7 @@ _ctypes_init_fielddesc(void)
case 'B': fd->pffi_type = &ffi_type_uchar; break;
case 'c': fd->pffi_type = &ffi_type_schar; break;
case 'd': fd->pffi_type = &ffi_type_double; break;
#if defined(Py_HAVE_C_COMPLEX) && defined(Py_FFI_TARGET_HAS_COMPLEX_TYPE)
#if defined(Py_HAVE_C_COMPLEX) && defined(Py_FFI_SUPPORT_C_COMPLEX)
case 'C': fd->pffi_type = &ffi_type_complex_double; break;
case 'E': fd->pffi_type = &ffi_type_complex_float; break;
case 'F': fd->pffi_type = &ffi_type_complex_longdouble; break;
Expand Down
4 changes: 2 additions & 2 deletions Modules/_ctypes/ctypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "pycore_moduleobject.h" // _PyModule_GetState()
#include "pycore_typeobject.h" // _PyType_GetModuleState()

#if defined(Py_HAVE_C_COMPLEX) && defined(Py_FFI_TARGET_HAS_COMPLEX_TYPE)
#if defined(Py_HAVE_C_COMPLEX) && defined(Py_FFI_SUPPORT_C_COMPLEX)
# include "../_complex.h" // complex
#endif

Expand Down Expand Up @@ -386,7 +386,7 @@ struct tagPyCArgObject {
double d;
float f;
void *p;
#if defined(Py_HAVE_C_COMPLEX) && defined(Py_FFI_TARGET_HAS_COMPLEX_TYPE)
#if defined(Py_HAVE_C_COMPLEX) && defined(Py_FFI_SUPPORT_C_COMPLEX)
double complex C;
float complex E;
long double complex F;
Expand Down
2 changes: 1 addition & 1 deletion configure

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -4124,7 +4124,7 @@ int main(void)
[ac_cv_ffi_complex_double_supported=no])
CC="$ac_save_cc"])
if test "$ac_cv_ffi_complex_double_supported" = "yes"; then
AC_DEFINE([Py_FFI_TARGET_HAS_COMPLEX_TYPE], [1],
AC_DEFINE([Py_FFI_SUPPORT_C_COMPLEX], [1],
[Defined if _Complex C type can be used with libffi.])
fi

Expand Down
2 changes: 1 addition & 1 deletion pyconfig.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -1683,7 +1683,7 @@
#undef Py_ENABLE_SHARED

/* Defined if _Complex C type can be used with libffi. */
#undef Py_FFI_TARGET_HAS_COMPLEX_TYPE
#undef Py_FFI_SUPPORT_C_COMPLEX

/* Define if you want to disable the GIL */
#undef Py_GIL_DISABLED
Expand Down
Loading
0