Skip to content

Commit 43bcedd

Browse files
authored
[compiler-rt] fix __sanitizer_siginfo type on freebsd. (#77379)
mostly interested in the first half of the type, adding also compile time check.
1 parent 012b697 commit 43bcedd

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_freebsd.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,8 @@ CHECK_TYPE_SIZE(nfds_t);
475475
CHECK_TYPE_SIZE(sigset_t);
476476

477477
COMPILER_CHECK(sizeof(__sanitizer_sigaction) == sizeof(struct sigaction));
478+
COMPILER_CHECK(sizeof(__sanitizer_siginfo) == sizeof(siginfo_t));
479+
CHECK_SIZE_AND_OFFSET(siginfo_t, si_value);
478480
// Can't write checks for sa_handler and sa_sigaction due to them being
479481
// preprocessor macros.
480482
CHECK_STRUCT_SIZE_AND_OFFSET(sigaction, sa_mask);

compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_freebsd.h

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,11 +301,29 @@ struct __sanitizer_sigset_t {
301301

302302
typedef __sanitizer_sigset_t __sanitizer_kernel_sigset_t;
303303

304+
union __sanitizer_sigval {
305+
int sival_int;
306+
void *sival_ptr;
307+
};
308+
304309
struct __sanitizer_siginfo {
305-
// The size is determined by looking at sizeof of real siginfo_t on linux.
306-
u64 opaque[128 / sizeof(u64)];
310+
int si_signo;
311+
int si_errno;
312+
int si_code;
313+
pid_t si_pid;
314+
u32 si_uid;
315+
int si_status;
316+
void *si_addr;
317+
union __sanitizer_sigval si_value;
318+
# if SANITIZER_WORDSIZE == 64
319+
char data[40];
320+
# else
321+
char data[32];
322+
# endif
307323
};
308324

325+
typedef __sanitizer_siginfo __sanitizer_siginfo_t;
326+
309327
using __sanitizer_sighandler_ptr = void (*)(int sig);
310328
using __sanitizer_sigactionhandler_ptr = void (*)(int sig,
311329
__sanitizer_siginfo *siginfo,

0 commit comments

Comments
 (0)