
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). 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 <mark@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-leave@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/PLXETSQE... Code of Conduct: http://python.org/psf/codeofconduct/
-- Night gathers, and now my watch begins. It shall not end until my death.