[libc] remove RT_USING_LIBC

This commit is contained in:
Meco Man 2021-12-26 09:41:24 -05:00 committed by Bernard Xiong
parent 5925abce3e
commit ed09f38012
59 changed files with 178 additions and 190 deletions

View File

@ -31,7 +31,6 @@ menu "On-chip Peripheral Drivers"
menuconfig BSP_USING_RTC menuconfig BSP_USING_RTC
bool "Enable RTC" bool "Enable RTC"
select RT_USING_RTC select RT_USING_RTC
select RT_USING_LIBC
default n default n
if BSP_USING_RTC if BSP_USING_RTC
choice choice

View File

@ -37,7 +37,6 @@ menu "On-chip Peripheral Drivers"
menuconfig BSP_USING_RTC menuconfig BSP_USING_RTC
bool "Enable RTC" bool "Enable RTC"
select RT_USING_RTC select RT_USING_RTC
select RT_USING_LIBC
default n default n
if BSP_USING_RTC if BSP_USING_RTC
choice choice

View File

@ -204,7 +204,6 @@ menu "On-chip Peripheral Drivers"
menuconfig BSP_USING_ONCHIP_RTC menuconfig BSP_USING_ONCHIP_RTC
bool "Enable RTC" bool "Enable RTC"
select RT_USING_RTC select RT_USING_RTC
select RT_USING_LIBC
default n default n
if BSP_USING_ONCHIP_RTC if BSP_USING_ONCHIP_RTC
config RTC_USING_INTERNAL_CLK config RTC_USING_INTERNAL_CLK

View File

@ -918,7 +918,6 @@ GD32 BSP 的制作规范主要分为 3 个方面工程配置ENV 配置和
- 系统空闲线程栈大小统一设置为 256IDLE_THREAD_STACK_SIZE - 系统空闲线程栈大小统一设置为 256IDLE_THREAD_STACK_SIZE
- 开启组件自动初始化RT_USING_COMPONENTS_INIT - 开启组件自动初始化RT_USING_COMPONENTS_INIT
- 需要开启 user main 选项RT_USING_USER_MAIN - 需要开启 user main 选项RT_USING_USER_MAIN
- 默认关闭 libcRT_USING_LIBC
- FinSH 默认只使用 MSH 模式FINSH_USING_MSH_ONLY - FinSH 默认只使用 MSH 模式FINSH_USING_MSH_ONLY
#### 4.1.3 IDE 配置 #### 4.1.3 IDE 配置

View File

@ -219,7 +219,6 @@ menu "On-chip Peripheral Drivers"
menuconfig BSP_USING_RTC menuconfig BSP_USING_RTC
bool "Enable RTC" bool "Enable RTC"
select RT_USING_RTC select RT_USING_RTC
select RT_USING_LIBC
default n default n
if BSP_USING_RTC if BSP_USING_RTC

View File

@ -31,7 +31,6 @@ menu "On-chip Peripheral Drivers"
menuconfig BSP_USING_RTC menuconfig BSP_USING_RTC
bool "Enable RTC" bool "Enable RTC"
select RT_USING_RTC select RT_USING_RTC
select RT_USING_LIBC
default n default n
if BSP_USING_RTC if BSP_USING_RTC
choice choice

View File

@ -137,7 +137,6 @@ menu "On-chip Peripheral Drivers"
select RT_USING_SDIO select RT_USING_SDIO
select RT_USING_DFS select RT_USING_DFS
select RT_USING_DFS_ELMFAT select RT_USING_DFS_ELMFAT
select RT_LIBC_USING_TIME
default y default y
config BSP_USING_RTC config BSP_USING_RTC

View File

@ -84,7 +84,6 @@ menu "On-chip Peripheral Drivers"
config BSP_USING_ONCHIP_RTC config BSP_USING_ONCHIP_RTC
bool "Enable RTC" bool "Enable RTC"
select RT_USING_RTC select RT_USING_RTC
select RT_USING_LIBC
default n default n
endmenu endmenu

View File

@ -390,7 +390,6 @@ menu "On-chip Peripheral Drivers"
menuconfig BSP_USING_ONCHIP_RTC menuconfig BSP_USING_ONCHIP_RTC
bool "Enable RTC" bool "Enable RTC"
select RT_USING_RTC select RT_USING_RTC
select RT_USING_LIBC
default n default n
if BSP_USING_ONCHIP_RTC if BSP_USING_ONCHIP_RTC
config NRFX_CLOCK_ENABLED config NRFX_CLOCK_ENABLED

View File

@ -374,7 +374,6 @@ menu "On-chip Peripheral Drivers"
menuconfig BSP_USING_ONCHIP_RTC menuconfig BSP_USING_ONCHIP_RTC
bool "Enable RTC" bool "Enable RTC"
select RT_USING_RTC select RT_USING_RTC
select RT_USING_LIBC
default n default n

View File

@ -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) - 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) - Turn on automatic component initialization (Macro: RT_USING_COMPONENTS_INIT)
- Need to enable the user main option (Macro: RT_USING_USER_MAIN) - 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) - FinSH only uses MSH mode by default (Macro: FINSH_USING_MSH_ONLY)
#### 4.1.3 IDE configuration #### 4.1.3 IDE configuration

View File

@ -269,7 +269,6 @@ STM32 BSP 的制作规范主要分为 3 个方面工程配置ENV 配置和
- 系统空闲线程栈大小统一设置为 256IDLE_THREAD_STACK_SIZE - 系统空闲线程栈大小统一设置为 256IDLE_THREAD_STACK_SIZE
- 开启组件自动初始化RT_USING_COMPONENTS_INIT - 开启组件自动初始化RT_USING_COMPONENTS_INIT
- 需要开启 user main 选项RT_USING_USER_MAIN - 需要开启 user main 选项RT_USING_USER_MAIN
- 默认关闭 libcRT_USING_LIBC
- FinSH 默认只使用 MSH 模式FINSH_USING_MSH_ONLY - FinSH 默认只使用 MSH 模式FINSH_USING_MSH_ONLY
#### 4.1.3 IDE 配置 #### 4.1.3 IDE 配置

