From 310b5a884f1f12364f53a2a699a52a66ddf9bcbe Mon Sep 17 00:00:00 2001 From: HuangXL Date: Fri, 9 Jun 2023 23:15:31 +0800 Subject: [PATCH 1/2] add the comment of function sigsuspend, sigtimedwait, sigwait, sigwaitinfo. --- components/libc/posix/signal/posix_signal.c | 49 ++++++++++++++++++--- 1 file changed, 43 insertions(+), 6 deletions(-) diff --git a/components/libc/posix/signal/posix_signal.c b/components/libc/posix/signal/posix_signal.c index 04b3b104f1b..111b1fc028f 100644 --- a/components/libc/posix/signal/posix_signal.c +++ b/components/libc/posix/signal/posix_signal.c @@ -44,7 +44,6 @@ void (*signal(int sig, void (*func)(int))) (int) * * @return Returns 0 on success. */ - int sigprocmask (int how, const sigset_t *set, sigset_t *oset) { rt_base_t level; @@ -90,7 +89,16 @@ int sigpending (sigset_t *set) sigprocmask(SIG_SETMASK, RT_NULL, set); return 0; } - +/** + * @brief This function will temporarily replace the signal mask of the calling thread + * with the mask given and then suspends the thread until delivery of an expected signal + * or a signal whose action is to terminate a process. + * + * @param set is a pointer of a sigset_t object that is used to replace the original mask of the calling thread. + * + * @return Returns 0 on success. + * If the return value is any other values, it means that the signal wait failed. + */ int sigsuspend (const sigset_t *set) { int ret = 0; @@ -125,7 +133,6 @@ int sigsuspend (const sigset_t *set) * * @return Returns 0 on success or -1 on failure. */ - int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact) { rt_sighandler_t old = RT_NULL; @@ -145,7 +152,19 @@ int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact) return 0; } - +/** + * @brief This function will suspends execution of the calling thread until one of + * the signals in the given set is pending. If none of the signals specified + * are pending, it will wait for the specified time interval. + * + * @param set is the set of signal values to be waited for. + * + * @param info is a pointer to the received signal info. + * + * @param timeout is a pointer to a timespec structure that specifys the waiting time. + * + * @return Return 0 on success. Otherwise, return -1 and set errno to indicate the error. + */ int sigtimedwait(const sigset_t *set, siginfo_t *info, const struct timespec *timeout) { int ret = 0; @@ -162,7 +181,16 @@ int sigtimedwait(const sigset_t *set, siginfo_t *info, const struct timespec *ti errno = ret; return -1; } - +/** + * @brief This function will suspend execution of the calling thread until one of + * the specified signal becomes pending and return the signal number. + * + * @param set is the set of signal values to be waited for. + * + * @param sig is a pointer to the received signal number. + * + * @return Return 0 on success or -1 on failure. + */ int sigwait(const sigset_t *set, int *sig) { siginfo_t si; @@ -172,7 +200,16 @@ int sigwait(const sigset_t *set, int *sig) *sig = si.si_signo; return 0; } - +/** + * @brief This function will suspend execution of the calling thread until one of + * the specified signal is pending. + * + * @param set is the set of signal values to be waited for. + * + * @param info is a pointer to the received signal info. + * + * @return Return 0 on success or -1 on failure. + */ int sigwaitinfo(const sigset_t *set, siginfo_t *info) { return sigtimedwait(set, info, NULL); From 3b6e9ad54ac6a5b6e0028eb3c3c822939e443824 Mon Sep 17 00:00:00 2001 From: HuangXL Date: Sat, 10 Jun 2023 10:22:18 +0800 Subject: [PATCH 2/2] use formatting to complie with the code specification --- components/libc/posix/signal/posix_signal.c | 36 ++++++++++----------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/components/libc/posix/signal/posix_signal.c b/components/libc/posix/signal/posix_signal.c index 111b1fc028f..25475bdbade 100644 --- a/components/libc/posix/signal/posix_signal.c +++ b/components/libc/posix/signal/posix_signal.c @@ -93,9 +93,9 @@ int sigpending (sigset_t *set) * @brief This function will temporarily replace the signal mask of the calling thread * with the mask given and then suspends the thread until delivery of an expected signal * or a signal whose action is to terminate a process. - * + * * @param set is a pointer of a sigset_t object that is used to replace the original mask of the calling thread. - * + * * @return Returns 0 on success. * If the return value is any other values, it means that the signal wait failed. */ @@ -153,16 +153,16 @@ int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact) return 0; } /** - * @brief This function will suspends execution of the calling thread until one of + * @brief This function will suspends execution of the calling thread until one of * the signals in the given set is pending. If none of the signals specified * are pending, it will wait for the specified time interval. - * - * @param set is the set of signal values to be waited for. - * - * @param info is a pointer to the received signal info. - * + * + * @param set is the set of signal values to be waited for. + * + * @param info is a pointer to the received signal info. + * * @param timeout is a pointer to a timespec structure that specifys the waiting time. - * + * * @return Return 0 on success. Otherwise, return -1 and set errno to indicate the error. */ int sigtimedwait(const sigset_t *set, siginfo_t *info, const struct timespec *timeout) @@ -182,13 +182,13 @@ int sigtimedwait(const sigset_t *set, siginfo_t *info, const struct timespec *ti return -1; } /** - * @brief This function will suspend execution of the calling thread until one of + * @brief This function will suspend execution of the calling thread until one of * the specified signal becomes pending and return the signal number. - * + * * @param set is the set of signal values to be waited for. - * + * * @param sig is a pointer to the received signal number. - * + * * @return Return 0 on success or -1 on failure. */ int sigwait(const sigset_t *set, int *sig) @@ -201,14 +201,14 @@ int sigwait(const sigset_t *set, int *sig) return 0; } /** - * @brief This function will suspend execution of the calling thread until one of + * @brief This function will suspend execution of the calling thread until one of * the specified signal is pending. - * + * * @param set is the set of signal values to be waited for. - * + * * @param info is a pointer to the received signal info. - * - * @return Return 0 on success or -1 on failure. + * + * @return Return 0 on success or -1 on failure. */ int sigwaitinfo(const sigset_t *set, siginfo_t *info) {