1 From b9b6faf66ae67648626470cb4fc3f0850ac4d842 Mon Sep 17 00:00:00 2001
2 From: David Disseldorp <ddiss@suse.de>
3 Date: Tue, 1 Sep 2020 13:49:21 +0200
4 Subject: [PATCH] cmake: detect and use sigdescr_np() if available
6 sys_siglist is deprecated with glibc 2.32. A new thread-safe and
7 async-signal safe sigdescr_np() function is provided, so use it if
10 Fixes: https://tracker.ceph.com/issues/47187
11 Signed-off-by: David Disseldorp <ddiss@suse.de>
13 cmake/modules/CephChecks.cmake | 1 +
14 src/global/signal_handler.h | 8 +++++---
15 src/include/config-h.in.cmake | 3 +++
16 3 files changed, 9 insertions(+), 3 deletions(-)
18 diff --git a/cmake/modules/CephChecks.cmake b/cmake/modules/CephChecks.cmake
19 index 23687283a7c6..ca86dcbc73de 100644
20 --- a/cmake/modules/CephChecks.cmake
21 +++ b/cmake/modules/CephChecks.cmake
22 @@ -24,6 +24,7 @@ check_function_exists(strerror_r HAVE_Strerror_R)
23 check_function_exists(name_to_handle_at HAVE_NAME_TO_HANDLE_AT)
24 check_function_exists(pipe2 HAVE_PIPE2)
25 check_function_exists(accept4 HAVE_ACCEPT4)
26 +check_function_exists(sigdescr_np HAVE_SIGDESCR_NP)
28 include(CMakePushCheckState)
29 cmake_push_check_state(RESET)
30 diff --git a/src/global/signal_handler.h b/src/global/signal_handler.h
31 index 476724201aa9..c101b2e28733 100644
32 --- a/src/global/signal_handler.h
33 +++ b/src/global/signal_handler.h
36 typedef void (*signal_handler_t)(int);
38 -#ifndef HAVE_REENTRANT_STRSIGNAL
39 -# define sig_str(signum) sys_siglist[signum]
41 +#ifdef HAVE_SIGDESCR_NP
42 +# define sig_str(signum) sigdescr_np(signum)
43 +#elif HAVE_REENTRANT_STRSIGNAL
44 # define sig_str(signum) strsignal(signum)
46 +# define sig_str(signum) sys_siglist[signum]
49 void install_sighandler(int signum, signal_handler_t handler, int flags);
50 diff --git a/src/include/config-h.in.cmake b/src/include/config-h.in.cmake
51 index 1ea3703f620c..59bd4273511a 100644
52 --- a/src/include/config-h.in.cmake
53 +++ b/src/include/config-h.in.cmake
55 /* Define to 1 if you have sched.h. */
56 #cmakedefine HAVE_SCHED 1
58 +/* Define to 1 if you have sigdescr_np. */
59 +#cmakedefine HAVE_SIGDESCR_NP 1
61 /* Support SSE (Streaming SIMD Extensions) instructions */