View File

@ -187,7 +187,6 @@ menu "On-chip Peripheral Drivers"
menuconfig BSP_USING_ONCHIP_RTC menuconfig BSP_USING_ONCHIP_RTC
bool "Enable RTC" bool "Enable RTC"
select RT_USING_RTC select RT_USING_RTC
select RT_USING_LIBC
default n default n
if BSP_USING_ONCHIP_RTC if BSP_USING_ONCHIP_RTC
choice choice

View File

@ -143,7 +143,6 @@ menu "On-chip Peripheral Drivers"
menuconfig BSP_USING_ONCHIP_RTC menuconfig BSP_USING_ONCHIP_RTC
bool "Enable RTC" bool "Enable RTC"
select RT_USING_RTC select RT_USING_RTC
select RT_USING_LIBC
default n default n
if BSP_USING_ONCHIP_RTC if BSP_USING_ONCHIP_RTC
choice choice

View File

@ -151,7 +151,6 @@ menu "On-chip Peripheral Drivers"
menuconfig BSP_USING_ONCHIP_RTC menuconfig BSP_USING_ONCHIP_RTC
bool "Enable RTC" bool "Enable RTC"
select RT_USING_RTC select RT_USING_RTC
select RT_USING_LIBC
default n default n
if BSP_USING_ONCHIP_RTC if BSP_USING_ONCHIP_RTC
choice choice

View File

@ -162,7 +162,6 @@ menu "On-chip Peripheral Drivers"
menuconfig BSP_USING_ONCHIP_RTC menuconfig BSP_USING_ONCHIP_RTC
bool "Enable RTC" bool "Enable RTC"
select RT_USING_RTC select RT_USING_RTC
select RT_USING_LIBC
default n default n
if BSP_USING_ONCHIP_RTC if BSP_USING_ONCHIP_RTC
choice choice

View File

@ -193,7 +193,6 @@ menu "On-chip Peripheral Drivers"
menuconfig BSP_USING_ONCHIP_RTC menuconfig BSP_USING_ONCHIP_RTC
bool "Enable RTC" bool "Enable RTC"
select RT_USING_RTC select RT_USING_RTC
select RT_USING_LIBC
default n default n
if BSP_USING_ONCHIP_RTC if BSP_USING_ONCHIP_RTC
choice choice

View File

@ -148,7 +148,6 @@ menu "Onboard Peripheral Drivers"
select RT_USING_WIFI select RT_USING_WIFI
select RT_WLAN_PROT_LWIP_PBUF_FORCE select RT_WLAN_PROT_LWIP_PBUF_FORCE
select RT_USING_LWIP select RT_USING_LWIP
select RT_USING_LIBC
select RT_USING_DFS select RT_USING_DFS
select DFS_USING_POSIX select DFS_USING_POSIX
select PKG_USING_FAL select PKG_USING_FAL

View File

@ -236,7 +236,6 @@ menu "On-chip Peripheral Drivers"
config BSP_USING_RTC config BSP_USING_RTC
bool "Enable RTC" bool "Enable RTC"
select RT_USING_RTC select RT_USING_RTC
select RT_USING_LIBC
default n default n
menuconfig BSP_USING_SPI menuconfig BSP_USING_SPI

View File

@ -236,7 +236,6 @@ menu "On-chip Peripheral Drivers"
config BSP_USING_RTC config BSP_USING_RTC
bool "Enable RTC" bool "Enable RTC"
select RT_USING_RTC select RT_USING_RTC
select RT_USING_LIBC
default n default n
menuconfig BSP_USING_SPI menuconfig BSP_USING_SPI

View File

@ -167,7 +167,6 @@ menu "On-chip Peripheral Drivers"
menuconfig BSP_USING_RTC menuconfig BSP_USING_RTC
bool "Enable RTC" bool "Enable RTC"
select RT_USING_RTC select RT_USING_RTC
select RT_USING_LIBC
default n default n
if BSP_USING_RTC if BSP_USING_RTC

View File

@ -283,7 +283,6 @@ menu "On-chip Peripheral Drivers"
menuconfig BSP_USING_ONCHIP_RTC menuconfig BSP_USING_ONCHIP_RTC
bool "Enable RTC" bool "Enable RTC"
select RT_USING_RTC select RT_USING_RTC
select RT_USING_LIBC
default n default n
if BSP_USING_ONCHIP_RTC if BSP_USING_ONCHIP_RTC
choice choice

View File

@ -9,8 +9,8 @@ if RT_USING_CPLUSPLUS
config RT_USING_CPLUSPLUS11 config RT_USING_CPLUSPLUS11
bool "Enable c++11 threading feature support" bool "Enable c++11 threading feature support"
default n default n
select RT_USING_LIBC select RT_USING_POSIX_FS
select RT_LIBC_USING_FILEIO select RT_USING_POSIX_DEVIO
select RT_USING_PTHREADS select RT_USING_PTHREADS
select RT_USING_RTC select RT_USING_RTC

View File

@ -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. 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. 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 About GNU GCC compiler
please add following string in your ld link script: please add following string in your ld link script:

View File

@ -95,8 +95,8 @@ extern "C" unsigned __ARM_TPL_thread_hw_concurrency()
extern "C" int __ARM_TPL_tls_create(__ARM_TPL_tls_key *__key, extern "C" int __ARM_TPL_tls_create(__ARM_TPL_tls_key *__key,
void (*__at_exit)(void *)) void (*__at_exit)(void *))
{ {
pthread_key_t key; pthread_key_t key;
if (pthread_key_create(&key, __at_exit) == 0) if (pthread_key_create(&key, __at_exit) == 0)
{ {
*__key = key; *__key = key;

View File

@ -4,7 +4,7 @@
#error "C++ version lower than C++11" #error "C++ version lower than C++11"
#endif #endif
//#if defined(RT_USING_LIBC) && defined(RT_USING_PTHREADS) //#if defined(RT_USING_PTHREADS)
#include <pthread.h> #include <pthread.h>
@ -509,4 +509,4 @@ namespace std
} }
} }
//#endif // (RT_USING_LIBC) && (RT_USING_PTHREADS) //#endif //(RT_USING_PTHREADS)

