On 29.01.2021 20:15, Victor Stinner wrote:
Hi Mark,

I tried to use C11 _Thread_local (Thread Local Storage, TLS) only with
GCC and clang and I got issues on macOS:
https://github.com/python/cpython/pull/23976

My PR uses __thread if _Thread_local is not available.

I don't think that MSC (Visual Studio) implements C11 _Thread_local,
but it provides __declspec(thread). I tried it and I got issues with
DLL. I didn't dig into this issue. MSC loves C++ but seems stuck at
C99 (I'm not even sure if it's fully implemented).

According to https://docs.microsoft.com/en-us/cpp/build/reference/std-specify-language-standard-version?view=msvc-160#c-standards-support-1 and https://docs.microsoft.com/en-us/cpp/overview/install-c17-support?view=msvc-160 , they only partially support C99, and C11 and C17 support is available in the Insider Preview version. The preview version supports all the required but no optional features (including optional features that were required in C99) and suggest to use features test macros.
They also say that the 2 standard modes are functonally equivalent except the 
version macro since C17 is a bugfix release.

AFAICS, this means that global C99 requirement is out of the question; C11/C17 can be considered when that MSVC version is released -- but alternative solutions are still needed for code chunks using optional features.



It seems like declaring a TLS in libpython and using it from an
extension module (another dynamic library) is causing issues depending
on the linker. It "should" work on macOS, but it doesn't.

See https://bugs.python.org/issue40522 for the produced machine code
on x86-64. In short, it's usually a single MOV using the FS register
(two MOV in the worst case).

Victor

On Thu, Jan 28, 2021 at 5:29 PM Mark Shannon <m...@hotpy.org> wrote:
Hi everyone,

PEP 7 says that C code should conform to C89 with a subset of C99 allowed.
It's 2021 and all the major compilers support C11 (ignoring the optional
parts).

C11 has support for thread locals, static asserts, and anonymous structs
and unions. All useful features.

Is there a good reason not to start using C11 now?

Cheers,
Mark.


_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/PLXETSQE7PRFXBXN2QY6VNPKUTM6I7OD/
Code of Conduct: http://python.org/psf/codeofconduct/


--
Regards,
Ivan
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/54Y55JCNK6PMSVFO4YUX7GZMH4VC53DQ/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to