diff --git a/Include/internal/pycore_object.h b/Include/internal/pycore_object.h index 41786cb267c2e9..3ecc5e9f0554b0 100644 --- a/Include/internal/pycore_object.h +++ b/Include/internal/pycore_object.h @@ -957,7 +957,8 @@ extern int _PyObject_IsInstanceDictEmpty(PyObject *); // Export for 'math' shared extension PyAPI_FUNC(PyObject*) _PyObject_LookupSpecial(PyObject *, PyObject *); -PyAPI_FUNC(int) _PyObject_LookupSpecialMethod(PyObject *attr, _PyStackRef *method_and_self); +PyAPI_FUNC(int) _PyObject_LookupSpecialMethod(PyObject *attr, _PyStackRef *method, + _PyStackRef *self); // Calls the method named `attr` on `self`, but does not set an exception if // the attribute does not exist. diff --git a/Include/internal/pycore_unicodeobject.h b/Include/internal/pycore_unicodeobject.h index ff3fda8583133e..c091aa94371a75 100644 --- a/Include/internal/pycore_unicodeobject.h +++ b/Include/internal/pycore_unicodeobject.h @@ -244,7 +244,7 @@ extern int _PyUnicodeWriter_FormatV( /* --- iconv Codec -------------------------------------------------------- */ -#ifdef HAVE_ICONV +#ifdef _Py_HAVE_ICONV extern PyObject* _PyUnicode_DecodeIconv( const char *encoding, /* iconv encoding name */ const char *string, /* encoded string */ diff --git a/Lib/test/test_external_inspection.py b/Lib/test/test_external_inspection.py index 1fed0f9175e8e1..fd647153f92be6 100644 --- a/Lib/test/test_external_inspection.py +++ b/Lib/test/test_external_inspection.py @@ -447,14 +447,15 @@ def test_long_task_name_is_truncated(self): async def main(): asyncio.create_task(asyncio.sleep(10_000), name="x" * 300) await asyncio.sleep(0) - return [ + names = [ task.task_name for info in RemoteUnwinder(os.getpid()).get_all_awaited_by() for task in info.awaited_by ] + return asyncio.current_task().get_name(), names - names = asyncio.run(main()) - self.assertIn("Task-1", names) + main_name, names = asyncio.run(main()) + self.assertIn(main_name, names) self.assertEqual([len(n) for n in names if n.startswith("x")], [255]) @skip_if_not_supported diff --git a/Modules/_codecsmodule.c b/Modules/_codecsmodule.c index 7cba234fc80b59..dd0ace58cf42fd 100644 --- a/Modules/_codecsmodule.c +++ b/Modules/_codecsmodule.c @@ -642,7 +642,7 @@ _codecs_code_page_decode_impl(PyObject *module, int codepage, #endif /* MS_WINDOWS */ -#ifdef HAVE_ICONV +#ifdef _Py_HAVE_ICONV /*[clinic input] _codecs.iconv_decode @@ -665,7 +665,7 @@ _codecs_iconv_decode_impl(PyObject *module, const char *encoding, return codec_tuple(decoded, consumed); } -#endif /* HAVE_ICONV */ +#endif /* _Py_HAVE_ICONV */ /* --- Encoder ------------------------------------------------------------ */ @@ -977,7 +977,7 @@ _codecs_code_page_encode_impl(PyObject *module, int code_page, PyObject *str, #endif /* MS_WINDOWS */ -#ifdef HAVE_ICONV +#ifdef _Py_HAVE_ICONV /*[clinic input] _codecs.iconv_encode @@ -996,7 +996,7 @@ _codecs_iconv_encode_impl(PyObject *module, const char *encoding, PyUnicode_GET_LENGTH(str)); } -#endif /* HAVE_ICONV */ +#endif /* _Py_HAVE_ICONV */ /* --- Error handler registry --------------------------------------------- */ diff --git a/Modules/_testinternalcapi/test_cases.c.h b/Modules/_testinternalcapi/test_cases.c.h index 7a75e80298fcd8..a04770bd83b176 100644 --- a/Modules/_testinternalcapi/test_cases.c.h +++ b/Modules/_testinternalcapi/test_cases.c.h @@ -10357,7 +10357,8 @@ ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__); _PyFrame_SetStackPointer(frame, stack_pointer); _PyFrame_StackPointerValidate(frame); - int err = _PyObject_LookupSpecialMethod(name, method_and_self); + int err = _PyObject_LookupSpecialMethod(name, &method_and_self[0], + &method_and_self[1]); _PyFrame_StackPointerInvalidate(frame); if (err <= 0) { if (err == 0) { diff --git a/Modules/clinic/_codecsmodule.c.h b/Modules/clinic/_codecsmodule.c.h index 788b9b706c8fbb..5ca9614f7f3216 100644 --- a/Modules/clinic/_codecsmodule.c.h +++ b/Modules/clinic/_codecsmodule.c.h @@ -1629,7 +1629,7 @@ _codecs_code_page_decode(PyObject *module, PyObject *const *args, Py_ssize_t nar #endif /* defined(MS_WINDOWS) */ -#if defined(HAVE_ICONV) +#if defined(_Py_HAVE_ICONV) PyDoc_STRVAR(_codecs_iconv_decode__doc__, "iconv_decode($module, encoding, data, errors=None, final=False, /)\n" @@ -1711,7 +1711,7 @@ _codecs_iconv_decode(PyObject *module, PyObject *const *args, Py_ssize_t nargs) return return_value; } -#endif /* defined(HAVE_ICONV) */ +#endif /* defined(_Py_HAVE_ICONV) */ PyDoc_STRVAR(_codecs_readbuffer_encode__doc__, "readbuffer_encode($module, data, errors=None, /)\n" @@ -2727,7 +2727,7 @@ _codecs_code_page_encode(PyObject *module, PyObject *const *args, Py_ssize_t nar #endif /* defined(MS_WINDOWS) */ -#if defined(HAVE_ICONV) +#if defined(_Py_HAVE_ICONV) PyDoc_STRVAR(_codecs_iconv_encode__doc__, "iconv_encode($module, encoding, str, errors=None, /)\n" @@ -2798,7 +2798,7 @@ _codecs_iconv_encode(PyObject *module, PyObject *const *args, Py_ssize_t nargs) return return_value; } -#endif /* defined(HAVE_ICONV) */ +#endif /* defined(_Py_HAVE_ICONV) */ PyDoc_STRVAR(_codecs_register_error__doc__, "register_error($module, errors, handler, /)\n" @@ -3033,4 +3033,4 @@ _codecs__normalize_encoding(PyObject *module, PyObject *const *args, Py_ssize_t #ifndef _CODECS_ICONV_ENCODE_METHODDEF #define _CODECS_ICONV_ENCODE_METHODDEF #endif /* !defined(_CODECS_ICONV_ENCODE_METHODDEF) */ -/*[clinic end generated code: output=912e04020d6a6144 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=d6e155d435335482 input=a9049054013a1b77]*/ diff --git a/Modules/mathmodule.c b/Modules/mathmodule.c index 16e7231214af2d..5e100da7a42417 100644 --- a/Modules/mathmodule.c +++ b/Modules/mathmodule.c @@ -212,7 +212,7 @@ static const double logpi = 1.144729885849400174143427351353058711647; } \ } -#ifndef HAVE_ACOSPI +#ifndef _Py_HAVE_ACOSPI /* acos(x)/pi. It conforms to C23 Annex 'F'. */ @@ -236,7 +236,7 @@ m_acospi(double x) #define m_acospi acospi #endif -#ifndef HAVE_ASINPI +#ifndef _Py_HAVE_ASINPI /* asin(x)/pi. It conforms to C23 Annex 'F'. */ @@ -254,7 +254,7 @@ m_asinpi(double x) #define m_asinpi asinpi #endif -#ifndef HAVE_ATANPI +#ifndef _Py_HAVE_ATANPI /* atan(x)/pi. It conforms to C23 Annex 'F'. */ @@ -272,7 +272,7 @@ m_atanpi(double x) #define m_atanpi atanpi #endif -#ifndef HAVE_ATAN2PI +#ifndef _Py_HAVE_ATAN2PI /* atan2(y, x)/pi. It conforms to C23 Annex 'F'. */ @@ -290,7 +290,7 @@ m_atan2pi(double y, double x) #define m_atan2pi atan2pi #endif -#ifndef HAVE_COSPI +#ifndef _Py_HAVE_COSPI /* cos(pi*x), giving accurate results for all finite x (especially x integral or close to an integer). It conforms to C23 Annex 'F'. @@ -318,7 +318,7 @@ m_cospi(double x) #define m_cospi cospi #endif -#ifndef HAVE_SINPI +#ifndef _Py_HAVE_SINPI /* sin(pi*x), giving accurate results for all finite x (especially x integral or close to an integer). It conforms to C23 Annex 'F'. @@ -362,7 +362,7 @@ m_sinpi(double x) #define m_sinpi sinpi #endif -#ifndef HAVE_TANPI +#ifndef _Py_HAVE_TANPI /* tan(pi*x), giving accurate results for all finite x (especially x integral or close to an integer). It conforms to C23 Annex 'F'. diff --git a/Objects/abstract.c b/Objects/abstract.c index 28f751965f36b9..da2a0b0c285b52 100644 --- a/Objects/abstract.c +++ b/Objects/abstract.c @@ -9,6 +9,7 @@ #include "pycore_list.h" // _PyList_AppendTakeRef() #include "pycore_long.h" // _PyLong_IsNegative() #include "pycore_object.h" // _Py_CheckSlotResult() +#include "pycore_stackref.h" // _PyStackRef #include "pycore_pybuffer.h" // _PyBuffer_ReleaseInInterpreterAndRawFree() #include "pycore_pyerrors.h" // _PyErr_Occurred() #include "pycore_pystate.h" // _PyThreadState_GET() @@ -2635,6 +2636,37 @@ object_isinstance(PyObject *inst, PyObject *cls) return retval; } +static int +call_special_method(PyThreadState *tstate, PyObject *cls, PyObject *name, + const char *where, PyObject *arg, PyObject **res) +{ + _PyCStackRef cref; + _PyThreadState_PushCStackRef(tstate, &cref); + _PyStackRef self = PyStackRef_FromPyObjectBorrow(cls); + int found = _PyObject_LookupSpecialMethod(name, &cref.ref, &self); + if (found > 0) { + *res = NULL; + if (!_Py_EnterRecursiveCallTstate(tstate, where)) { + PyObject *method = PyStackRef_AsPyObjectBorrow(cref.ref); + PyObject *args[2] = {PyStackRef_AsPyObjectBorrow(self), arg}; + if (args[0] != NULL) { + /* Unbound method: prepend self. */ + *res = PyObject_Vectorcall(method, args, 2, NULL); + } + else { + *res = PyObject_Vectorcall(method, args + 1, 1, NULL); + } + _Py_LeaveRecursiveCallTstate(tstate); + } + if (*res == NULL) { + found = -1; + } + } + PyStackRef_XCLOSE(self); + _PyThreadState_PopCStackRef(tstate, &cref); + return found; +} + static int object_recursive_isinstance(PyThreadState *tstate, PyObject *inst, PyObject *cls) { @@ -2672,26 +2704,16 @@ object_recursive_isinstance(PyThreadState *tstate, PyObject *inst, PyObject *cls return r; } - PyObject *checker = _PyObject_LookupSpecial(cls, &_Py_ID(__instancecheck__)); - if (checker != NULL) { - if (_Py_EnterRecursiveCallTstate(tstate, " in __instancecheck__")) { - Py_DECREF(checker); - return -1; - } - - PyObject *res = PyObject_CallOneArg(checker, inst); - _Py_LeaveRecursiveCallTstate(tstate); - Py_DECREF(checker); - - if (res == NULL) { - return -1; - } + PyObject *res; + int found = call_special_method(tstate, cls, &_Py_ID(__instancecheck__), + " in __instancecheck__", inst, &res); + if (found > 0) { int ok = PyObject_IsTrue(res); Py_DECREF(res); return ok; } - else if (_PyErr_Occurred(tstate)) { + else if (found < 0) { return -1; } @@ -2731,8 +2753,6 @@ recursive_issubclass(PyObject *derived, PyObject *cls) static int object_issubclass(PyThreadState *tstate, PyObject *derived, PyObject *cls) { - PyObject *checker; - /* We know what type's __subclasscheck__ does. */ if (PyType_CheckExact(cls)) { /* Quick test for an exact match */ @@ -2763,23 +2783,15 @@ object_issubclass(PyThreadState *tstate, PyObject *derived, PyObject *cls) return r; } - checker = _PyObject_LookupSpecial(cls, &_Py_ID(__subclasscheck__)); - if (checker != NULL) { - int ok = -1; - if (_Py_EnterRecursiveCallTstate(tstate, " in __subclasscheck__")) { - Py_DECREF(checker); - return ok; - } - PyObject *res = PyObject_CallOneArg(checker, derived); - _Py_LeaveRecursiveCallTstate(tstate); - Py_DECREF(checker); - if (res != NULL) { - ok = PyObject_IsTrue(res); - Py_DECREF(res); - } + PyObject *res; + int found = call_special_method(tstate, cls, &_Py_ID(__subclasscheck__), + " in __subclasscheck__", derived, &res); + if (found > 0) { + int ok = PyObject_IsTrue(res); + Py_DECREF(res); return ok; } - else if (_PyErr_Occurred(tstate)) { + else if (found < 0) { return -1; } diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 30958310227af0..b9e11426042407 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -2931,17 +2931,22 @@ _PyObject_LookupSpecial(PyObject *self, PyObject *attr) return res; } -// Lookup the method name `attr` on `self`. On entry, `method_and_self[0]` -// is null and `method_and_self[1]` is `self`. On exit, `method_and_self[0]` -// is the method object and `method_and_self[1]` is `self` if the method is -// not bound. +// Lookup the method name `attr` on `*self`. On entry, `*method` is null. +// On exit, `*method` is the method object and `*self` is cleared if the +// method is bound. // Return 1 on success, -1 on error, and 0 if the method is missing. +// +// `method` must point to a location that the garbage collector can see, +// such as the `ref` field of a `_PyCStackRef` or a slot on the interpreter +// stack. A descriptor may be invoked while `*method` holds the only +// reference to the method object, and that can trigger a collection. int -_PyObject_LookupSpecialMethod(PyObject *attr, _PyStackRef *method_and_self) +_PyObject_LookupSpecialMethod(PyObject *attr, _PyStackRef *method, + _PyStackRef *self) { - PyObject *self = PyStackRef_AsPyObjectBorrow(method_and_self[1]); - _PyType_LookupStackRefAndVersion(Py_TYPE(self), attr, &method_and_self[0]); - PyObject *method_o = PyStackRef_AsPyObjectBorrow(method_and_self[0]); + PyObject *self_o = PyStackRef_AsPyObjectBorrow(*self); + _PyType_LookupStackRefAndVersion(Py_TYPE(self_o), attr, method); + PyObject *method_o = PyStackRef_AsPyObjectBorrow(*method); if (method_o == NULL) { return 0; } @@ -2953,14 +2958,14 @@ _PyObject_LookupSpecialMethod(PyObject *attr, _PyStackRef *method_and_self) descrgetfunc f = Py_TYPE(method_o)->tp_descr_get; if (f != NULL) { - PyObject *func = f(method_o, self, (PyObject *)(Py_TYPE(self))); + PyObject *func = f(method_o, self_o, (PyObject *)(Py_TYPE(self_o))); if (func == NULL) { return -1; } - PyStackRef_CLEAR(method_and_self[0]); // clear method - method_and_self[0] = PyStackRef_FromPyObjectSteal(func); + PyStackRef_CLEAR(*method); // clear method + *method = PyStackRef_FromPyObjectSteal(func); } - PyStackRef_CLEAR(method_and_self[1]); // clear self + PyStackRef_CLEAR(*self); // clear self return 1; } diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index da9f8dcc223fc0..77de3f735cc42a 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -67,7 +67,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #endif -#ifdef HAVE_ICONV +#ifdef _Py_HAVE_ICONV #include // iconv_open() #endif @@ -8220,7 +8220,7 @@ PyUnicode_AsMBCSString(PyObject *unicode) /* --- iconv Codec -------------------------------------------------------- */ -#ifdef HAVE_ICONV +#ifdef _Py_HAVE_ICONV /* iconv pivot: native-endian UTF-32, a raw array of Py_UCS4. One input unit is one code point, so error handlers get the exact position. A platform whose @@ -8602,7 +8602,7 @@ _PyUnicode_EncodeIconv(const char *encoding, PyObject *unicode, return result; } -#endif /* HAVE_ICONV */ +#endif /* _Py_HAVE_ICONV */ /* --- Character Mapping Codec -------------------------------------------- */ diff --git a/Python/bytecodes.c b/Python/bytecodes.c index fb0cdf4d65e060..fdfd5a0e609046 100644 --- a/Python/bytecodes.c +++ b/Python/bytecodes.c @@ -4141,7 +4141,8 @@ dummy_func( op(_LOAD_SPECIAL, (method_and_self[2] -- method_and_self[2])) { PyObject *name = _Py_SpecialMethods[oparg].name; - int err = _PyObject_LookupSpecialMethod(name, method_and_self); + int err = _PyObject_LookupSpecialMethod(name, &method_and_self[0], + &method_and_self[1]); if (err <= 0) { if (err == 0) { PyObject *owner = PyStackRef_AsPyObjectBorrow(method_and_self[1]); diff --git a/Python/executor_cases.c.h b/Python/executor_cases.c.h index 9aad9e003765cf..e3dc2e781a3beb 100644 --- a/Python/executor_cases.c.h +++ b/Python/executor_cases.c.h @@ -16224,7 +16224,8 @@ PyObject *name = _Py_SpecialMethods[oparg].name; _PyFrame_SetStackPointer(frame, stack_pointer); _PyFrame_StackPointerValidate(frame); - int err = _PyObject_LookupSpecialMethod(name, method_and_self); + int err = _PyObject_LookupSpecialMethod(name, &method_and_self[0], + &method_and_self[1]); _PyFrame_StackPointerInvalidate(frame); if (err <= 0) { if (err == 0) { diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h index 77c18b3d61fefc..48f76ccf59f8bc 100644 --- a/Python/generated_cases.c.h +++ b/Python/generated_cases.c.h @@ -10355,7 +10355,8 @@ ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__); _PyFrame_SetStackPointer(frame, stack_pointer); _PyFrame_StackPointerValidate(frame); - int err = _PyObject_LookupSpecialMethod(name, method_and_self); + int err = _PyObject_LookupSpecialMethod(name, &method_and_self[0], + &method_and_self[1]); _PyFrame_StackPointerInvalidate(frame); if (err <= 0) { if (err == 0) { diff --git a/Tools/build/check_capi_macros_ignored.txt b/Tools/build/check_capi_macros_ignored.txt index 406535e54664e8..877c8d72e72827 100644 --- a/Tools/build/check_capi_macros_ignored.txt +++ b/Tools/build/check_capi_macros_ignored.txt @@ -73,18 +73,14 @@ GETPGRP_HAVE_ARG HAVE_ACCEPT HAVE_ACCEPT4 HAVE_ACOSH -HAVE_ACOSPI HAVE_ADDRINFO HAVE_ALARM HAVE_ALIGNED_REQUIRED HAVE_ALLOCA_H HAVE_ALTZONE HAVE_ASINH -HAVE_ASINPI HAVE_ASM_TYPES_H -HAVE_ATAN2PI HAVE_ATANH -HAVE_ATANPI HAVE_BACKTRACE HAVE_BIND HAVE_BIND_TEXTDOMAIN_CODESET @@ -118,7 +114,6 @@ HAVE_CONFSTR HAVE_CONIO_H HAVE_CONNECT HAVE_COPY_FILE_RANGE -HAVE_COSPI HAVE_CTERMID HAVE_CTERMID_R HAVE_CURSES_DEFINE_KEY @@ -298,7 +293,6 @@ HAVE_GRANTPT HAVE_GRP_H HAVE_HSTRERROR HAVE_HTOLE64 -HAVE_ICONV HAVE_ICONV_H HAVE_IF_INDEXTONAME HAVE_IF_NAMEINDEX @@ -511,7 +505,6 @@ HAVE_SIGRELSE HAVE_SIGTIMEDWAIT HAVE_SIGWAIT HAVE_SIGWAITINFO -HAVE_SINPI HAVE_SNPRINTF HAVE_SOCKADDR_ALG HAVE_SOCKADDR_SA_LEN @@ -603,7 +596,6 @@ HAVE_SYS_UN_H HAVE_SYS_UTSNAME_H HAVE_SYS_WAIT_H HAVE_SYS_XATTR_H -HAVE_TANPI HAVE_TCGETPGRP HAVE_TCSETPGRP HAVE_TEMPNAM diff --git a/configure b/configure index 809885af1cd20d..84f2030049ac31 100755 --- a/configure +++ b/configure @@ -642,7 +642,6 @@ ac_includes_default="\ #endif" ac_header_c_list= -ac_func_c_list= ac_subst_vars='LTLIBOBJS MODULE_BLOCK JIT_SHIM_BUILD_O @@ -3440,13 +3439,6 @@ as_fn_append ac_header_c_list " sys/types.h sys_types_h HAVE_SYS_TYPES_H" as_fn_append ac_header_c_list " unistd.h unistd_h HAVE_UNISTD_H" as_fn_append ac_header_c_list " wchar.h wchar_h HAVE_WCHAR_H" as_fn_append ac_header_c_list " minix/config.h minix_config_h HAVE_MINIX_CONFIG_H" -as_fn_append ac_func_c_list " acospi HAVE_ACOSPI" -as_fn_append ac_func_c_list " asinpi HAVE_ASINPI" -as_fn_append ac_func_c_list " atanpi HAVE_ATANPI" -as_fn_append ac_func_c_list " atan2pi HAVE_ATAN2PI" -as_fn_append ac_func_c_list " cospi HAVE_COSPI" -as_fn_append ac_func_c_list " sinpi HAVE_SINPI" -as_fn_append ac_func_c_list " tanpi HAVE_TANPI" # Auxiliary files required by this configure script. ac_aux_files="install-sh config.guess config.sub" @@ -3625,6 +3617,8 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu + + if test "$srcdir" != . -a "$srcdir" != "$(pwd)"; then # If we're building out-of-tree, we need to make sure the following # resources get picked up before their $srcdir counterparts. @@ -14913,7 +14907,7 @@ fi printf "%s\n" "$ac_cv_have_iconv" >&6; } if test "$ac_cv_have_iconv" != no; then -printf "%s\n" "#define HAVE_ICONV 1" >>confdefs.h +printf "%s\n" "#define _Py_HAVE_ICONV 1" >>confdefs.h if test "$ac_cv_have_iconv" = -liconv; then LIBS="-liconv $LIBS" @@ -27589,24 +27583,298 @@ fi done -ac_func= -for ac_item in $ac_func_c_list -do - if test $ac_func; then - ac_fn_c_check_func "$LINENO" $ac_func ac_cv_func_$ac_func - if eval test \"x\$ac_cv_func_$ac_func\" = xyes; then - echo "#define $ac_item 1" >> confdefs.h - fi - ac_func= - else - ac_func=$ac_item - fi -done + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for acospi" >&5 +printf %s "checking for acospi... " >&6; } +if test ${ac_cv_func_acospi+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main (void) +{ +void *x=acospi + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + ac_cv_func_acospi=yes +else case e in #( + e) ac_cv_func_acospi=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_acospi" >&5 +printf "%s\n" "$ac_cv_func_acospi" >&6; } + if test "x$ac_cv_func_acospi" = xyes +then : + +printf "%s\n" "#define _Py_HAVE_ACOSPI 1" >>confdefs.h + +fi + + + + + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for asinpi" >&5 +printf %s "checking for asinpi... " >&6; } +if test ${ac_cv_func_asinpi+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main (void) +{ +void *x=asinpi + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + ac_cv_func_asinpi=yes +else case e in #( + e) ac_cv_func_asinpi=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_asinpi" >&5 +printf "%s\n" "$ac_cv_func_asinpi" >&6; } + if test "x$ac_cv_func_asinpi" = xyes +then : + +printf "%s\n" "#define _Py_HAVE_ASINPI 1" >>confdefs.h + +fi + + + + + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for atanpi" >&5 +printf %s "checking for atanpi... " >&6; } +if test ${ac_cv_func_atanpi+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main (void) +{ +void *x=atanpi + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + ac_cv_func_atanpi=yes +else case e in #( + e) ac_cv_func_atanpi=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_atanpi" >&5 +printf "%s\n" "$ac_cv_func_atanpi" >&6; } + if test "x$ac_cv_func_atanpi" = xyes +then : + +printf "%s\n" "#define _Py_HAVE_ATANPI 1" >>confdefs.h + +fi + + + + + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for atan2pi" >&5 +printf %s "checking for atan2pi... " >&6; } +if test ${ac_cv_func_atan2pi+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main (void) +{ +void *x=atan2pi + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + ac_cv_func_atan2pi=yes +else case e in #( + e) ac_cv_func_atan2pi=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_atan2pi" >&5 +printf "%s\n" "$ac_cv_func_atan2pi" >&6; } + if test "x$ac_cv_func_atan2pi" = xyes +then : + +printf "%s\n" "#define _Py_HAVE_ATAN2PI 1" >>confdefs.h + +fi + + + + + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for cospi" >&5 +printf %s "checking for cospi... " >&6; } +if test ${ac_cv_func_cospi+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main (void) +{ +void *x=cospi + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + ac_cv_func_cospi=yes +else case e in #( + e) ac_cv_func_cospi=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_cospi" >&5 +printf "%s\n" "$ac_cv_func_cospi" >&6; } + if test "x$ac_cv_func_cospi" = xyes +then : + +printf "%s\n" "#define _Py_HAVE_COSPI 1" >>confdefs.h + +fi + + + + + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for sinpi" >&5 +printf %s "checking for sinpi... " >&6; } +if test ${ac_cv_func_sinpi+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main (void) +{ +void *x=sinpi + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + ac_cv_func_sinpi=yes +else case e in #( + e) ac_cv_func_sinpi=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_sinpi" >&5 +printf "%s\n" "$ac_cv_func_sinpi" >&6; } + if test "x$ac_cv_func_sinpi" = xyes +then : + +printf "%s\n" "#define _Py_HAVE_SINPI 1" >>confdefs.h + +fi + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for tanpi" >&5 +printf %s "checking for tanpi... " >&6; } +if test ${ac_cv_func_tanpi+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main (void) +{ +void *x=tanpi + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + ac_cv_func_tanpi=yes +else case e in #( + e) ac_cv_func_tanpi=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_tanpi" >&5 +printf "%s\n" "$ac_cv_func_tanpi" >&6; } + if test "x$ac_cv_func_tanpi" = xyes +then : + +printf "%s\n" "#define _Py_HAVE_TANPI 1" >>confdefs.h + +fi + + LIBS=$LIBS_SAVE diff --git a/configure.ac b/configure.ac index 8e5377a8f0ac75..bc94908213d2c7 100644 --- a/configure.ac +++ b/configure.ac @@ -73,6 +73,12 @@ AC_DEFUN([PY_CHECK_FUNC], AS_VAR_POPDEF([py_define]) ]) +dnl PY_CHECK_FUNC_PRIVATE(FUNCTION, [INCLUDES], [AC_DEFINE-VAR]) +dnl Similar to PY_CHECK_FUNC but define macro _Py_HAVE_xxx instead of HAVE_xxx +AC_DEFUN([PY_CHECK_FUNC_PRIVATE], +[ PY_CHECK_FUNC([$1], [$2], m4_ifblank([$3], [[_Py_HAVE_]m4_toupper($1)], [$3])) +]) + dnl PY_CHECK_LIB(LIBRARY, FUNCTION, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND], [OTHER-LIBRARIES]) dnl Like AC_CHECK_LIB() but does not modify LIBS AC_DEFUN([PY_CHECK_LIB], @@ -3986,7 +3992,7 @@ if test "$py_have_iconv" = yes; then ]) ]) if test "$ac_cv_have_iconv" != no; then - AC_DEFINE([HAVE_ICONV], [1], + AC_DEFINE([_Py_HAVE_ICONV], [1], [Define if you have a working iconv() function.]) if test "$ac_cv_have_iconv" = -liconv; then LIBS="-liconv $LIBS" @@ -6549,7 +6555,13 @@ AC_CHECK_FUNCS( [AC_MSG_ERROR([Python requires C99 compatible libm])] ) -AC_CHECK_FUNCS_ONCE(acospi asinpi atanpi atan2pi cospi sinpi tanpi) +PY_CHECK_FUNC_PRIVATE([acospi]) +PY_CHECK_FUNC_PRIVATE([asinpi]) +PY_CHECK_FUNC_PRIVATE([atanpi]) +PY_CHECK_FUNC_PRIVATE([atan2pi]) +PY_CHECK_FUNC_PRIVATE([cospi]) +PY_CHECK_FUNC_PRIVATE([sinpi]) +PY_CHECK_FUNC_PRIVATE([tanpi]) LIBS=$LIBS_SAVE dnl For multiprocessing module, check that sem_open diff --git a/pyconfig.h.in b/pyconfig.h.in index 2bf45a290a4ed1..d1de60ad757f4d 100644 --- a/pyconfig.h.in +++ b/pyconfig.h.in @@ -55,9 +55,6 @@ /* Define to 1 if you have the 'acosh' function. */ #undef HAVE_ACOSH -/* Define to 1 if you have the 'acospi' function. */ -#undef HAVE_ACOSPI - /* struct addrinfo (netdb.h) */ #undef HAVE_ADDRINFO @@ -76,21 +73,12 @@ /* Define to 1 if you have the 'asinh' function. */ #undef HAVE_ASINH -/* Define to 1 if you have the 'asinpi' function. */ -#undef HAVE_ASINPI - /* Define to 1 if you have the header file. */ #undef HAVE_ASM_TYPES_H -/* Define to 1 if you have the 'atan2pi' function. */ -#undef HAVE_ATAN2PI - /* Define to 1 if you have the 'atanh' function. */ #undef HAVE_ATANH -/* Define to 1 if you have the 'atanpi' function. */ -#undef HAVE_ATANPI - /* Define to 1 if you have the 'backtrace' function. */ #undef HAVE_BACKTRACE @@ -191,9 +179,6 @@ /* Define to 1 if you have the 'copy_file_range' function. */ #undef HAVE_COPY_FILE_RANGE -/* Define to 1 if you have the 'cospi' function. */ -#undef HAVE_COSPI - /* Define to 1 if you have the 'ctermid' function. */ #undef HAVE_CTERMID @@ -742,9 +727,6 @@ /* Define this if you have le64toh() */ #undef HAVE_HTOLE64 -/* Define if you have a working iconv() function. */ -#undef HAVE_ICONV - /* Define to 1 if you have the header file. */ #undef HAVE_ICONV_H @@ -1384,9 +1366,6 @@ /* Define to 1 if you have the 'sigwaitinfo' function. */ #undef HAVE_SIGWAITINFO -/* Define to 1 if you have the 'sinpi' function. */ -#undef HAVE_SINPI - /* Define to 1 if you have the 'snprintf' function. */ #undef HAVE_SNPRINTF @@ -1665,9 +1644,6 @@ /* Define to 1 if you have the header file. */ #undef HAVE_SYS_XATTR_H -/* Define to 1 if you have the 'tanpi' function. */ -#undef HAVE_TANPI - /* Define to 1 if you have the 'tcgetpgrp' function. */ #undef HAVE_TCGETPGRP @@ -2203,6 +2179,21 @@ /* HACL* library can compile SIMD256 implementations */ #undef _Py_HACL_CAN_COMPILE_VEC256 +/* Define if you have the 'acospi' function. */ +#undef _Py_HAVE_ACOSPI + +/* Define if you have the 'asinpi' function. */ +#undef _Py_HAVE_ASINPI + +/* Define if you have the 'atan2pi' function. */ +#undef _Py_HAVE_ATAN2PI + +/* Define if you have the 'atanpi' function. */ +#undef _Py_HAVE_ATANPI + +/* Define if you have the 'cospi' function. */ +#undef _Py_HAVE_COSPI + /* Define if compiler supports __builtin_shufflevector with 128-bit vectors AND the target architecture has native SIMD (not just API availability) */ #undef _Py_HAVE_EFFICIENT_BUILTIN_SHUFFLEVECTOR @@ -2210,6 +2201,9 @@ /* Defined if _Float16 C type is supported */ #undef _Py_HAVE_FLOAT16 +/* Define if you have a working iconv() function. */ +#undef _Py_HAVE_ICONV + /* Define to 1 if libgcc __register_frame and __deregister_frame are linkable. */ #undef _Py_HAVE_LIBGCC_EH_FRAME_REGISTRATION @@ -2217,6 +2211,12 @@ /* Define if you have the 'PR_SET_VMA_ANON_NAME' constant. */ #undef _Py_HAVE_PR_SET_VMA_ANON_NAME +/* Define if you have the 'sinpi' function. */ +#undef _Py_HAVE_SINPI + +/* Define if you have the 'tanpi' function. */ +#undef _Py_HAVE_TANPI + /* Thread stack size set by the linker (in bytes). */ #undef _Py_LINKER_THREAD_STACK_SIZE