Merge pull request #3888 from mysterywolf/master
[add] [libc] libc新增getline/getdelim函数(posix.1-2008)
This commit is contained in:
commit
ac751db670
@ -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
|
||||
|
@ -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
|
||||
|
||||
#
|
||||
|
@ -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 */
|
||||
|
@ -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
|
||||
|
@ -5,16 +5,16 @@
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2020-09-05 Meco Man fix bugs
|
||||
*/
|
||||
#ifndef __TYPES_H__
|
||||
#define __TYPES_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <rtthread.h>
|
||||
|
||||
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
|
||||
|
@ -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')
|
||||
|
1
components/libc/compilers/common/readme.md
Normal file
1
components/libc/compilers/common/readme.md
Normal file
@ -0,0 +1 @@
|
||||
This folder is "common" for armlibc newlibc and dlib. It's not "common" for minilibc.
|
@ -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 */
|
||||
|
@ -9,7 +9,9 @@
|
||||
#ifndef _TERMIOS_H__
|
||||
#define _TERMIOS_H__
|
||||
|
||||
#ifdef RT_USING_POSIX_TERMIOS
|
||||
#include <sys/types.h>
|
||||
#include <posix_termios.h>
|
||||
#endif
|
||||
|
||||
#endif
|
@ -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 <sys/time.h>
|
||||
|
@ -8,10 +8,11 @@
|
||||
* 2020-09-01 Meco Man First Version
|
||||
*/
|
||||
|
||||
#include <termios.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef RT_USING_POSIX_TERMIOS
|
||||
#include <termios.h>
|
||||
|
||||
int isatty(int fd)
|
||||
{
|
||||
struct termios ts;
|
||||
|
@ -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 <sys/types.h>
|
||||
#include <posix_termios.h>
|
||||
|
||||
#endif
|
@ -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)
|
||||
|
||||
|
@ -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 <sys/types.h>
|
||||
#include <posix_termios.h>
|
||||
|
||||
#endif
|
@ -1,82 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2018, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
*/
|
||||
#include <sys/time.h>
|
||||
#include <rtthread.h>
|
||||
|
||||
#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();
|
||||
}
|
30
components/libc/getline/README.md
Normal file
30
components/libc/getline/README.md
Normal file
@ -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
|
13
components/libc/getline/SConscript
Normal file
13
components/libc/getline/SConscript
Normal file
@ -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')
|
24
components/libc/getline/UNLICENSE
Normal file
24
components/libc/getline/UNLICENSE
Normal file
@ -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 <http://unlicense.org/>
|
79
components/libc/getline/posix_getline.c
Normal file
79
components/libc/getline/posix_getline.c
Normal file
@ -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 <posix_getline.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <rtlibc.h>
|
||||
|
||||
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);
|
||||
}
|
||||
|
24
components/libc/getline/posix_getline.h
Normal file
24
components/libc/getline/posix_getline.h
Normal file
@ -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 <stdio.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
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 */
|
||||
|
@ -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 <sys/time.h>
|
||||
#define LWIP_TIMEVAL_PRIVATE 0
|
||||
#else
|
||||
|
@ -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 <sys/time.h>
|
||||
#define LWIP_TIMEVAL_PRIVATE 0
|
||||
#else
|
||||
|
@ -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 <sys/time.h>
|
||||
#define LWIP_TIMEVAL_PRIVATE 0
|
||||
#else
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
#include <rtconfig.h>
|
||||
|
||||
#if defined(RT_USING_NEWLIB) || defined(_WIN32)
|
||||
#if defined(RT_USING_NEWLIB) || defined(_WIN32) || defined( __GNUC__ )
|
||||
/* use errno.h file in toolchains */
|
||||
#include <errno.h>
|
||||
#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)
|
||||
|
@ -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 <fcntl.h>
|
||||
|
||||
#ifndef O_NONBLOCK
|
||||
|
@ -2,10 +2,6 @@
|
||||
* Copyright (c) 2006-2018, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/*
|
||||
* File : libc_errno.h
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
@ -17,7 +13,7 @@
|
||||
|
||||
#include <rtconfig.h>
|
||||
|
||||
#if defined(RT_USING_NEWLIB) || defined(_WIN32)
|
||||
#if defined(RT_USING_NEWLIB) || defined(_WIN32) || defined( __GNUC__ )
|
||||
#include <sys/types.h>
|
||||
#if defined(HAVE_SYS_SELECT_H)
|
||||
#include <sys/select.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
|
||||
|
25
include/libc/libc_limits.h
Normal file
25
include/libc/libc_limits.h
Normal file
@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2018, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2020-09-05 Meco Manthe first version
|
||||
*/
|
||||
|
||||
#ifndef LIBC_LIMITS_H__
|
||||
#define LIBC_LIMITS_H__
|
||||
|
||||
#include <limits.h>
|
||||
#include <rtconfig.h>
|
||||
|
||||
#ifdef RT_USING_POSIX
|
||||
|
||||
#ifndef SSIZE_MAX
|
||||
# define SSIZE_MAX LONG_MAX
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
@ -15,6 +15,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#ifdef HAVE_CCONFIG_H
|
||||
#include <cconfig.h>
|
||||
#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;
|
||||
};
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
#include <rtconfig.h>
|
||||
|
||||
#if defined(RT_USING_NEWLIB)
|
||||
#if defined(RT_USING_NEWLIB) || defined( __GNUC__ )
|
||||
/* use header file of newlib */
|
||||
#include <sys/stat.h>
|
||||
|
||||
|
22
include/libc/libc_stdio.h
Normal file
22
include/libc/libc_stdio.h
Normal file
@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2018, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2020-09-05 Meco Manthe first version
|
||||
*/
|
||||
|
||||
#ifndef LIBC_STDIO_H__
|
||||
#define LIBC_STDIO_H__
|
||||
|
||||
#include <rtconfig.h>
|
||||
|
||||
#ifdef RT_USING_POSIX_GETLINE
|
||||
|
||||
#include <posix_getline.h>
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user