summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/libc/libc_errno.h323
-rw-r--r--include/libc/libc_fcntl.h6
-rw-r--r--include/libc/libc_fdset.h6
-rw-r--r--include/libc/libc_ioctl.h4
-rw-r--r--include/libc/libc_limits.h25
-rw-r--r--include/libc/libc_signal.h26
-rw-r--r--include/libc/libc_stat.h2
-rw-r--r--include/libc/libc_stdio.h22
-rw-r--r--include/rtdbg.h65
-rw-r--r--include/rtdef.h115
-rw-r--r--include/rthw.h22
-rw-r--r--include/rtlibc.h2
-rw-r--r--include/rtservice.h18
-rw-r--r--include/rtthread.h38
14 files changed, 420 insertions, 254 deletions
diff --git a/include/libc/libc_errno.h b/include/libc/libc_errno.h
index 82ae8cf943..9143c841f2 100644
--- a/include/libc/libc_errno.h
+++ b/include/libc/libc_errno.h
@@ -2,10 +2,6 @@
* Copyright (c) 2006-2018, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
- */
-
-/*
- * File : libc_errno.h
*
* Change Logs:
* Date Author Notes
@@ -17,145 +13,194 @@
#include <rtconfig.h>
-#if defined(RT_USING_NEWLIB) || defined(_WIN32)
-/* use errno.h file in newlib */
+#if defined(RT_USING_NEWLIB) || defined(_WIN32) || (defined( __GNUC__ ) && !defined(__ARMCC_VERSION))
+/* use errno.h file in toolchains */
#include <errno.h>
+#endif
+
+#if defined(__CC_ARM)
+/*
+defined in armcc/errno.h
+
+#define EDOM 1
+#define ERANGE 2
+#define EILSEQ 4
+#define ESIGNUM 3
+#define EINVAL 5
+#define ENOMEM 6
+*/
+#define ERROR_BASE_NO 7
+
+#elif defined(__IAR_SYSTEMS_ICC__)
+/* defined in iar/errno.h
+#define EDOM 33
+#define ERANGE 34
+#define EFPOS 35
+#define EILSEQ 36
+*/
+#define ERROR_BASE_NO 36
+
#else
-/* define errno self. */
-#define EPERM 1
-#define ENOENT 2
-#define ESRCH 3
-#define EINTR 4
-#define EIO 5
-#define ENXIO 6
-#define E2BIG 7
-#define ENOEXEC 8
-#define EBADF 9
-#define ECHILD 10
-#define EAGAIN 11
-#define ENOMEM 12
-#define EACCES 13
-#define EFAULT 14
-#define ENOTBLK 15
-#define EBUSY 16
-#define EEXIST 17
-#define EXDEV 18
-#define ENODEV 19
-#define ENOTDIR 20
-#define EISDIR 21
-#define EINVAL 22
-#define ENFILE 23
-#define EMFILE 24
-#define ENOTTY 25
-#define ETXTBSY 26
-#define EFBIG 27
-#define ENOSPC 28
-#define ESPIPE 29
-#define EROFS 30
-#define EMLINK 31
-#define EPIPE 32
-#define EDOM 33
-#define ERANGE 34
-#define EDEADLK 35
-#define ENAMETOOLONG 36
-#define ENOLCK 37
-#define ENOSYS 38
-#define ENOTEMPTY 39
-#define ELOOP 40
+
+#define ERROR_BASE_NO 0
+#endif
+
+#if !defined(RT_USING_NEWLIB) && !defined(_WIN32) && !(defined( __GNUC__ ) && !defined(__ARMCC_VERSION))
+
+#define EPERM (ERROR_BASE_NO + 1)
+#define ENOENT (ERROR_BASE_NO + 2)
+#define ESRCH (ERROR_BASE_NO + 3)
+#define EINTR (ERROR_BASE_NO + 4)
+#define EIO (ERROR_BASE_NO + 5)
+#define ENXIO (ERROR_BASE_NO + 6)
+#define E2BIG (ERROR_BASE_NO + 7)
+#define ENOEXEC (ERROR_BASE_NO + 8)
+#define EBADF (ERROR_BASE_NO + 9)
+#define ECHILD (ERROR_BASE_NO + 10)
+#define EAGAIN (ERROR_BASE_NO + 11)
+
+#ifndef ENOMEM
+#define ENOMEM (ERROR_BASE_NO + 12)
+#endif
+
+#define EACCES (ERROR_BASE_NO + 13)
+#define EFAULT (ERROR_BASE_NO + 14)
+#define ENOTBLK (ERROR_BASE_NO + 15)
+#define EBUSY (ERROR_BASE_NO + 16)
+#define EEXIST (ERROR_BASE_NO + 17)
+#define EXDEV (ERROR_BASE_NO + 18)
+#define ENODEV (ERROR_BASE_NO + 19)
+#define ENOTDIR (ERROR_BASE_NO + 20)
+#define EISDIR (ERROR_BASE_NO + 21)
+
+#ifndef EINVAL
+#define EINVAL (ERROR_BASE_NO + 22)
+#endif
+
+#define ENFILE (ERROR_BASE_NO + 23)
+#define EMFILE (ERROR_BASE_NO + 24)
+#define ENOTTY (ERROR_BASE_NO + 25)
+#define ETXTBSY (ERROR_BASE_NO + 26)
+#define EFBIG (ERROR_BASE_NO + 27)
+#define ENOSPC (ERROR_BASE_NO + 28)
+#define ESPIPE (ERROR_BASE_NO + 29)
+#define EROFS (ERROR_BASE_NO + 30)
+#define EMLINK (ERROR_BASE_NO + 31)
+#define EPIPE (ERROR_BASE_NO + 32)
+
+#ifndef EDOM
+#define EDOM (ERROR_BASE_NO + 33)
+#endif
+
+#ifndef ERANGE
+#define ERANGE (ERROR_BASE_NO + 34)
+#endif
+
+#define EDEADLK (ERROR_BASE_NO + 35)
+#define ENAMETOOLONG (ERROR_BASE_NO + 36)
+#define ENOLCK (ERROR_BASE_NO + 37)
+#define ENOSYS (ERROR_BASE_NO + 38)
+#define ENOTEMPTY (ERROR_BASE_NO + 39)
+#define ELOOP (ERROR_BASE_NO + 40)
#define EWOULDBLOCK EAGAIN
-#define ENOMSG 42
-#define EIDRM 43
-#define ECHRNG 44
-#define EL2NSYNC 45
-#define EL3HLT 46
-#define EL3RST 47
-#define ELNRNG 48
-#define EUNATCH 49
-#define ENOCSI 50
-#define EL2HLT 51
-#define EBADE 52
-#define EBADR 53
-#define EXFULL 54
-#define ENOANO 55
-#define EBADRQC 56
-#define EBADSLT 57
+#define ENOMSG (ERROR_BASE_NO + 42)
+#define EIDRM (ERROR_BASE_NO + 43)
+#define ECHRNG (ERROR_BASE_NO + 44)
+#define EL2NSYNC (ERROR_BASE_NO + 45)
+#define EL3HLT (ERROR_BASE_NO + 46)
+#define EL3RST (ERROR_BASE_NO + 47)
+#define ELNRNG (ERROR_BASE_NO + 48)
+#define EUNATCH (ERROR_BASE_NO + 49)
+#define ENOCSI (ERROR_BASE_NO + 50)
+#define EL2HLT (ERROR_BASE_NO + 51)
+#define EBADE (ERROR_BASE_NO + 52)
+#define EBADR (ERROR_BASE_NO + 53)
+#define EXFULL (ERROR_BASE_NO + 54)
+#define ENOANO (ERROR_BASE_NO + 55)
+#define EBADRQC (ERROR_BASE_NO + 56)
+#define EBADSLT (ERROR_BASE_NO + 57)
#define EDEADLOCK EDEADLK
-#define EBFONT 59
-#define ENOSTR 60
-#define ENODATA 61
-#define ETIME 62
-#define ENOSR 63
-#define ENONET 64
-#define ENOPKG 65
-#define EREMOTE 66
-#define ENOLINK 67
-#define EADV 68
-#define ESRMNT 69
-#define ECOMM 70
-#define EPROTO 71
-#define EMULTIHOP 72
-#define EDOTDOT 73
-#define EBADMSG 74
-#define EOVERFLOW 75
-#define ENOTUNIQ 76
-#define EBADFD 77
-#define EREMCHG 78
-#define ELIBACC 79
-#define ELIBBAD 80
-#define ELIBSCN 81
-#define ELIBMAX 82
-#define ELIBEXEC 83
-#define EILSEQ 84
-#define ERESTART 85
-#define ESTRPIPE 86
-#define EUSERS 87
-#define ENOTSOCK 88
-#define EDESTADDRREQ 89
-#define EMSGSIZE 90
-#define EPROTOTYPE 91
-#define ENOPROTOOPT 92
-#define EPROTONOSUPPORT 93
-#define ESOCKTNOSUPPORT 94
-#define EOPNOTSUPP 95
-#define ENOTSUP EOPNOTSUPP
-#define EPFNOSUPPORT 96
-#define EAFNOSUPPORT 97
-#define EADDRINUSE 98
-#define EADDRNOTAVAIL 99
-#define ENETDOWN 100
-#define ENETUNREACH 101
-#define ENETRESET 102
-#define ECONNABORTED 103
-#define ECONNRESET 104
-#define ENOBUFS 105
-#define EISCONN 106
-#define ENOTCONN 107
-#define ESHUTDOWN 108
-#define ETOOMANYREFS 109
-#define ETIMEDOUT 110
-#define ECONNREFUSED 111
-#define EHOSTDOWN 112
-#define EHOSTUNREACH 113
-#define EALREADY 114
-#define EINPROGRESS 115
-#define ESTALE 116
-#define EUCLEAN 117
-#define ENOTNAM 118
-#define ENAVAIL 119
-#define EISNAM 120
-#define EREMOTEIO 121
-#define EDQUOT 122
-#define ENOMEDIUM 123
-#define EMEDIUMTYPE 124
-#define ECANCELED 125
-#define ENOKEY 126
-#define EKEYEXPIRED 127
-#define EKEYREVOKED 128
-#define EKEYREJECTED 129
-#define EOWNERDEAD 130
-#define ENOTRECOVERABLE 131
-#define ERFKILL 132
-#define EHWPOISON 133
+#define EBFONT (ERROR_BASE_NO + 59)
+#define ENOSTR (ERROR_BASE_NO + 60)
+#define ENODATA (ERROR_BASE_NO + 61)
+#define ETIME (ERROR_BASE_NO + 62)
+#define ENOSR (ERROR_BASE_NO + 63)
+#define ENONET (ERROR_BASE_NO + 64)
+#define ENOPKG (ERROR_BASE_NO + 65)
+#define EREMOTE (ERROR_BASE_NO + 66)
+#define ENOLINK (ERROR_BASE_NO + 67)
+#define EADV (ERROR_BASE_NO + 68)
+#define ESRMNT (ERROR_BASE_NO + 69)
+#define ECOMM (ERROR_BASE_NO + 70)
+#define EPROTO (ERROR_BASE_NO + 71)
+#define EMULTIHOP (ERROR_BASE_NO + 72)
+#define EDOTDOT (ERROR_BASE_NO + 73)
+#define EBADMSG (ERROR_BASE_NO + 74)
+#define EOVERFLOW (ERROR_BASE_NO + 75)
+#define ENOTUNIQ (ERROR_BASE_NO + 76)
+#define EBADFD (ERROR_BASE_NO + 77)
+#define EREMCHG (ERROR_BASE_NO + 78)
+#define ELIBACC (ERROR_BASE_NO + 79)
+#define ELIBBAD (ERROR_BASE_NO + 80)
+#define ELIBSCN (ERROR_BASE_NO + 81)
+#define ELIBMAX (ERROR_BASE_NO + 82)
+#define ELIBEXEC (ERROR_BASE_NO + 83)
+
+#ifndef EILSEQ
+#define EILSEQ (ERROR_BASE_NO + 84)
+#endif
+
+#define ERESTART (ERROR_BASE_NO + 85)
+#define ESTRPIPE (ERROR_BASE_NO + 86)
+#define EUSERS (ERROR_BASE_NO + 87)
+#define ENOTSOCK (ERROR_BASE_NO + 88)
+#define EDESTADDRREQ (ERROR_BASE_NO + 89)
+#define EMSGSIZE (ERROR_BASE_NO + 90)
+#define EPROTOTYPE (ERROR_BASE_NO + 91)
+#define ENOPROTOOPT (ERROR_BASE_NO + 92)
+#define EPROTONOSUPPORT (ERROR_BASE_NO + 93)
+#define ESOCKTNOSUPPORT (ERROR_BASE_NO + 94)
+#define EOPNOTSUPP (ERROR_BASE_NO + 95)
+#define ENOTSUP EOPNOTSUPP
+#define EPFNOSUPPORT (ERROR_BASE_NO + 96)
+#define EAFNOSUPPORT (ERROR_BASE_NO + 97)
+#define EADDRINUSE (ERROR_BASE_NO + 98)
+#define EADDRNOTAVAIL (ERROR_BASE_NO + 99)
+#define ENETDOWN (ERROR_BASE_NO + 100)
+#define ENETUNREACH (ERROR_BASE_NO + 101)
+#define ENETRESET (ERROR_BASE_NO + 102)
+#define ECONNABORTED (ERROR_BASE_NO + 103)
+#define ECONNRESET (ERROR_BASE_NO + 104)
+#define ENOBUFS (ERROR_BASE_NO + 105)
+#define EISCONN (ERROR_BASE_NO + 106)
+#define ENOTCONN (ERROR_BASE_NO + 107)
+#define ESHUTDOWN (ERROR_BASE_NO + 108)
+#define ETOOMANYREFS (ERROR_BASE_NO + 109)
+#define ETIMEDOUT (ERROR_BASE_NO + 110)
+#define ECONNREFUSED (ERROR_BASE_NO + 111)
+#define EHOSTDOWN (ERROR_BASE_NO + 112)
+#define EHOSTUNREACH (ERROR_BASE_NO + 113)
+#define EALREADY (ERROR_BASE_NO + 114)
+#define EINPROGRESS (ERROR_BASE_NO + 115)
+#define ESTALE (ERROR_BASE_NO + 116)
+#define EUCLEAN (ERROR_BASE_NO + 117)
+#define ENOTNAM (ERROR_BASE_NO + 118)
+#define ENAVAIL (ERROR_BASE_NO + 119)
+#define EISNAM (ERROR_BASE_NO + 120)
+#define EREMOTEIO (ERROR_BASE_NO + 121)
+#define EDQUOT (ERROR_BASE_NO + 122)
+#define ENOMEDIUM (ERROR_BASE_NO + 123)
+#define EMEDIUMTYPE (ERROR_BASE_NO + 124)
+#define ECANCELED (ERROR_BASE_NO + 125)
+#define ENOKEY (ERROR_BASE_NO + 126)
+#define EKEYEXPIRED (ERROR_BASE_NO + 127)
+#define EKEYREVOKED (ERROR_BASE_NO + 128)
+#define EKEYREJECTED (ERROR_BASE_NO + 129)
+#define EOWNERDEAD (ERROR_BASE_NO + 130)
+#define ENOTRECOVERABLE (ERROR_BASE_NO + 131)
+#define ERFKILL (ERROR_BASE_NO + 132)
+#define EHWPOISON (ERROR_BASE_NO + 133)
+
#endif
#endif
diff --git a/include/libc/libc_fcntl.h b/include/libc/libc_fcntl.h
index 1b7c69b1f4..d149d86964 100644
--- a/include/libc/libc_fcntl.h
+++ b/include/libc/libc_fcntl.h
@@ -2,10 +2,6 @@
* Copyright (c) 2006-2018, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
- */
-
-/*
- * File : libc_fcntl.h
*
* Change Logs:
* Date Author Notes
@@ -16,7 +12,7 @@
#ifndef LIBC_FCNTL_H__
#define LIBC_FCNTL_H__
-#if defined(RT_USING_NEWLIB) || defined(_WIN32)
+#if defined(RT_USING_NEWLIB) || defined(_WIN32) || (defined( __GNUC__ ) && !defined(__ARMCC_VERSION))
#include <fcntl.h>
#ifndef O_NONBLOCK
diff --git a/include/libc/libc_fdset.h b/include/libc/libc_fdset.h
index ecd965cd22..9700c7e83e 100644
--- a/include/libc/libc_fdset.h
+++ b/include/libc/libc_fdset.h
@@ -2,10 +2,6 @@
* Copyright (c) 2006-2018, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
- */
-
-/*
- * File : libc_errno.h
*
* Change Logs:
* Date Author Notes
@@ -17,7 +13,7 @@
#include <rtconfig.h>
-#if defined(RT_USING_NEWLIB) || defined(_WIN32)
+#if defined(RT_USING_NEWLIB) || defined(_WIN32) || (defined( __GNUC__ ) && !defined(__ARMCC_VERSION))
#include <sys/types.h>
#if defined(HAVE_SYS_SELECT_H)
#include <sys/select.h>
diff --git a/include/libc/libc_ioctl.h b/include/libc/libc_ioctl.h
index ef5a5257a8..42a21a2cea 100644
--- a/include/libc/libc_ioctl.h
+++ b/include/libc/libc_ioctl.h
@@ -2,10 +2,6 @@
* Copyright (c) 2006-2018, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
- */
-
-/*
- * File : libc_ioctl.h
*
* Change Logs:
* Date Author Notes
diff --git a/include/libc/libc_limits.h b/include/libc/libc_limits.h
new file mode 100644
index 0000000000..b8368160df
--- /dev/null
+++ b/include/libc/libc_limits.h
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2006-2018, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date Author Notes
+ * 2020-09-05 Meco Manthe first version
+ */
+
+#ifndef LIBC_LIMITS_H__
+#define LIBC_LIMITS_H__
+
+#include <limits.h>
+#include <rtconfig.h>
+
+#ifdef RT_USING_POSIX
+
+#ifndef SSIZE_MAX
+# define SSIZE_MAX LONG_MAX
+#endif
+
+#endif
+
+#endif
diff --git a/include/libc/libc_signal.h b/include/libc/libc_signal.h
index 71f8de125d..539685de3e 100644
--- a/include/libc/libc_signal.h
+++ b/include/libc/libc_signal.h
@@ -15,6 +15,7 @@
extern "C" {
#endif
+#include <stdint.h>
#ifdef HAVE_CCONFIG_H
#include <cconfig.h>
#endif
@@ -24,7 +25,7 @@ extern "C" {
NOTE: P1003.1c/D10, p. 34 adds sigev_notify_function and
sigev_notify_attributes to the sigevent structure. */
-union sigval
+union sigval
{
int sival_int; /* Integer signal value */
void *sival_ptr; /* Pointer signal value */
@@ -46,8 +47,8 @@ struct sigevent
#ifndef HAVE_SIGINFO
struct siginfo
{
- rt_uint16_t si_signo;
- rt_uint16_t si_code;
+ uint16_t si_signo;
+ uint16_t si_code;
union sigval si_value;
};
@@ -63,13 +64,14 @@ typedef struct siginfo siginfo_t;
#define SI_MESGQ 0x05 /* Signal generated by arrival of a
message on an empty message queue. */
-#ifdef RT_USING_NEWLIB
-#include <sys/signal.h>
+#if !defined(RT_USING_NEWLIB)
+typedef void (*_sig_func_ptr)(int);
+typedef unsigned long sigset_t;
#endif
-#if defined(__CC_ARM) || defined(__CLANG_ARM)
#include <signal.h>
-typedef unsigned long sigset_t;
+
+#if defined(__CC_ARM) || defined(__CLANG_ARM)
#define SIGHUP 1
/* #define SIGINT 2 */
@@ -105,9 +107,7 @@ typedef unsigned long sigset_t;
#define SIG_BLOCK 1 /* set of signals to block */
#define SIG_UNBLOCK 2 /* set of signals to, well, unblock */
-typedef void (*_sig_func_ptr)(int);
-
-struct sigaction
+struct sigaction
{
_sig_func_ptr sa_handler;
sigset_t sa_mask;
@@ -124,8 +124,6 @@ int sigprocmask (int how, const sigset_t *set, sigset_t *oset);
int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact);
#elif defined(__IAR_SYSTEMS_ICC__)
-#include <signal.h>
-typedef unsigned long sigset_t;
#define SIGHUP 1
#define SIGINT 2
@@ -161,9 +159,7 @@ typedef unsigned long sigset_t;
#define SIG_BLOCK 1 /* set of signals to block */
#define SIG_UNBLOCK 2 /* set of signals to, well, unblock */
-typedef void (*_sig_func_ptr)(int);
-
-struct sigaction
+struct sigaction
{
_sig_func_ptr sa_handler;
sigset_t sa_mask;
diff --git a/include/libc/libc_stat.h b/include/libc/libc_stat.h
index 9079d1ef15..6497cfe12c 100644
--- a/include/libc/libc_stat.h
+++ b/include/libc/libc_stat.h
@@ -9,7 +9,7 @@
#include <rtconfig.h>
-#if defined(RT_USING_NEWLIB)
+#if defined(RT_USING_NEWLIB) || (defined( __GNUC__ ) && !defined(__ARMCC_VERSION))
/* use header file of newlib */
#include <sys/stat.h>
diff --git a/include/libc/libc_stdio.h b/include/libc/libc_stdio.h
new file mode 100644
index 0000000000..85ba509852
--- /dev/null
+++ b/include/libc/libc_stdio.h
@@ -0,0 +1,22 @@
+/*
+ * Copyright (c) 2006-2018, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date Author Notes
+ * 2020-09-05 Meco Manthe first version
+ */
+
+#ifndef LIBC_STDIO_H__
+#define LIBC_STDIO_H__
+
+#include <rtconfig.h>
+
+#ifdef RT_USING_POSIX_GETLINE
+
+#include <posix_getline.h>
+
+#endif
+
+#endif
diff --git a/include/rtdbg.h b/include/rtdbg.h
index 9036a0cd66..be5a57f312 100644
--- a/include/rtdbg.h
+++ b/include/rtdbg.h
@@ -18,17 +18,13 @@
* In your C/C++ file, enable/disable DEBUG_ENABLE macro, and then include this
* header file.
*
- * #define DBG_SECTION_NAME "MOD"
- * #define DBG_ENABLE // enable debug macro
- * #define DBG_LEVEL DBG_INFO
- * #include <rtdbg.h> // must after of DEBUG_ENABLE or some other options
+ * #define DBG_TAG "MOD_TAG"
+ * #define DBG_LVL DBG_INFO
+ * #include <rtdbg.h> // must after of DBG_LVL, DBG_TAG or other options
*
* Then in your C/C++ file, you can use LOG_X macro to print out logs:
* LOG_D("this is a debug log!");
* LOG_E("this is a error log!");
- *
- * If you want to use different color for different kinds log, you can
- * #define DBG_COLOR
*/
#ifndef RT_DBG_H__
@@ -36,7 +32,21 @@
#include <rtconfig.h>
-#if defined(RT_USING_ULOG) && defined(DBG_ENABLE)
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* the debug log will force enable when RT_DEBUG macro is defined */
+#if defined(RT_DEBUG) && !defined(DBG_ENABLE)
+#define DBG_ENABLE
+#endif
+
+/* it will force output color log when RT_DEBUG_COLOR macro is defined */
+#if defined(RT_DEBUG_COLOR) && !defined(DBG_COLOR)
+#define DBG_COLOR
+#endif
+
+#if defined(RT_USING_ULOG)
/* using ulog compatible with rtdbg */
#include <ulog.h>
#else
@@ -47,15 +57,29 @@
#define DBG_INFO 2
#define DBG_LOG 3
+#ifdef DBG_TAG
+#ifndef DBG_SECTION_NAME
+#define DBG_SECTION_NAME DBG_TAG
+#endif
+#else
+/* compatible with old version */
#ifndef DBG_SECTION_NAME
#define DBG_SECTION_NAME "DBG"
#endif
+#endif /* DBG_TAG */
#ifdef DBG_ENABLE
+#ifdef DBG_LVL
+#ifndef DBG_LEVEL
+#define DBG_LEVEL DBG_LVL
+#endif
+#else
+/* compatible with old version */
#ifndef DBG_LEVEL
#define DBG_LEVEL DBG_WARNING
#endif
+#endif /* DBG_LVL */
/*
* The color for terminal (foreground)
@@ -71,13 +95,13 @@
#ifdef DBG_COLOR
#define _DBG_COLOR(n) rt_kprintf("\033["#n"m")
#define _DBG_LOG_HDR(lvl_name, color_n) \
- rt_kprintf("\033["#color_n"m["lvl_name"/"DBG_SECTION_NAME"] ")
+ rt_kprintf("\033["#color_n"m[" lvl_name "/" DBG_SECTION_NAME "] ")
#define _DBG_LOG_X_END \
rt_kprintf("\033[0m\n")
#else
#define _DBG_COLOR(n)
#define _DBG_LOG_HDR(lvl_name, color_n) \
- rt_kprintf("["lvl_name"/"DBG_SECTION_NAME"] ")
+ rt_kprintf("[" lvl_name "/" DBG_SECTION_NAME "] ")
#define _DBG_LOG_X_END \
rt_kprintf("\n")
#endif /* DBG_COLOR */
@@ -108,23 +132,6 @@
__FUNCTION__, __LINE__); \
}
-#define dbg_enter \
- if ((DBG_LEVEL) <= DBG_LOG){ \
- _DBG_COLOR(32); \
- rt_kprintf(DBG_SECTION_NAME " Enter %s\n", \
- __FUNCTION__); \
- _DBG_COLOR(0); \
- }
-
-#define dbg_exit \
- if ((DBG_LEVEL) <= DBG_LOG){ \
- _DBG_COLOR(32); \
- rt_kprintf(DBG_SECTION_NAME " Exit %s:%d\n", \
- __FUNCTION__); \
- _DBG_COLOR(0); \
- }
-
-
#define dbg_log_line(lvl, color_n, fmt, ...) \
do \
{ \
@@ -173,4 +180,8 @@
#endif /* defined(RT_USING_ULOG) && define(DBG_ENABLE) */
+#ifdef __cplusplus
+}
+#endif
+
#endif /* RT_DBG_H__ */
diff --git a/include/rtdef.h b/include/rtdef.h
index 6d5263ef62..e4ddbd37d3 100644
--- a/include/rtdef.h
+++ b/include/rtdef.h
@@ -29,6 +29,11 @@
* 2018-11-22 Jesven add smp member to struct rt_thread
* add struct rt_cpu
* add smp relevant macros
+ * 2019-01-27 Bernard change version number to v4.0.1
+ * 2019-05-17 Bernard change version number to v4.0.2
+ * 2019-12-20 Bernard change version number to v4.0.3
+ * 2020-08-10 Meco Man add macro for struct rt_device_ops
+ * 2020-10-23 Meco Man define maximum value of ipc type
*/
#ifndef __RT_DEF_H__
@@ -45,18 +50,19 @@ extern "C" {
* @addtogroup BasicDef
*/
-/*@{*/
+/**@{*/
/* RT-Thread version information */
#define RT_VERSION 4L /**< major version number */
#define RT_SUBVERSION 0L /**< minor version number */
-#define RT_REVISION 0L /**< revise version number */
+#define RT_REVISION 3L /**< revise version number */
/* RT-Thread version */
#define RTTHREAD_VERSION ((RT_VERSION * 10000) + \
(RT_SUBVERSION * 100) + RT_REVISION)
/* RT-Thread basic data type definitions */
+#ifndef RT_USING_ARCH_DATA_TYPE
typedef signed char rt_int8_t; /**< 8bit integer type */
typedef signed short rt_int16_t; /**< 16bit integer type */
typedef signed int rt_int32_t; /**< 32bit integer type */
@@ -71,6 +77,7 @@ typedef unsigned long rt_uint64_t; /**< 64bit unsigned inte
typedef signed long long rt_int64_t; /**< 64bit integer type */
typedef unsigned long long rt_uint64_t; /**< 64bit unsigned integer type */
#endif
+#endif
typedef int rt_bool_t; /**< boolean type */
typedef long rt_base_t; /**< Nbit CPU related date type */
@@ -88,7 +95,7 @@ typedef rt_base_t rt_off_t; /**< Type for offset */
#define RT_TRUE 1 /**< boolean true */
#define RT_FALSE 0 /**< boolean fails */
-/*@}*/
+/**@}*/
/* maximum value of base type */
#define RT_UINT8_MAX 0xff /**< Maxium number of UINT8 */
@@ -96,6 +103,13 @@ typedef rt_base_t rt_off_t; /**< Type for offset */
#define RT_UINT32_MAX 0xffffffff /**< Maxium number of UINT32 */
#define RT_TICK_MAX RT_UINT32_MAX /**< Maxium number of tick */
+/* maximum value of ipc type */
+#define RT_SEM_VALUE_MAX RT_UINT16_MAX /**< Maxium number of semaphore .value */
+#define RT_MUTEX_VALUE_MAX RT_UINT16_MAX /**< Maxium number of mutex .value */
+#define RT_MUTEX_HOLD_MAX RT_UINT8_MAX /**< Maxium number of mutex .hold */
+#define RT_MB_ENTRY_MAX RT_UINT16_MAX /**< Maxium number of mailbox .entry */
+#define RT_MQ_ENTRY_MAX RT_UINT16_MAX /**< Maxium number of message queue .entry */
+
#if defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
#define __CLANG_ARM
#endif
@@ -196,11 +210,11 @@ typedef int (*init_fn_t)(void);
};
#define INIT_EXPORT(fn, level) \
const char __rti_##fn##_name[] = #fn; \
- RT_USED const struct rt_init_desc __rt_init_desc_##fn SECTION(".rti_fn."level) = \
+ RT_USED const struct rt_init_desc __rt_init_desc_##fn SECTION(".rti_fn." level) = \
{ __rti_##fn##_name, fn};
#else
#define INIT_EXPORT(fn, level) \
- RT_USED const init_fn_t __rt_init_##fn SECTION(".rti_fn."level) = fn
+ RT_USED const init_fn_t __rt_init_##fn SECTION(".rti_fn." level) = fn
#endif
#endif
#else
@@ -259,7 +273,7 @@ typedef int (*init_fn_t)(void);
* @addtogroup Error
*/
-/*@{*/
+/**@{*/
/* RT-Thread error code definitions */
#define RT_EOK 0 /**< There is no error */
@@ -274,7 +288,7 @@ typedef int (*init_fn_t)(void);
#define RT_EINTR 9 /**< Interrupted system call */
#define RT_EINVAL 10 /**< Invalid argument */
-/*@}*/
+/**@}*/
/**
* @ingroup BasicDef
@@ -325,7 +339,7 @@ typedef struct rt_slist_node rt_slist_t; /**< Type for single lis
* @addtogroup KernelObject
*/
-/*@{*/
+/**@{*/
/*
* kernel object macros
@@ -367,19 +381,20 @@ typedef struct rt_object *rt_object_t; /**< Type for kernel obj
*/
enum rt_object_class_type
{
- RT_Object_Class_Thread = 0, /**< The object is a thread. */
- RT_Object_Class_Semaphore, /**< The object is a semaphore. */
- RT_Object_Class_Mutex, /**< The object is a mutex. */
- RT_Object_Class_Event, /**< The object is a event. */
- RT_Object_Class_MailBox, /**< The object is a mail box. */
- RT_Object_Class_MessageQueue, /**< The object is a message queue. */
- RT_Object_Class_MemHeap, /**< The object is a memory heap */
- RT_Object_Class_MemPool, /**< The object is a memory pool. */
- RT_Object_Class_Device, /**< The object is a device */
- RT_Object_Class_Timer, /**< The object is a timer. */
- RT_Object_Class_Module, /**< The object is a module. */
- RT_Object_Class_Unknown, /**< The object is unknown. */
- RT_Object_Class_Static = 0x80 /**< The object is a static object. */
+ RT_Object_Class_Null = 0x00, /**< The object is not used. */
+ RT_Object_Class_Thread = 0x01, /**< The object is a thread. */
+ RT_Object_Class_Semaphore = 0x02, /**< The object is a semaphore. */
+ RT_Object_Class_Mutex = 0x03, /**< The object is a mutex. */
+ RT_Object_Class_Event = 0x04, /**< The object is a event. */
+ RT_Object_Class_MailBox = 0x05, /**< The object is a mail box. */
+ RT_Object_Class_MessageQueue = 0x06, /**< The object is a message queue. */
+ RT_Object_Class_MemHeap = 0x07, /**< The object is a memory heap. */
+ RT_Object_Class_MemPool = 0x08, /**< The object is a memory pool. */
+ RT_Object_Class_Device = 0x09, /**< The object is a device. */
+ RT_Object_Class_Timer = 0x0a, /**< The object is a timer. */
+ RT_Object_Class_Module = 0x0b, /**< The object is a module. */
+ RT_Object_Class_Unknown = 0x0c, /**< The object is unknown. */
+ RT_Object_Class_Static = 0x80 /**< The object is a static object. */
};
/**
@@ -402,13 +417,13 @@ struct rt_object_information
#define RT_OBJECT_HOOK_CALL(func, argv)
#endif
-/*@}*/
+/**@}*/
/**
* @addtogroup Clock
*/
-/*@{*/
+/**@{*/
/**
* clock & timer macros
@@ -425,6 +440,7 @@ struct rt_object_information
#define RT_TIMER_CTRL_GET_TIME 0x1 /**< get timer control command */
#define RT_TIMER_CTRL_SET_ONESHOT 0x2 /**< change timer to one shot */
#define RT_TIMER_CTRL_SET_PERIODIC 0x3 /**< change timer to periodic */
+#define RT_TIMER_CTRL_GET_STATE 0x4 /**< get timer run state active or deactive*/
#ifndef RT_TIMER_SKIP_LIST_LEVEL
#define RT_TIMER_SKIP_LIST_LEVEL 1
@@ -452,7 +468,7 @@ struct rt_timer
};
typedef struct rt_timer *rt_timer_t;
-/*@}*/
+/**@}*/
/**
* @addtogroup Signal
@@ -465,13 +481,13 @@ typedef siginfo_t rt_siginfo_t;
#define RT_SIG_MAX 32
#endif
-/*@}*/
+/**@}*/
/**
* @addtogroup Thread
*/
-/*@{*/
+/**@{*/
/*
* Thread
@@ -486,11 +502,15 @@ typedef siginfo_t rt_siginfo_t;
#define RT_THREAD_RUNNING 0x03 /**< Running status */
#define RT_THREAD_BLOCK RT_THREAD_SUSPEND /**< Blocked status */
#define RT_THREAD_CLOSE 0x04 /**< Closed status */
-#define RT_THREAD_STAT_MASK 0x0f
+#define RT_THREAD_STAT_MASK 0x07
+
+#define RT_THREAD_STAT_YIELD 0x08 /**< indicate whether remaining_tick has been reloaded since last schedule */
+#define RT_THREAD_STAT_YIELD_MASK RT_THREAD_STAT_YIELD
-#define RT_THREAD_STAT_SIGNAL 0x10
+#define RT_THREAD_STAT_SIGNAL 0x10 /**< task hold signals */
#define RT_THREAD_STAT_SIGNAL_READY (RT_THREAD_STAT_SIGNAL | RT_THREAD_READY)
-#define RT_THREAD_STAT_SIGNAL_WAIT 0x20
+#define RT_THREAD_STAT_SIGNAL_WAIT 0x20 /**< task is waiting for signals */
+#define RT_THREAD_STAT_SIGNAL_PENDING 0x40 /**< signals is held and it has not been procressed */
#define RT_THREAD_STAT_SIGNAL_MASK 0xf0
/**
@@ -507,13 +527,13 @@ typedef siginfo_t rt_siginfo_t;
#define RT_CPU_DETACHED RT_CPUS_NR /**< The thread not running on cpu. */
#define RT_CPU_MASK ((1 << RT_CPUS_NR) - 1) /**< All CPUs mask bit. */
-#ifndef RT_SCHEDULE_IPI_IRQ
-#define RT_SCHEDULE_IPI_IRQ 0
+#ifndef RT_SCHEDULE_IPI
+#define RT_SCHEDULE_IPI 0
#endif
/**
* CPUs definitions
- *
+ *
*/
struct rt_cpu
{
@@ -571,6 +591,7 @@ struct rt_thread
rt_uint16_t scheduler_lock_nest; /**< scheduler lock count */
rt_uint16_t cpus_lock_nest; /**< cpus lock count */
+ rt_uint16_t critical_lock_nest; /**< critical lock count */
#endif /*RT_USING_SMP*/
/* priority */
@@ -592,7 +613,9 @@ struct rt_thread
rt_sigset_t sig_pending; /**< the pending signals */
rt_sigset_t sig_mask; /**< the mask bits of signal */
+#ifndef RT_USING_SMP
void *sig_ret; /**< the return stack pointer from signal */
+#endif
rt_sighandler_t *sig_vectors; /**< vectors of signal handler */
void *si_list; /**< the signal infor list */
#endif
@@ -609,17 +632,17 @@ struct rt_thread
void *lwp;
#endif
- rt_uint32_t user_data; /**< private user data beyond this thread */
+ rt_ubase_t user_data; /**< private user data beyond this thread */
};
typedef struct rt_thread *rt_thread_t;
-/*@}*/
+/**@}*/
/**
* @addtogroup IPC
*/
-/*@{*/
+/**@{*/
/**
* IPC flags and control command definitions
@@ -652,6 +675,7 @@ struct rt_semaphore
struct rt_ipc_object parent; /**< inherit from ipc_object */
rt_uint16_t value; /**< value of semaphore. */
+ rt_uint16_t reserved; /**< reserved field */
};
typedef struct rt_semaphore *rt_sem_t;
#endif
@@ -733,17 +757,19 @@ struct rt_messagequeue
void *msg_queue_head; /**< list head */
void *msg_queue_tail; /**< list tail */
void *msg_queue_free; /**< pointer indicated the free node of queue */
+
+ rt_list_t suspend_sender_thread; /**< sender thread suspended on this message queue */
};
typedef struct rt_messagequeue *rt_mq_t;
#endif
-/*@}*/
+/**@}*/
/**
* @addtogroup MM
*/
-/*@{*/
+/**@{*/
/*
* memory management
@@ -806,19 +832,18 @@ struct rt_mempool
rt_size_t block_free_count; /**< numbers of free memory block */
rt_list_t suspend_thread; /**< threads pended on this resource */
- rt_size_t suspend_thread_count; /**< numbers of thread pended on this resource */
};
typedef struct rt_mempool *rt_mp_t;
#endif
-/*@}*/
+/**@}*/
#ifdef RT_USING_DEVICE
/**
* @addtogroup Device
*/
-/*@{*/
+/**@{*/
/**
* device (I/O) class type
@@ -844,6 +869,9 @@ enum rt_device_class_type
RT_Device_Class_Portal, /**< Portal device */
RT_Device_Class_Timer, /**< Timer device */
RT_Device_Class_Miscellaneous, /**< Miscellaneous device */
+ RT_Device_Class_Sensor, /**< Sensor device */
+ RT_Device_Class_Touch, /**< Touch device */
+ RT_Device_Class_PHY, /**< PHY device */
RT_Device_Class_Unknown /**< unknown device */
};
@@ -880,6 +908,7 @@ enum rt_device_class_type
#define RT_DEVICE_CTRL_RESUME 0x01 /**< resume device */
#define RT_DEVICE_CTRL_SUSPEND 0x02 /**< suspend device */
#define RT_DEVICE_CTRL_CONFIG 0x03 /**< configure device */
+#define RT_DEVICE_CTRL_CLOSE 0x04 /**< close device */
#define RT_DEVICE_CTRL_SET_INT 0x10 /**< set interrupt */
#define RT_DEVICE_CTRL_CLR_INT 0x11 /**< clear interrupt */
@@ -901,6 +930,8 @@ enum rt_device_class_type
#define RT_DEVICE_CTRL_RTC_SET_ALARM 0x13 /**< set alarm */
typedef struct rt_device *rt_device_t;
+
+#ifdef RT_USING_DEVICE_OPS
/**
* operations set for device object
*/
@@ -914,6 +945,7 @@ struct rt_device_ops
rt_size_t (*write) (rt_device_t dev, rt_off_t pos, const void *buffer, rt_size_t size);
rt_err_t (*control)(rt_device_t dev, int cmd, void *args);
};
+#endif
/**
* WaitQueue structure
@@ -1015,6 +1047,7 @@ enum
RTGRAPHIC_PIXEL_FORMAT_ABGR888,
RTGRAPHIC_PIXEL_FORMAT_ARGB565,
RTGRAPHIC_PIXEL_FORMAT_ALPHA,
+ RTGRAPHIC_PIXEL_FORMAT_COLOR,
};
/**
@@ -1063,7 +1096,7 @@ struct rt_device_graphic_ops
};
#define rt_graphix_ops(device) ((struct rt_device_graphic_ops *)(device->user_data))
-/*@}*/
+/**@}*/
#endif
/* definitions for libc */
diff --git a/include/rthw.h b/include/rthw.h
index dee10b0bee..89877faf90 100644
--- a/include/rthw.h
+++ b/include/rthw.h
@@ -37,7 +37,7 @@ extern "C" {
#endif
#ifndef RT_CPU_CACHE_LINE_SZ
-#define RT_CPU_CACHE_LINE_SZ 32
+#define RT_CPU_CACHE_LINE_SZ 32
#endif
enum RT_HW_CACHE_OPS
@@ -143,6 +143,12 @@ typedef union {
} tickets;
} rt_hw_spinlock_t;
+struct rt_spinlock
+{
+ rt_hw_spinlock_t lock;
+};
+
+void rt_hw_spin_lock_init(rt_hw_spinlock_t *lock);
void rt_hw_spin_lock(rt_hw_spinlock_t *lock);
void rt_hw_spin_unlock(rt_hw_spinlock_t *lock);
@@ -153,10 +159,11 @@ extern rt_hw_spinlock_t _rt_critical_lock;
#define __RT_HW_SPIN_LOCK_INITIALIZER(lockname) {0}
-#define __RT_HW_SPIN_LOCK_UNLOCKED(lockname) \
- (struct rt_hw_spinlock ) __RT_HW_SPIN_LOCK_INITIALIZER(lockname)
+#define __RT_HW_SPIN_LOCK_UNLOCKED(lockname) \
+ (rt_hw_spinlock_t) __RT_HW_SPIN_LOCK_INITIALIZER(lockname)
-#define RT_DEFINE_SPINLOCK(x) struct rt_hw_spinlock x = __RT_HW_SPIN_LOCK_UNLOCKED(x)
+#define RT_DEFINE_SPINLOCK(x) rt_hw_spinlock_t x = __RT_HW_SPIN_LOCK_UNLOCKED(x)
+#define RT_DECLARE_SPINLOCK(x)
/**
* ipi function
@@ -172,6 +179,13 @@ void rt_hw_secondary_cpu_up(void);
* secondary cpu idle function
*/
void rt_hw_secondary_cpu_idle_exec(void);
+#else
+
+#define RT_DEFINE_SPINLOCK(x)
+#define RT_DECLARE_SPINLOCK(x) rt_ubase_t x
+
+#define rt_hw_spin_lock(lock) *(lock) = rt_hw_interrupt_disable()
+#define rt_hw_spin_unlock(lock) rt_hw_interrupt_enable(*(lock))
#endif
diff --git a/include/rtlibc.h b/include/rtlibc.h
index b3a548beb1..fb8c782095 100644
--- a/include/rtlibc.h
+++ b/include/rtlibc.h
@@ -20,6 +20,8 @@
#include "libc/libc_dirent.h"
#include "libc/libc_signal.h"
#include "libc/libc_fdset.h"
+#include "libc/libc_limits.h"
+#include "libc/libc_stdio.h"
#if defined(__CC_ARM) || defined(__CLANG_ARM) || defined(__IAR_SYSTEMS_ICC__)
typedef signed long off_t;
diff --git a/include/rtservice.h b/include/rtservice.h
index 3b6fc94c92..5bd2b1c23b 100644
--- a/include/rtservice.h
+++ b/include/rtservice.h
@@ -24,7 +24,7 @@ extern "C" {
* @addtogroup KernelService
*/
-/*@{*/
+/**@{*/
/**
* rt_container_of - return the member address of ptr, if the type of ptr is the
@@ -128,21 +128,21 @@ rt_inline unsigned int rt_list_len(const rt_list_t *l)
/**
* rt_list_for_each - iterate over a list
- * @pos: the rt_list_t * to use as a loop cursor.
- * @head: the head for your list.
+ * @pos: the rt_list_t * to use as a loop cursor.
+ * @head: the head for your list.
*/
#define rt_list_for_each(pos, head) \
for (pos = (head)->next; pos != (head); pos = pos->next)
/**
* rt_list_for_each_safe - iterate over a list safe against removal of list entry
- * @pos: the rt_list_t * to use as a loop cursor.
- * @n: another rt_list_t * to use as temporary storage
- * @head: the head for your list.
+ * @pos: the rt_list_t * to use as a loop cursor.
+ * @n: another rt_list_t * to use as temporary storage
+ * @head: the head for your list.
*/
#define rt_list_for_each_safe(pos, n, head) \
- for (pos = (head)->next, n = pos->next; pos != (head); \
- pos = n, n = pos->next)
+ for (pos = (head)->next, n = pos->next; pos != (head); \
+ pos = n, n = pos->next)
/**
* rt_list_for_each_entry - iterate over list of given type
@@ -306,7 +306,7 @@ rt_inline int rt_slist_isempty(rt_slist_t *l)
#define rt_slist_tail_entry(ptr, type, member) \
rt_slist_entry(rt_slist_tail(ptr), type, member)
-/*@}*/
+/**@}*/
#ifdef __cplusplus
}
diff --git a/include/rtthread.h b/include/rtthread.h
index d2356b8eda..a76601a3bf 100644
--- a/include/rtthread.h
+++ b/include/rtthread.h
@@ -41,6 +41,9 @@ extern "C" {
void rt_system_object_init(void);
struct rt_object_information *
rt_object_get_information(enum rt_object_class_type type);
+int rt_object_get_length(enum rt_object_class_type type);
+int rt_object_get_pointers(enum rt_object_class_type type, rt_object_t *pointers, int maxlen);
+
void rt_object_init(struct rt_object *object,
enum rt_object_class_type type,
const char *name);
@@ -75,7 +78,7 @@ void rt_system_tick_init(void);
rt_tick_t rt_tick_get(void);
void rt_tick_set(rt_tick_t tick);
void rt_tick_increase(void);
-int rt_tick_from_millisecond(rt_int32_t ms);
+rt_tick_t rt_tick_from_millisecond(rt_int32_t ms);
void rt_system_timer_init(void);
void rt_system_timer_thread_init(void);
@@ -138,6 +141,7 @@ rt_err_t rt_thread_delete(rt_thread_t thread);
rt_err_t rt_thread_yield(void);
rt_err_t rt_thread_delay(rt_tick_t tick);
+rt_err_t rt_thread_delay_until(rt_tick_t *tick, rt_tick_t inc_tick);
rt_err_t rt_thread_mdelay(rt_int32_t ms);
rt_err_t rt_thread_control(rt_thread_t thread, int cmd, void *arg);
rt_err_t rt_thread_suspend(rt_thread_t thread);
@@ -378,8 +382,12 @@ rt_mq_t rt_mq_create(const char *name,
rt_uint8_t flag);
rt_err_t rt_mq_delete(rt_mq_t mq);
-rt_err_t rt_mq_send(rt_mq_t mq, void *buffer, rt_size_t size);
-rt_err_t rt_mq_urgent(rt_mq_t mq, void *buffer, rt_size_t size);
+rt_err_t rt_mq_send(rt_mq_t mq, const void *buffer, rt_size_t size);
+rt_err_t rt_mq_send_wait(rt_mq_t mq,
+ const void *buffer,
+ rt_size_t size,
+ rt_int32_t timeout);
+rt_err_t rt_mq_urgent(rt_mq_t mq, const void *buffer, rt_size_t size);
rt_err_t rt_mq_recv(rt_mq_t mq,
void *buffer,
rt_size_t size,
@@ -387,6 +395,27 @@ rt_err_t rt_mq_recv(rt_mq_t mq,
rt_err_t rt_mq_control(rt_mq_t mq, int cmd, void *arg);
#endif
+/*
+ * spinlock
+ */
+#ifdef RT_USING_SMP
+struct rt_spinlock;
+
+void rt_spin_lock_init(struct rt_spinlock *lock);
+void rt_spin_lock(struct rt_spinlock *lock);
+void rt_spin_unlock(struct rt_spinlock *lock);
+rt_base_t rt_spin_lock_irqsave(struct rt_spinlock *lock);
+void rt_spin_unlock_irqrestore(struct rt_spinlock *lock, rt_base_t level);
+
+#else
+#define rt_spin_lock_init(lock) /* nothing */
+#define rt_spin_lock(lock) rt_enter_critical()
+#define rt_spin_unlock(lock) rt_exit_critical()
+#define rt_spin_lock_irqsave(lock) rt_hw_interrupt_disable()
+#define rt_spin_unlock_irqrestore(lock, level) rt_hw_interrupt_enable(level)
+
+#endif
+
/**@}*/
#ifdef RT_USING_DEVICE
@@ -516,6 +545,7 @@ void *rt_memcpy(void *dest, const void *src, rt_ubase_t n);
rt_int32_t rt_strncmp(const char *cs, const char *ct, rt_ubase_t count);
rt_int32_t rt_strcmp(const char *cs, const char *ct);
rt_size_t rt_strlen(const char *src);
+rt_size_t rt_strnlen(const char *s, rt_ubase_t maxlen);
char *rt_strdup(const char *s);
#if defined(__CC_ARM) || defined(__CLANG_ARM)
/* leak strdup interface */
@@ -527,7 +557,7 @@ rt_int32_t rt_sscanf(const char *buf, const char *fmt, ...);
char *rt_strncpy(char *dest, const char *src, rt_ubase_t n);
void *rt_memmove(void *dest, const void *src, rt_ubase_t n);
rt_int32_t rt_memcmp(const void *cs, const void *ct, rt_ubase_t count);
-rt_uint32_t rt_strcasecmp(const char *a, const char *b);
+rt_int32_t rt_strcasecmp(const char *a, const char *b);
void rt_show_version(void);