modified: components/libc/posix/delay/delay.c Added comments for all functions in this file

modified:   components/libc/posix/signal/posix_signal.c		Add comments to the sigqueue function, although it does not have an internal implementation
modified:   components/libc/posix/signal/posix_signal.h		Added detailed explanation to all members of the rt_signal_value enumeration
This commit is contained in:
Troy 2024-03-25 14:24:26 +08:00 committed by Meco Man
parent 7c2353a622
commit fe512e6411
3 changed files with 83 additions and 34 deletions

View File

@ -12,36 +12,68 @@
#include <rtthread.h>
#include <rthw.h>
/**
* @brief Delays the execution of the current thread for the specified number of milliseconds.
*
* @param msecs The number of milliseconds to sleep.
*/
void msleep(unsigned int msecs)
{
rt_thread_mdelay(msecs);
}
RTM_EXPORT(msleep);
/**
* @brief Delays the execution of the current thread for the specified number of seconds.
*
* @param seconds The number of seconds to sleep.
*/
void ssleep(unsigned int seconds)
{
msleep(seconds * 1000);
}
RTM_EXPORT(ssleep);
/**
* @brief Delays the execution of the current thread for the specified number of milliseconds.
*
* @param msecs The number of milliseconds to delay.
*/
void mdelay(unsigned long msecs)
{
rt_hw_us_delay(msecs * 1000);
}
RTM_EXPORT(mdelay);
/**
* @brief Delays the execution of the current thread for the specified number of microseconds.
*
* @param usecs The number of microseconds to delay.
*/
void udelay(unsigned long usecs)
{
rt_hw_us_delay(usecs);
}
RTM_EXPORT(udelay);
/**
* @brief Delays the execution of the current thread for approximately one microsecond.
*
* @param nsecs This parameter is ignored.
*/
void ndelay(unsigned long nsecs)
{
rt_hw_us_delay(1);
}
RTM_EXPORT(ndelay);
/**
* @brief Delays the execution of the current thread for the specified number of seconds.
*
* @param seconds The number of seconds to sleep.
*
* @return Returns 0 on success.
*/
unsigned int sleep(unsigned int seconds)
{
if (rt_thread_self() != RT_NULL)
@ -61,6 +93,13 @@ unsigned int sleep(unsigned int seconds)
}
RTM_EXPORT(sleep);
/**
* @brief Delays the execution of the current thread for the specified number of microseconds.
*
* @param usec The number of microseconds to sleep.
*
* @return Returns 0 on success.
*/
int usleep(useconds_t usec)
{
if (rt_thread_self() != RT_NULL)

View File

@ -229,6 +229,16 @@ int raise(int sig)
}
#include <sys/types.h>
/**
* @brief Sends a signal to the caller.
*
* This function sends the signal specified by @p sig to the caller.
*
* @param sig The signal to be sent.
* This should be one of the standard signal macros such as SIGUSR1, SIGUSR2, etc.
*
* @return Returns 0 on success. If an error occurs, -1 is returned and errno is set appropriately.
*/
int sigqueue (pid_t pid, int signo, const union sigval value)
{
/* no support, signal queue */

View File

@ -18,40 +18,40 @@ extern "C" {
#include <sys/signal.h>
enum rt_signal_value{
SIG1 = SIGHUP,
SIG2 = SIGINT,
SIG3 = SIGQUIT,
SIG4 = SIGILL,
SIG5 = SIGTRAP,
SIG6 = SIGABRT,
SIG7 = SIGEMT,
SIG8 = SIGFPE,
SIG9 = SIGKILL,
SIG10 = SIGBUS,
SIG11 = SIGSEGV,
SIG12 = SIGSYS,
SIG13 = SIGPIPE,
SIG14 = SIGALRM,
SIG15 = SIGTERM,
SIG16 = SIGURG,
SIG17 = SIGSTOP,
SIG18 = SIGTSTP,
SIG19 = SIGCONT,
SIG20 = SIGCHLD,
SIG21 = SIGTTIN,
SIG22 = SIGTTOU,
SIG23 = SIGPOLL,
SIG24 = 24, // SIGXCPU,
SIG25 = 25, // SIGXFSZ,
SIG26 = 26, // SIGVTALRM,
SIG27 = 27, // SIGPROF,
SIG28 = SIGWINCH,
SIG29 = 29, // SIGLOST,
SIG30 = SIGUSR1,
SIG31 = SIGUSR2,
SIGRT_MIN = 27, // SIGRTMIN,
SIGRT_MAX = 31, // SIGRTMAX,
SIGMAX = NSIG,
SIG1 = SIGHUP, // Hangup detected on controlling terminal or death of controlling process
SIG2 = SIGINT, // Interrupt from keyboard
SIG3 = SIGQUIT, // Quit from keyboard
SIG4 = SIGILL, // Illegal instruction
SIG5 = SIGTRAP, // Trace trap
SIG6 = SIGABRT, // Abort signal from abort(3)
SIG7 = SIGEMT, // Emulator trap
SIG8 = SIGFPE, // Floating-point exception
SIG9 = SIGKILL, // Kill signal
SIG10 = SIGBUS, // Bus error
SIG11 = SIGSEGV, // Segmentation fault
SIG12 = SIGSYS, // Bad system call
SIG13 = SIGPIPE, // Broken pipe
SIG14 = SIGALRM, // Timer signal from alarm(2)
SIG15 = SIGTERM, // Termination signal
SIG16 = SIGURG, // Urgent condition on socket
SIG17 = SIGSTOP, // Stop executing (cannot be caught or ignored)
SIG18 = SIGTSTP, // Stop signal from keyboard to suspend execution
SIG19 = SIGCONT, // Continue if stopped
SIG20 = SIGCHLD, // Child status has changed
SIG21 = SIGTTIN, // Background read from control terminal attempted by background process
SIG22 = SIGTTOU, // Background write to control terminal attempted by background process
SIG23 = SIGPOLL, // Pollable event
SIG24 = 24, // SIGXCPU: CPU time limit exceeded
SIG25 = 25, // SIGXFSZ: File size limit exceeded
SIG26 = 26, // SIGVTALRM: Virtual timer expired
SIG27 = 27, // SIGPROF: Profiling timer expired
SIG28 = SIGWINCH,// Window size changed
SIG29 = 29, // SIGLOST
SIG30 = SIGUSR1, // User-defined signal 1
SIG31 = SIGUSR2, // User-defined signal 2
SIGRT_MIN = 27, // SIGRTMIN: Minimum real-time signal number
SIGRT_MAX = 31, // SIGRTMAX: Maximum real-time signal number
SIGMAX = NSIG // Number of signals (total)
};
#ifdef __cplusplus