diff --git a/bsp/at32/at32f403a-start/board/Kconfig b/bsp/at32/at32f403a-start/board/Kconfig index 9816ab4729b306236606c2786c4b6c697ecf06c3..f16afc9bfeaace4463bb243d26de28d5a4aef26b 100644 --- a/bsp/at32/at32f403a-start/board/Kconfig +++ b/bsp/at32/at32f403a-start/board/Kconfig @@ -31,7 +31,6 @@ menu "On-chip Peripheral Drivers" menuconfig BSP_USING_RTC bool "Enable RTC" select RT_USING_RTC - select RT_USING_LIBC default n if BSP_USING_RTC choice diff --git a/bsp/at32/at32f407-start/board/Kconfig b/bsp/at32/at32f407-start/board/Kconfig index 5a3b46274c3d3e6cfab86c600c61ac603886c678..c0c63ed753b936244a2f7fa69ddda044834c541f 100644 --- a/bsp/at32/at32f407-start/board/Kconfig +++ b/bsp/at32/at32f407-start/board/Kconfig @@ -37,7 +37,6 @@ menu "On-chip Peripheral Drivers" menuconfig BSP_USING_RTC bool "Enable RTC" select RT_USING_RTC - select RT_USING_LIBC default n if BSP_USING_RTC choice diff --git a/bsp/bluetrum/ab32vg1-ab-prougen/board/Kconfig b/bsp/bluetrum/ab32vg1-ab-prougen/board/Kconfig index 3f52d1798e637a24d504f06d62771e5ab1b90d59..8c7d93c61a4c685bc7495d45967dfb2a771003f7 100644 --- a/bsp/bluetrum/ab32vg1-ab-prougen/board/Kconfig +++ b/bsp/bluetrum/ab32vg1-ab-prougen/board/Kconfig @@ -204,7 +204,6 @@ menu "On-chip Peripheral Drivers" menuconfig BSP_USING_ONCHIP_RTC bool "Enable RTC" select RT_USING_RTC - select RT_USING_LIBC default n if BSP_USING_ONCHIP_RTC config RTC_USING_INTERNAL_CLK diff --git "a/bsp/gd32/docs/GD32\347\263\273\345\210\227BSP\345\210\266\344\275\234\346\225\231\347\250\213.md" "b/bsp/gd32/docs/GD32\347\263\273\345\210\227BSP\345\210\266\344\275\234\346\225\231\347\250\213.md" index 8f50f631c90fe85de3b3da077852a3aea6f91655..6a894cc54a9a894f2b1619718a2aa8cf6c0c1752 100644 --- "a/bsp/gd32/docs/GD32\347\263\273\345\210\227BSP\345\210\266\344\275\234\346\225\231\347\250\213.md" +++ "b/bsp/gd32/docs/GD32\347\263\273\345\210\227BSP\345\210\266\344\275\234\346\225\231\347\250\213.md" @@ -918,7 +918,6 @@ GD32 BSP 的制作规范主要分为 3 个方面:工程配置,ENV 配置和 - 系统空闲线程栈大小统一设置为 256(宏:IDLE_THREAD_STACK_SIZE) - 开启组件自动初始化(宏:RT_USING_COMPONENTS_INIT) - 需要开启 user main 选项(宏:RT_USING_USER_MAIN) -- 默认关闭 libc(宏:RT_USING_LIBC) - FinSH 默认只使用 MSH 模式(宏:FINSH_USING_MSH_ONLY) #### 4.1.3 IDE 配置 diff --git a/bsp/hc32f4a0/board/Kconfig b/bsp/hc32f4a0/board/Kconfig index c33c82d89e04ce84f6771e40dbf5ceaba65162be..77eaf83ea20d0585600c8e7db4be5e139deb9b52 100644 --- a/bsp/hc32f4a0/board/Kconfig +++ b/bsp/hc32f4a0/board/Kconfig @@ -219,7 +219,6 @@ menu "On-chip Peripheral Drivers" menuconfig BSP_USING_RTC bool "Enable RTC" select RT_USING_RTC - select RT_USING_LIBC default n if BSP_USING_RTC diff --git a/bsp/hk32/hk32f030c8-mini/board/Kconfig b/bsp/hk32/hk32f030c8-mini/board/Kconfig index 16b2d2387849a228e1ba9ec586ff5a77ba013721..34025eda33d44e2c98b3983c5d9abf452520aaf2 100644 --- a/bsp/hk32/hk32f030c8-mini/board/Kconfig +++ b/bsp/hk32/hk32f030c8-mini/board/Kconfig @@ -31,7 +31,6 @@ menu "On-chip Peripheral Drivers" menuconfig BSP_USING_RTC bool "Enable RTC" select RT_USING_RTC - select RT_USING_LIBC default n if BSP_USING_RTC choice diff --git a/bsp/lpc55sxx/lpc55s69_nxp_evk/board/Kconfig b/bsp/lpc55sxx/lpc55s69_nxp_evk/board/Kconfig index 94669d3736f98faa64fc850c024fe46e936ae918..ffd90e53f2a0df6f9fb15214197f5b6487398754 100644 --- a/bsp/lpc55sxx/lpc55s69_nxp_evk/board/Kconfig +++ b/bsp/lpc55sxx/lpc55s69_nxp_evk/board/Kconfig @@ -137,7 +137,6 @@ menu "On-chip Peripheral Drivers" select RT_USING_SDIO select RT_USING_DFS select RT_USING_DFS_ELMFAT - select RT_LIBC_USING_TIME default y config BSP_USING_RTC diff --git a/bsp/maxim/MAX32660_EVSYS/board/Kconfig b/bsp/maxim/MAX32660_EVSYS/board/Kconfig index 5a470ca469395cf7bdb81aa26a287efa707ea37c..63fd7067b2ca365ab00a6823f5de90dbcf859925 100644 --- a/bsp/maxim/MAX32660_EVSYS/board/Kconfig +++ b/bsp/maxim/MAX32660_EVSYS/board/Kconfig @@ -84,7 +84,6 @@ menu "On-chip Peripheral Drivers" config BSP_USING_ONCHIP_RTC bool "Enable RTC" select RT_USING_RTC - select RT_USING_LIBC default n endmenu diff --git a/bsp/nrf5x/nrf52832/board/Kconfig b/bsp/nrf5x/nrf52832/board/Kconfig index bc61640851057f0293fdcc1730a553fa016720e3..61881a78fde0fd9fd0a6708974ff96cdfea07768 100644 --- a/bsp/nrf5x/nrf52832/board/Kconfig +++ b/bsp/nrf5x/nrf52832/board/Kconfig @@ -390,7 +390,6 @@ menu "On-chip Peripheral Drivers" menuconfig BSP_USING_ONCHIP_RTC bool "Enable RTC" select RT_USING_RTC - select RT_USING_LIBC default n if BSP_USING_ONCHIP_RTC config NRFX_CLOCK_ENABLED diff --git a/bsp/nrf5x/nrf52840/board/Kconfig b/bsp/nrf5x/nrf52840/board/Kconfig index 12c921fc7fc62b9c782d0c8f3d584a99b6430c7a..f52beb2f31f627cf197807a9d0cc2d78757f90bc 100644 --- a/bsp/nrf5x/nrf52840/board/Kconfig +++ b/bsp/nrf5x/nrf52840/board/Kconfig @@ -374,7 +374,6 @@ menu "On-chip Peripheral Drivers" menuconfig BSP_USING_ONCHIP_RTC bool "Enable RTC" select RT_USING_RTC - select RT_USING_LIBC default n diff --git a/bsp/stm32/docs/How to make a STM32 BSP for RT-Thread.md b/bsp/stm32/docs/How to make a STM32 BSP for RT-Thread.md index 2b677e7dfb82fe1b218f4918ab86002775b19630..b5e84671d087ea0c90de1f396ecd5fa756b60035 100644 --- a/bsp/stm32/docs/How to make a STM32 BSP for RT-Thread.md +++ b/bsp/stm32/docs/How to make a STM32 BSP for RT-Thread.md @@ -221,7 +221,6 @@ The specifications of making STM32 BSP are mainly divided into three aspects: en - The system idle thread stack size is uniformly set to 256 (Macro: IDLE_THREAD_STACK_SIZE) - Turn on automatic component initialization (Macro: RT_USING_COMPONENTS_INIT) - Need to enable the user main option (Macro: RT_USING_USER_MAIN) -- Disable libc by default (Macro: RT_USING_LIBC) - FinSH only uses MSH mode by default (Macro: FINSH_USING_MSH_ONLY) #### 4.1.3 IDE configuration diff --git "a/bsp/stm32/docs/STM32\347\263\273\345\210\227BSP\345\210\266\344\275\234\346\225\231\347\250\213.md" "b/bsp/stm32/docs/STM32\347\263\273\345\210\227BSP\345\210\266\344\275\234\346\225\231\347\250\213.md" index 5d09fddf50e8e7ce1ed5faf77dacecee52d3d292..91eca7e3a07e98e11d47c51e23c4abbdae761cac 100644 --- "a/bsp/stm32/docs/STM32\347\263\273\345\210\227BSP\345\210\266\344\275\234\346\225\231\347\250\213.md" +++ "b/bsp/stm32/docs/STM32\347\263\273\345\210\227BSP\345\210\266\344\275\234\346\225\231\347\250\213.md" @@ -269,7 +269,6 @@ STM32 BSP 的制作规范主要分为 3 个方面:工程配置,ENV 配置和 - 系统空闲线程栈大小统一设置为 256(宏:IDLE_THREAD_STACK_SIZE) - 开启组件自动初始化(宏:RT_USING_COMPONENTS_INIT) - 需要开启 user main 选项(宏:RT_USING_USER_MAIN) -- 默认关闭 libc(宏:RT_USING_LIBC) - FinSH 默认只使用 MSH 模式(宏:FINSH_USING_MSH_ONLY) #### 4.1.3 IDE 配置 diff --git a/bsp/stm32/libraries/templates/stm32l1xx/board/Kconfig b/bsp/stm32/libraries/templates/stm32l1xx/board/Kconfig index 1bfdf4513b6f2d5e82d7b0d00aa365944bca1920..3ec4eedb9962b4fb822528b40fd291eb1cb82686 100644 --- a/bsp/stm32/libraries/templates/stm32l1xx/board/Kconfig +++ b/bsp/stm32/libraries/templates/stm32l1xx/board/Kconfig @@ -187,7 +187,6 @@ menu "On-chip Peripheral Drivers" menuconfig BSP_USING_ONCHIP_RTC bool "Enable RTC" select RT_USING_RTC - select RT_USING_LIBC default n if BSP_USING_ONCHIP_RTC choice diff --git a/bsp/stm32/libraries/templates/stm32wbxx/board/Kconfig b/bsp/stm32/libraries/templates/stm32wbxx/board/Kconfig index 3a5a05b63f05352cd6ffa17b53d684942aff9baf..428a7d35928493e1dd15afe6ac68b6792a64be56 100644 --- a/bsp/stm32/libraries/templates/stm32wbxx/board/Kconfig +++ b/bsp/stm32/libraries/templates/stm32wbxx/board/Kconfig @@ -143,7 +143,6 @@ menu "On-chip Peripheral Drivers" menuconfig BSP_USING_ONCHIP_RTC bool "Enable RTC" select RT_USING_RTC - select RT_USING_LIBC default n if BSP_USING_ONCHIP_RTC choice diff --git a/bsp/stm32/libraries/templates/stm32xx_board_Kconfig b/bsp/stm32/libraries/templates/stm32xx_board_Kconfig index 42c8528c603c2f3cb14b92528b20c772d36c946b..ba8f7bd25bf245dc4685bb28dc5eb3c690c898e2 100644 --- a/bsp/stm32/libraries/templates/stm32xx_board_Kconfig +++ b/bsp/stm32/libraries/templates/stm32xx_board_Kconfig @@ -151,7 +151,6 @@ menu "On-chip Peripheral Drivers" menuconfig BSP_USING_ONCHIP_RTC bool "Enable RTC" select RT_USING_RTC - select RT_USING_LIBC default n if BSP_USING_ONCHIP_RTC choice diff --git a/bsp/stm32/stm32f407-armfly-v5/board/Kconfig b/bsp/stm32/stm32f407-armfly-v5/board/Kconfig index 7c6b8a97f0e697a2f73b9d2ed962d1da99140631..5073e6e7a483d9d23047a19b5427d6cbbea93b5e 100644 --- a/bsp/stm32/stm32f407-armfly-v5/board/Kconfig +++ b/bsp/stm32/stm32f407-armfly-v5/board/Kconfig @@ -162,7 +162,6 @@ menu "On-chip Peripheral Drivers" menuconfig BSP_USING_ONCHIP_RTC bool "Enable RTC" select RT_USING_RTC - select RT_USING_LIBC default n if BSP_USING_ONCHIP_RTC choice diff --git a/bsp/stm32/stm32f746-st-nucleo/board/Kconfig b/bsp/stm32/stm32f746-st-nucleo/board/Kconfig index 8aba5902a664c73f8fb578781184a61cd6562a86..83868f1a5dd43a7f7c684bb2cc90e5a94ebd83d0 100644 --- a/bsp/stm32/stm32f746-st-nucleo/board/Kconfig +++ b/bsp/stm32/stm32f746-st-nucleo/board/Kconfig @@ -193,7 +193,6 @@ menu "On-chip Peripheral Drivers" menuconfig BSP_USING_ONCHIP_RTC bool "Enable RTC" select RT_USING_RTC - select RT_USING_LIBC default n if BSP_USING_ONCHIP_RTC choice diff --git a/bsp/stm32/stm32l475-atk-pandora/board/Kconfig b/bsp/stm32/stm32l475-atk-pandora/board/Kconfig index 627ef48251bfbe29a02583fd96603a11c9381ad1..767c446a13f1e5ee18fb48ea041381dcf631dd9a 100644 --- a/bsp/stm32/stm32l475-atk-pandora/board/Kconfig +++ b/bsp/stm32/stm32l475-atk-pandora/board/Kconfig @@ -148,7 +148,6 @@ menu "Onboard Peripheral Drivers" select RT_USING_WIFI select RT_WLAN_PROT_LWIP_PBUF_FORCE select RT_USING_LWIP - select RT_USING_LIBC select RT_USING_DFS select DFS_USING_POSIX select PKG_USING_FAL diff --git a/bsp/swm320-lq100/drivers/Kconfig b/bsp/swm320-lq100/drivers/Kconfig index 2ad515ae90b801b3b0ea63e46f5abedf975c1108..6858ab0568adb4a1f1deb509ac69a3b3c44313af 100644 --- a/bsp/swm320-lq100/drivers/Kconfig +++ b/bsp/swm320-lq100/drivers/Kconfig @@ -236,7 +236,6 @@ menu "On-chip Peripheral Drivers" config BSP_USING_RTC bool "Enable RTC" select RT_USING_RTC - select RT_USING_LIBC default n menuconfig BSP_USING_SPI diff --git a/bsp/swm320/drivers/Kconfig b/bsp/swm320/drivers/Kconfig index 2ad515ae90b801b3b0ea63e46f5abedf975c1108..6858ab0568adb4a1f1deb509ac69a3b3c44313af 100644 --- a/bsp/swm320/drivers/Kconfig +++ b/bsp/swm320/drivers/Kconfig @@ -236,7 +236,6 @@ menu "On-chip Peripheral Drivers" config BSP_USING_RTC bool "Enable RTC" select RT_USING_RTC - select RT_USING_LIBC default n menuconfig BSP_USING_SPI diff --git a/bsp/tae32f5300/drivers/Kconfig b/bsp/tae32f5300/drivers/Kconfig index 46e8ed25ec0746afce1461bc5e70df3b005be172..6e7d491d04c3fa046ed4f431b2ba15a88d6332e8 100644 --- a/bsp/tae32f5300/drivers/Kconfig +++ b/bsp/tae32f5300/drivers/Kconfig @@ -167,7 +167,6 @@ menu "On-chip Peripheral Drivers" menuconfig BSP_USING_RTC bool "Enable RTC" select RT_USING_RTC - select RT_USING_LIBC default n if BSP_USING_RTC diff --git a/bsp/tm4c123bsp/board/Kconfig b/bsp/tm4c123bsp/board/Kconfig index db5b976281d51627fb39c799ff017bff734192a5..f6136621de9e7918df2a5006b6bf2eaa5dece45c 100644 --- a/bsp/tm4c123bsp/board/Kconfig +++ b/bsp/tm4c123bsp/board/Kconfig @@ -283,7 +283,6 @@ menu "On-chip Peripheral Drivers" menuconfig BSP_USING_ONCHIP_RTC bool "Enable RTC" select RT_USING_RTC - select RT_USING_LIBC default n if BSP_USING_ONCHIP_RTC choice diff --git a/components/cplusplus/Kconfig b/components/cplusplus/Kconfig index 42b5cf9556ca9d036adf762a8c2863d1de30cfe8..3d5757fe4272d3cc8d60c2a8aeddf62716957371 100644 --- a/components/cplusplus/Kconfig +++ b/components/cplusplus/Kconfig @@ -9,8 +9,8 @@ if RT_USING_CPLUSPLUS config RT_USING_CPLUSPLUS11 bool "Enable c++11 threading feature support" default n - select RT_USING_LIBC - select RT_LIBC_USING_FILEIO + select RT_USING_POSIX_FS + select RT_USING_POSIX_DEVIO select RT_USING_PTHREADS select RT_USING_RTC diff --git a/components/cplusplus/README.md b/components/cplusplus/README.md index d02048d1f1398c9738c8b41ab4759a53813f339b..46c8c78a69b145934ff72b8f16b915044627e3d2 100644 --- a/components/cplusplus/README.md +++ b/components/cplusplus/README.md @@ -11,8 +11,6 @@ Because RT-Thread RTOS is used in embedded system mostly, there are some rules f 4. Static class variables are discouraged. The time and place to call their constructor function could not be precisely controlled and make multi-threaded programming a nightmare. 5. Multiple inheritance is strongly discouraged, as it can cause intolerable confusion. -*NOTE*: The libc (RT_USING_LIBC in rtconfig.h) must be enable. - About GNU GCC compiler please add following string in your ld link script: diff --git a/components/cplusplus/cpp11/armclang/thread.cpp b/components/cplusplus/cpp11/armclang/thread.cpp index 6b38d9b3a7317770623a9cb64ccfa66a095060a0..e10ffb9cfe8e6e19e3cd366a496dbfc0c61e0b5d 100644 --- a/components/cplusplus/cpp11/armclang/thread.cpp +++ b/components/cplusplus/cpp11/armclang/thread.cpp @@ -95,8 +95,8 @@ extern "C" unsigned __ARM_TPL_thread_hw_concurrency() extern "C" int __ARM_TPL_tls_create(__ARM_TPL_tls_key *__key, void (*__at_exit)(void *)) { - pthread_key_t key; - + pthread_key_t key; + if (pthread_key_create(&key, __at_exit) == 0) { *__key = key; diff --git a/components/cplusplus/cpp11/gcc/mutex b/components/cplusplus/cpp11/gcc/mutex index cc593cc139449f8483a42f50db353a63dd35cdae..3fdf86632b7aa8dad31794f1e92608b43f79803f 100644 --- a/components/cplusplus/cpp11/gcc/mutex +++ b/components/cplusplus/cpp11/gcc/mutex @@ -4,7 +4,7 @@ #error "C++ version lower than C++11" #endif -//#if defined(RT_USING_LIBC) && defined(RT_USING_PTHREADS) +//#if defined(RT_USING_PTHREADS) #include @@ -509,4 +509,4 @@ namespace std } } -//#endif // (RT_USING_LIBC) && (RT_USING_PTHREADS) \ No newline at end of file +//#endif //(RT_USING_PTHREADS) \ No newline at end of file diff --git a/components/cplusplus/cpp11/gcc/mutex.cpp b/components/cplusplus/cpp11/gcc/mutex.cpp index 014460ffde0d5f8742113e61617f6cb6eb7adb2c..e11f6d8990cdd56c12fa2a1377a3399e9ca3027d 100644 --- a/components/cplusplus/cpp11/gcc/mutex.cpp +++ b/components/cplusplus/cpp11/gcc/mutex.cpp @@ -34,7 +34,7 @@ namespace std get_once_functor_lock_ptr() = m_ptr; } - extern "C" + extern "C" { void once_proxy() { @@ -42,7 +42,7 @@ namespace std function once_call = std::move(once_functor); // no need to hold the lock anymore - unique_lock* lock_ptr = get_once_functor_lock_ptr(); + unique_lock* lock_ptr = get_once_functor_lock_ptr(); get_once_functor_lock_ptr() = nullptr; lock_ptr->unlock(); diff --git a/components/cplusplus/cpp11/gcc/thread b/components/cplusplus/cpp11/gcc/thread index 5b64decd6a0a137319138daaf343857491e1225b..60e3ec964ca7444ab5a6834591fb23030432f441 100644 --- a/components/cplusplus/cpp11/gcc/thread +++ b/components/cplusplus/cpp11/gcc/thread @@ -4,7 +4,7 @@ #error "C++ version lower than C++11" #endif -//#if defined(RT_USING_LIBC) && defined(RT_USING_PTHREADS) +//#if defined(RT_USING_PTHREADS) #include #include diff --git a/components/cplusplus/cpp11/gcc/thread.cpp b/components/cplusplus/cpp11/gcc/thread.cpp index 947170da25bf45c90a928e7bbb91dace15f9aff6..3979da0dc4518e980406221f00a29a47f05cdbeb 100644 --- a/components/cplusplus/cpp11/gcc/thread.cpp +++ b/components/cplusplus/cpp11/gcc/thread.cpp @@ -35,17 +35,17 @@ namespace std { auto raw_ptr = b.get(); // transfer the ownership of the invoker to the new thread - raw_ptr->this_ptr = std::move(b); + raw_ptr->this_ptr = std::move(b); int err = pthread_create(&_m_thr.__cpp_thread_t, NULL, &execute_native_thread_routine, raw_ptr); - if (err) + if (err) { raw_ptr->this_ptr.reset(); throw_system_error(err, "Failed to create a thread"); } - - } + + } thread::~thread() { @@ -59,12 +59,12 @@ namespace std if (joinable()) err = pthread_join(native_handle(), NULL); - - if (err) + + if (err) { throw_system_error(err, "thread::join failed"); } - + _m_thr = id(); } @@ -78,14 +78,14 @@ namespace std { throw_system_error(err, "thread::detach failed"); } - + _m_thr = id(); } // TODO: not yet actually implemented. // The standard states that the returned value should only be considered a hint. - unsigned thread::hardware_concurrency() noexcept - { + unsigned thread::hardware_concurrency() noexcept + { int __n = _RT_NPROCS; if (__n < 0) __n = 0; diff --git a/components/dfs/filesystems/elmfat/dfs_elm.c b/components/dfs/filesystems/elmfat/dfs_elm.c index 166c9d77da5090da858d714b731b6476c15b5567..b7cdaf8522df9bd967578b188e087e233eb85f97 100644 --- a/components/dfs/filesystems/elmfat/dfs_elm.c +++ b/components/dfs/filesystems/elmfat/dfs_elm.c @@ -945,7 +945,6 @@ DWORD get_fattime(void) { DWORD fat_time = 0; -#if defined(RT_LIBC_USING_TIME) || defined(RT_USING_LIBC) time_t now; struct tm *p_tm; struct tm tm_now; @@ -968,7 +967,6 @@ DWORD get_fattime(void) (DWORD)tm_now.tm_hour << 11 | (DWORD)tm_now.tm_min << 5 | (DWORD)tm_now.tm_sec / 2 ; -#endif /* defined(RT_LIBC_USING_TIME) || defined(RT_USING_LIBC) */ return fat_time; } diff --git a/components/libc/Kconfig b/components/libc/Kconfig index 69f8e1ae3622040af1fec827bbb307a9aca51ebf..0556cf618372aac873ada332c67ff18a20702ef5 100644 --- a/components/libc/Kconfig +++ b/components/libc/Kconfig @@ -1,38 +1,16 @@ menu "POSIX layer and C standard library" -config RT_USING_LIBC - bool "Enable libc APIs from the toolchain" +config RT_USING_MODULE + bool "Enable dynamic module with dlopen/dlsym/dlclose feature" default n -if RT_USING_LIBC - config RT_LIBC_USING_TIME - default y - - config RT_LIBC_USING_FILEIO - bool "Enable libc with file operation, eg.fopen/fwrite/fread/getchar/STDIO" - select RT_USING_POSIX_FS - select RT_USING_POSIX_DEVIO - default n - - config RT_USING_MODULE - bool "Enable dynamic module with dlopen/dlsym/dlclose feature" +if RT_USING_MODULE + config RT_USING_CUSTOM_DLMODULE + bool "Enable load dynamic module by custom" default n - - if RT_USING_MODULE - config RT_USING_CUSTOM_DLMODULE - bool "Enable load dynamic module by custom" - default n - endif -endif - -if RT_USING_LIBC != y - config RT_LIBC_USING_TIME - bool "Enable time functions without compiler's libc" - default y endif config RT_LIBC_DEFAULT_TIMEZONE - depends on (RT_LIBC_USING_TIME || RT_USING_LIBC) int "Set the default time zone (UTC+)" range -12 12 default 8 diff --git a/components/libc/compilers/armlibc/README.md b/components/libc/compilers/armlibc/README.md index 4d2a73b6bea8d8a524761436908228e9f0e00895..fc0d75023480fecf51d168f21125ce3c4c5fb329 100644 --- a/components/libc/compilers/armlibc/README.md +++ b/components/libc/compilers/armlibc/README.md @@ -1,9 +1,3 @@ # ARMLIB (Keil-MDK) porting for RT-Thread -Please define RT_USING_LIBC and compile RT-Thread with Keil-MDK compiler. - - - -## More Information - https://www.keil.com/support/man/docs/armlib/ \ No newline at end of file diff --git a/components/libc/compilers/armlibc/SConscript b/components/libc/compilers/armlibc/SConscript index bf1a2993041855b4ac68b1845c28c1a0cc0693d3..7fc94ccaa4eed3ba346e634b8c272082926d7bb1 100644 --- a/components/libc/compilers/armlibc/SConscript +++ b/components/libc/compilers/armlibc/SConscript @@ -7,6 +7,6 @@ group = [] CPPDEFINES = ['RT_USING_ARM_LIBC'] if rtconfig.PLATFORM == 'armcc' or rtconfig.PLATFORM == 'armclang': - group = DefineGroup('libc', src, depend = ['RT_USING_LIBC'], CPPDEFINES = CPPDEFINES) + group = DefineGroup('compiler-libc', src, depend = [], CPPDEFINES = CPPDEFINES) Return('group') diff --git a/components/libc/compilers/armlibc/mem_std.c b/components/libc/compilers/armlibc/syscall_mem.c similarity index 96% rename from components/libc/compilers/armlibc/mem_std.c rename to components/libc/compilers/armlibc/syscall_mem.c index f8a81c7873455b6b7c6af013d2f5131d4ba17025..b5403dfaf3c39da2804fcb640045056d014fa28c 100644 --- a/components/libc/compilers/armlibc/mem_std.c +++ b/components/libc/compilers/armlibc/syscall_mem.c @@ -13,7 +13,7 @@ #include #ifndef RT_USING_HEAP -#define DBG_TAG "armlibc.mem" +#define DBG_TAG "armlibc.syscall.mem" #define DBG_LVL DBG_INFO #include diff --git a/components/libc/compilers/armlibc/syscalls.c b/components/libc/compilers/armlibc/syscalls.c index 0e965d62af29390e858cdd53d29514e5f2ad42bd..77bf37dcbc5e8f16dd461948a1e2530ef16bce90 100644 --- a/components/libc/compilers/armlibc/syscalls.c +++ b/components/libc/compilers/armlibc/syscalls.c @@ -21,6 +21,7 @@ #include #include #include +#include #ifdef RT_USING_POSIX_DEVIO #include "libc.h" #endif /* RT_USING_POSIX_DEVIO */ @@ -69,6 +70,7 @@ FILEHANDLE _sys_open(const char *name, int openmode) return (STDERR); #ifndef DFS_USING_POSIX + LOG_W("%s: %s", __func__, warning_without_fs); return 0; /* error */ #else /* Correct openmode from fopen to open */ @@ -113,6 +115,7 @@ int _sys_close(FILEHANDLE fh) return close(fh); #else + LOG_W("%s: %s", __func__, warning_without_fs); return 0; #endif /* DFS_USING_POSIX */ } @@ -152,12 +155,13 @@ int _sys_read(FILEHANDLE fh, unsigned char *buf, unsigned len, int mode) #ifdef RT_USING_POSIX_DEVIO if (libc_stdio_get_console() < 0) { - LOG_W("Do not invoke standard output before initializing libc"); + LOG_W("Do not invoke standard output before initializing compiler-libc"); return 0; /* error, but keep going */ } size = read(STDIN_FILENO, buf, len); return len - size; /* success */ #else + LOG_W("%s: %s", __func__, warning_without_devio); return 0; /* error */ #endif /* RT_USING_POSIX_DEVIO */ } @@ -178,6 +182,7 @@ int _sys_read(FILEHANDLE fh, unsigned char *buf, unsigned len, int mode) } } #else + LOG_W("%s: %s", __func__, warning_without_fs); return 0; /* error */ #endif /* DFS_USING_POSIX */ } @@ -228,6 +233,7 @@ int _sys_write(FILEHANDLE fh, const unsigned char *buf, unsigned len, int mode) return 0; /* error */ } #else + LOG_W("%s: %s", __func__, warning_without_fs); return 0; /* error */ #endif /* DFS_USING_POSIX */ } @@ -246,6 +252,7 @@ int _sys_seek(FILEHANDLE fh, long pos) /* position is relative to the start of file fh */ return lseek(fh, pos, 0); #else + LOG_W("%s: %s", __func__, warning_without_fs); return 0; /* error */ #endif /* DFS_USING_POSIX */ } @@ -301,6 +308,7 @@ long _sys_flen(FILEHANDLE fh) fstat(fh, &stat); return stat.st_size; #else + LOG_W("%s: %s", __func__, warning_without_fs); return 0; #endif /* DFS_USING_POSIX */ } @@ -318,6 +326,7 @@ int remove(const char *filename) #ifdef DFS_USING_POSIX return unlink(filename); #else + LOG_W("%s: %s", __func__, warning_without_fs); return 0; /* error */ #endif /* DFS_USING_POSIX */ } @@ -345,13 +354,14 @@ int fgetc(FILE *f) if (libc_stdio_get_console() < 0) { - LOG_W("Do not invoke standard output before initializing libc"); + LOG_W("Do not invoke standard output before initializing compiler-libc"); return 0; } if(read(STDIN_FILENO, &ch, 1) == 1) return ch; #endif /* RT_USING_POSIX_DEVIO */ + LOG_W("%s: %s", __func__, warning_without_devio); return 0; /* error */ } diff --git a/components/libc/compilers/common/SConscript b/components/libc/compilers/common/SConscript index 504bf84e569995032ffcd2cb31a391001ff258a3..26cd9ab1d8b0a2dd58b95228e04af3a7ea50706f 100644 --- a/components/libc/compilers/common/SConscript +++ b/components/libc/compilers/common/SConscript @@ -10,12 +10,9 @@ CPPDEFINES = [] if rtconfig.CROSS_TOOL == 'keil': CPPDEFINES += ['__CLK_TCK=RT_TICK_PER_SECOND'] -if GetDepend('RT_USING_LIBC'): - src += Glob('*.c') -elif GetDepend('RT_LIBC_USING_TIME'): - src += ['time.c'] +src += Glob('*.c') -group = DefineGroup('libc', src, depend = [], CPPPATH = CPPPATH, CPPDEFINES = CPPDEFINES) +group = DefineGroup('compiler-libc', src, depend = [], CPPPATH = CPPPATH, CPPDEFINES = CPPDEFINES) list = os.listdir(cwd) for item in list: diff --git a/components/libc/compilers/common/compiler_private.c b/components/libc/compilers/common/compiler_private.c new file mode 100644 index 0000000000000000000000000000000000000000..6e9a6001f0fde6143174a7bf64cba3f99cdc5fab --- /dev/null +++ b/components/libc/compilers/common/compiler_private.c @@ -0,0 +1,13 @@ +/* + * Copyright (c) 2006-2021, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2021-12-26 Meco Man First Version + */ +#include "compiler_private.h" + +const char *warning_without_fs = "Please enable RT_USING_POSIX_FS"; +const char *warning_without_devio = "Please enable RT_USING_POSIX_FS and RT_USING_POSIX_DEVIO"; diff --git a/components/libc/compilers/common/compiler_private.h b/components/libc/compilers/common/compiler_private.h new file mode 100644 index 0000000000000000000000000000000000000000..79bac3b787d29d619d8baca3c475a2daa94b6662 --- /dev/null +++ b/components/libc/compilers/common/compiler_private.h @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2006-2021, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2021-12-26 Meco Man First Version + */ +#ifndef __COMPILER_PRIVATE_H__ +#define __COMPILER_PRIVATE_H__ + +#include + +extern const char *warning_without_fs; +extern const char *warning_without_devio; + +#endif /* __COMPILER_PRIVATE_H__ */ diff --git a/components/libc/compilers/common/nogcc/SConscript b/components/libc/compilers/common/nogcc/SConscript index c766c8f82dd1a8fa04959d246a10136039c7c4bd..091848a6d5afb42cabd79b4ad5d0b4bfca408930 100644 --- a/components/libc/compilers/common/nogcc/SConscript +++ b/components/libc/compilers/common/nogcc/SConscript @@ -7,9 +7,8 @@ cwd = GetCurrentDir() CPPPATH = [cwd] group = [] -if GetDepend('RT_USING_LIBC'): - src += Glob('*.c') +src += Glob('*.c') if rtconfig.PLATFORM != 'gcc' or rtconfig.ARCH == 'sim': - group = DefineGroup('libc', src, depend = [], CPPPATH = CPPPATH) + group = DefineGroup('compiler-libc', src, depend = [], CPPPATH = CPPPATH) Return('group') diff --git a/components/libc/compilers/common/time.c b/components/libc/compilers/common/time.c index 4d204a0c001836041716d10a42f173a5dceae852..1fe11561f74160a406d86e44f64031d5f2352bd8 100644 --- a/components/libc/compilers/common/time.c +++ b/components/libc/compilers/common/time.c @@ -25,7 +25,7 @@ #include #include #include -#ifdef RT_USING_DEVICE +#ifdef RT_USING_RTC #include #endif @@ -33,6 +33,8 @@ #define DBG_LVL DBG_INFO #include +#define WARNING_NO_RTC "Cannot find a RTC device!" + /* seconds per day */ #define SPD 24*60*60 @@ -108,7 +110,7 @@ static rt_err_t get_timeval(struct timeval *tv) else { /* LOG_W will cause a recursive printing if ulog timestamp function is enabled */ - rt_kprintf("Cannot find a RTC device to provide time!\r\n"); + rt_kprintf(WARNING_NO_RTC); return -RT_ENOSYS; } @@ -116,7 +118,7 @@ static rt_err_t get_timeval(struct timeval *tv) #else /* LOG_W will cause a recursive printing if ulog timestamp function is enabled */ - rt_kprintf("Cannot find a RTC device to provide time!\r\n"); + rt_kprintf(WARNING_NO_RTC); return -RT_ENOSYS; #endif /* RT_USING_RTC */ } @@ -153,14 +155,14 @@ static int set_timeval(struct timeval *tv) } else { - LOG_W("Cannot find a RTC device to provide time!"); + LOG_W(WARNING_NO_RTC); return -RT_ENOSYS; } return rst; #else - LOG_W("Cannot find a RTC device to provide time!"); + LOG_W(WARNING_NO_RTC); return -RT_ENOSYS; #endif /* RT_USING_RTC */ } @@ -525,7 +527,7 @@ INIT_COMPONENT_EXPORT(_rt_clock_time_system_init); int clock_getres(clockid_t clockid, struct timespec *res) { #ifndef RT_USING_RTC - LOG_W("Cannot find a RTC device to save time!"); + LOG_W(WARNING_NO_RTC); return -1; #else int ret = 0; @@ -564,7 +566,7 @@ RTM_EXPORT(clock_getres); int clock_gettime(clockid_t clockid, struct timespec *tp) { #ifndef RT_USING_RTC - LOG_W("Cannot find a RTC device to save time!"); + LOG_W(WARNING_NO_RTC); return -1; #else int ret = 0; @@ -628,7 +630,7 @@ int clock_nanosleep(clockid_t clockid, int flags, const struct timespec *rqtp, s int clock_settime(clockid_t clockid, const struct timespec *tp) { #ifndef RT_USING_RTC - LOG_W("Cannot find a RTC device to save time!"); + LOG_W(WARNING_NO_RTC); return -1; #else register rt_base_t level; diff --git a/components/libc/compilers/dlib/README.md b/components/libc/compilers/dlib/README.md index acd08f90749adeb654e178c85fb577f396e74abb..e4d70e813579fcddba2718acef116b4d4a406de2 100644 --- a/components/libc/compilers/dlib/README.md +++ b/components/libc/compilers/dlib/README.md @@ -1,9 +1,3 @@ # DLIB (IAR) porting for RT-Thread -Please define RT_USING_LIBC and compile RT-Thread with IAR compiler. - - - -## More Information - http://www.iarsys.co.jp/download/LMS2/arm/7502/ewarm7502doc/arm/doc/EWARM_DevelopmentGuide.ENU.pdf P.130 \ No newline at end of file diff --git a/components/libc/compilers/dlib/SConscript b/components/libc/compilers/dlib/SConscript index f685873e16ee392dae8301e8c1c160f436158d97..2c5dbc426d0c13a05e1ee6ef164f4086613bbfae 100644 --- a/components/libc/compilers/dlib/SConscript +++ b/components/libc/compilers/dlib/SConscript @@ -15,6 +15,6 @@ if rtconfig.PLATFORM == 'iar': if LooseVersion(IARVersion()) < LooseVersion("8.20.1"): CPPDEFINES = CPPDEFINES + ['_DLIB_THREAD_SUPPORT'] - group = DefineGroup('libc', src, depend = ['RT_USING_LIBC'], CPPDEFINES = CPPDEFINES) + group = DefineGroup('compiler-libc', src, depend = [], CPPDEFINES = CPPDEFINES) Return('group') diff --git a/components/libc/compilers/dlib/syscall_close.c b/components/libc/compilers/dlib/syscall_close.c index 30ee6f2388c120fc8f44c3b5af284e22f33b6503..9ac60076f44c3ca57729a87fc8f98e65e29ffc30 100644 --- a/components/libc/compilers/dlib/syscall_close.c +++ b/components/libc/compilers/dlib/syscall_close.c @@ -10,6 +10,10 @@ #include #include #include +#include +#define DBG_TAG "dlib.syscall.close" +#define DBG_LVL DBG_INFO +#include /* * The "__close" function should close the file corresponding to @@ -27,6 +31,7 @@ int __close(int handle) #ifdef DFS_USING_POSIX return close(handle); #else + LOG_W(warning_without_fs); return _LLIO_ERROR; #endif /* DFS_USING_POSIX */ } diff --git a/components/libc/compilers/dlib/syscall_lseek.c b/components/libc/compilers/dlib/syscall_lseek.c index 622f613c517153eac60ddddf547a1dcc612f210e..b7ec0fa7a9e947f7d80ead871d3ba2aec961a11e 100644 --- a/components/libc/compilers/dlib/syscall_lseek.c +++ b/components/libc/compilers/dlib/syscall_lseek.c @@ -10,6 +10,10 @@ #include #include #include +#include +#define DBG_TAG "dlib.syscall.lseek" +#define DBG_LVL DBG_INFO +#include /* * The "__lseek" function makes the next file operation (__read or @@ -36,6 +40,7 @@ long __lseek(int handle, long offset, int whence) #ifdef DFS_USING_POSIX return lseek(handle, offset, whence); #else + LOG_W(warning_without_fs); return _LLIO_ERROR; #endif /* DFS_USING_POSIX */ } diff --git a/components/libc/compilers/dlib/syscall_mem.c b/components/libc/compilers/dlib/syscall_mem.c index 74b960f0b92380caa8c61e51591138f4febaa897..57060da842ac4048ed99456912cda8f8398a170f 100644 --- a/components/libc/compilers/dlib/syscall_mem.c +++ b/components/libc/compilers/dlib/syscall_mem.c @@ -12,7 +12,7 @@ #include #ifndef RT_USING_HEAP -#define DBG_TAG "dlib.syscall_mem" +#define DBG_TAG "dlib.syscall.mem" #define DBG_LVL DBG_INFO #include #define _NO_HEAP_ERROR() do{LOG_E("Please enable RT_USING_HEAP");\ diff --git a/components/libc/compilers/dlib/syscall_open.c b/components/libc/compilers/dlib/syscall_open.c index 66cddc83c15696a986a584799ff848f73b9f2f74..3d31f0cf69b341205f1afea5a0544ade162fd879 100644 --- a/components/libc/compilers/dlib/syscall_open.c +++ b/components/libc/compilers/dlib/syscall_open.c @@ -11,6 +11,10 @@ #include #include #include +#include +#define DBG_TAG "dlib.syscall.open" +#define DBG_LVL DBG_INFO +#include /* * The "__open" function opens the file named "filename" as specified @@ -22,56 +26,58 @@ int __open(const char *filename, int mode) { #ifdef DFS_USING_POSIX - int handle; - int open_mode = O_RDONLY; + int handle; + int open_mode = O_RDONLY; - if (mode & _LLIO_CREAT) - { - open_mode |= O_CREAT; - - /* Check what we should do with it if it exists. */ - if (mode & _LLIO_APPEND) + if (mode & _LLIO_CREAT) { - /* Append to the existing file. */ - open_mode |= O_APPEND; + open_mode |= O_CREAT; + + /* Check what we should do with it if it exists. */ + if (mode & _LLIO_APPEND) + { + /* Append to the existing file. */ + open_mode |= O_APPEND; + } + + if (mode & _LLIO_TRUNC) + { + /* Truncate the existsing file. */ + open_mode |= O_TRUNC; + } } - if (mode & _LLIO_TRUNC) + if (mode & _LLIO_TEXT) { - /* Truncate the existsing file. */ - open_mode |= O_TRUNC; + /* we didn't support text mode */ } - } - if (mode & _LLIO_TEXT) - { - /* we didn't support text mode */ - } - - switch (mode & _LLIO_RDWRMASK) - { - case _LLIO_RDONLY: - break; - - case _LLIO_WRONLY: - open_mode |= O_WRONLY; - break; + switch (mode & _LLIO_RDWRMASK) + { + case _LLIO_RDONLY: + break; - case _LLIO_RDWR: - /* The file should be opened for both reads and writes. */ - open_mode |= O_RDWR; - break; + case _LLIO_WRONLY: + open_mode |= O_WRONLY; + break; - default: - return _LLIO_ERROR; - } + case _LLIO_RDWR: + /* The file should be opened for both reads and writes. */ + open_mode |= O_RDWR; + break; - handle = open(filename, open_mode, 0); - if (handle < 0) - return _LLIO_ERROR; + default: + return _LLIO_ERROR; + } - return handle; + handle = open(filename, open_mode, 0); + if (handle < 0) + { + return _LLIO_ERROR; + } + return handle; #else - return _LLIO_ERROR; + LOG_W(warning_without_fs); + return _LLIO_ERROR; #endif /* DFS_USING_POSIX */ } diff --git a/components/libc/compilers/dlib/syscall_read.c b/components/libc/compilers/dlib/syscall_read.c index 62bc05d2434cfb349791bb0e8e69d7c6f579d585..29941c23dbe314b5b7094c4e30c6a08eea085a94 100644 --- a/components/libc/compilers/dlib/syscall_read.c +++ b/components/libc/compilers/dlib/syscall_read.c @@ -14,8 +14,8 @@ #ifdef RT_USING_POSIX_DEVIO #include "libc.h" #endif /* RT_USING_POSIX_DEVIO */ - -#define DBG_TAG "dlib.syscall_read" +#include +#define DBG_TAG "dlib.syscall.read" #define DBG_LVL DBG_INFO #include @@ -42,11 +42,12 @@ size_t __read(int handle, unsigned char *buf, size_t len) #ifdef RT_USING_POSIX_DEVIO if (libc_stdio_get_console() < 0) { - LOG_W("Do not invoke standard input before initializing libc"); + LOG_W("Do not invoke standard input before initializing compiler-libc"); return 0; /* error, but keep going */ } return read(STDIN_FILENO, buf, len); /* return the length of the data read */ #else + LOG_W(warning_without_devio); return _LLIO_ERROR; #endif /* RT_USING_POSIX_DEVIO */ } @@ -58,6 +59,7 @@ size_t __read(int handle, unsigned char *buf, size_t len) size = read(handle, buf, len); return size; /* return the length of the data read */ #else + LOG_W(warning_without_fs); return _LLIO_ERROR; #endif /* DFS_USING_POSIX */ } diff --git a/components/libc/compilers/dlib/syscall_remove.c b/components/libc/compilers/dlib/syscall_remove.c index 870f91b8c11e7a946aee27e567ce6ea9c1dfff54..9b5d596eb5a4c3e9677547dad6491ab86758bd51 100644 --- a/components/libc/compilers/dlib/syscall_remove.c +++ b/components/libc/compilers/dlib/syscall_remove.c @@ -10,6 +10,10 @@ #include #include #include +#include +#define DBG_TAG "dlib.syscall.remove" +#define DBG_LVL DBG_INFO +#include /* * The "remove" function should remove the file named "filename". It @@ -23,6 +27,7 @@ int remove(const char *filename) #ifdef DFS_USING_POSIX return unlink(filename); #else + LOG_W(warning_without_fs); return _LLIO_ERROR; #endif /* DFS_USING_POSIX */ } diff --git a/components/libc/compilers/dlib/syscall_write.c b/components/libc/compilers/dlib/syscall_write.c index 2bc5863d8aa81ea655a80d3164f357a0b78ecad0..11a6f9cca5374d7f40e9cee1b07cf1e5bcc7021b 100644 --- a/components/libc/compilers/dlib/syscall_write.c +++ b/components/libc/compilers/dlib/syscall_write.c @@ -11,7 +11,8 @@ #include #include #include -#define DBG_TAG "dlib.syscall_write" +#include +#define DBG_TAG "dlib.syscall.write" #define DBG_LVL DBG_INFO #include @@ -63,6 +64,7 @@ size_t __write(int handle, const unsigned char *buf, size_t len) size = write(handle, buf, len); return size; /* return the length of the data written */ #else + LOG_W(warning_without_fs); return _LLIO_ERROR; #endif /* DFS_USING_POSIX */ } diff --git a/components/libc/compilers/gcc/newlib/README.md b/components/libc/compilers/gcc/newlib/README.md index 62172e6a5566673e1649acf8e64a18c1e56a7317..4614375b45d59df70a490eb282e5d4ba585fc4bf 100644 --- a/components/libc/compilers/gcc/newlib/README.md +++ b/components/libc/compilers/gcc/newlib/README.md @@ -1,10 +1,4 @@ # NEWLIB (GCC) porting for RT-Thread -Please define RT_USING_LIBC and compile RT-Thread with GCC compiler. - - - -## More Information - https://sourceware.org/newlib/libc.html#Reentrancy diff --git a/components/libc/compilers/gcc/newlib/SConscript b/components/libc/compilers/gcc/newlib/SConscript index d51bbdad84e0f7bdec47fef7a66c4dc31b84f7ec..7a2be2e781b19392aca05fcc0d58e30e344cfa6f 100644 --- a/components/libc/compilers/gcc/newlib/SConscript +++ b/components/libc/compilers/gcc/newlib/SConscript @@ -10,11 +10,8 @@ LIBS = ['m'] # link libm CPPPATH = [cwd] if rtconfig.PLATFORM == 'gcc': - if GetDepend('RT_USING_LIBC'): - LIBS += ['c'] # link libc - src += Glob('*.c') - else: - src += ['syscalls.c'] + LIBS += ['c'] # link libc + src += Glob('*.c') #report newlib version print('Newlib version:' + GetNewLibVersion(rtconfig)) @@ -22,7 +19,7 @@ if rtconfig.PLATFORM == 'gcc': # identify this is Newlib, and only enable POSIX.1-1990 CPPDEFINES = ['RT_USING_NEWLIB', '_POSIX_C_SOURCE=1'] - group = DefineGroup('libc', src, depend = [], CPPPATH = CPPPATH, CPPDEFINES = CPPDEFINES, LIBS = LIBS) + group = DefineGroup('compiler-libc', src, depend = [], CPPPATH = CPPPATH, CPPDEFINES = CPPDEFINES, LIBS = LIBS) list = os.listdir(cwd) diff --git a/components/libc/compilers/gcc/newlib/syscalls.c b/components/libc/compilers/gcc/newlib/syscalls.c index 8fe8c5be4b7c24bbe57761c3b9ae1f50169a301b..65dece0d02b0c1edf6e1204ac77907c822fa2f13 100644 --- a/components/libc/compilers/gcc/newlib/syscalls.c +++ b/components/libc/compilers/gcc/newlib/syscalls.c @@ -26,7 +26,7 @@ #ifdef RT_USING_MODULE #include #endif /* RT_USING_MODULE */ - +#include #define DBG_TAG "newlib.syscalls" #define DBG_LVL DBG_INFO #include @@ -92,8 +92,6 @@ void __libc_init_array(void) /* __libc_init_array is ARM code, not Thumb; it will cause a hardfault. */ } -#ifdef RT_USING_LIBC - /* Reentrant versions of system calls. */ #ifndef _REENT_ONLY int *__errno () @@ -112,6 +110,7 @@ int _close_r(struct _reent *ptr, int fd) #ifdef DFS_USING_POSIX return close(fd); #else + LOG_W("%s: %s", __func__, warning_without_fs); ptr->_errno = ENOTSUP; return -1; #endif /* DFS_USING_POSIX */ @@ -185,10 +184,10 @@ _off_t _lseek_r(struct _reent *ptr, int fd, _off_t pos, int whence) { #ifdef DFS_USING_POSIX _off_t rc; - rc = lseek(fd, pos, whence); return rc; #else + LOG_W("%s: %s", __func__, warning_without_fs); ptr->_errno = ENOTSUP; return -1; #endif /* DFS_USING_POSIX */ @@ -198,10 +197,10 @@ int _mkdir_r(struct _reent *ptr, const char *name, int mode) { #ifdef DFS_USING_POSIX int rc; - rc = mkdir(name, mode); return rc; #else + LOG_W("%s: %s", __func__, warning_without_fs); ptr->_errno = ENOTSUP; return -1; #endif /* DFS_USING_POSIX */ @@ -214,6 +213,7 @@ int _open_r(struct _reent *ptr, const char *file, int flags, int mode) rc = open(file, flags, mode); return rc; #else + LOG_W("%s: %s", __func__, warning_without_fs); ptr->_errno = ENOTSUP; return -1; #endif /* DFS_USING_POSIX */ @@ -228,10 +228,11 @@ _ssize_t _read_r(struct _reent *ptr, int fd, void *buf, size_t nbytes) #ifdef RT_USING_POSIX_DEVIO if (libc_stdio_get_console() < 0) { - LOG_W("Do not invoke standard input before initializing libc"); + LOG_W("Do not invoke standard input before initializing compiler-libc"); return 0; } #else + LOG_W("%s: %s", __func__, warning_without_devio); ptr->_errno = ENOTSUP; return -1; #endif /* RT_USING_POSIX_DEVIO */ @@ -245,6 +246,7 @@ _ssize_t _read_r(struct _reent *ptr, int fd, void *buf, size_t nbytes) rc = read(fd, buf, nbytes); return rc; #else + LOG_W("%s: %s", __func__, warning_without_fs); ptr->_errno = ENOTSUP; return -1; #endif /* DFS_USING_POSIX */ @@ -254,10 +256,10 @@ int _rename_r(struct _reent *ptr, const char *old, const char *new) { #ifdef DFS_USING_POSIX int rc; - rc = rename(old, new); return rc; #else + LOG_W("%s: %s", __func__, warning_without_fs); ptr->_errno = ENOTSUP; return -1; #endif /* DFS_USING_POSIX */ @@ -267,10 +269,10 @@ int _stat_r(struct _reent *ptr, const char *file, struct stat *pstat) { #ifdef DFS_USING_POSIX int rc; - rc = stat(file, pstat); return rc; #else + LOG_W("%s: %s", __func__, warning_without_fs); ptr->_errno = ENOTSUP; return -1; #endif /* DFS_USING_POSIX */ @@ -281,6 +283,7 @@ int _unlink_r(struct _reent *ptr, const char *file) #ifdef DFS_USING_POSIX return unlink(file); #else + LOG_W("%s: %s", __func__, warning_without_fs); ptr->_errno = ENOTSUP; return -1; #endif /* DFS_USING_POSIX */ @@ -315,6 +318,7 @@ _ssize_t _write_r(struct _reent *ptr, int fd, const void *buf, size_t nbytes) rc = write(fd, buf, nbytes); return rc; #else + LOG_W("%s: %s", __func__, warning_without_fs); ptr->_errno = ENOTSUP; return -1; #endif /* DFS_USING_POSIX */ @@ -333,5 +337,3 @@ These functions are implemented and replaced by the 'common/time.c' file int _gettimeofday_r(struct _reent *ptr, struct timeval *__tp, void *__tzp); _CLOCK_T_ _times_r(struct _reent *ptr, struct tms *ptms); */ - -#endif /* RT_USING_LIBC */ diff --git a/components/libc/libdl/arch/riscv.c b/components/libc/libdl/arch/riscv.c index 33cae28d1694a7196ebdb7b03574868f4c3d16bf..c7c454e16890df1406d391606d0fccdd80c09cf6 100644 --- a/components/libc/libdl/arch/riscv.c +++ b/components/libc/libdl/arch/riscv.c @@ -1,12 +1,12 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 - * + * * Change Logs: * Date Author Notes * 2021/04/23 chunyexixiaoyu first version - + */ #include "../dlmodule.h" @@ -31,7 +31,7 @@ int dlmodule_relocate(struct rt_dlmodule *module, Elf_Rel *rel, Elf_Addr sym_val Elf64_Addr *where, tmp; Elf64_Sword addend, offset; rt_uint64_t upper, lower, sign, j1, j2; - + where = (Elf64_Addr *)((rt_uint8_t *)module->mem_space + rel->r_offset - module->vstart_addr); @@ -50,7 +50,7 @@ int dlmodule_relocate(struct rt_dlmodule *module, Elf_Rel *rel, Elf_Addr sym_val case R_RISCV_JUMP_SLOT: *where = (Elf64_Addr)sym_val; RT_DEBUG_LOG(RT_DEBUG_MODULE, ("R_RISCV_JUMP_SLOT: %x -> %x\n",where, *where)); - break; + break; default: RT_DEBUG_LOG(RT_DEBUG_MODULE, ("__riscv__ELF: invalid relocate TYPE %d\n", ELF64_R_TYPE(rel->r_info))); return -1; diff --git a/components/libc/posix/Kconfig b/components/libc/posix/Kconfig index ef1389f9c3038409e78aaa1ae4290b1d51db5895..39411a1be5406280490b3d1a7b295a20c8310877 100644 --- a/components/libc/posix/Kconfig +++ b/components/libc/posix/Kconfig @@ -41,14 +41,13 @@ config RT_USING_POSIX_DELAY config RT_USING_POSIX_CLOCK bool "Enable clock/time functions, clock_gettime()/clock_settime()/clock_getres() etc" - select RT_LIBC_USING_TIME if !RT_USING_LIBC select RT_USING_POSIX_DELAY default n config RT_USING_POSIX_GETLINE bool "Enable getline()/getdelim()" - select RT_USING_LIBC - select RT_LIBC_USING_FILEIO + select RT_USING_POSIX_FS + select RT_USING_POSIX_DEVIO default n config RT_USING_PTHREADS diff --git a/components/libc/posix/io/libc.c b/components/libc/posix/io/libc.c index 0107f3a58b10c3ab7a746e5c6e963f22f0dc62e0..4bb647c16b9bd01d0eda522305751bf89b5d3034 100644 --- a/components/libc/posix/io/libc.c +++ b/components/libc/posix/io/libc.c @@ -33,8 +33,7 @@ int libc_system_init(void) } INIT_COMPONENT_EXPORT(libc_system_init); -#ifdef RT_USING_POSIX_DEVIO -#if defined(RT_USING_LIBC) && defined(RT_USING_NEWLIB) +#if defined(RT_USING_POSIX_DEVIO) && defined(RT_USING_NEWLIB) #define STDIO_DEVICE_NAME_MAX 32 static FILE* std_console = NULL; int libc_stdio_set_console(const char* device_name, int mode) @@ -135,5 +134,4 @@ int libc_stdio_set_console(const char* device_name, int mode) int libc_stdio_get_console(void) { return std_fd; } -#endif /* defined(RT_USING_LIBC) && defined(RT_USING_NEWLIB) */ -#endif /* RT_USING_POSIX_DEVIO */ +#endif /* defined(RT_USING_POSIX_DEVIO) && defined(RT_USING_NEWLIB) */ diff --git a/components/libc/posix/signal/SConscript b/components/libc/posix/signal/SConscript index 07cd98cbe02810a3159fa409b916b611ed2bc9cb..9c712fa6940d26d15f178209dd8897561c31b1ea 100644 --- a/components/libc/posix/signal/SConscript +++ b/components/libc/posix/signal/SConscript @@ -7,7 +7,7 @@ src = Glob('*.c') + Glob('*.cpp') CPPPATH = [cwd] group = DefineGroup('POSIX', src, - depend = ['RT_USING_SIGNALS', 'RT_USING_PTHREADS', 'RT_USING_LIBC'], + depend = ['RT_USING_SIGNALS', 'RT_USING_PTHREADS'], CPPPATH = CPPPATH) Return('group') diff --git a/components/lwp/Kconfig b/components/lwp/Kconfig index 82193e3b0039013718161ac6776faa3a7617b954..fde442d2352e488e213b8425ebb10bd576e46a9a 100644 --- a/components/lwp/Kconfig +++ b/components/lwp/Kconfig @@ -2,7 +2,6 @@ config RT_USING_LWP bool "Using light-weight process" select RT_USING_POSIX_FS select RT_USING_POSIX_SELECT - select RT_USING_LIBC depends on ARCH_ARM_CORTEX_M || ARCH_ARM_ARM9 || ARCH_ARM_CORTEX_A default n help diff --git a/components/net/lwip-2.1.2/src/lwipopts.h b/components/net/lwip-2.1.2/src/lwipopts.h index 95e88961d2215d20a764e24d39bea3e61874674b..ca70de012a505b7387cbdd7be8b3018b33c9bb0e 100644 --- a/components/net/lwip-2.1.2/src/lwipopts.h +++ b/components/net/lwip-2.1.2/src/lwipopts.h @@ -231,11 +231,7 @@ # define SSIZE_MAX LONG_MAX # endif -#ifdef RT_USING_LIBC #define LWIP_NO_UNISTD_H 0 -#else -#define LWIP_NO_UNISTD_H 1 -#endif /* ---------- Memory options ---------- */ #define MEMCPY(dst,src,len) rt_memcpy(dst,src,len) diff --git a/components/utilities/Kconfig b/components/utilities/Kconfig index d5d878e86f6fddfbd967fa4b4a25adb999854689..af0fe054aea3e5639456c7c5fa3f3bdcd62e3090 100644 --- a/components/utilities/Kconfig +++ b/components/utilities/Kconfig @@ -136,7 +136,6 @@ config RT_USING_ULOG menu "log format" config ULOG_OUTPUT_FLOAT bool "Enable float number support. It will using more thread stack." - select RT_USING_LIBC default n help The default formater is using rt_vsnprint and it not supported float number.