@@ -139,6 +139,35 @@ complete listing.
139139
140140 .. versionadded :: 3.3
141141
142+ .. c :macro :: Py_ALIGNED(num)
143+
144+ Specify alignment to *num * bytes on compilers that support it.
145+
146+ Consider using the C11 standard ``_Alignas `` specifier over this macro.
147+
148+ .. c :macro :: Py_ARITHMETIC_RIGHT_SHIFT(type, integer, positions)
149+
150+ Similar to ``integer >> positions ``, but forces sign extension, as the C
151+ standard does not define whether a right-shift of a signed integer will
152+ perform sign extension or a zero-fill.
153+
154+ *integer * should be any signed integer type.
155+ *positions * is the number of positions to shift to the right.
156+
157+ Both *integer * and *positions * can be evaluated more than once;
158+ consequently, avoid directly passing a function call or some other
159+ operation with side-effects to this macro. Instead, store the result as a
160+ variable and then pass it.
161+
162+ *type * is unused and only kept for backwards compatibility. Historically,
163+ *type * was used to cast *integer *.
164+
165+ .. versionchanged :: 3.1
166+
167+ This macro is now valid for all signed integer types, not just those for
168+ which ``unsigned type `` is legal. As a result, *type * is no longer
169+ used.
170+
142171.. c :macro :: Py_ALWAYS_INLINE
143172
144173 Ask the compiler to always inline a static inline function. The compiler can
@@ -161,6 +190,15 @@ complete listing.
161190
162191 .. versionadded :: 3.11
163192
193+ .. c :macro :: Py_CAN_START_THREADS
194+
195+ If this macro is defined, then the current system is able to start threads.
196+
197+ Currently, all systems supported by CPython (per :pep: `11 `), with the
198+ exception of some WebAssembly platforms, support starting threads.
199+
200+ .. versionadded :: 3.13
201+
164202.. c :macro :: Py_CHARMASK(c)
165203
166204 Argument must be a character or an integer in the range [-128, 127] or [0,
@@ -178,11 +216,35 @@ complete listing.
178216 .. versionchanged :: 3.8
179217 MSVC support was added.
180218
219+ .. c :macro :: Py_FORCE_EXPANSION(X)
220+
221+ This is equivalent to ``X ``, which is useful for token-pasting in
222+ macros, as macro expansions in *X * are forcefully evaluated by the
223+ preprocessor.
224+
225+ .. c :macro :: Py_GCC_ATTRIBUTE(name)
226+
227+ Use a GCC attribute *name *, hiding it from compilers that don't support GCC
228+ attributes (such as MSVC).
229+
230+ This expands to ``__attribute__((name)) `` on a GCC compiler, and expands
231+ to nothing on compilers that don't support GCC attributes.
232+
181233.. c :macro :: Py_GETENV(s)
182234
183235 Like ``getenv(s) ``, but returns ``NULL `` if :option: `-E ` was passed on the
184236 command line (see :c:member: `PyConfig.use_environment `).
185237
238+ .. c :macro :: Py_LL(number)
239+
240+ Use *number * as a ``long long `` integer literal.
241+
242+ This usally expands to *number * followed by ``LL ``, but will expand to some
243+ compiler-specific suffixes (such as ``I64 ``) on older compilers.
244+
245+ In modern versions of Python, this macro is not very useful, as C99 and
246+ later require the ``LL `` suffix to be valid for an integer.
247+
186248.. c :macro :: Py_LOCAL(type)
187249
188250 Declare a function returning the specified *type * using a fast-calling
@@ -232,13 +294,37 @@ complete listing.
232294
233295 .. versionadded :: 3.11
234296
297+ .. c :macro :: Py_SAFE_DOWNCAST(value, larger, smaller)
298+
299+ Cast *value * to type *smaller * from type *larger *, validating that no
300+ information was lost.
301+
302+ On release builds of Python, this is roughly equivalent to
303+ ``(smaller) value `` (in C++, ``static_cast<smaller>(value) `` will be
304+ used instead).
305+
306+ On debug builds (implying that :c:macro: `Py_DEBUG ` is defined), this asserts
307+ that no information was lost with the cast from *larger * to *smaller *.
308+
309+ *value *, *larger *, and *smaller * may all be evaluated more than once in the
310+ expression; consequently, do not pass an expression with side-effects directly to
311+ this macro.
312+
235313.. c :macro :: Py_STRINGIFY(x)
236314
237315 Convert ``x `` to a C string. E.g. ``Py_STRINGIFY(123) `` returns
238316 ``"123" ``.
239317
240318 .. versionadded :: 3.4
241319
320+ .. c :macro :: Py_ULL(number)
321+
322+ Similar to :c:macro: `Py_LL `, but *number * will be an ``unsigned long long ``
323+ literal instead. This is done by appending ``U `` to the result of ``Py_LL ``.
324+
325+ In modern versions of Python, this macro is not very useful, as C99 and
326+ later require the ``ULL ``/``LLU `` suffixes to be valid for an integer.
327+
242328.. c :macro :: Py_UNREACHABLE()
243329
244330 Use this when you have a code path that cannot be reached by design.
@@ -379,6 +465,16 @@ complete listing.
379465 This macro is intended for defining CPython's C API itself;
380466 extension modules should not use it for their own symbols.
381467
468+ .. c :macro :: Py_VA_COPY
469+
470+ This is a :term: `soft deprecated ` alias to the C99-standard ``va_copy ``
471+ function.
472+
473+ Historically, this would use a compiler-specific method to copy a ``va_list ``.
474+
475+ .. versionchanged :: 3.6
476+ This is now an alias to ``va_copy ``.
477+
382478
383479.. _api-objects :
384480
0 commit comments