Skip to content

Commit 43c5493

Browse files
ycsincfriedt
authored andcommitted
posix: signal: check RTSIG limit
Use build assert to make sure that the realtime signal constants are configured properly in the Kconfig. Signed-off-by: Yong Cong Sin <[email protected]>
1 parent 5970543 commit 43c5493

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

lib/posix/Kconfig

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ source "lib/posix/Kconfig.fnmatch"
4444
source "lib/posix/Kconfig.fs"
4545
source "lib/posix/Kconfig.getopt"
4646
source "lib/posix/Kconfig.key"
47+
source "lib/posix/Kconfig.limits"
4748
source "lib/posix/Kconfig.mqueue"
4849
source "lib/posix/Kconfig.mutex"
4950
source "lib/posix/Kconfig.pthread"

lib/posix/Kconfig.limits

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Copyright (c) 2023 Meta
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
if POSIX_SIGNAL
6+
config POSIX_LIMITS_RTSIG_MAX
7+
int "_POSIX_RTSIG_MAX value in limits.h"
8+
default 8
9+
help
10+
Define the _POSIX_RTSIG_MAX value in limits.h.
11+
IEEE 1003.1 defines this to be 8.
12+
13+
endif

lib/posix/signal.c

+3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
#define SIGNO_WORD_IDX(_signo) (signo / BITS_PER_LONG)
1414
#define SIGNO_WORD_BIT(_signo) (signo & BIT_MASK(LOG2(BITS_PER_LONG)))
1515

16+
BUILD_ASSERT(CONFIG_POSIX_LIMITS_RTSIG_MAX >= 0);
17+
BUILD_ASSERT(CONFIG_POSIX_RTSIG_MAX >= CONFIG_POSIX_LIMITS_RTSIG_MAX);
18+
1619
static inline bool signo_valid(int signo)
1720
{
1821
return ((signo > 0) && (signo < _NSIG));

0 commit comments

Comments
 (0)