Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-30832: Remove own implementation for thread-local storage #2537

Merged
merged 4 commits into from
Jul 3, 2017

Conversation

ma8ma
Copy link
Contributor

@ma8ma ma8ma commented Jul 3, 2017

CPython has provided the own implementation for thread-local storage (TLS) on Python/thread.c, it's used in the case which a platform has not supplied native TLS. However, currently all supported platforms (NT and pthreads) have provided native TLS and defined the Py_HAVE_NATIVE_TLS macro with unconditional in any case.
Therefore, I'd propose removing outdated code.

http://bugs.python.org/issue30832

Note that the comment for TLS API description is kept up because it isn't in other places. If new Thread Specific Storage API (PEP 539) makes to be in public, this description is removed and probably create description for new API into Doc/c-api.

CPython has provided the own implementation for thread-local storage
(TLS) on Python/thread.c, it's used in the case which a platform has
not supplied native TLS.  However, currently all supported platforms
(NT and pthreads) have provided native TLS and defined the
Py_HAVE_NATIVE_TLS macro with unconditional in any case.

CPython has provided the own implementation for thread-local storage (TLS)
on Python/thread.c, it's used in the case which a platform has not supplied
native TLS. However, currently all supported platforms (NT and pthreads)
Copy link
Member

Choose a reason for hiding this comment

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

Maybe replace "NT" with Windows.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.

@@ -114,12 +114,9 @@ PyThread_set_stacksize(size_t size)
#endif
}

#ifndef Py_HAVE_NATIVE_TLS
Copy link
Member

Choose a reason for hiding this comment

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

I suggest to keep the #ifndef and emit a compiler error (#error "...") here with an helpful error message, like the http://bugs.python.org/issue30832 URL.

Or maybe, chain the following two if and add the error in a new #else block?

#ifdef _POSIX_THREADS
#define PYTHREAD_NAME "pthread"
#include "thread_pthread.h"
#endif

#ifdef NT_THREADS
#define PYTHREAD_NAME "nt"
#include "thread_nt.h"
#endif

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd like to change to directive chain and remove Py_HAVE_NATIVE_TLS. In fact, native TLS is required.

Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

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

You can now remove Py_HAVE_NATIVE_TLS define. It's no more used. No?

Python/thread.c Outdated
This code stolen from "thread_sgi.h", where it was the only
implementation of an existing Python TLS API.
/* If the platform has not supplied a platform-specific thread-local
storage implementation, CPython does not provide thread feature.
Copy link
Member

Choose a reason for hiding this comment

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

I don't understand this comment. If you require thread support, CPython compilation fails with the above #error. It doesn't disable thread support for you. I suggest to remove this comment.

Copy link
Contributor Author

@ma8ma ma8ma Jul 3, 2017

Choose a reason for hiding this comment

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

Yeah, it has been no more sense.
Should title and news change like "Change the requirement for CPython thread feature to native thread"?

@vstinner
Copy link
Member

vstinner commented Jul 3, 2017

Should title and news change like "Change the requirement for CPython thread feature to native thread"?

I don't think so.

@vstinner vstinner merged commit aa0aa04 into python:master Jul 3, 2017
@vstinner
Copy link
Member

vstinner commented Jul 3, 2017

Ok. I merged your PR. Let's watch buildbots http://buildbot.python.org/all/waterfall?category=3.x.stable&category=3.x.unstable Maybe I will regret in a few minutes ;-)

@ma8ma
Copy link
Contributor Author

ma8ma commented Jul 3, 2017

@Haypo Thank you for testing!

@ma8ma ma8ma deleted the bpo-30832-remove-own-impl-for-tls branch July 5, 2017 11:34
vstinner added a commit that referenced this pull request Jul 5, 2017
vstinner added a commit that referenced this pull request Jul 5, 2017
* Revert "bpo-30854: Fix compile error when --without-threads (#2581)"

This reverts commit 0c31163.

* Revert "NEWS for 30777 (#2576)"

This reverts commit aaa917f.

* Revert "bpo-21624: IDLE -- minor htest fixes (#2575)"

This reverts commit 2000150.

* Revert "bpo-30777: IDLE: configdialog - add docstrings and improve comments (#2440)"

This reverts commit 7eb5883.

* Revert "bpo-30319: socket.close() now ignores ECONNRESET (#2565)"

This reverts commit 67e1478.

* Revert "bpo-30789: Use a single memory block for co_extra. (#2555)"

This reverts commit 378ebb6.

* Revert "bpo-30845: Enhance test_concurrent_futures cleanup (#2564)"

This reverts commit 3df9dec.

* Revert "bpo-29293: multiprocessing.Condition.notify() lacks parameter `n` (#2480)"

This reverts commit 4835041.

* Revert "Remove outdated FOX from GUI FAQ (GH-2538)"

This reverts commit d3ed287.

* Revert "bpo-6691: Pyclbr now reports nested classes and functions. (#2503)"

This reverts commit 246ff3b.

* Revert "bpo-29464: Rename METH_FASTCALL to METH_FASTCALL|METH_KEYWORDS and make (#1955)"

This reverts commit 6969eaf.

* Revert "bpo-30832: Remove own implementation for thread-local storage (#2537)"

This reverts commit aa0aa04.

* Revert "bpo-30764: Fix regrtest --fail-env-changed --forever (#2536)"

This reverts commit 5e87592.

* Revert "bpo-30822: Deduplicate ZoneInfoTest classes in test_datetime. (#2534)"

This reverts commit 34b5487.

* Revert "bpo-30822: Fix testing of datetime module. (#2530)"

This reverts commit 98b6bc3.
ma8ma added a commit to ma8ma/cpython that referenced this pull request Jul 13, 2017
Resolve conflicts:
aa0aa04 bpo-30832: Remove own implementation for thread-local storage (python#2537)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants