[libc-commits] [PATCH] D71094: [libc] Add implementation of errno and define the other macros of errno.h.
Fangrui Song via Phabricator via libc-commits
libc-commits at lists.llvm.org
Fri Dec 6 00:54:38 PST 2019
MaskRay added inline comments.
================
Comment at: libc/src/errno/llvmlibc_errno.h:14
+// public header.
+extern int &llvmlibc_errno;
+
----------------
sivachandra wrote:
> abrachet wrote:
> > MaskRay wrote:
> > > I don't think this will work. In the test translation unit, the compiler does not know that `llvmlibc_errno` is bound to a thread-local variable.
> > >
> > > Even in the definition site, it's not clear to me that a reference to a thread-local variable will guarantee to work.
> > Right, it must be `thread_local int &`. I've tested it only briefly, if the reference isn't `thread_local` it doesn't work. As far as I can tell `thread_local int &` works.
> >
> >
> Sigh yes. This declaration has to include `thread_local` for everything to work correctly. Will update in the next round.
But why do we need a thread_local reference in the first place? It is represented as a thread_local pointer that is initialized to the return address of a TLS wrapper function under the hood. You can check the codegen. The performance is bad.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D71094/new/
https://reviews.llvm.org/D71094
More information about the libc-commits
mailing list