View File

@ -34,7 +34,7 @@ namespace std
get_once_functor_lock_ptr() = m_ptr; get_once_functor_lock_ptr() = m_ptr;
} }
extern "C" extern "C"
{ {
void once_proxy() void once_proxy()
{ {
@ -42,7 +42,7 @@ namespace std
function<void()> once_call = std::move(once_functor); function<void()> once_call = std::move(once_functor);
// no need to hold the lock anymore // no need to hold the lock anymore
unique_lock<mutex>* lock_ptr = get_once_functor_lock_ptr(); unique_lock<mutex>* lock_ptr = get_once_functor_lock_ptr();
get_once_functor_lock_ptr() = nullptr; get_once_functor_lock_ptr() = nullptr;
lock_ptr->unlock(); lock_ptr->unlock();

View File

@ -4,7 +4,7 @@
#error "C++ version lower than C++11" #error "C++ version lower than C++11"
#endif #endif
//#if defined(RT_USING_LIBC) && defined(RT_USING_PTHREADS) //#if defined(RT_USING_PTHREADS)
#include <unistd.h> #include <unistd.h>
#include <pthread.h> #include <pthread.h>

View File

@ -35,17 +35,17 @@ namespace std
{ {
auto raw_ptr = b.get(); auto raw_ptr = b.get();
// transfer the ownership of the invoker to the new thread // 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, int err = pthread_create(&_m_thr.__cpp_thread_t, NULL,
&execute_native_thread_routine, raw_ptr); &execute_native_thread_routine, raw_ptr);
if (err) if (err)
{ {
raw_ptr->this_ptr.reset(); raw_ptr->this_ptr.reset();
throw_system_error(err, "Failed to create a thread"); throw_system_error(err, "Failed to create a thread");
} }
} }
thread::~thread() thread::~thread()
{ {
@ -59,12 +59,12 @@ namespace std
if (joinable()) if (joinable())
err = pthread_join(native_handle(), NULL); err = pthread_join(native_handle(), NULL);
if (err) if (err)
{ {
throw_system_error(err, "thread::join failed"); throw_system_error(err, "thread::join failed");
} }
_m_thr = id(); _m_thr = id();
} }
@ -78,14 +78,14 @@ namespace std
{ {
throw_system_error(err, "thread::detach failed"); throw_system_error(err, "thread::detach failed");
} }
_m_thr = id(); _m_thr = id();
} }
// TODO: not yet actually implemented. // TODO: not yet actually implemented.
// The standard states that the returned value should only be considered a hint. // 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; int __n = _RT_NPROCS;
if (__n < 0) if (__n < 0)
__n = 0; __n = 0;

View File

@ -945,7 +945,6 @@ DWORD get_fattime(void)
{ {
DWORD fat_time = 0; DWORD fat_time = 0;
#if defined(RT_LIBC_USING_TIME) || defined(RT_USING_LIBC)
time_t now; time_t now;
struct tm *p_tm; struct tm *p_tm;
struct tm tm_now; struct tm tm_now;
@ -968,7 +967,6 @@ DWORD get_fattime(void)
(DWORD)tm_now.tm_hour << 11 | (DWORD)tm_now.tm_hour << 11 |
(DWORD)tm_now.tm_min << 5 | (DWORD)tm_now.tm_min << 5 |
(DWORD)tm_now.tm_sec / 2 ; (DWORD)tm_now.tm_sec / 2 ;
#endif /* defined(RT_LIBC_USING_TIME) || defined(RT_USING_LIBC) */
return fat_time; return fat_time;
} }

View File

@ -1,38 +1,16 @@
menu "POSIX layer and C standard library" menu "POSIX layer and C standard library"
config RT_USING_LIBC config RT_USING_MODULE
bool "Enable libc APIs from the toolchain" bool "Enable dynamic module with dlopen/dlsym/dlclose feature"
default n default n
if RT_USING_LIBC if RT_USING_MODULE
config RT_LIBC_USING_TIME config RT_USING_CUSTOM_DLMODULE
default y bool "Enable load dynamic module by custom"
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 default n
config RT_USING_MODULE
bool "Enable dynamic module with dlopen/dlsym/dlclose feature"
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 endif
config RT_LIBC_DEFAULT_TIMEZONE config RT_LIBC_DEFAULT_TIMEZONE
depends on (RT_LIBC_USING_TIME || RT_USING_LIBC)
int "Set the default time zone (UTC+)" int "Set the default time zone (UTC+)"
range -12 12 range -12 12
default 8 default 8

View File

@ -1,9 +1,3 @@
# ARMLIB (Keil-MDK) porting for RT-Thread # 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/ https://www.keil.com/support/man/docs/armlib/

View File

@ -7,6 +7,6 @@ group = []
CPPDEFINES = ['RT_USING_ARM_LIBC'] CPPDEFINES = ['RT_USING_ARM_LIBC']
if rtconfig.PLATFORM == 'armcc' or rtconfig.PLATFORM == 'armclang': 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') Return('group')

View File

@ -13,7 +13,7 @@
#include <stddef.h> #include <stddef.h>
#ifndef RT_USING_HEAP #ifndef RT_USING_HEAP
#define DBG_TAG "armlibc.mem" #define DBG_TAG "armlibc.syscall.mem"
#define DBG_LVL DBG_INFO #define DBG_LVL DBG_INFO
#include <rtdbg.h> #include <rtdbg.h>

View File

