[libc-commits] [PATCH] D150026: [libc] Use Linux errno and signal strings for Fuchsia
Siva Chandra via Phabricator via libc-commits
libc-commits at lists.llvm.org
Fri May 19 14:37:10 PDT 2023
sivachandra added inline comments.
================
Comment at: libc/src/__support/StringUtil/tables/error_table.h:32
+ return STDC_ERRORS + POSIX_ERRORS + LINUX_ERRORS;
+ } else {
+ return STDC_ERRORS;
----------------
If the `else` path is taken here, then `LINUX_ERRORS` will not be included and will lead to a build error. Do you have any suggestions on how to handle this? Following is an idea that comes to my mind.
I prefer to reduce the number of conditionals and use a more explicit structure like this.
1. The errors, as specified by the various [de facto] standards, can stay as they are today:
```
tables/
stdc_errors.h
posix_errors.h
linux_extension_errors.h
```
2. We will add couple more tables (more can be added in future):
```
tables/
...
linux_platform_errors.h
minimal_platform_errors.h
```
3. `linux_platform_errors.h` will include `stdc_errors.h`,`posix_errors.h` and `linux_extension_errors.h` and define `PLATFORM_ERRORS` as
```
PLATFORM_ERRORS = STDC_ERRORS + POSIX_ERRORS + LINUX_ERRORS;
```
4. `minimal_platform_errors.h` will include only `stdc_errors.h` and define `PLATFORM_ERRORS` as:
```
PLATFORM_ERRORS = STDC_ERRORS;
```
5. In the parent directly, we will add a new file named `platform_errors.h` which will have the following structure:
```
#if defined(__linux__) || defined(__Fuchsia__)
#include "tables/linux_platform_errors.h"
#else
#include "tables/minimal_platform_errors.h"
#endif
```
In effect, there is only one condtional confined to `platform_errors.h`.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D150026/new/
https://reviews.llvm.org/D150026
More information about the libc-commits
mailing list