[libc-commits] [PATCH] D71094: [libc] Add implementation of errno and define the other macros of errno.h.

Alex Brachet via Phabricator via libc-commits libc-commits at lists.llvm.org
Fri Dec 6 00:32:27 PST 2019


abrachet added inline comments.


================
Comment at: libc/src/errno/errno_location.cpp:14
+static thread_local int __errno = 0;
+int &llvmlibc_errno = __errno;
+
----------------
If we do end up keeping this reference we could also put it behind `namespace __llvm_libc` and call it something less verbose, perhaps.


================
Comment at: libc/src/errno/llvmlibc_errno.h:14
+// public header.
+extern int &llvmlibc_errno;
+
----------------
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.




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