summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
author192.168.1.134 <[email protected]>2021-12-09 19:18:24 +0800
committer192.168.1.134 <[email protected]>2021-12-09 19:18:24 +0800
commit6378f95f00fd51410d2715da55d728d4a40494de (patch)
treebb46a565875d538189e1c1dfc9b1cfddf6862a92 /src
parentd6b05287bbeaf9369546009e5af445f350b97fe9 (diff)
parent462f093cbd7531098de3b7aadb5f8d5f1b99b4a9 (diff)
Merge branch 'master' of https://github.com/RT-Thread/rt-thread
Diffstat (limited to 'src')
-rw-r--r--src/Kconfig222
-rw-r--r--src/device.c8
-rw-r--r--src/kservice.c67
-rw-r--r--src/thread.c1
-rw-r--r--src/timer.c4
5 files changed, 146 insertions, 156 deletions
diff --git a/src/Kconfig b/src/Kconfig
index 38cbb7a715..8647d35698 100644
--- a/src/Kconfig
+++ b/src/Kconfig
@@ -115,33 +115,40 @@ config RT_USING_TIMER_SOFT
thread.
if RT_USING_TIMER_SOFT
-config RT_TIMER_THREAD_PRIO
- int "The priority level value of timer thread"
- default 4
-
-config RT_TIMER_THREAD_STACK_SIZE
- int "The stack size of timer thread"
- default 512
+ config RT_TIMER_THREAD_PRIO
+ int "The priority level value of timer thread"
+ default 4
+ config RT_TIMER_THREAD_STACK_SIZE
+ int "The stack size of timer thread"
+ default 512
endif
menu "kservice optimization"
-config RT_KSERVICE_USING_STDLIB
- bool "Enable kservice to use standard C library"
- default n
+ config RT_KSERVICE_USING_STDLIB
+ bool "Enable kservice to use standard C library"
+ default n
-config RT_KSERVICE_USING_TINY_SIZE
- bool "Enable kservice to use tiny size"
- default n
+ config RT_KSERVICE_USING_TINY_SIZE
+ bool "Enable kservice to use tiny size"
+ default n
-config RT_USING_ASM_MEMCPY
- bool
- default n
+ config RT_USING_ASM_MEMCPY
+ bool
+ default n
-config RT_USING_TINY_FFS
- bool "Enable kservice to use tiny ffs"
- default n
+ config RT_USING_ASM_MEMSET
+ bool
+ default n
+
+ config RT_USING_TINY_FFS
+ bool "Enable kservice to use tiny finding first bit set method"
+ default n
+
+ config RT_PRINTF_LONGLONG
+ bool "Enable rt_printf-family functions to support long long format"
+ default n
endmenu
@@ -151,121 +158,122 @@ menuconfig RT_DEBUG
if RT_DEBUG
-config RT_DEBUG_COLOR
- bool "Enable color debugging log"
- default n
+ config RT_DEBUG_COLOR
+ bool "Enable color debugging log"
+ default n
-config RT_DEBUG_INIT_CONFIG
- bool "Enable debugging of components initialization"
- default n
+ config RT_DEBUG_INIT_CONFIG
+ bool "Enable debugging of components initialization"
+ default n
-config RT_DEBUG_INIT
- int
- default 1 if RT_DEBUG_INIT_CONFIG
+ config RT_DEBUG_INIT
+ int
+ default 1 if RT_DEBUG_INIT_CONFIG
-config RT_DEBUG_THREAD_CONFIG
- bool "Enable debugging of Thread State Changes"
- default n
+ config RT_DEBUG_THREAD_CONFIG
+ bool "Enable debugging of Thread State Changes"
+ default n
-config RT_DEBUG_THREAD
- int
- default 1 if RT_DEBUG_THREAD_CONFIG
+ config RT_DEBUG_THREAD
+ int
+ default 1 if RT_DEBUG_THREAD_CONFIG
-config RT_DEBUG_SCHEDULER_CONFIG
- bool "Enable debugging of Scheduler"
- default n
+ config RT_DEBUG_SCHEDULER_CONFIG
+ bool "Enable debugging of Scheduler"
+ default n
-config RT_DEBUG_SCHEDULER
- int
- default 1 if RT_DEBUG_SCHEDULER_CONFIG
+ config RT_DEBUG_SCHEDULER
+ int
+ default 1 if RT_DEBUG_SCHEDULER_CONFIG
-config RT_DEBUG_IPC_CONFIG
- bool "Enable debugging of IPC"
- default n
+ config RT_DEBUG_IPC_CONFIG
+ bool "Enable debugging of IPC"
+ default n
-config RT_DEBUG_IPC
- int
- default 1 if RT_DEBUG_IPC_CONFIG
+ config RT_DEBUG_IPC
+ int
+ default 1 if RT_DEBUG_IPC_CONFIG
-config RT_DEBUG_TIMER_CONFIG
- bool "Enable debugging of Timer"
- default n
+ config RT_DEBUG_TIMER_CONFIG
+ bool "Enable debugging of Timer"
+ default n
-config RT_DEBUG_TIMER
- int
- default 1 if RT_DEBUG_TIMER_CONFIG
+ config RT_DEBUG_TIMER
+ int
+ default 1 if RT_DEBUG_TIMER_CONFIG
-config RT_DEBUG_IRQ_CONFIG
- bool "Enable debugging of IRQ(Interrupt Request)"
- default n
+ config RT_DEBUG_IRQ_CONFIG
+ bool "Enable debugging of IRQ(Interrupt Request)"
+ default n
-config RT_DEBUG_IRQ
- int
- default 1 if RT_DEBUG_IRQ_CONFIG
+ config RT_DEBUG_IRQ
+ int
+ default 1 if RT_DEBUG_IRQ_CONFIG
-config RT_DEBUG_MEM_CONFIG
- bool "Enable debugging of Small Memory Algorithm"
- default n
+ config RT_DEBUG_MEM_CONFIG
+ bool "Enable debugging of Small Memory Algorithm"
+ default n
-config RT_DEBUG_MEM
- int
- default 1 if RT_DEBUG_MEM_CONFIG
+ config RT_DEBUG_MEM
+ int
+ default 1 if RT_DEBUG_MEM_CONFIG
-config RT_DEBUG_SLAB_CONFIG
- bool "Enable debugging of SLAB Memory Algorithm"
- default n
+ config RT_DEBUG_SLAB_CONFIG
+ bool "Enable debugging of SLAB Memory Algorithm"
+ default n
-config RT_DEBUG_SLAB
- int
- default 1 if RT_DEBUG_SLAB_CONFIG
+ config RT_DEBUG_SLAB
+ int
+ default 1 if RT_DEBUG_SLAB_CONFIG
-config RT_DEBUG_MEMHEAP_CONFIG
- bool "Enable debugging of Memory Heap Algorithm"
- default n
+ config RT_DEBUG_MEMHEAP_CONFIG
+ bool "Enable debugging of Memory Heap Algorithm"
+ default n
-config RT_DEBUG_MEMHEAP
- int
- default 1 if RT_DEBUG_MEMHEAP_CONFIG
+ config RT_DEBUG_MEMHEAP
+ int
+ default 1 if RT_DEBUG_MEMHEAP_CONFIG
-config RT_DEBUG_MODULE_CONFIG
- bool "Enable debugging of Application Module"
- default n
+ config RT_DEBUG_MODULE_CONFIG
+ bool "Enable debugging of Application Module"
+ default n
-config RT_DEBUG_MODULE
- int
- default 1 if RT_DEBUG_MODULE_CONFIG
+ config RT_DEBUG_MODULE
+ int
+ default 1 if RT_DEBUG_MODULE_CONFIG
endif
menu "Inter-Thread communication"
-config RT_USING_SEMAPHORE
- bool "Enable semaphore"
- default y
+ config RT_USING_SEMAPHORE
+ bool "Enable semaphore"
+ default y
-config RT_USING_MUTEX
- bool "Enable mutex"
- default y
+ config RT_USING_MUTEX
+ bool "Enable mutex"
+ default y
-config RT_USING_EVENT
- bool "Enable event flag"
- default y
+ config RT_USING_EVENT
+ bool "Enable event flag"
+ default y
-config RT_USING_MAILBOX
- bool "Enable mailbox"
- default y
+ config RT_USING_MAILBOX
+ bool "Enable mailbox"
+ default y
-config RT_USING_MESSAGEQUEUE
- bool "Enable message queue"
- default y
+ config RT_USING_MESSAGEQUEUE
+ bool "Enable message queue"
+ default y
+
+ config RT_USING_SIGNALS
+ bool "Enable signals"
+ select RT_USING_MEMPOOL
+ default n
+ help
+ A signal is an asynchronous notification sent to a specific thread
+ in order to notify it of an event that occurred.
-config RT_USING_SIGNALS
- bool "Enable signals"
- select RT_USING_MEMPOOL
- default n
- help
- A signal is an asynchronous notification sent to a specific thread
- in order to notify it of an event that occurred.
endmenu
menu "Memory Management"
@@ -371,17 +379,13 @@ menu "Kernel Device Object"
config RT_CONSOLE_DEVICE_NAME
string "the device name for console"
default "uart"
-
- config RT_PRINTF_LONGLONG
- bool "rt_kprintf support long long"
- default n
endif
endmenu
config RT_VER_NUM
hex
- default 0x40004
+ default 0x40100
help
RT-Thread version number
diff --git a/src/device.c b/src/device.c
index 6e22c2b692..ebb8f26854 100644
--- a/src/device.c
+++ b/src/device.c
@@ -16,9 +16,9 @@
*/
#include <rtthread.h>
-#ifdef RT_USING_POSIX
+#ifdef RT_USING_POSIX_DEVIO
#include <rtdevice.h> /* for wqueue_init */
-#endif /* RT_USING_POSIX */
+#endif /* RT_USING_POSIX_DEVIO */
#ifdef RT_USING_DEVICE
@@ -64,10 +64,10 @@ rt_err_t rt_device_register(rt_device_t dev,
dev->ref_count = 0;
dev->open_flag = 0;
-#ifdef RT_USING_POSIX
+#ifdef RT_USING_POSIX_DEVIO
dev->fops = RT_NULL;
rt_wqueue_init(&(dev->wait_queue));
-#endif /* RT_USING_POSIX */
+#endif /* RT_USING_POSIX_DEVIO */
return RT_EOK;
}
diff --git a/src/kservice.c b/src/kservice.c
index 6a42b92047..8b959cbd68 100644
--- a/src/kservice.c
+++ b/src/kservice.c
@@ -115,6 +115,7 @@ int *_rt_errno(void)
}
RTM_EXPORT(_rt_errno);
+#ifndef RT_USING_ASM_MEMSET
/**
* This function will set the content of memory to specified value.
*
@@ -127,7 +128,7 @@ RTM_EXPORT(_rt_errno);
*
* @return The address of source memory.
*/
-RT_WEAK void *rt_memset(void *s, int c, rt_ubase_t count)
+void *rt_memset(void *s, int c, rt_ubase_t count)
{
#ifdef RT_KSERVICE_USING_TINY_SIZE
char *xs = (char *)s;
@@ -200,6 +201,7 @@ RT_WEAK void *rt_memset(void *s, int c, rt_ubase_t count)
#endif /* RT_KSERVICE_USING_TINY_SIZE */
}
RTM_EXPORT(rt_memset);
+#endif /* RT_USING_ASM_MEMSET */
#ifndef RT_USING_ASM_MEMCPY
/**
@@ -338,7 +340,7 @@ RTM_EXPORT(rt_memmove);
* If the result > 0, cs is greater than ct.
* If the result = 0, cs is equal to ct.
*/
-RT_WEAK rt_int32_t rt_memcmp(const void *cs, const void *ct, rt_ubase_t count)
+rt_int32_t rt_memcmp(const void *cs, const void *ct, rt_ubase_t count)
{
const unsigned char *su1, *su2;
int res = 0;
@@ -591,7 +593,6 @@ RTM_EXPORT(rt_show_version);
/* private function */
#define _ISDIGIT(c) ((unsigned)((c) - '0') < 10)
-#ifdef RT_PRINTF_LONGLONG
/**
* This function will duplicate a string.
*
@@ -601,44 +602,38 @@ RTM_EXPORT(rt_show_version);
*
* @return the duplicated string pointer.
*/
+#ifdef RT_PRINTF_LONGLONG
rt_inline int divide(long long *n, int base)
+#else
+rt_inline int divide(long *n, int base)
+#endif /* RT_PRINTF_LONGLONG */
{
int res;
/* optimized for processor which does not support divide instructions. */
if (base == 10)
{
+#ifdef RT_PRINTF_LONGLONG
res = (int)(((unsigned long long)*n) % 10U);
*n = (long long)(((unsigned long long)*n) / 10U);
- }
- else
- {
- res = (int)(((unsigned long long)*n) % 16U);
- *n = (long long)(((unsigned long long)*n) / 16U);
- }
-
- return res;
-}
#else
-rt_inline int divide(long *n, int base)
-{
- int res;
-
- /* optimized for processor which does not support divide instructions. */
- if (base == 10)
- {
res = (int)(((unsigned long)*n) % 10U);
*n = (long)(((unsigned long)*n) / 10U);
+#endif
}
else
{
+#ifdef RT_PRINTF_LONGLONG
+ res = (int)(((unsigned long long)*n) % 16U);
+ *n = (long long)(((unsigned long long)*n) / 16U);
+#else
res = (int)(((unsigned long)*n) % 16U);
*n = (long)(((unsigned long)*n) / 16U);
+#endif
}
return res;
}
-#endif /* RT_PRINTF_LONGLONG */
rt_inline int skip_atoi(const char **s)
{
@@ -657,7 +652,6 @@ rt_inline int skip_atoi(const char **s)
#define SPECIAL (1 << 5) /* 0x */
#define LARGE (1 << 6) /* use 'ABCDEF' instead of 'abcdef' */
-#ifdef RT_PRINTF_PRECISION
static char *print_number(char *buf,
char *end,
#ifdef RT_PRINTF_LONGLONG
@@ -667,20 +661,10 @@ static char *print_number(char *buf,
#endif /* RT_PRINTF_LONGLONG */
int base,
int s,
+#ifdef RT_PRINTF_PRECISION
int precision,
- int type)
-#else
-static char *print_number(char *buf,
- char *end,
-#ifdef RT_PRINTF_LONGLONG
- long long num,
-#else
- long num,
-#endif /* RT_PRINTF_LONGLONG */
- int base,
- int s,
- int type)
#endif /* RT_PRINTF_PRECISION */
+ int type)
{
char c, sign;
#ifdef RT_PRINTF_LONGLONG
@@ -842,10 +826,7 @@ static char *print_number(char *buf,
*
* @return The number of characters actually written to buffer.
*/
-rt_int32_t rt_vsnprintf(char *buf,
- rt_size_t size,
- const char *fmt,
- va_list args)
+RT_WEAK int rt_vsnprintf(char *buf, rt_size_t size, const char *fmt, va_list args)
{
#ifdef RT_PRINTF_LONGLONG
unsigned long long num;
@@ -1119,7 +1100,7 @@ RTM_EXPORT(rt_vsnprintf);
*
* @return The number of characters actually written to buffer.
*/
-rt_int32_t rt_snprintf(char *buf, rt_size_t size, const char *fmt, ...)
+int rt_snprintf(char *buf, rt_size_t size, const char *fmt, ...)
{
rt_int32_t n;
va_list args;
@@ -1143,7 +1124,7 @@ RTM_EXPORT(rt_snprintf);
*
* @return The number of characters actually written to buffer.
*/
-rt_int32_t rt_vsprintf(char *buf, const char *format, va_list arg_ptr)
+int rt_vsprintf(char *buf, const char *format, va_list arg_ptr)
{
return rt_vsnprintf(buf, (rt_size_t) - 1, format, arg_ptr);
}
@@ -1158,7 +1139,7 @@ RTM_EXPORT(rt_vsprintf);
*
* @return The number of characters actually written to buffer.
*/
-rt_int32_t rt_sprintf(char *buf, const char *format, ...)
+int rt_sprintf(char *buf, const char *format, ...)
{
rt_int32_t n;
va_list arg_ptr;
@@ -1258,8 +1239,10 @@ void rt_kputs(const char *str)
* This function will print a formatted string on system console.
*
* @param fmt is the format parameters.
+ *
+ * @return The number of characters actually written to buffer.
*/
-RT_WEAK void rt_kprintf(const char *fmt, ...)
+RT_WEAK int rt_kprintf(const char *fmt, ...)
{
va_list args;
rt_size_t length;
@@ -1287,6 +1270,8 @@ RT_WEAK void rt_kprintf(const char *fmt, ...)
rt_hw_console_output(rt_log_buf);
#endif /* RT_USING_DEVICE */
va_end(args);
+
+ return length;
}
RTM_EXPORT(rt_kprintf);
#endif /* RT_USING_CONSOLE */
diff --git a/src/thread.c b/src/thread.c
index ab5264053e..6256deaf82 100644
--- a/src/thread.c
+++ b/src/thread.c
@@ -31,6 +31,7 @@
#include <rthw.h>
#include <rtthread.h>
+#include <stddef.h>
#ifdef RT_USING_HOOK
static void (*rt_thread_suspend_hook)(rt_thread_t thread);
diff --git a/src/timer.c b/src/timer.c
index 25ba175306..846c33263b 100644
--- a/src/timer.c
+++ b/src/timer.c
@@ -560,12 +560,12 @@ rt_err_t rt_timer_control(rt_timer_t timer, int cmd, void *arg)
if(timer->parent.flag & RT_TIMER_FLAG_ACTIVATED)
{
/*timer is start and run*/
- *(rt_tick_t *)arg = RT_TIMER_FLAG_ACTIVATED;
+ *(rt_uint32_t *)arg = RT_TIMER_FLAG_ACTIVATED;
}
else
{
/*timer is stop*/
- *(rt_tick_t *)arg = RT_TIMER_FLAG_DEACTIVATED;
+ *(rt_uint32_t *)arg = RT_TIMER_FLAG_DEACTIVATED;
}
break;