summaryrefslogtreecommitdiffstats
path: root/Include/pymacro.h
Commit message (Collapse)AuthorAgeFilesLines
* gh-118124: fix assert related C++ checks on Solaris/Illumos (#121974)Jakub Kulík2024-07-211-5/+5
| | | Fix check for static_assert() for C++ on some platforms.
* Check for compiler warnings in test_cext on Windows (#121088)Victor Stinner2024-06-281-1/+2
| | | | | | | | On Windows, test_cext and test_cppext now pass /WX flag to the MSC compiler to treat all compiler warnings as errors. In verbose mode, these tests now log the compiler commands to help debugging. Change Py_BUILD_ASSERT_EXPR implementation on Windows to avoid a compiler warning about an unnamed structure.
* gh-118124: Use static_assert() in Py_BUILD_ASSERT() on C11 (#118398)Victor Stinner2024-04-301-16/+33
| | | | | | Use static_assert() in Py_BUILD_ASSERT() and Py_BUILD_ASSERT_EXPR() on C11 and newer and C++11 and newer. Add tests to test_cext and test_cppext.
* gh-111964: Implement stop-the-world pauses (gh-112471)Sam Gross2024-01-231-0/+3
| | | | | | | | | | | | | | | | | The `--disable-gil` builds occasionally need to pause all but one thread. Some examples include: * Cyclic garbage collection, where this is often called a "stop the world event" * Before calling `fork()`, to ensure a consistent state for internal data structures * During interpreter shutdown, to ensure that daemon threads aren't accessing Python objects This adds the following functions to implement global and per-interpreter pauses: * `_PyEval_StopTheWorldAll()` and `_PyEval_StartTheWorldAll()` (for the global runtime) * `_PyEval_StopTheWorld()` and `_PyEval_StartTheWorld()` (per-interpreter) (The function names may change.) These functions are no-ops outside of the `--disable-gil` build.
* gh-107249: Implement Py_UNUSED() for MSVC (#107250)Victor Stinner2023-07-251-0/+9
| | | | | | | | | | | | | | | | | Fix warnings C4100 in Py_UNUSED() when Python is built with "cl /W4". Example with this function included by Python.h: static inline unsigned int PyUnicode_IS_READY(PyObject* Py_UNUSED(op)) { return 1; } Without this change, building a C program with "cl /W4" which just includes Python.h emits the warning: Include\cpython/unicodeobject.h(199): warning C4100: '_unused_op': unreferenced formal parameter This change fix this warning.
* gh-99069: Consolidate checks for static_assert (#94766)Joshua Root2023-04-051-13/+16
| | | | | | | | | | | | | | | | | | | | Several platforms don't define the static_assert macro despite having compiler support for the _Static_assert keyword. The macro needs to be defined since it is used unconditionally in the Python code. So it should always be safe to define it if undefined and not in C++11 (or later) mode. Hence, remove the checks for particular platforms or libc versions, and just define static_assert anytime it needs to be defined but isn't. That way, all platforms that need the fix will get it, regardless of whether someone specifically thought of them. Also document that certain macOS versions are among the platforms that need this. The C2x draft (currently expected to become C23) makes static_assert a keyword to match C++. So only define the macro for up to C17. Co-authored-by: Victor Stinner <vstinner@python.org>
* gh-91731: Don't define 'static_assert' in C++11 where is a keyword to avoid ↵Pablo Galindo Salgado2022-06-131-0/+2
| | | | UB (GH-93700)
* gh-82616: Add Py_IS_TYPE_SIGNED() macro (#93178)Victor Stinner2022-05-271-0/+5
| | | | | | _posixsubprocess: add a static assertion to ensure that the pid_t type is signed. Replace _Py_IntegralTypeSigned() with _Py_IS_TYPE_SIGNED().
* gh-91731: Fix typo in pymacro.h (#92618)Pablo Galindo Salgado2022-05-101-1/+1
| | | | | | | | | * Fix typo in pymacro.h * Update Include/pymacro.h Co-authored-by: Victor Stinner <vstinner@python.org> Co-authored-by: Victor Stinner <vstinner@python.org>
* gh-91731: Add macro compatibility for static_assert for old libcs (GH-92559)Pablo Galindo Salgado2022-05-091-0/+8
|
* gh-91782: Define static_assert() macro on FreeBSD (#91787)Victor Stinner2022-04-211-0/+9
| | | | | On FreeBSD, if the static_assert() macro is not defined, define it in Python until <sys/cdefs.h> supports C11: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=255290
* bpo-45476: Add _Py_RVALUE() macro (GH-29860)Victor Stinner2021-11-301-0/+4
| | | | | | | | | | | | | | | | | | Add a new _Py_RVALUE() macro to prevent using an expression as an l-value. Replace a "(void)" cast with the _Py_RVALUE() macro in the following macros: * PyCell_SET() * PyList_SET_ITEM() * PyTuple_SET_ITEM() * _PyGCHead_SET_FINALIZED() * _PyGCHead_SET_NEXT() * asdl_seq_SET() * asdl_seq_SET_UNTYPED() Add also parentheses around macro arguments in PyCell_SET() and PyTuple_SET_ITEM() macros.
* bpo-41875: Use __builtin_unreachable when possible (GH-22433)Dong-hee Na2020-09-281-1/+3
|
* bpo-38249: Expand Py_UNREACHABLE() to __builtin_unreachable() in the release ↵Serhiy Storchaka2020-03-091-3/+7
| | | | | mode. (GH-16329) Co-authored-by: Victor Stinner <vstinner@python.org>
* bpo-38205: Py_UNREACHABLE() calls Py_FatalError() (GH-16290)Victor Stinner2019-09-201-23/+18
|
* Enhance Py_UNREACHABLE macro (GH-16032)Zachary Ware2019-09-121-0/+26
|
* Support Py_UNUSED() on clang (GH-13544)Victor Stinner2019-05-241-3/+8
|
* bpo-36641: Add "const" to PyDoc_VAR macro (GH-12854)Inada Naoki2019-04-161-1/+1
| | | It reduces "data" segment in python about 200KB.
* bpo-31338 (#3374)Barry Warsaw2017-09-151-0/+2
| | | | | | | * Add Py_UNREACHABLE() as an alias to abort(). * Use Py_UNREACHABLE() instead of assert(0) * Convert more unreachable code to use Py_UNREACHABLE() * Document Py_UNREACHABLE() and a few other macros.
* bpo-29936: fix typo __GNU*C*_MINOR__ (#878)Niklas Fiekas2017-03-291-1/+1
|
* Add Py_MEMBER_SIZE macroVictor Stinner2016-09-081-0/+3
| | | | | Issue #27350: use Py_MEMBER_SIZE() macro to get the size of PyDictKeyEntry.dk_indices, rather than hardcoding 8.
* replace Py_(u)intptr_t with the c99 standard typesBenjamin Peterson2016-09-061-4/+4
|
* Issue #25558: Use compile-time asserts.Serhiy Storchaka2015-11-071-0/+4
|
* Issue #21490: Add new C macros: Py_ABS() and Py_STRINGIFY()Victor Stinner2014-05-141-1/+14
| | | | | Keep _Py_STRINGIZE() in PC/pyconfig.h to not introduce a dependency between pyconfig.h and pymacros.h.
* Issue #19976: Argument Clinic METH_NOARGS functions now alwaysLarry Hastings2014-01-041-0/+6
| | | | take two parameters.
* Fix test for GCC 3.1+ but not strict ANSI CChristian Heimes2013-06-241-1/+1
|
* Issue #16881: Fix Py_ARRAY_LENGTH macro for GCC < 3.1.Christian Heimes2013-01-061-2/+5
|
* GCC doesn't support typeof in strict ansi mode (e.g. -ansi or -std=c89)Christian Heimes2012-09-231-1/+1
|
* Issue #15144: Fix possible integer overflow when handling pointers as ↵Antoine Pitrou2012-09-201-0/+14
| | | | | | integer values, by using Py_uintptr_t instead of size_t. Patch by Serhiy Storchaka.
* Rename Py_BUILD_ASSERT to Py_BUILD_ASSERT_EXPRVictor Stinner2011-09-291-6/+5
| | | | | To make it clearer that Py_BUILD_ASSERT_EXPR(cond) cannot be used as assert(cond).
* pymacro.h: Inline _Py_ARRAY_LENGTH_CHECK() and add http://ccodearchive.net/Victor Stinner2011-09-291-13/+12
|
* Enhance Py_ARRAY_LENGTH(): fail at build time if the argument is not an arrayVictor Stinner2011-09-281-0/+57
Move other various macros to pymcacro.h Thanks Rusty Russell for having written these amazing C macros!