[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:08:14 PST 2019
MaskRay added inline comments.
================
Comment at: libc/config/linux/api.td:34
+ extern int *__errno_location();
+ #define errno *__errno_location()
+ }];
----------------
sivachandra wrote:
> MaskRay wrote:
> > `()`
> >
> > Otherwise `errno[0]` is incorrect.
> We don't want to put it in parenthesis because we want to error on uses like `errno[0]`. `errno` is supposed to be an lvalue of int type and allowing `errno[0]` actually amounts to leaking implementation detail.
I know errno[0] will be an error anyway.
However, this breaks grouping: `*__errno_location()[0]`
You also don't want `3 errno` to be treated as `3*__errno_location()`, do you?
================
Comment at: libc/src/errno/llvmlibc_errno.h:14
+// public header.
+extern int &llvmlibc_errno;
+
----------------
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.
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