@ -21,6 +21,7 @@
#include <fcntl.h> #include <fcntl.h>
#include <unistd.h> #include <unistd.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <compiler_private.h>
#ifdef RT_USING_POSIX_DEVIO #ifdef RT_USING_POSIX_DEVIO
#include "libc.h" #include "libc.h"
#endif /* RT_USING_POSIX_DEVIO */ #endif /* RT_USING_POSIX_DEVIO */
@ -69,6 +70,7 @@ FILEHANDLE _sys_open(const char *name, int openmode)
return (STDERR); return (STDERR);
#ifndef DFS_USING_POSIX #ifndef DFS_USING_POSIX
LOG_W("%s: %s", __func__, warning_without_fs);
return 0; /* error */ return 0; /* error */
#else #else
/* Correct openmode from fopen to open */ /* Correct openmode from fopen to open */
@ -113,6 +115,7 @@ int _sys_close(FILEHANDLE fh)
return close(fh); return close(fh);
#else #else
LOG_W("%s: %s", __func__, warning_without_fs);
return 0; return 0;
#endif /* DFS_USING_POSIX */ #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 #ifdef RT_USING_POSIX_DEVIO
if (libc_stdio_get_console() < 0) 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 */ return 0; /* error, but keep going */
} }
size = read(STDIN_FILENO, buf, len); size = read(STDIN_FILENO, buf, len);
return len - size; /* success */ return len - size; /* success */
#else #else
LOG_W("%s: %s", __func__, warning_without_devio);
return 0; /* error */ return 0; /* error */
#endif /* RT_USING_POSIX_DEVIO */ #endif /* RT_USING_POSIX_DEVIO */
} }
@ -178,6 +182,7 @@ int _sys_read(FILEHANDLE fh, unsigned char *buf, unsigned len, int mode)
} }
} }
#else #else
LOG_W("%s: %s", __func__, warning_without_fs);
return 0; /* error */ return 0; /* error */
#endif /* DFS_USING_POSIX */ #endif /* DFS_USING_POSIX */
} }
@ -228,6 +233,7 @@ int _sys_write(FILEHANDLE fh, const unsigned char *buf, unsigned len, int mode)
return 0; /* error */ return 0; /* error */
} }
#else #else
LOG_W("%s: %s", __func__, warning_without_fs);
return 0; /* error */ return 0; /* error */
#endif /* DFS_USING_POSIX */ #endif /* DFS_USING_POSIX */
} }
@ -246,6 +252,7 @@ int _sys_seek(FILEHANDLE fh, long pos)
/* position is relative to the start of file fh */ /* position is relative to the start of file fh */
return lseek(fh, pos, 0); return lseek(fh, pos, 0);
#else #else
LOG_W("%s: %s", __func__, warning_without_fs);
return 0; /* error */ return 0; /* error */
#endif /* DFS_USING_POSIX */ #endif /* DFS_USING_POSIX */
} }
@ -301,6 +308,7 @@ long _sys_flen(FILEHANDLE fh)
fstat(fh, &stat); fstat(fh, &stat);
return stat.st_size; return stat.st_size;
#else #else
LOG_W("%s: %s", __func__, warning_without_fs);
return 0; return 0;
#endif /* DFS_USING_POSIX */ #endif /* DFS_USING_POSIX */
} }
@ -318,6 +326,7 @@ int remove(const char *filename)
#ifdef DFS_USING_POSIX #ifdef DFS_USING_POSIX
return unlink(filename); return unlink(filename);
#else #else
LOG_W("%s: %s", __func__, warning_without_fs);
return 0; /* error */ return 0; /* error */
#endif /* DFS_USING_POSIX */ #endif /* DFS_USING_POSIX */
} }
@ -345,13 +354,14 @@ int fgetc(FILE *f)
if (libc_stdio_get_console() < 0) 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; return 0;
} }
if(read(STDIN_FILENO, &ch, 1) == 1) if(read(STDIN_FILENO, &ch, 1) == 1)
return ch; return ch;
#endif /* RT_USING_POSIX_DEVIO */ #endif /* RT_USING_POSIX_DEVIO */
LOG_W("%s: %s", __func__, warning_without_devio);
return 0; /* error */ return 0; /* error */
} }

View File

@ -10,12 +10,9 @@ CPPDEFINES = []
if rtconfig.CROSS_TOOL == 'keil': if rtconfig.CROSS_TOOL == 'keil':
CPPDEFINES += ['__CLK_TCK=RT_TICK_PER_SECOND'] CPPDEFINES += ['__CLK_TCK=RT_TICK_PER_SECOND']
if GetDepend('RT_USING_LIBC'): src += Glob('*.c')
src += Glob('*.c')
elif GetDepend('RT_LIBC_USING_TIME'):
src += ['time.c']
group = DefineGroup('libc', src, depend = [], CPPPATH = CPPPATH, CPPDEFINES = CPPDEFINES) group = DefineGroup('compiler-libc', src, depend = [], CPPPATH = CPPPATH, CPPDEFINES = CPPDEFINES)
list = os.listdir(cwd) list = os.listdir(cwd)
for item in list: for item in list:

View File

@ -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";

View File

@ -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 <rtconfig.h>
extern const char *warning_without_fs;
extern const char *warning_without_devio;
#endif /* __COMPILER_PRIVATE_H__ */

View File

@ -7,9 +7,8 @@ cwd = GetCurrentDir()
CPPPATH = [cwd] CPPPATH = [cwd]
group = [] group = []
if GetDepend('RT_USING_LIBC'): src += Glob('*.c')
src += Glob('*.c')
if rtconfig.PLATFORM != 'gcc' or rtconfig.ARCH == 'sim': 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') Return('group')

View File

