From 96e6deac294667c2637415c8ddd0fed9cee35ede Mon Sep 17 00:00:00 2001 From: Bernard Xiong Date: Thu, 27 Dec 2018 09:11:07 +0800 Subject: [Kernel] Fix the errno definitions in armcc/iar. --- components/libc/compilers/dlib/sys/errno.h | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 components/libc/compilers/dlib/sys/errno.h (limited to 'components/libc/compilers/dlib/sys') diff --git a/components/libc/compilers/dlib/sys/errno.h b/components/libc/compilers/dlib/sys/errno.h deleted file mode 100644 index 1ecb58b74c..0000000000 --- a/components/libc/compilers/dlib/sys/errno.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 SYS_ERRNO_H__ -#define SYS_ERRNO_H__ - -#include - - -#endif -- cgit v1.3.1 From 6b7335a36f644b79972da39f8e60ebe7d78d9acd Mon Sep 17 00:00:00 2001 From: ZYH Date: Fri, 22 Mar 2019 14:20:23 +0800 Subject: [libc]fix size_t ssize_t --- components/libc/compilers/armlibc/sys/types.h | 6 +++++- components/libc/compilers/dlib/sys/types.h | 6 +++++- components/libc/compilers/minilibc/sys/types.h | 11 +++++++++-- 3 files changed, 19 insertions(+), 4 deletions(-) (limited to 'components/libc/compilers/dlib/sys') diff --git a/components/libc/compilers/armlibc/sys/types.h b/components/libc/compilers/armlibc/sys/types.h index 4c76dfc429..001ace4dd2 100644 --- a/components/libc/compilers/armlibc/sys/types.h +++ b/components/libc/compilers/armlibc/sys/types.h @@ -15,6 +15,10 @@ 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 signed long ssize_t; /* Used for a count of bytes or an error indication. */ +#ifndef ARCH_CPU_64BIT +typedef signed int ssize_t; /* Used for a count of bytes or an error indication. */ +#else +typedef long signed int ssize_t; /* Used for a count of bytes or an error indication. */ +#endif #endif diff --git a/components/libc/compilers/dlib/sys/types.h b/components/libc/compilers/dlib/sys/types.h index 4c76dfc429..001ace4dd2 100644 --- a/components/libc/compilers/dlib/sys/types.h +++ b/components/libc/compilers/dlib/sys/types.h @@ -15,6 +15,10 @@ 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 signed long ssize_t; /* Used for a count of bytes or an error indication. */ +#ifndef ARCH_CPU_64BIT +typedef signed int ssize_t; /* Used for a count of bytes or an error indication. */ +#else +typedef long signed int ssize_t; /* Used for a count of bytes or an error indication. */ +#endif #endif diff --git a/components/libc/compilers/minilibc/sys/types.h b/components/libc/compilers/minilibc/sys/types.h index 0c00a79d1e..d3abc6bb38 100644 --- a/components/libc/compilers/minilibc/sys/types.h +++ b/components/libc/compilers/minilibc/sys/types.h @@ -8,10 +8,17 @@ */ #ifndef __TYPES_H__ #define __TYPES_H__ +#include typedef long off_t; -typedef unsigned long size_t; -typedef signed long ssize_t; /* Used for a count of bytes or an error indication. */ + +#ifndef ARCH_CPU_64BIT +typedef unsigned int size_t; +typedef signed int ssize_t; /* Used for a count of bytes or an error indication. */ +#else +typedef long unsigned int size_t; +typedef long signed int ssize_t; /* Used for a count of bytes or an error indication. */ +#endif typedef unsigned char u_char; typedef unsigned short u_short; -- cgit v1.3.1 From 2844e3d974c85ad8e5f4a17ac8a536d327febdaf Mon Sep 17 00:00:00 2001 From: Bernard Xiong Date: Mon, 8 Jul 2019 13:34:57 +0800 Subject: [dlib] Add more header files for IAR/dlib --- components/libc/compilers/dlib/sys/errno.h | 16 ++++++++++++++++ components/libc/compilers/dlib/sys/signal.h | 16 ++++++++++++++++ components/libc/compilers/dlib/sys/unistd.h | 8 -------- 3 files changed, 32 insertions(+), 8 deletions(-) create mode 100644 components/libc/compilers/dlib/sys/errno.h create mode 100644 components/libc/compilers/dlib/sys/signal.h (limited to 'components/libc/compilers/dlib/sys') diff --git a/components/libc/compilers/dlib/sys/errno.h b/components/libc/compilers/dlib/sys/errno.h new file mode 100644 index 0000000000..1ad4c8acc0 --- /dev/null +++ b/components/libc/compilers/dlib/sys/errno.h @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2006-2018, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2019-07-08 Bernard The first version + */ + +#ifndef SYS_ERRNO_H__ +#define SYS_ERRNO_H__ + +#include + +#endif diff --git a/components/libc/compilers/dlib/sys/signal.h b/components/libc/compilers/dlib/sys/signal.h new file mode 100644 index 0000000000..22adb1228b --- /dev/null +++ b/components/libc/compilers/dlib/sys/signal.h @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2006-2018, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2019-07-08 Bernard The first version + */ + +#ifndef SYS_SIGNAL_H__ +#define SYS_SIGNAL_H__ + +#include + +#endif diff --git a/components/libc/compilers/dlib/sys/unistd.h b/components/libc/compilers/dlib/sys/unistd.h index 5985a42996..29f68f24f8 100644 --- a/components/libc/compilers/dlib/sys/unistd.h +++ b/components/libc/compilers/dlib/sys/unistd.h @@ -34,14 +34,6 @@ #define _FNDELAY _FNONBLOCK /* non blocking I/O (4.2 style) */ #define _FNOCTTY 0x8000 /* don't assign a ctty on this open */ -#define O_RDONLY 0 /* +1 == FREAD */ -#define O_WRONLY 1 /* +1 == FWRITE */ -#define O_RDWR 2 /* +1 == FREAD|FWRITE */ -#define O_APPEND _FAPPEND -#define O_CREAT _FCREAT -#define O_TRUNC _FTRUNC -#define O_EXCL _FEXCL -#define O_SYNC _FSYNC #endif #endif /* _SYS_UNISTD_H */ -- cgit v1.3.1 From a186ada6da915062895518e565a1dc52a0ff44dc Mon Sep 17 00:00:00 2001 From: zhangjun <2281979437@qq.com> Date: Tue, 10 Sep 2019 09:59:11 +0800 Subject: [components][libc][compilers]移动time相关头文件到common目录 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/libc/compilers/armlibc/sys/time.h | 54 ------------------------ components/libc/compilers/common/sys/time.h | 60 +++++++++++++++++++++++++++ components/libc/compilers/common/time.c | 32 ++++----------- components/libc/compilers/dlib/sys/time.h | 61 ---------------------------- 4 files changed, 67 insertions(+), 140 deletions(-) delete mode 100644 components/libc/compilers/armlibc/sys/time.h create mode 100644 components/libc/compilers/common/sys/time.h delete mode 100644 components/libc/compilers/dlib/sys/time.h (limited to 'components/libc/compilers/dlib/sys') diff --git a/components/libc/compilers/armlibc/sys/time.h b/components/libc/compilers/armlibc/sys/time.h deleted file mode 100644 index bac122e183..0000000000 --- a/components/libc/compilers/armlibc/sys/time.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2006-2018, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - */ -#ifndef _SYS_TIME_H_ -#define _SYS_TIME_H_ - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef _TIMEVAL_DEFINED -#define _TIMEVAL_DEFINED -/* - * Structure returned by gettimeofday(2) system call, - * and used in other calls. - */ -struct timeval { - long tv_sec; /* seconds */ - long tv_usec; /* and microseconds */ -}; -#endif /* _TIMEVAL_DEFINED */ - -#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 */ - int tz_dsttime; /* type of dst correction */ -}; - -int gettimeofday(struct timeval *tp, void *ignore); -struct tm *gmtime_r(const time_t *timep, struct tm *r); - -#ifdef __cplusplus -} -#endif - -#endif /* _SYS_TIME_H_ */ diff --git a/components/libc/compilers/common/sys/time.h b/components/libc/compilers/common/sys/time.h new file mode 100644 index 0000000000..1d68eeafa3 --- /dev/null +++ b/components/libc/compilers/common/sys/time.h @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2006-2018, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + */ +#ifndef _SYS_TIME_H_ +#define _SYS_TIME_H_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _TIMEVAL_DEFINED +#define _TIMEVAL_DEFINED +/* + * Structure returned by gettimeofday(2) system call, + * and used in other calls. + */ +struct timeval { + long tv_sec; /* seconds */ + long tv_usec; /* and microseconds */ +}; +#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 */ + int tz_dsttime; /* type of dst correction */ +}; + +int gettimeofday(struct timeval *tp, void *ignore); +struct tm *gmtime_r(const time_t *timep, struct tm *r); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_TIME_H_ */ diff --git a/components/libc/compilers/common/time.c b/components/libc/compilers/common/time.c index 097faedfe5..10682ae002 100644 --- a/components/libc/compilers/common/time.c +++ b/components/libc/compilers/common/time.c @@ -8,7 +8,7 @@ * 2019-08-21 zhangjun copy from minilibc */ -#include +#include #include #if !defined (__IAR_SYSTEMS_ICC__) @@ -213,44 +213,26 @@ char* ctime(const time_t *timep) #endif /* __IAR_SYSTEMS_ICC__ */ -/* - * Structure returned by gettimeofday(2) system call, - * and used in other calls. - */ -struct timeval { - long tv_sec; /* seconds */ - long tv_usec; /* and microseconds */ -}; - -#ifdef RT_USING_DEVICE int gettimeofday(struct timeval *tp, void *ignore) { - time_t time; + time_t time = 0; +#ifdef RT_USING_DEVICE 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; -} +#else + tv->tv_sec = 0; + tv->tv_usec = 0; #endif -#ifndef _gettimeofday -/* Dummy function when hardware do not have RTC */ -int _gettimeofday( struct timeval *tv, void *ignore) -{ - tv->tv_sec = 0; // convert to seconds - tv->tv_usec = 0; // get remaining microseconds - return 0; // return non-zero for error + return time; } -#endif /** diff --git a/components/libc/compilers/dlib/sys/time.h b/components/libc/compilers/dlib/sys/time.h deleted file mode 100644 index baf566936b..0000000000 --- a/components/libc/compilers/dlib/sys/time.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2006-2018, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - */ -#ifndef _SYS_TIME_H_ -#define _SYS_TIME_H_ - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef _TIMEVAL_DEFINED -#define _TIMEVAL_DEFINED -/* - * Structure returned by gettimeofday(2) system call, - * and used in other calls. - */ -struct timeval { - long tv_sec; /* seconds */ - long tv_usec; /* and microseconds */ -}; -#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 */ - int tz_dsttime; /* type of dst correction */ -}; - -int gettimeofday(struct timeval *tp, void *ignore); -struct tm *gmtime_r(const time_t *timep, struct tm *r); - -#ifdef __cplusplus -} -#endif - -#endif /* _SYS_TIME_H_ */ -- cgit v1.3.1 From 5721fa8990e4178a427564a1e546df507c87c2b4 Mon Sep 17 00:00:00 2001 From: mysterywolf <920369182@qq.com> Date: Wed, 2 Sep 2020 10:33:37 +0800 Subject: Signed-off-by: mysterywolf --- components/libc/compilers/armlibc/fcntl.h | 2 ++ components/libc/compilers/dlib/sys/unistd.h | 4 ++++ 2 files changed, 6 insertions(+) (limited to 'components/libc/compilers/dlib/sys') diff --git a/components/libc/compilers/armlibc/fcntl.h b/components/libc/compilers/armlibc/fcntl.h index 80cf1b4409..3e650a8471 100644 --- a/components/libc/compilers/armlibc/fcntl.h +++ b/components/libc/compilers/armlibc/fcntl.h @@ -9,6 +9,8 @@ #ifndef FCNTL_H__ #define FCNTL_H__ +#include + #ifdef RT_USING_DFS #include #endif diff --git a/components/libc/compilers/dlib/sys/unistd.h b/components/libc/compilers/dlib/sys/unistd.h index 29f68f24f8..9564daba8d 100644 --- a/components/libc/compilers/dlib/sys/unistd.h +++ b/components/libc/compilers/dlib/sys/unistd.h @@ -36,4 +36,8 @@ #endif + +int isatty (int fd); +char * ttyname (int desc); + #endif /* _SYS_UNISTD_H */ -- cgit v1.3.1