diff --git a/lib/libc/minimal/CMakeLists.txt b/lib/libc/minimal/CMakeLists.txt index 71a404e7870926a..61f7a48ff804bd3 100644 --- a/lib/libc/minimal/CMakeLists.txt +++ b/lib/libc/minimal/CMakeLists.txt @@ -10,6 +10,7 @@ set(STRERROR_TABLE_H ${GEN_DIR}/libc/minimal/strerror_table.h) zephyr_library_cc_option(-fno-builtin) zephyr_library_sources( + source/signal/signal.c source/stdlib/atoi.c source/stdlib/strtol.c source/stdlib/strtoul.c diff --git a/lib/libc/minimal/include/signal.h b/lib/libc/minimal/include/signal.h new file mode 100644 index 000000000000000..f465db67d87572d --- /dev/null +++ b/lib/libc/minimal/include/signal.h @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2023 Meta + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_LIB_LIBC_MINIMAL_INCLUDE_SIGNAL_H_ +#define ZEPHYR_LIB_LIBC_MINIMAL_INCLUDE_SIGNAL_H_ + +#define SIG_DFL ((sighandler_t)0) +#define SIG_ERR ((sighandler_t)1) +#define SIG_IGN ((sighandler_t)-1) + +#ifdef __cplusplus +extern "C" { +#endif + +typedef int sig_atomic_t; /* Atomic entity type (ANSI) */ + +/* Note: sighandler_t is a gnu-ism, but it simplifies the declaration below */ +typedef void (*sighandler_t)(int signo); + +sighandler_t signal(int signum, sighandler_t handler); + +#ifdef __cplusplus +} +#endif + +#endif /* ZEPHYR_LIB_LIBC_MINIMAL_INCLUDE_SIGNAL_H_ */ diff --git a/lib/libc/minimal/source/signal/signal.c b/lib/libc/minimal/source/signal/signal.c new file mode 100644 index 000000000000000..eb371ab652fd0c1 --- /dev/null +++ b/lib/libc/minimal/source/signal/signal.c @@ -0,0 +1,12 @@ +/* + * Copyright (c) 2023 Meta + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include + +sighandler_t signal(int signum, sighandler_t handler) +{ + return SIG_DFL; +}