@ -25,7 +25,7 @@
#include <sys/errno.h> #include <sys/errno.h>
#include <rtthread.h> #include <rtthread.h>
#include <rthw.h> #include <rthw.h>
#ifdef RT_USING_DEVICE #ifdef RT_USING_RTC
#include <rtdevice.h> #include <rtdevice.h>
#endif #endif
@ -33,6 +33,8 @@
#define DBG_LVL DBG_INFO #define DBG_LVL DBG_INFO
#include <rtdbg.h> #include <rtdbg.h>
#define WARNING_NO_RTC "Cannot find a RTC device!"
/* seconds per day */ /* seconds per day */
#define SPD 24*60*60 #define SPD 24*60*60
@ -108,7 +110,7 @@ static rt_err_t get_timeval(struct timeval *tv)
else else
{ {
/* LOG_W will cause a recursive printing if ulog timestamp function is enabled */ /* 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; return -RT_ENOSYS;
} }
@ -116,7 +118,7 @@ static rt_err_t get_timeval(struct timeval *tv)
#else #else
/* LOG_W will cause a recursive printing if ulog timestamp function is enabled */ /* 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; return -RT_ENOSYS;
#endif /* RT_USING_RTC */ #endif /* RT_USING_RTC */
} }
@ -153,14 +155,14 @@ static int set_timeval(struct timeval *tv)
} }
else else
{ {
LOG_W("Cannot find a RTC device to provide time!"); LOG_W(WARNING_NO_RTC);
return -RT_ENOSYS; return -RT_ENOSYS;
} }
return rst; return rst;
#else #else
LOG_W("Cannot find a RTC device to provide time!"); LOG_W(WARNING_NO_RTC);
return -RT_ENOSYS; return -RT_ENOSYS;
#endif /* RT_USING_RTC */ #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) int clock_getres(clockid_t clockid, struct timespec *res)
{ {
#ifndef RT_USING_RTC #ifndef RT_USING_RTC
LOG_W("Cannot find a RTC device to save time!"); LOG_W(WARNING_NO_RTC);
return -1; return -1;
#else #else
int ret = 0; int ret = 0;
@ -564,7 +566,7 @@ RTM_EXPORT(clock_getres);
int clock_gettime(clockid_t clockid, struct timespec *tp) int clock_gettime(clockid_t clockid, struct timespec *tp)
{ {
#ifndef RT_USING_RTC #ifndef RT_USING_RTC
LOG_W("Cannot find a RTC device to save time!"); LOG_W(WARNING_NO_RTC);
return -1; return -1;
#else #else
int ret = 0; 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) int clock_settime(clockid_t clockid, const struct timespec *tp)
{ {
#ifndef RT_USING_RTC #ifndef RT_USING_RTC
LOG_W("Cannot find a RTC device to save time!"); LOG_W(WARNING_NO_RTC);
return -1; return -1;
#else #else
register rt_base_t level; register rt_base_t level;

View File

@ -1,9 +1,3 @@
# DLIB (IAR) porting for RT-Thread # 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 http://www.iarsys.co.jp/download/LMS2/arm/7502/ewarm7502doc/arm/doc/EWARM_DevelopmentGuide.ENU.pdf P.130

View File

@ -15,6 +15,6 @@ if rtconfig.PLATFORM == 'iar':
if LooseVersion(IARVersion()) < LooseVersion("8.20.1"): if LooseVersion(IARVersion()) < LooseVersion("8.20.1"):
CPPDEFINES = CPPDEFINES + ['_DLIB_THREAD_SUPPORT'] 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') Return('group')

View File

@ -10,6 +10,10 @@
#include <rtthread.h> #include <rtthread.h>
#include <LowLevelIOInterface.h> #include <LowLevelIOInterface.h>
#include <unistd.h> #include <unistd.h>
#include <compiler_private.h>
#define DBG_TAG "dlib.syscall.close"
#define DBG_LVL DBG_INFO
#include <rtdbg.h>
/* /*
* The "__close" function should close the file corresponding to * The "__close" function should close the file corresponding to
@ -27,6 +31,7 @@ int __close(int handle)
#ifdef DFS_USING_POSIX #ifdef DFS_USING_POSIX
return close(handle); return close(handle);
#else #else
LOG_W(warning_without_fs);
return _LLIO_ERROR; return _LLIO_ERROR;
#endif /* DFS_USING_POSIX */ #endif /* DFS_USING_POSIX */
} }

View File

@ -10,6 +10,10 @@
#include <rtthread.h> #include <rtthread.h>
#include <LowLevelIOInterface.h> #include <LowLevelIOInterface.h>
#include <unistd.h> #include <unistd.h>
#include <compiler_private.h>
#define DBG_TAG "dlib.syscall.lseek"
#define DBG_LVL DBG_INFO
#include <rtdbg.h>
/* /*
* The "__lseek" function makes the next file operation (__read or * 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 #ifdef DFS_USING_POSIX
return lseek(handle, offset, whence); return lseek(handle, offset, whence);
#else #else
LOG_W(warning_without_fs);
return _LLIO_ERROR; return _LLIO_ERROR;
#endif /* DFS_USING_POSIX */ #endif /* DFS_USING_POSIX */
} }

View File

@ -12,7 +12,7 @@
#include <stddef.h> #include <stddef.h>
#ifndef RT_USING_HEAP #ifndef RT_USING_HEAP
#define DBG_TAG "dlib.syscall_mem" #define DBG_TAG "dlib.syscall.mem"
#define DBG_LVL DBG_INFO #define DBG_LVL DBG_INFO
#include <rtdbg.h> #include <rtdbg.h>
#define _NO_HEAP_ERROR() do{LOG_E("Please enable RT_USING_HEAP");\ #define _NO_HEAP_ERROR() do{LOG_E("Please enable RT_USING_HEAP");\

View File

@ -11,6 +11,10 @@
#include <rtthread.h> #include <rtthread.h>
#include <LowLevelIOInterface.h> #include <LowLevelIOInterface.h>
#include <fcntl.h> #include <fcntl.h>
#include <compiler_private.h>
#define DBG_TAG "dlib.syscall.open"
#define DBG_LVL DBG_INFO
#include <rtdbg.h>
/* /*
* The "__open" function opens the file named "filename" as specified * The "__open" function opens the file named "filename" as specified
@ -22,56 +26,58 @@
int __open(const char *filename, int mode) int __open(const char *filename, int mode)
{ {
#ifdef DFS_USING_POSIX #ifdef DFS_USING_POSIX
int handle; int handle;
int open_mode = O_RDONLY; int open_mode = O_RDONLY;
if (mode & _LLIO_CREAT) if (mode & _LLIO_CREAT)
{
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_CREAT;
open_mode |= O_APPEND;
/* 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. */ /* we didn't support text mode */
open_mode |= O_TRUNC;
} }
}
if (mode & _LLIO_TEXT) switch (mode & _LLIO_RDWRMASK)
{ {
/* we didn't support text mode */ case _LLIO_RDONLY:
} break;
switch (mode & _LLIO_RDWRMASK) case _LLIO_WRONLY:
{ open_mode |= O_WRONLY;
case _LLIO_RDONLY: break;
break;
case _LLIO_WRONLY: case _LLIO_RDWR:
open_mode |= O_WRONLY; /* The file should be opened for both reads and writes. */
break; open_mode |= O_RDWR;
break;
case _LLIO_RDWR: default:
/* The file should be opened for both reads and writes. */ return _LLIO_ERROR;
open_mode |= O_RDWR; }
break;
default: handle = open(filename, open_mode, 0);
return _LLIO_ERROR; if (handle < 0)
} {
return _LLIO_ERROR;
handle = open(filename, open_mode, 0); }
if (handle < 0) return handle;
return _LLIO_ERROR;
return handle;
#else #else
return _LLIO_ERROR; LOG_W(warning_without_fs);
return _LLIO_ERROR;
#endif /* DFS_USING_POSIX */ #endif /* DFS_USING_POSIX */
} }

