diff --git a/bsp/efm32/rtconfig.h b/bsp/efm32/rtconfig.h index 4ee9bf1a8e..040f07fa02 100644 --- a/bsp/efm32/rtconfig.h +++ b/bsp/efm32/rtconfig.h @@ -213,6 +213,7 @@ /* SECTION: Runtime library */ // #define RT_USING_NOLIBC // #define RT_USING_NEWLIB +#define RT_LIBC_USING_TIME /* SECTION: Console options */ #define RT_USING_CONSOLE diff --git a/bsp/lpc408x/.config b/bsp/lpc408x/.config index 5c079205e1..b07e256c26 100644 --- a/bsp/lpc408x/.config +++ b/bsp/lpc408x/.config @@ -7,6 +7,7 @@ # RT-Thread Kernel # CONFIG_RT_NAME_MAX=8 +# CONFIG_RT_USING_ARCH_DATA_TYPE is not set # CONFIG_RT_USING_SMP is not set CONFIG_RT_ALIGN_SIZE=4 # CONFIG_RT_THREAD_PRIORITY_8 is not set @@ -63,8 +64,9 @@ CONFIG_RT_USING_DEVICE=y CONFIG_RT_USING_CONSOLE=y CONFIG_RT_CONSOLEBUF_SIZE=128 CONFIG_RT_CONSOLE_DEVICE_NAME="uart0" -CONFIG_RT_VER_NUM=0x40001 +CONFIG_RT_VER_NUM=0x40003 CONFIG_ARCH_ARM=y +CONFIG_RT_USING_CPU_FFS=y CONFIG_ARCH_ARM_CORTEX_M=y CONFIG_ARCH_ARM_CORTEX_M4=y # CONFIG_ARCH_CPU_STACK_GROWS_UPWARD is not set @@ -138,6 +140,7 @@ CONFIG_RT_USING_DFS_DEVFS=y # CONFIG_RT_USING_DEVICE_IPC=y CONFIG_RT_PIPE_BUFSZ=512 +# CONFIG_RT_USING_SYSTEM_WORKQUEUE is not set CONFIG_RT_USING_SERIAL=y CONFIG_RT_SERIAL_USING_DMA=y CONFIG_RT_SERIAL_RB_BUFSZ=64 @@ -147,10 +150,10 @@ CONFIG_RT_SERIAL_RB_BUFSZ=64 # CONFIG_RT_USING_I2C is not set CONFIG_RT_USING_PIN=y # CONFIG_RT_USING_ADC is not set +# CONFIG_RT_USING_DAC is not set # CONFIG_RT_USING_PWM is not set # CONFIG_RT_USING_MTD_NOR is not set # CONFIG_RT_USING_MTD_NAND is not set -# CONFIG_RT_USING_MTD is not set # CONFIG_RT_USING_PM is not set # CONFIG_RT_USING_RTC is not set # CONFIG_RT_USING_SDIO is not set @@ -158,10 +161,10 @@ CONFIG_RT_USING_PIN=y # CONFIG_RT_USING_WDT is not set # CONFIG_RT_USING_AUDIO is not set # CONFIG_RT_USING_SENSOR is not set - -# -# Using WiFi -# +# CONFIG_RT_USING_TOUCH is not set +# CONFIG_RT_USING_HWCRYPTO is not set +# CONFIG_RT_USING_PULSE_ENCODER is not set +# CONFIG_RT_USING_INPUT_CAPTURE is not set # CONFIG_RT_USING_WIFI is not set # @@ -175,6 +178,7 @@ CONFIG_RT_USING_PIN=y # # CONFIG_RT_USING_LIBC is not set # CONFIG_RT_USING_PTHREADS is not set +CONFIG_RT_LIBC_USING_TIME=y # # Network @@ -185,18 +189,15 @@ CONFIG_RT_USING_PIN=y # # CONFIG_RT_USING_SAL is not set +# +# Network interface device +# +# CONFIG_RT_USING_NETDEV is not set + # # light weight TCP/IP stack # # CONFIG_RT_USING_LWIP is not set -# CONFIG_RT_USING_LWIP141 is not set -# CONFIG_RT_USING_LWIP202 is not set -# CONFIG_RT_USING_LWIP210 is not set - -# -# Modbus master and slave stack -# -# CONFIG_RT_USING_MODBUS is not set # # AT commands @@ -211,16 +212,9 @@ CONFIG_RT_USING_PIN=y # # Utilities # -# CONFIG_RT_USING_LOGTRACE is not set # CONFIG_RT_USING_RYM is not set # CONFIG_RT_USING_ULOG is not set # CONFIG_RT_USING_UTEST is not set - -# -# ARM CMSIS -# -# CONFIG_RT_USING_CMSIS_OS is not set -# CONFIG_RT_USING_RTT_CMSIS is not set # CONFIG_RT_USING_LWP is not set # @@ -230,13 +224,20 @@ CONFIG_RT_USING_PIN=y # # IoT - internet of things # +# CONFIG_PKG_USING_LORAWAN_DRIVER is not set # CONFIG_PKG_USING_PAHOMQTT is not set +# CONFIG_PKG_USING_UMQTT is not set # CONFIG_PKG_USING_WEBCLIENT is not set # CONFIG_PKG_USING_WEBNET is not set # CONFIG_PKG_USING_MONGOOSE is not set +# CONFIG_PKG_USING_MYMQTT is not set +# CONFIG_PKG_USING_KAWAII_MQTT is not set +# CONFIG_PKG_USING_BC28_MQTT is not set # CONFIG_PKG_USING_WEBTERMINAL is not set # CONFIG_PKG_USING_CJSON is not set # CONFIG_PKG_USING_JSMN is not set +# CONFIG_PKG_USING_LIBMODBUS is not set +# CONFIG_PKG_USING_FREEMODBUS is not set # CONFIG_PKG_USING_LJSON is not set # CONFIG_PKG_USING_EZXML is not set # CONFIG_PKG_USING_NANOPB is not set @@ -254,10 +255,14 @@ CONFIG_RT_USING_PIN=y # Wiced WiFi # # CONFIG_PKG_USING_WLAN_WICED is not set +# CONFIG_PKG_USING_RW007 is not set # CONFIG_PKG_USING_COAP is not set # CONFIG_PKG_USING_NOPOLL is not set # CONFIG_PKG_USING_NETUTILS is not set +# CONFIG_PKG_USING_CMUX is not set +# CONFIG_PKG_USING_PPP_DEVICE is not set # CONFIG_PKG_USING_AT_DEVICE is not set +# CONFIG_PKG_USING_ATSRV_SOCKET is not set # CONFIG_PKG_USING_WIZNET is not set # @@ -267,7 +272,29 @@ CONFIG_RT_USING_PIN=y # CONFIG_PKG_USING_GAGENT_CLOUD is not set # CONFIG_PKG_USING_ALI_IOTKIT is not set # CONFIG_PKG_USING_AZURE is not set -# CONFIG_PKG_USING_TENCENT_IOTKIT is not set +# CONFIG_PKG_USING_TENCENT_IOT_EXPLORER is not set +# CONFIG_PKG_USING_JIOT-C-SDK is not set +# CONFIG_PKG_USING_UCLOUD_IOT_SDK is not set +# CONFIG_PKG_USING_JOYLINK is not set +# CONFIG_PKG_USING_NIMBLE is not set +# CONFIG_PKG_USING_OTA_DOWNLOADER is not set +# CONFIG_PKG_USING_IPMSG is not set +# CONFIG_PKG_USING_LSSDP is not set +# CONFIG_PKG_USING_AIRKISS_OPEN is not set +# CONFIG_PKG_USING_LIBRWS is not set +# CONFIG_PKG_USING_TCPSERVER is not set +# CONFIG_PKG_USING_PROTOBUF_C is not set +# CONFIG_PKG_USING_ONNX_PARSER is not set +# CONFIG_PKG_USING_ONNX_BACKEND is not set +# CONFIG_PKG_USING_DLT645 is not set +# CONFIG_PKG_USING_QXWZ is not set +# CONFIG_PKG_USING_SMTP_CLIENT is not set +# CONFIG_PKG_USING_ABUP_FOTA is not set +# CONFIG_PKG_USING_LIBCURL2RTT is not set +# CONFIG_PKG_USING_CAPNP is not set +# CONFIG_PKG_USING_RT_CJSON_TOOLS is not set +# CONFIG_PKG_USING_AGILE_TELNET is not set +# CONFIG_PKG_USING_NMEALIB is not set # # security packages @@ -275,6 +302,8 @@ CONFIG_RT_USING_PIN=y # CONFIG_PKG_USING_MBEDTLS is not set # CONFIG_PKG_USING_libsodium is not set # CONFIG_PKG_USING_TINYCRYPT is not set +# CONFIG_PKG_USING_TFM is not set +# CONFIG_PKG_USING_YD_CRYPTO is not set # # language packages @@ -288,6 +317,9 @@ CONFIG_RT_USING_PIN=y # # CONFIG_PKG_USING_OPENMV is not set # CONFIG_PKG_USING_MUPDF is not set +# CONFIG_PKG_USING_STEMWIN is not set +# CONFIG_PKG_USING_WAVPLAYER is not set +# CONFIG_PKG_USING_TJPGD is not set # # tools packages @@ -299,6 +331,15 @@ CONFIG_RT_USING_PIN=y # CONFIG_PKG_USING_RDB is not set # CONFIG_PKG_USING_QRCODE is not set # CONFIG_PKG_USING_ULOG_EASYFLASH is not set +# CONFIG_PKG_USING_ADBD is not set +# CONFIG_PKG_USING_COREMARK is not set +# CONFIG_PKG_USING_DHRYSTONE is not set +# CONFIG_PKG_USING_NR_MICRO_SHELL is not set +# CONFIG_PKG_USING_CHINESE_FONT_LIBRARY is not set +# CONFIG_PKG_USING_LUNAR_CALENDAR is not set +# CONFIG_PKG_USING_BS8116A is not set +# CONFIG_PKG_USING_GPS_RMC is not set +# CONFIG_PKG_USING_URLENCODE is not set # # system packages @@ -310,27 +351,74 @@ CONFIG_RT_USING_PIN=y # CONFIG_PKG_USING_LWEXT4 is not set # CONFIG_PKG_USING_PARTITION is not set # CONFIG_PKG_USING_FAL is not set +# CONFIG_PKG_USING_FLASHDB is not set # CONFIG_PKG_USING_SQLITE is not set # CONFIG_PKG_USING_RTI is not set # CONFIG_PKG_USING_LITTLEVGL2RTT is not set # CONFIG_PKG_USING_CMSIS is not set # CONFIG_PKG_USING_DFS_YAFFS is not set # CONFIG_PKG_USING_LITTLEFS is not set +# CONFIG_PKG_USING_THREAD_POOL is not set +# CONFIG_PKG_USING_ROBOTS is not set +# CONFIG_PKG_USING_EV is not set +# CONFIG_PKG_USING_SYSWATCH is not set +# CONFIG_PKG_USING_SYS_LOAD_MONITOR is not set +# CONFIG_PKG_USING_PLCCORE is not set +# CONFIG_PKG_USING_RAMDISK is not set +# CONFIG_PKG_USING_MININI is not set +# CONFIG_PKG_USING_QBOOT is not set +# CONFIG_PKG_USING_UCOSIII_WRAPPER is not set # # peripheral libraries and drivers # +# CONFIG_PKG_USING_SENSORS_DRIVERS is not set # CONFIG_PKG_USING_REALTEK_AMEBA is not set # CONFIG_PKG_USING_SHT2X is not set -# CONFIG_PKG_USING_AHT10 is not set -# CONFIG_PKG_USING_AP3216C is not set +# CONFIG_PKG_USING_SHT3X is not set # CONFIG_PKG_USING_STM32_SDIO is not set # CONFIG_PKG_USING_ICM20608 is not set # CONFIG_PKG_USING_U8G2 is not set # CONFIG_PKG_USING_BUTTON is not set -# CONFIG_PKG_USING_MPU6XXX is not set # CONFIG_PKG_USING_PCF8574 is not set +# CONFIG_PKG_USING_SX12XX is not set +# CONFIG_PKG_USING_SIGNAL_LED is not set +# CONFIG_PKG_USING_LEDBLINK is not set +# CONFIG_PKG_USING_LITTLED is not set +# CONFIG_PKG_USING_LKDGUI is not set +# CONFIG_PKG_USING_NRF5X_SDK is not set +# CONFIG_PKG_USING_NRFX is not set +# CONFIG_PKG_USING_WM_LIBRARIES is not set # CONFIG_PKG_USING_KENDRYTE_SDK is not set +# CONFIG_PKG_USING_INFRARED is not set +# CONFIG_PKG_USING_ROSSERIAL is not set +# CONFIG_PKG_USING_AGILE_BUTTON is not set +# CONFIG_PKG_USING_AGILE_LED is not set +# CONFIG_PKG_USING_AT24CXX is not set +# CONFIG_PKG_USING_MOTIONDRIVER2RTT is not set +# CONFIG_PKG_USING_AD7746 is not set +# CONFIG_PKG_USING_PCA9685 is not set +# CONFIG_PKG_USING_I2C_TOOLS is not set +# CONFIG_PKG_USING_NRF24L01 is not set +# CONFIG_PKG_USING_TOUCH_DRIVERS is not set +# CONFIG_PKG_USING_MAX17048 is not set +# CONFIG_PKG_USING_RPLIDAR is not set +# CONFIG_PKG_USING_AS608 is not set +# CONFIG_PKG_USING_RC522 is not set +# CONFIG_PKG_USING_WS2812B is not set +# CONFIG_PKG_USING_EMBARC_BSP is not set +# CONFIG_PKG_USING_EXTERN_RTC_DRIVERS is not set +# CONFIG_PKG_USING_MULTI_RTIMER is not set +# CONFIG_PKG_USING_MAX7219 is not set +# CONFIG_PKG_USING_BEEP is not set +# CONFIG_PKG_USING_EASYBLINK is not set +# CONFIG_PKG_USING_PMS_SERIES is not set +# CONFIG_PKG_USING_CAN_YMODEM is not set +# CONFIG_PKG_USING_LORA_RADIO_DRIVER is not set +# CONFIG_PKG_USING_QLED is not set +# CONFIG_PKG_USING_PAJ7620 is not set +# CONFIG_PKG_USING_AGILE_CONSOLE is not set +# CONFIG_PKG_USING_LD3320 is not set # # miscellaneous packages @@ -341,11 +429,15 @@ CONFIG_RT_USING_PIN=y # CONFIG_PKG_USING_MINILZO is not set # CONFIG_PKG_USING_QUICKLZ is not set # CONFIG_PKG_USING_MULTIBUTTON is not set +# CONFIG_PKG_USING_FLEXIBLE_BUTTON is not set # CONFIG_PKG_USING_CANFESTIVAL is not set # CONFIG_PKG_USING_ZLIB is not set # CONFIG_PKG_USING_DSTR is not set # CONFIG_PKG_USING_TINYFRAME is not set # CONFIG_PKG_USING_KENDRYTE_DEMO is not set +# CONFIG_PKG_USING_DIGITALCTRL is not set +# CONFIG_PKG_USING_UPACKER is not set +# CONFIG_PKG_USING_UPARAM is not set # # samples: kernel and components samples @@ -356,6 +448,15 @@ CONFIG_RT_USING_PIN=y # CONFIG_PKG_USING_PERIPHERAL_SAMPLES is not set # CONFIG_PKG_USING_HELLO is not set # CONFIG_PKG_USING_VI is not set +# CONFIG_PKG_USING_NNOM is not set +# CONFIG_PKG_USING_LIBANN is not set +# CONFIG_PKG_USING_ELAPACK is not set +# CONFIG_PKG_USING_ARMv7M_DWT is not set +# CONFIG_PKG_USING_VT100 is not set +# CONFIG_PKG_USING_ULAPACK is not set +# CONFIG_PKG_USING_UKAL is not set +# CONFIG_PKG_USING_CRCLIB is not set +# CONFIG_PKG_USING_THREES is not set CONFIG_SOC_LPC4088=y # diff --git a/bsp/lpc408x/rtconfig.h b/bsp/lpc408x/rtconfig.h index 536e3712e7..25bba085a6 100644 --- a/bsp/lpc408x/rtconfig.h +++ b/bsp/lpc408x/rtconfig.h @@ -40,8 +40,9 @@ #define RT_USING_CONSOLE #define RT_CONSOLEBUF_SIZE 128 #define RT_CONSOLE_DEVICE_NAME "uart0" -#define RT_VER_NUM 0x40001 +#define RT_VER_NUM 0x40003 #define ARCH_ARM +#define RT_USING_CPU_FFS #define ARCH_ARM_CORTEX_M #define ARCH_ARM_CORTEX_M4 @@ -101,26 +102,24 @@ #define RT_SERIAL_RB_BUFSZ 64 #define RT_USING_PIN -/* Using WiFi */ - - /* Using USB */ /* POSIX layer and C standard library */ +#define RT_LIBC_USING_TIME /* Network */ /* Socket abstraction layer */ +/* Network interface device */ + + /* light weight TCP/IP stack */ -/* Modbus master and slave stack */ - - /* AT commands */ @@ -130,9 +129,6 @@ /* Utilities */ -/* ARM CMSIS */ - - /* RT-Thread online packages */ /* IoT - internet of things */ diff --git a/components/libc/Kconfig b/components/libc/Kconfig index 26e156522b..65c8d44225 100644 --- a/components/libc/Kconfig +++ b/components/libc/Kconfig @@ -22,11 +22,15 @@ if RT_USING_LIBC && RT_USING_DFS if RT_USING_POSIX config RT_USING_POSIX_MMAP - bool "Enable mmap() api" + bool "Enable mmap() API" default n config RT_USING_POSIX_TERMIOS - bool "Enable termios feature" + bool "Enable termios APIs" + default n + + config RT_USING_POSIX_GETLINE + bool "Enable getline()/getdelim() APIs" default n config RT_USING_POSIX_AIO diff --git a/components/libc/compilers/armlibc/sys/types.h b/components/libc/compilers/armlibc/sys/types.h index 001ace4dd2..2aad77c99d 100644 --- a/components/libc/compilers/armlibc/sys/types.h +++ b/components/libc/compilers/armlibc/sys/types.h @@ -5,16 +5,16 @@ * * Change Logs: * Date Author Notes + * 2020-09-05 Meco Man fix bugs */ #ifndef __TYPES_H__ #define __TYPES_H__ #include -#include -typedef rt_int32_t clockid_t; -typedef rt_int32_t key_t; /* Used for interprocess communication. */ -typedef rt_int32_t pid_t; /* Used for process IDs and process group IDs. */ +typedef int32_t clockid_t; +typedef int32_t key_t; /* Used for interprocess communication. */ +typedef int32_t pid_t; /* Used for process IDs and process group IDs. */ #ifndef ARCH_CPU_64BIT typedef signed int ssize_t; /* Used for a count of bytes or an error indication. */ #else diff --git a/components/libc/compilers/common/SConscript b/components/libc/compilers/common/SConscript index a8d2606820..2407301405 100644 --- a/components/libc/compilers/common/SConscript +++ b/components/libc/compilers/common/SConscript @@ -8,12 +8,15 @@ group = [] CPPPATH = [cwd] if GetDepend('RT_USING_LIBC'): - src += Glob('*.c') + src += Glob('*.c') else: - if GetDepend('RT_LIBC_USING_TIME'): + if GetDepend('RT_LIBC_USING_TIME') and not GetDepend('RT_USING_MINILIBC'): src += ['time.c'] -if (rtconfig.PLATFORM == 'armcc' or rtconfig.PLATFORM == 'iar') and rtconfig.ARCH != 'sim' : - group = DefineGroup('libc', src, depend = [''], CPPPATH = CPPPATH) +if GetDepend('RT_USING_POSIX') == False: + SrcRemove(src, ['unistd.c']) + +if not GetDepend('RT_USING_MINILIBC') and (GetDepend('RT_USING_LIBC') or GetDepend('RT_LIBC_USING_TIME')): + group = DefineGroup('libc', src, depend = [''], CPPPATH = CPPPATH) Return('group') diff --git a/components/libc/compilers/common/readme.md b/components/libc/compilers/common/readme.md new file mode 100644 index 0000000000..cb91d95f45 --- /dev/null +++ b/components/libc/compilers/common/readme.md @@ -0,0 +1 @@ +This folder is "common" for armlibc newlibc and dlib. It's not "common" for minilibc. \ No newline at end of file diff --git a/components/libc/compilers/common/sys/time.h b/components/libc/compilers/common/sys/time.h index 1d68eeafa3..22f1c17f5e 100644 --- a/components/libc/compilers/common/sys/time.h +++ b/components/libc/compilers/common/sys/time.h @@ -5,6 +5,7 @@ * * Change Logs: * Date Author Notes + * 2020-09-07 Meco Man combine gcc armcc iccarm */ #ifndef _SYS_TIME_H_ #define _SYS_TIME_H_ @@ -15,6 +16,14 @@ extern "C" { #endif +/* + * Skip define timespec for IAR version over 8.10.1 where __VER__ is 8010001. + */ +#if defined ( __ICCARM__ ) && (__VER__ >= 8010001) +#define _TIMESPEC_DEFINED +#endif + + #ifndef _TIMEVAL_DEFINED #define _TIMEVAL_DEFINED /* @@ -27,23 +36,6 @@ struct timeval { }; #endif /* _TIMEVAL_DEFINED */ -/* - * Skip define timespec for IAR version over 8.10.1 where __VER__ is 8010001. - */ -#if defined ( __ICCARM__ ) && (__VER__ >= 8010001) -#define _TIMESPEC_DEFINED -#endif - -#ifndef _TIMESPEC_DEFINED -#define _TIMESPEC_DEFINED -/* - * Structure defined by POSIX.1b to be like a timeval. - */ -struct timespec { - time_t tv_sec; /* seconds */ - long tv_nsec; /* and nanoseconds */ -}; -#endif /* _TIMESPEC_DEFINED */ struct timezone { int tz_minuteswest; /* minutes west of Greenwich */ diff --git a/components/libc/compilers/armlibc/termios.h b/components/libc/compilers/common/termios.h similarity index 87% rename from components/libc/compilers/armlibc/termios.h rename to components/libc/compilers/common/termios.h index 1956121225..ee2b4d5718 100644 --- a/components/libc/compilers/armlibc/termios.h +++ b/components/libc/compilers/common/termios.h @@ -9,7 +9,9 @@ #ifndef _TERMIOS_H__ #define _TERMIOS_H__ +#ifdef RT_USING_POSIX_TERMIOS #include #include +#endif #endif diff --git a/components/libc/compilers/common/time.c b/components/libc/compilers/common/time.c index 50a800b259..99dab71eb4 100644 --- a/components/libc/compilers/common/time.c +++ b/components/libc/compilers/common/time.c @@ -6,6 +6,7 @@ * Change Logs: * Date Author Notes * 2019-08-21 zhangjun copy from minilibc + * 2020-09-07 Meco Man combine gcc armcc iccarm */ #include diff --git a/components/libc/compilers/common/unistd.c b/components/libc/compilers/common/unistd.c index 04a0886655..4068fc5cf5 100644 --- a/components/libc/compilers/common/unistd.c +++ b/components/libc/compilers/common/unistd.c @@ -8,10 +8,11 @@ * 2020-09-01 Meco Man First Version */ -#include #include #ifdef RT_USING_POSIX_TERMIOS +#include + int isatty(int fd) { struct termios ts; diff --git a/components/libc/compilers/dlib/termios.h b/components/libc/compilers/dlib/termios.h deleted file mode 100644 index 1956121225..0000000000 --- a/components/libc/compilers/dlib/termios.h +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright (c) 2006-2018, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - */ -#ifndef _TERMIOS_H__ -#define _TERMIOS_H__ - -#include -#include - -#endif diff --git a/components/libc/compilers/minilibc/SConscript b/components/libc/compilers/minilibc/SConscript index 518d800571..dec657028f 100644 --- a/components/libc/compilers/minilibc/SConscript +++ b/components/libc/compilers/minilibc/SConscript @@ -8,7 +8,7 @@ group = [] CPPPATH = [cwd] CPPDEFINES = ['RT_USING_MINILIBC'] -if rtconfig.PLATFORM == 'gcc' and rtconfig.ARCH != 'sim' and not GetDepend('RT_USING_LIBC'): +if rtconfig.PLATFORM == 'gcc' and rtconfig.ARCH != 'sim' and not GetDepend('RT_USING_LIBC') and GetDepend('RT_USING_MINILIBC'): group = DefineGroup('libc', src, depend = [''], CPPPATH = CPPPATH, CPPDEFINES = CPPDEFINES) diff --git a/components/libc/compilers/newlib/termios.h b/components/libc/compilers/newlib/termios.h deleted file mode 100644 index 1956121225..0000000000 --- a/components/libc/compilers/newlib/termios.h +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright (c) 2006-2018, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - */ -#ifndef _TERMIOS_H__ -#define _TERMIOS_H__ - -#include -#include - -#endif diff --git a/components/libc/compilers/newlib/time.c b/components/libc/compilers/newlib/time.c deleted file mode 100644 index f099d51330..0000000000 --- a/components/libc/compilers/newlib/time.c +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2006-2018, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - */ -#include -#include - -#ifdef RT_USING_DEVICE -int gettimeofday(struct timeval *tp, void *ignore) -{ - time_t time; - rt_device_t device; - - device = rt_device_find("rtc"); - RT_ASSERT(device != RT_NULL); - - rt_device_control(device, RT_DEVICE_CTRL_RTC_GET_TIME, &time); - if (tp != RT_NULL) - { - tp->tv_sec = time; - tp->tv_usec = 0; - } - - return time; -} -#endif - -/** - * Returns the current time. - * - * @param time_t * t the timestamp pointer, if not used, keep NULL. - * - * @return time_t return timestamp current. - * - */ -/* for IAR 6.2 later Compiler */ -#if defined (__IAR_SYSTEMS_ICC__) && (__VER__) >= 6020000 -#pragma module_name = "?time" -time_t (__time32)(time_t *t) /* Only supports 32-bit timestamp */ -#else -time_t time(time_t *t) -#endif -{ - time_t time_now = 0; - -#ifdef RT_USING_RTC - static rt_device_t device = RT_NULL; - - /* optimization: find rtc device only first. */ - if (device == RT_NULL) - { - device = rt_device_find("rtc"); - } - - /* read timestamp from RTC device. */ - if (device != RT_NULL) - { - if (rt_device_open(device, 0) == RT_EOK) - { - rt_device_control(device, RT_DEVICE_CTRL_RTC_GET_TIME, &time_now); - rt_device_close(device); - } - } -#endif /* RT_USING_RTC */ - - /* if t is not NULL, write timestamp to *t */ - if (t != RT_NULL) - { - *t = time_now; - } - - return time_now; -} - -RT_WEAK clock_t clock(void) -{ - return rt_tick_get(); -} diff --git a/components/libc/getline/README.md b/components/libc/getline/README.md new file mode 100644 index 0000000000..3ba5a96b3d --- /dev/null +++ b/components/libc/getline/README.md @@ -0,0 +1,30 @@ +# getline/getdelim for RT-Thread POSIX(IEEE Std 1003.1-2008) + +[![Build Status](https://travis-ci.org/ivanrad/getline.svg?branch=master)](https://travis-ci.org/ivanrad/getline) + +https://github.com/ivanrad/getline + +Read a delimited record from stream. + +Yet another (hopefully portable C) implementation of getline/getdelim. +These are ersatz functions, a drop-in replacement, to be used on those occasions when your C library does not already support them. + +For more details, see [Open Group Base Specification for getdelim/getline][opengroup-spec]. + +## Building the project + +Just run `make`. + +## License + +This code is unlicensed -- free and released into the public domain. See `UNLICENSE` file for more information. + +[opengroup-spec]: http://pubs.opengroup.org/onlinepubs/9699919799/functions/getline.html + + +## 联系&维护 +Meco Man + +jiantingman@foxmail.com + +https://github.com/mysterywolf/getline diff --git a/components/libc/getline/SConscript b/components/libc/getline/SConscript new file mode 100644 index 0000000000..fa4c8618c1 --- /dev/null +++ b/components/libc/getline/SConscript @@ -0,0 +1,13 @@ +# RT-Thread building script for component + +from building import * + +cwd = GetCurrentDir() +src = Glob('*.c') + Glob('*.cpp') +CPPPATH = [cwd] + +group = DefineGroup('libc', src, + depend = ['RT_USING_LIBC', 'RT_USING_POSIX','RT_USING_POSIX_GETLINE'], + CPPPATH = CPPPATH) + +Return('group') diff --git a/components/libc/getline/UNLICENSE b/components/libc/getline/UNLICENSE new file mode 100644 index 0000000000..68a49daad8 --- /dev/null +++ b/components/libc/getline/UNLICENSE @@ -0,0 +1,24 @@ +This is free and unencumbered software released into the public domain. + +Anyone is free to copy, modify, publish, use, compile, sell, or +distribute this software, either in source code form or as a compiled +binary, for any purpose, commercial or non-commercial, and by any +means. + +In jurisdictions that recognize copyright laws, the author or authors +of this software dedicate any and all copyright interest in the +software to the public domain. We make this dedication for the benefit +of the public at large and to the detriment of our heirs and +successors. We intend this dedication to be an overt act of +relinquishment in perpetuity of all present and future rights to this +software under copyright law. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +For more information, please refer to diff --git a/components/libc/getline/posix_getline.c b/components/libc/getline/posix_getline.c new file mode 100644 index 0000000000..2c60ca7647 --- /dev/null +++ b/components/libc/getline/posix_getline.c @@ -0,0 +1,79 @@ +/* posix_getline.c + * RT-Thread POSIX + * getdelim(), getline() - read a delimited record from stream, ersatz implementation + * This code is unlicensed -- free and released into the public domain. + * https://man7.org/linux/man-pages/man3/getline.3.html + * Authors: + * https://github.com/ivanrad/getline + * https://github.com/mysterywolf/getline/ + * + * Meco Man 2020-09-03 First Version + */ + +#include +#include +#include +#include + +ssize_t getdelim(char **lineptr, size_t *n, int delim, FILE *stream) { + char *cur_pos, *new_lineptr; + size_t new_lineptr_len; + int c; + + if (lineptr == NULL || n == NULL || stream == NULL) { + errno = EINVAL; + return -1; + } + + if (*lineptr == NULL) { + *n = 128; /* init len */ + if ((*lineptr = (char *)malloc(*n)) == NULL) { + errno = ENOMEM; + return -1; + } + } + + cur_pos = *lineptr; + for (;;) { + c = getc(stream); + + if (ferror(stream) || (c == EOF && cur_pos == *lineptr)) + return -1; + + if (c == EOF) + break; + + if ((*lineptr + *n - cur_pos) < 2) { + if (SSIZE_MAX / 2 < *n) { +#ifdef EOVERFLOW + errno = EOVERFLOW; +#else + errno = ERANGE; /* no EOVERFLOW defined */ +#endif + return -1; + } + new_lineptr_len = *n * 2; + + if ((new_lineptr = (char *)realloc(*lineptr, new_lineptr_len)) == NULL) { + errno = ENOMEM; + return -1; + } + cur_pos = new_lineptr + (cur_pos - *lineptr); + *lineptr = new_lineptr; + *n = new_lineptr_len; + } + + *cur_pos++ = (char)c; + + if (c == delim) + break; + } + + *cur_pos = '\0'; + return (ssize_t)(cur_pos - *lineptr); +} + +ssize_t getline(char **lineptr, size_t *n, FILE *stream) { + return getdelim(lineptr, n, '\n', stream); +} + diff --git a/components/libc/getline/posix_getline.h b/components/libc/getline/posix_getline.h new file mode 100644 index 0000000000..c7d6021af3 --- /dev/null +++ b/components/libc/getline/posix_getline.h @@ -0,0 +1,24 @@ +/* posix_getline.h + * RT-Thread POSIX + * getdelim(), getline() - read a delimited record from stream, ersatz implementation + * This code is unlicensed -- free and released into the public domain. + * https://man7.org/linux/man-pages/man3/getline.3.html + * Authors: + * https://github.com/ivanrad/getline + * https://github.com/mysterywolf/getline/ + * + * Meco Man 2020-09-03 First Version + */ + + +#ifndef POSIX_GETLINE_H +#define POSIX_GETLINE_H + +#include +#include + +ssize_t getdelim(char **lineptr, size_t *n, int delim, FILE *stream); +ssize_t getline(char **lineptr, size_t *n, FILE *stream); + +#endif /* POSIX_GETLINE_H */ + diff --git a/components/net/lwip-1.4.1/src/arch/include/arch/cc.h b/components/net/lwip-1.4.1/src/arch/include/arch/cc.h index 5304091755..604477dab8 100644 --- a/components/net/lwip-1.4.1/src/arch/include/arch/cc.h +++ b/components/net/lwip-1.4.1/src/arch/include/arch/cc.h @@ -66,7 +66,7 @@ typedef uintptr_t mem_ptr_t; #endif /* __CC_ARM/__IAR_SYSTEMS_ICC__ */ #endif -#if defined(RT_USING_LIBC) || defined(RT_USING_MINILIBC) || defined(RT_LIBC_USING_TIME) +#if defined(RT_USING_LIBC) || defined(RT_USING_MINILIBC) || defined(RT_LIBC_USING_TIME) || defined ( __GNUC__) #include #define LWIP_TIMEVAL_PRIVATE 0 #else diff --git a/components/net/lwip-2.0.2/src/arch/include/arch/cc.h b/components/net/lwip-2.0.2/src/arch/include/arch/cc.h index 491cab6b5f..00536a8419 100644 --- a/components/net/lwip-2.0.2/src/arch/include/arch/cc.h +++ b/components/net/lwip-2.0.2/src/arch/include/arch/cc.h @@ -45,7 +45,7 @@ #define S32_F "ld" #define X32_F "lx" -#if defined(RT_USING_LIBC) || defined(RT_USING_MINILIBC) || defined(RT_LIBC_USING_TIME) +#if defined(RT_USING_LIBC) || defined(RT_USING_MINILIBC) || defined(RT_LIBC_USING_TIME) || defined ( __GNUC__) #include #define LWIP_TIMEVAL_PRIVATE 0 #else diff --git a/components/net/lwip-2.1.2/src/arch/include/arch/cc.h b/components/net/lwip-2.1.2/src/arch/include/arch/cc.h index c1b4cf7d29..6905ecd442 100644 --- a/components/net/lwip-2.1.2/src/arch/include/arch/cc.h +++ b/components/net/lwip-2.1.2/src/arch/include/arch/cc.h @@ -59,7 +59,7 @@ #endif /* __CC_ARM/__IAR_SYSTEMS_ICC__ */ #endif /* RT_USING_LIBC */ -#if defined(RT_USING_LIBC) || defined(RT_USING_MINILIBC) || defined(RT_LIBC_USING_TIME) +#if defined(RT_USING_LIBC) || defined(RT_USING_MINILIBC) || defined(RT_LIBC_USING_TIME) || defined ( __GNUC__) #include #define LWIP_TIMEVAL_PRIVATE 0 #else diff --git a/include/libc/libc_errno.h b/include/libc/libc_errno.h index 0f3bc7635a..00c1f733d3 100644 --- a/include/libc/libc_errno.h +++ b/include/libc/libc_errno.h @@ -13,7 +13,7 @@ #include -#if defined(RT_USING_NEWLIB) || defined(_WIN32) +#if defined(RT_USING_NEWLIB) || defined(_WIN32) || defined( __GNUC__ ) /* use errno.h file in toolchains */ #include #endif @@ -45,7 +45,7 @@ defined in armcc/errno.h #define ERROR_BASE_NO 0 #endif -#if !defined(RT_USING_NEWLIB) && !defined(_WIN32) +#if !defined(RT_USING_NEWLIB) && !defined(_WIN32) && !defined(__GNUC__ ) #define EPERM (ERROR_BASE_NO + 1) #define ENOENT (ERROR_BASE_NO + 2) diff --git a/include/libc/libc_fcntl.h b/include/libc/libc_fcntl.h index 1b7c69b1f4..39740b7d85 100644 --- a/include/libc/libc_fcntl.h +++ b/include/libc/libc_fcntl.h @@ -2,10 +2,6 @@ * Copyright (c) 2006-2018, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 - */ - -/* - * File : libc_fcntl.h * * Change Logs: * Date Author Notes @@ -16,7 +12,7 @@ #ifndef LIBC_FCNTL_H__ #define LIBC_FCNTL_H__ -#if defined(RT_USING_NEWLIB) || defined(_WIN32) +#if defined(RT_USING_NEWLIB) || defined(_WIN32) || defined( __GNUC__ ) #include #ifndef O_NONBLOCK diff --git a/include/libc/libc_fdset.h b/include/libc/libc_fdset.h index ecd965cd22..4a778b51c1 100644 --- a/include/libc/libc_fdset.h +++ b/include/libc/libc_fdset.h @@ -2,10 +2,6 @@ * Copyright (c) 2006-2018, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 - */ - -/* - * File : libc_errno.h * * Change Logs: * Date Author Notes @@ -17,7 +13,7 @@ #include -#if defined(RT_USING_NEWLIB) || defined(_WIN32) +#if defined(RT_USING_NEWLIB) || defined(_WIN32) || defined( __GNUC__ ) #include #if defined(HAVE_SYS_SELECT_H) #include diff --git a/include/libc/libc_ioctl.h b/include/libc/libc_ioctl.h index ef5a5257a8..42a21a2cea 100644 --- a/include/libc/libc_ioctl.h +++ b/include/libc/libc_ioctl.h @@ -2,10 +2,6 @@ * Copyright (c) 2006-2018, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 - */ - -/* - * File : libc_ioctl.h * * Change Logs: * Date Author Notes diff --git a/include/libc/libc_limits.h b/include/libc/libc_limits.h new file mode 100644 index 0000000000..b8368160df --- /dev/null +++ b/include/libc/libc_limits.h @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2006-2018, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2020-09-05 Meco Manthe first version + */ + +#ifndef LIBC_LIMITS_H__ +#define LIBC_LIMITS_H__ + +#include +#include + +#ifdef RT_USING_POSIX + +#ifndef SSIZE_MAX +# define SSIZE_MAX LONG_MAX +#endif + +#endif + +#endif diff --git a/include/libc/libc_signal.h b/include/libc/libc_signal.h index 898fe13f43..539685de3e 100644 --- a/include/libc/libc_signal.h +++ b/include/libc/libc_signal.h @@ -15,6 +15,7 @@ extern "C" { #endif +#include #ifdef HAVE_CCONFIG_H #include #endif @@ -46,8 +47,8 @@ struct sigevent #ifndef HAVE_SIGINFO struct siginfo { - rt_uint16_t si_signo; - rt_uint16_t si_code; + uint16_t si_signo; + uint16_t si_code; union sigval si_value; }; diff --git a/include/libc/libc_stat.h b/include/libc/libc_stat.h index 9079d1ef15..9388688572 100644 --- a/include/libc/libc_stat.h +++ b/include/libc/libc_stat.h @@ -9,7 +9,7 @@ #include -#if defined(RT_USING_NEWLIB) +#if defined(RT_USING_NEWLIB) || defined( __GNUC__ ) /* use header file of newlib */ #include diff --git a/include/libc/libc_stdio.h b/include/libc/libc_stdio.h new file mode 100644 index 0000000000..85ba509852 --- /dev/null +++ b/include/libc/libc_stdio.h @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2006-2018, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2020-09-05 Meco Manthe first version + */ + +#ifndef LIBC_STDIO_H__ +#define LIBC_STDIO_H__ + +#include + +#ifdef RT_USING_POSIX_GETLINE + +#include + +#endif + +#endif diff --git a/include/rtlibc.h b/include/rtlibc.h index b3a548beb1..fb8c782095 100644 --- a/include/rtlibc.h +++ b/include/rtlibc.h @@ -20,6 +20,8 @@ #include "libc/libc_dirent.h" #include "libc/libc_signal.h" #include "libc/libc_fdset.h" +#include "libc/libc_limits.h" +#include "libc/libc_stdio.h" #if defined(__CC_ARM) || defined(__CLANG_ARM) || defined(__IAR_SYSTEMS_ICC__) typedef signed long off_t;