This is an archive of the discontinued LLVM Phabricator instance.

[libc] Re-enable functions from signal.h and re-enable abort.
ClosedPublic

Authored by sivachandra on Sep 23 2022, 2:51 PM.

Details

Summary

They were disabled because we were including linux/signal.h from our
signal.h. Linux's signal.h is not designed to be included from user
programs as it causes a lot of non-standard name pollution. Also, it is
not self-contained. This change defines types and macros relevant for
signal related syscalls within libc's headers and removes inclusion of
Linux headers.

This patch enables the funtions only for x86_64. They will be enabled
for aarch64 also in a follow up patch after testing.

Diff Detail

Event Timeline

sivachandra created this revision.Sep 23 2022, 2:51 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptSep 23 2022, 2:51 PM
sivachandra requested review of this revision.Sep 23 2022, 2:51 PM
lntue accepted this revision.Sep 23 2022, 4:30 PM
This revision is now accepted and ready to land.Sep 23 2022, 4:30 PM
abrachet accepted this revision.Sep 29 2022, 3:54 PM
abrachet added inline comments.
libc/include/llvm-libc-macros/signal-macros.h
12–14

Should this be __linux__?

libc/include/llvm-libc-types/siginfo_t.h
3

This got moved to the next line

28

FWIW, this looks like it's architecture dependent. Admittedly I don't remember the story about why we moved away from using Linux headers. It might be nice to leave around something like

#if ! (defined(LLVM_LIBC_ARCH_X86_64) || defined(LLVM_LIBC_ARCH_AARCH64))
#error "this siginfo may not be valid for your architecture"
#endif

Though I have no strong preference because it looks like only mips and ia64 have other implementations of this type

libc/include/llvm-libc-types/struct_sigaction.h
22

Should this be __linux__? From looking at various other man pages (and your comment right bellow) this is seemingly only on Linux.

sivachandra marked 2 inline comments as done.

Address comments.

sivachandra added inline comments.Sep 30 2022, 12:31 AM
libc/include/llvm-libc-macros/signal-macros.h
12–14

I don't remember why we started doing #ifdef __unix__ - I have changed to __linux__ now. I will cleanup other instances in a different change.

libc/include/llvm-libc-types/siginfo_t.h
28

About Linux headers, tl;dr - they lead to name pollution in user programs.

About making this struct target specific or excluding it, I think we can do it when we have an example to deal with.

This revision was landed with ongoing or failed builds.Sep 30 2022, 12:32 AM
This revision was automatically updated to reflect the committed changes.
libc/src/signal/linux/sigfillset.cpp