View File

@ -14,8 +14,8 @@
#ifdef RT_USING_POSIX_DEVIO #ifdef RT_USING_POSIX_DEVIO
#include "libc.h" #include "libc.h"
#endif /* RT_USING_POSIX_DEVIO */ #endif /* RT_USING_POSIX_DEVIO */
#include <compiler_private.h>
#define DBG_TAG "dlib.syscall_read" #define DBG_TAG "dlib.syscall.read"
#define DBG_LVL DBG_INFO #define DBG_LVL DBG_INFO
#include <rtdbg.h> #include <rtdbg.h>
@ -42,11 +42,12 @@ size_t __read(int handle, unsigned char *buf, size_t len)
#ifdef RT_USING_POSIX_DEVIO #ifdef RT_USING_POSIX_DEVIO
if (libc_stdio_get_console() < 0) 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 0; /* error, but keep going */
} }
return read(STDIN_FILENO, buf, len); /* return the length of the data read */ return read(STDIN_FILENO, buf, len); /* return the length of the data read */
#else #else
LOG_W(warning_without_devio);
return _LLIO_ERROR; return _LLIO_ERROR;
#endif /* RT_USING_POSIX_DEVIO */ #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); size = read(handle, buf, len);
return size; /* return the length of the data read */ return size; /* return the length of the data read */
#else #else
LOG_W(warning_without_fs);
return _LLIO_ERROR; return _LLIO_ERROR;
#endif /* DFS_USING_POSIX */ #endif /* DFS_USING_POSIX */
} }

View File

@ -10,6 +10,10 @@
#include <rtthread.h> #include <rtthread.h>
#include <LowLevelIOInterface.h> #include <LowLevelIOInterface.h>
#include <unistd.h> #include <unistd.h>
#include <compiler_private.h>
#define DBG_TAG "dlib.syscall.remove"
#define DBG_LVL DBG_INFO
#include <rtdbg.h>
/* /*
* The "remove" function should remove the file named "filename". It * The "remove" function should remove the file named "filename". It
@ -23,6 +27,7 @@ int remove(const char *filename)
#ifdef DFS_USING_POSIX #ifdef DFS_USING_POSIX
return unlink(filename); return unlink(filename);
#else #else
LOG_W(warning_without_fs);
return _LLIO_ERROR; return _LLIO_ERROR;
#endif /* DFS_USING_POSIX */ #endif /* DFS_USING_POSIX */
} }

View File

@ -11,7 +11,8 @@
#include <rtthread.h> #include <rtthread.h>
#include <LowLevelIOInterface.h> #include <LowLevelIOInterface.h>
#include <unistd.h> #include <unistd.h>
#define DBG_TAG "dlib.syscall_write" #include <compiler_private.h>
#define DBG_TAG "dlib.syscall.write"
#define DBG_LVL DBG_INFO #define DBG_LVL DBG_INFO
#include <rtdbg.h> #include <rtdbg.h>
@ -63,6 +64,7 @@ size_t __write(int handle, const unsigned char *buf, size_t len)
size = write(handle, buf, len); size = write(handle, buf, len);
return size; /* return the length of the data written */ return size; /* return the length of the data written */
#else #else
LOG_W(warning_without_fs);
return _LLIO_ERROR; return _LLIO_ERROR;
#endif /* DFS_USING_POSIX */ #endif /* DFS_USING_POSIX */
} }

View File

@ -1,10 +1,4 @@
# NEWLIB (GCC) porting for RT-Thread # 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 https://sourceware.org/newlib/libc.html#Reentrancy

View File

