Skip to content

[libc] Minor fixes/additions to signal.h header. - #217469

Merged
vonosmas merged 2 commits into
llvm:mainfrom
vonosmas:sighal-h-updates
Aug 19, 2026
Merged

[libc] Minor fixes/additions to signal.h header.#217469
vonosmas merged 2 commits into
llvm:mainfrom
vonosmas:sighal-h-updates

Conversation

@vonosmas

Copy link
Copy Markdown
Contributor
  • Fix a typo for si_overrun field inside siginfo_t struct (it is accessible via si_overrun macro, and names should match)
  • Add sig_t type which is used in BSD for signal handler function. It's identical to GNU's sighandler_t, and glibc provides both. Clarify this in their YAML entries.
  • Add more Linux-specific SI_* values.

@vonosmas
vonosmas requested a review from a team as a code owner August 19, 2026 21:39
@llvmorg-github-actions

Copy link
Copy Markdown

@llvm/pr-subscribers-libc

Author: Alexey Samsonov (vonosmas)

Changes
  • Fix a typo for si_overrun field inside siginfo_t struct (it is accessible via si_overrun macro, and names should match)
  • Add sig_t type which is used in BSD for signal handler function. It's identical to GNU's sighandler_t, and glibc provides both. Clarify this in their YAML entries.
  • Add more Linux-specific SI_* values.

Full diff: https://github.com/llvm/llvm-project/pull/217469.diff

6 Files Affected:

  • (modified) libc/include/CMakeLists.txt (+1)
  • (modified) libc/include/llvm-libc-macros/linux/signal-macros.h (+4)
  • (modified) libc/include/llvm-libc-types/CMakeLists.txt (+1)
  • (added) libc/include/llvm-libc-types/sig_t.h (+20)
  • (modified) libc/include/llvm-libc-types/siginfo_t.h (+1-1)
  • (modified) libc/include/signal.yaml (+5)
diff --git a/libc/include/CMakeLists.txt b/libc/include/CMakeLists.txt
index 91d601d50a711..4dcb5a2ea696a 100644
--- a/libc/include/CMakeLists.txt
+++ b/libc/include/CMakeLists.txt
@@ -414,6 +414,7 @@ add_header_macro(
     .llvm-libc-macros.signal_macros
     .llvm-libc-types.pid_t
     .llvm-libc-types.sig_atomic_t
+    .llvm-libc-types.sig_t
     .llvm-libc-types.sighandler_t
     .llvm-libc-types.siginfo_t
     .llvm-libc-types.sigset_t
diff --git a/libc/include/llvm-libc-macros/linux/signal-macros.h b/libc/include/llvm-libc-macros/linux/signal-macros.h
index e9fff447f9086..8532c423c395f 100644
--- a/libc/include/llvm-libc-macros/linux/signal-macros.h
+++ b/libc/include/llvm-libc-macros/linux/signal-macros.h
@@ -150,5 +150,9 @@
 #define SI_TIMER (-2)   // Expiration of a timer set by timer_settime()
 #define SI_ASYNCIO (-4) // Completion of an synchronous I/O request
 #define SI_MESGQ (-3)   // Arrival of a message on an empty message queue
+#define SI_SIGIO (-5)   // Queued SIGIO, on older versions of Linux
+#define SI_TKILL (-6)   // Sent by tkill or tgkill
+#define SI_ASYNCNL (-60) // Async name lookup completion
+#define SI_KERNEL 128    // Sent by the kernel
 
 #endif // LLVM_LIBC_MACROS_LINUX_SIGNAL_MACROS_H
diff --git a/libc/include/llvm-libc-types/CMakeLists.txt b/libc/include/llvm-libc-types/CMakeLists.txt
index 1c999bfd0b857..69d62619f7979 100644
--- a/libc/include/llvm-libc-types/CMakeLists.txt
+++ b/libc/include/llvm-libc-types/CMakeLists.txt
@@ -122,6 +122,7 @@ add_header(rlim_t HDR rlim_t.h)
 add_header(sem_t HDR sem_t.h DEPENDS .__futex_word)
 add_header(time_t HDR time_t_64.h DEST_HDR time_t.h)
 add_header(timer_t HDR timer_t.h)
+add_header(sig_t HDR sig_t.h)
 add_header(sighandler_t HDR sighandler_t.h)
 add_header(stack_t HDR stack_t.h DEPENDS .size_t)
 add_header(suseconds_t HDR suseconds_t.h)
diff --git a/libc/include/llvm-libc-types/sig_t.h b/libc/include/llvm-libc-types/sig_t.h
new file mode 100644
index 0000000000000..ad6b1aeb5617c
--- /dev/null
+++ b/libc/include/llvm-libc-types/sig_t.h
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Definition of sig_t type.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_TYPES_SIG_T_H
+#define LLVM_LIBC_TYPES_SIG_T_H
+
+// BSD type for signal handlers.
+typedef void (*sig_t)(int);
+
+#endif // LLVM_LIBC_TYPES_SIG_T_H
diff --git a/libc/include/llvm-libc-types/siginfo_t.h b/libc/include/llvm-libc-types/siginfo_t.h
index 20fdd461bb6df..67366e40b1ebc 100644
--- a/libc/include/llvm-libc-types/siginfo_t.h
+++ b/libc/include/llvm-libc-types/siginfo_t.h
@@ -33,7 +33,7 @@ typedef struct {
     /* POSIX.1b timers */
     struct {
       int si_tid;             /* timer id */
-      int _overrun;           /* overrun count */
+      int si_overrun;         /* overrun count */
       union sigval si_sigval; /* same as below */
     } _timer;
 
diff --git a/libc/include/signal.yaml b/libc/include/signal.yaml
index 7ab557875af71..307bbfedbec01 100644
--- a/libc/include/signal.yaml
+++ b/libc/include/signal.yaml
@@ -23,7 +23,12 @@ macros:
 types:
   - type_name: pid_t
   - type_name: sig_atomic_t
+  - type_name: sig_t
+    standards:
+      - bsd
   - type_name: sighandler_t
+    standards:
+      - gnu
   - type_name: siginfo_t
   - type_name: sigset_t
   - type_name: stack_t

@michaelrj-google michaelrj-google left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@vonosmas
vonosmas merged commit f39d581 into llvm:main Aug 19, 2026
47 checks passed
@vonosmas
vonosmas deleted the sighal-h-updates branch August 19, 2026 22:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants