Skip to content

Commit a0f0bda

Browse files
committed
Document Py_ARITHMETIC_RIGHT_SHIFT
1 parent 85d1c40 commit a0f0bda

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

Doc/c-api/intro.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,23 @@ complete listing.
174174
This does not use the C11 standard ``_Alignas`` specifier; prefer use of
175175
that over this macro.
176176

177+
.. c:macro:: Py_ARITHMETIC_RIGHT_SHIFT(type, integer, positions)
178+
179+
Similar to :c:expr:`integer >> positions`, but forces sign extension, as the C
180+
standard does not define whether a right-shift of a signed integer will
181+
perform sign extension or a zero-fill.
182+
183+
*integer* should be any signed integer type.
184+
*positions* is the number of positions to shift to the right.
185+
186+
Both *integer* and *positions* can be evaluated more than once;
187+
consequently, avoid directly passing a function call or some other
188+
expensive operation to this macro. Instead, store the result as a
189+
variable and then pass it.
190+
191+
*type* is the type of the expression. In modern versions of Python, this is
192+
unused. Historically, *type* was used to cast *integer*.
193+
177194
.. c:macro:: Py_ALWAYS_INLINE
178195
179196
Ask the compiler to always inline a static inline function. The compiler can

0 commit comments

Comments
 (0)