@ -10,11 +10,8 @@ LIBS = ['m'] # link libm
CPPPATH = [cwd] CPPPATH = [cwd]
if rtconfig.PLATFORM == 'gcc': if rtconfig.PLATFORM == 'gcc':
if GetDepend('RT_USING_LIBC'): LIBS += ['c'] # link libc
LIBS += ['c'] # link libc src += Glob('*.c')
src += Glob('*.c')
else:
src += ['syscalls.c']
#report newlib version #report newlib version
print('Newlib version:' + GetNewLibVersion(rtconfig)) print('Newlib version:' + GetNewLibVersion(rtconfig))
@ -22,7 +19,7 @@ if rtconfig.PLATFORM == 'gcc':
# identify this is Newlib, and only enable POSIX.1-1990 # identify this is Newlib, and only enable POSIX.1-1990
CPPDEFINES = ['RT_USING_NEWLIB', '_POSIX_C_SOURCE=1'] 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) list = os.listdir(cwd)

View File

@ -26,7 +26,7 @@
#ifdef RT_USING_MODULE #ifdef RT_USING_MODULE
#include <dlmodule.h> #include <dlmodule.h>
#endif /* RT_USING_MODULE */ #endif /* RT_USING_MODULE */
#include <compiler_private.h>
#define DBG_TAG "newlib.syscalls" #define DBG_TAG "newlib.syscalls"
#define DBG_LVL DBG_INFO #define DBG_LVL DBG_INFO
#include <rtdbg.h> #include <rtdbg.h>
@ -92,8 +92,6 @@ void __libc_init_array(void)
/* __libc_init_array is ARM code, not Thumb; it will cause a hardfault. */ /* __libc_init_array is ARM code, not Thumb; it will cause a hardfault. */
} }
#ifdef RT_USING_LIBC
/* Reentrant versions of system calls. */ /* Reentrant versions of system calls. */
#ifndef _REENT_ONLY #ifndef _REENT_ONLY
int *__errno () int *__errno ()
@ -112,6 +110,7 @@ int _close_r(struct _reent *ptr, int fd)
#ifdef DFS_USING_POSIX #ifdef DFS_USING_POSIX
return close(fd); return close(fd);
#else #else
LOG_W("%s: %s", __func__, warning_without_fs);
ptr->_errno = ENOTSUP; ptr->_errno = ENOTSUP;
return -1; return -1;
#endif /* DFS_USING_POSIX */ #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 #ifdef DFS_USING_POSIX
_off_t rc; _off_t rc;
rc = lseek(fd, pos, whence); rc = lseek(fd, pos, whence);
return rc; return rc;
#else #else
LOG_W("%s: %s", __func__, warning_without_fs);
ptr->_errno = ENOTSUP; ptr->_errno = ENOTSUP;
return -1; return -1;
#endif /* DFS_USING_POSIX */ #endif /* DFS_USING_POSIX */
@ -198,10 +197,10 @@ int _mkdir_r(struct _reent *ptr, const char *name, int mode)
{ {
#ifdef DFS_USING_POSIX #ifdef DFS_USING_POSIX
int rc; int rc;
rc = mkdir(name, mode); rc = mkdir(name, mode);
return rc; return rc;
#else #else
LOG_W("%s: %s", __func__, warning_without_fs);
ptr->_errno = ENOTSUP; ptr->_errno = ENOTSUP;
return -1; return -1;
#endif /* DFS_USING_POSIX */ #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); rc = open(file, flags, mode);
return rc; return rc;
#else #else
LOG_W("%s: %s", __func__, warning_without_fs);
ptr->_errno = ENOTSUP; ptr->_errno = ENOTSUP;
return -1; return -1;
#endif /* DFS_USING_POSIX */ #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 #ifdef RT_USING_POSIX_DEVIO
if (libc_stdio_get_console() < 0) 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; return 0;
} }
#else #else
LOG_W("%s: %s", __func__, warning_without_devio);
ptr->_errno = ENOTSUP; ptr->_errno = ENOTSUP;
return -1; return -1;
#endif /* RT_USING_POSIX_DEVIO */ #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); rc = read(fd, buf, nbytes);
return rc; return rc;
#else #else
LOG_W("%s: %s", __func__, warning_without_fs);
ptr->_errno = ENOTSUP; ptr->_errno = ENOTSUP;
return -1; return -1;
#endif /* DFS_USING_POSIX */ #endif /* DFS_USING_POSIX */
@ -254,10 +256,10 @@ int _rename_r(struct _reent *ptr, const char *old, const char *new)
{ {
#ifdef DFS_USING_POSIX #ifdef DFS_USING_POSIX
int rc; int rc;
rc = rename(old, new); rc = rename(old, new);
return rc; return rc;
#else #else
LOG_W("%s: %s", __func__, warning_without_fs);
ptr->_errno = ENOTSUP; ptr->_errno = ENOTSUP;
return -1; return -1;
#endif /* DFS_USING_POSIX */ #endif /* DFS_USING_POSIX */
@ -267,10 +269,10 @@ int _stat_r(struct _reent *ptr, const char *file, struct stat *pstat)
{ {
#ifdef DFS_USING_POSIX #ifdef DFS_USING_POSIX
int rc; int rc;
rc = stat(file, pstat); rc = stat(file, pstat);
return rc; return rc;
#else #else
LOG_W("%s: %s", __func__, warning_without_fs);
ptr->_errno = ENOTSUP; ptr->_errno = ENOTSUP;
return -1; return -1;
#endif /* DFS_USING_POSIX */ #endif /* DFS_USING_POSIX */
@ -281,6 +283,7 @@ int _unlink_r(struct _reent *ptr, const char *file)
#ifdef DFS_USING_POSIX #ifdef DFS_USING_POSIX
return unlink(file); return unlink(file);
#else #else
LOG_W("%s: %s", __func__, warning_without_fs);
ptr->_errno = ENOTSUP; ptr->_errno = ENOTSUP;
return -1; return -1;
#endif /* DFS_USING_POSIX */ #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); rc = write(fd, buf, nbytes);
return rc; return rc;
#else #else
LOG_W("%s: %s", __func__, warning_without_fs);
ptr->_errno = ENOTSUP; ptr->_errno = ENOTSUP;
return -1; return -1;
#endif /* DFS_USING_POSIX */ #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); int _gettimeofday_r(struct _reent *ptr, struct timeval *__tp, void *__tzp);
_CLOCK_T_ _times_r(struct _reent *ptr, struct tms *ptms); _CLOCK_T_ _times_r(struct _reent *ptr, struct tms *ptms);
*/ */
#endif /* RT_USING_LIBC */

View File

@ -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 * SPDX-License-Identifier: Apache-2.0
* *
* Change Logs: * Change Logs:
* Date Author Notes * Date Author Notes
* 2021/04/23 chunyexixiaoyu first version * 2021/04/23 chunyexixiaoyu first version
*/ */
#include "../dlmodule.h" #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_Addr *where, tmp;
Elf64_Sword addend, offset; Elf64_Sword addend, offset;
rt_uint64_t upper, lower, sign, j1, j2; rt_uint64_t upper, lower, sign, j1, j2;
where = (Elf64_Addr *)((rt_uint8_t *)module->mem_space where = (Elf64_Addr *)((rt_uint8_t *)module->mem_space
+ rel->r_offset + rel->r_offset
- module->vstart_addr); - 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: case R_RISCV_JUMP_SLOT:
*where = (Elf64_Addr)sym_val; *where = (Elf64_Addr)sym_val;
RT_DEBUG_LOG(RT_DEBUG_MODULE, ("R_RISCV_JUMP_SLOT: %x -> %x\n",where, *where)); RT_DEBUG_LOG(RT_DEBUG_MODULE, ("R_RISCV_JUMP_SLOT: %x -> %x\n",where, *where));
break; break;
default: default:
RT_DEBUG_LOG(RT_DEBUG_MODULE, ("__riscv__ELF: invalid relocate TYPE %d\n", ELF64_R_TYPE(rel->r_info))); RT_DEBUG_LOG(RT_DEBUG_MODULE, ("__riscv__ELF: invalid relocate TYPE %d\n", ELF64_R_TYPE(rel->r_info)));
return -1; return -1;

View File

@ -41,14 +41,13 @@ config RT_USING_POSIX_DELAY
config RT_USING_POSIX_CLOCK config RT_USING_POSIX_CLOCK
bool "Enable clock/time functions, clock_gettime()/clock_settime()/clock_getres() etc" 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 select RT_USING_POSIX_DELAY
default n default n
config RT_USING_POSIX_GETLINE config RT_USING_POSIX_GETLINE
bool "Enable getline()/getdelim()" bool "Enable getline()/getdelim()"
select RT_USING_LIBC select RT_USING_POSIX_FS
select RT_LIBC_USING_FILEIO select RT_USING_POSIX_DEVIO
default n default n
config RT_USING_PTHREADS config RT_USING_PTHREADS

View File

@ -33,8 +33,7 @@ int libc_system_init(void)
} }
INIT_COMPONENT_EXPORT(libc_system_init); INIT_COMPONENT_EXPORT(libc_system_init);
#ifdef RT_USING_POSIX_DEVIO #if defined(RT_USING_POSIX_DEVIO) && defined(RT_USING_NEWLIB)
#if defined(RT_USING_LIBC) && defined(RT_USING_NEWLIB)
#define STDIO_DEVICE_NAME_MAX 32 #define STDIO_DEVICE_NAME_MAX 32
static FILE* std_console = NULL; static FILE* std_console = NULL;
int libc_stdio_set_console(const char* device_name, int mode) 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) { int libc_stdio_get_console(void) {
return std_fd; return std_fd;
} }
#endif /* defined(RT_USING_LIBC) && defined(RT_USING_NEWLIB) */ #endif /* defined(RT_USING_POSIX_DEVIO) && defined(RT_USING_NEWLIB) */
#endif /* RT_USING_POSIX_DEVIO */

View File

@ -7,7 +7,7 @@ src = Glob('*.c') + Glob('*.cpp')
CPPPATH = [cwd] CPPPATH = [cwd]
group = DefineGroup('POSIX', src, group = DefineGroup('POSIX', src,
depend = ['RT_USING_SIGNALS', 'RT_USING_PTHREADS', 'RT_USING_LIBC'], depend = ['RT_USING_SIGNALS', 'RT_USING_PTHREADS'],
CPPPATH = CPPPATH) CPPPATH = CPPPATH)
Return('group') Return('group')

View File

@ -2,7 +2,6 @@ config RT_USING_LWP
bool "Using light-weight process" bool "Using light-weight process"
select RT_USING_POSIX_FS select RT_USING_POSIX_FS
select RT_USING_POSIX_SELECT select RT_USING_POSIX_SELECT
select RT_USING_LIBC
depends on ARCH_ARM_CORTEX_M || ARCH_ARM_ARM9 || ARCH_ARM_CORTEX_A depends on ARCH_ARM_CORTEX_M || ARCH_ARM_ARM9 || ARCH_ARM_CORTEX_A
default n default n
help help

View File

@ -231,11 +231,7 @@
# define SSIZE_MAX LONG_MAX # define SSIZE_MAX LONG_MAX
# endif # endif
#ifdef RT_USING_LIBC
#define LWIP_NO_UNISTD_H 0 #define LWIP_NO_UNISTD_H 0
#else
#define LWIP_NO_UNISTD_H 1
#endif
/* ---------- Memory options ---------- */ /* ---------- Memory options ---------- */
#define MEMCPY(dst,src,len) rt_memcpy(dst,src,len) #define MEMCPY(dst,src,len) rt_memcpy(dst,src,len)

View File

@ -136,7 +136,6 @@ config RT_USING_ULOG
menu "log format" menu "log format"
config ULOG_OUTPUT_FLOAT config ULOG_OUTPUT_FLOAT
bool "Enable float number support. It will using more thread stack." bool "Enable float number support. It will using more thread stack."
select RT_USING_LIBC
default n default n
help help
The default formater is using rt_vsnprint and it not supported float number. The default formater is using rt_vsnprint and it not supported float number.