Skip to content

Commit

Permalink
posix: signal: check RTSIG limit
Browse files Browse the repository at this point in the history
Use build assert to make sure that the realtime signal
constants are configured properly in the Kconfig.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
  • Loading branch information
ycsin authored and cfriedt committed Jul 18, 2023
1 parent 5970543 commit 43c5493
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/posix/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ source "lib/posix/Kconfig.fnmatch"
source "lib/posix/Kconfig.fs"
source "lib/posix/Kconfig.getopt"
source "lib/posix/Kconfig.key"
source "lib/posix/Kconfig.limits"
source "lib/posix/Kconfig.mqueue"
source "lib/posix/Kconfig.mutex"
source "lib/posix/Kconfig.pthread"
Expand Down
13 changes: 13 additions & 0 deletions lib/posix/Kconfig.limits
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright (c) 2023 Meta
#
# SPDX-License-Identifier: Apache-2.0

if POSIX_SIGNAL
config POSIX_LIMITS_RTSIG_MAX
int "_POSIX_RTSIG_MAX value in limits.h"
default 8
help
Define the _POSIX_RTSIG_MAX value in limits.h.
IEEE 1003.1 defines this to be 8.

endif
3 changes: 3 additions & 0 deletions lib/posix/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
#define SIGNO_WORD_IDX(_signo) (signo / BITS_PER_LONG)
#define SIGNO_WORD_BIT(_signo) (signo & BIT_MASK(LOG2(BITS_PER_LONG)))

BUILD_ASSERT(CONFIG_POSIX_LIMITS_RTSIG_MAX >= 0);
BUILD_ASSERT(CONFIG_POSIX_RTSIG_MAX >= CONFIG_POSIX_LIMITS_RTSIG_MAX);

static inline bool signo_valid(int signo)
{
return ((signo > 0) && (signo < _NSIG));
Expand Down

0 comments on commit 43c5493

Please sign in to comment.