FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-110014: Fix _POSIX_THREADS and _POSIX_SEMAPHORES usage by vstinner · Pull Request #110139 · python/cpython · GitHub

/ cpython Public

gh-110014: Fix _POSIX_THREADS and _POSIX_SEMAPHORES usage - #110139

Merged
vstinner merged 3 commits into
python:mainfrom
vstinner:internal_posix_threads
Sep 30, 2023
Merged

gh-110014: Fix _POSIX_THREADS and _POSIX_SEMAPHORES usage#110139
vstinner merged 3 commits into
python:mainfrom
vstinner:internal_posix_threads

Conversation

vstinner commented Sep 30, 2023
edited by github-actions Bot
Loading

Copy link
Copy Markdown
Member
  • pycore_pythread.h is now the central place to make sure that _POSIX_THREADS and _POSIX_SEMAPHORES macros are defined if available.
  • Make sure that pycore_pythread.h is included when _POSIX_THREADS and _POSIX_SEMAPHORES macros are tested.
  • PY_TIMEOUT_MAX is now defined as a constant, since its value depends on _POSIX_THREADS, instead of being defined as a macro.
  • Document the change and give hints how to fix affected code.

📚 Documentation preview 📚: https://cpython-previews--110139.org.readthedocs.build/

* pycore_pythread.h is now the central place to make sure that
  _POSIX_THREADS and _POSIX_SEMAPHORES macros are defined if
  available.
* Make sure that pycore_pythread.h is included when _POSIX_THREADS
  and _POSIX_SEMAPHORES macros are tested.
* PY_TIMEOUT_MAX is now defined as a constant, since its value
  depends on _POSIX_THREADS, instead of being defined as a macro.
* Prevent integer overflow in the preprocessor when computing
  PY_TIMEOUT_MAX_VALUE on Windows:
  replace "0xFFFFFFFELL * 1000 < LLONG_MAX"
  with "0xFFFFFFFELL < LLONG_MAX / 1000".
* Document the change and give hints how to fix affected code.

Copy link
Copy Markdown
Member Author

@encukou: "Oops", I have to add an exception to Tools/build/smelly.py to tolerate the new symbol PY_TIMEOUT_MAX. Before, Python only exported symbols starting with Py, _Py and __Py (macOS). Copy of my comment:

# "Legacy": some old symbols are prefixed by "PY_".
EXCEPTIONS = frozenset({
    'PY_TIMEOUT_MAX',
})

I would prefer to prefix all public symbols with Py and only have private symbols, but at least, now we have tooling to detect when new symbols with different prefix are added ;-)

vstinner requested review from a team and encukou as code owners September 30, 2023 16:13
vstinner merged commit 74e425e into python:main Sep 30, 2023
vstinner deleted the internal_posix_threads branch September 30, 2023 17:25

Copy link
Copy Markdown
Member Author

Oh. I don't know if it's related or not, but I had to write PR gh-110155 to add many <unistd.h>. WASM/WASI builds were badly broken :-(

Comment thread Misc/stable_abi.toml
added = '3.2'

# Not mentioned in PEP 384, was implemented as a macro in Python <= 3.12
[data.PY_TIMEOUT_MAX]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

@vstinner Could we instead exclude this undocumented constant from the limited API?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I checked and apparently, it's safe to remove this constant, so I created PR gh-110217 for that.

Glyphack pushed a commit to Glyphack/cpython that referenced this pull request Sep 2, 2024
…on#110139)

* pycore_pythread.h is now the central place to make sure that
  _POSIX_THREADS and _POSIX_SEMAPHORES macros are defined if
  available.
* Make sure that pycore_pythread.h is included when _POSIX_THREADS
  and _POSIX_SEMAPHORES macros are tested.
* PY_TIMEOUT_MAX is now defined as a constant, since its value
  depends on _POSIX_THREADS, instead of being defined as a macro.
* Prevent integer overflow in the preprocessor when computing
  PY_TIMEOUT_MAX_VALUE on Windows:
  replace "0xFFFFFFFELL * 1000 < LLONG_MAX"
  with "0xFFFFFFFELL < LLONG_MAX / 1000".
* Document the change and give hints how to fix affected code.
* Add an exception for PY_TIMEOUT_MAX  name to smelly.py
* Add PY_TIMEOUT_MAX to the stable ABI
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL