This is an archive of the discontinued LLVM Phabricator instance.

[libc] Use Linux errno and signal strings for Fuchsia
ClosedPublic

Authored by mcgrathr on May 6 2023, 2:12 AM.

Details

Summary

The exact set of supported values is determined by the <errno.h>
and <signal.h> headers, which don't (yet) come from llvm-libc on
Fuchsia. The mappings of SIG* and E* codes to psignal/strsignal
and perror/strerror text used in Fuchsia libc today is the same
as for Linux.

Diff Detail

Event Timeline

mcgrathr created this revision.May 6 2023, 2:12 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptMay 6 2023, 2:12 AM
mcgrathr requested review of this revision.May 6 2023, 2:12 AM
abrachet accepted this revision.May 6 2023, 10:47 AM
This revision is now accepted and ready to land.May 6 2023, 10:47 AM
This revision was automatically updated to reflect the committed changes.
sivachandra added inline comments.
libc/src/__support/StringUtil/tables/error_table.h
32

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
  1. We will add couple more tables (more can be added in future):
tables/
    ...
    linux_platform_errors.h
    minimal_platform_errors.h
  1. 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;
  1. minimal_platform_errors.h will include only stdc_errors.h and define PLATFORM_ERRORS as:
PLATFORM_ERRORS = STDC_ERRORS;
  1. 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.

mcgrathr added inline comments.May 22 2023, 1:09 PM
libc/src/__support/StringUtil/tables/error_table.h
32

That sounds fine to me.