diff options
| author | xph <[email protected]> | 2020-04-09 16:35:28 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2020-04-09 16:35:28 +0800 |
| commit | ca7f01d79b3e0a997c771cec298e4ebd65b75809 (patch) | |
| tree | 3d2c48aae7203b14038ba7b98b500b5343ed7f2a /components/libc/compilers/dlib | |
| parent | f763f8e7284b0492c5a65ad0abf94ee1963d7dcc (diff) | |
| parent | baa3145bfe61b3330b6a160523cc5470fa5db3a7 (diff) | |
Merge pull request #1 from RT-Thread/master
sync rtt
Diffstat (limited to 'components/libc/compilers/dlib')
| -rw-r--r-- | components/libc/compilers/dlib/libc.h | 10 | ||||
| -rw-r--r-- | components/libc/compilers/dlib/sys/errno.h | 5 | ||||
| -rw-r--r-- | components/libc/compilers/dlib/sys/signal.h | 16 | ||||
| -rw-r--r-- | components/libc/compilers/dlib/sys/time.h | 60 | ||||
| -rw-r--r-- | components/libc/compilers/dlib/sys/types.h | 6 | ||||
| -rw-r--r-- | components/libc/compilers/dlib/sys/unistd.h | 8 | ||||
| -rw-r--r-- | components/libc/compilers/dlib/time.c | 84 |
7 files changed, 32 insertions, 157 deletions
diff --git a/components/libc/compilers/dlib/libc.h b/components/libc/compilers/dlib/libc.h index 7b2665c32b..5b46bee0c8 100644 --- a/components/libc/compilers/dlib/libc.h +++ b/components/libc/compilers/dlib/libc.h @@ -13,11 +13,17 @@ #include <stddef.h> +#ifdef __cplusplus +extern "C" { +#endif int libc_system_init(void); int libc_stdio_set_console(const char* device_name, int mode); int libc_stdio_get_console(void); -int libc_stdio_read (void *buffer, size_t size); -int libc_stdio_write(const void *buffer, size_t size); +int libc_stdio_read(void* buffer, size_t size); +int libc_stdio_write(const void* buffer, size_t size); +#ifdef __cplusplus +} +#endif #endif diff --git a/components/libc/compilers/dlib/sys/errno.h b/components/libc/compilers/dlib/sys/errno.h index 1ecb58b74c..1ad4c8acc0 100644 --- a/components/libc/compilers/dlib/sys/errno.h +++ b/components/libc/compilers/dlib/sys/errno.h @@ -5,11 +5,12 @@ * * Change Logs: * Date Author Notes + * 2019-07-08 Bernard The first version */ + #ifndef SYS_ERRNO_H__ #define SYS_ERRNO_H__ -#include <rtthread.h> - +#include <errno.h> #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 <libc/libc_signal.h> + +#endif diff --git a/components/libc/compilers/dlib/sys/time.h b/components/libc/compilers/dlib/sys/time.h deleted file mode 100644 index 766d219faf..0000000000 --- a/components/libc/compilers/dlib/sys/time.h +++ /dev/null @@ -1,60 +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 <time.h> -#include <sys/types.h> - -#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); - -#ifdef __cplusplus -} -#endif - -#endif /* _SYS_TIME_H_ */ 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/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 */ diff --git a/components/libc/compilers/dlib/time.c b/components/libc/compilers/dlib/time.c deleted file mode 100644 index bea01e90e5..0000000000 --- a/components/libc/compilers/dlib/time.c +++ /dev/null @@ -1,84 +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"); - if (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; - } - - return 0; -} -#endif - -/** - * Returns the current time. - * - * @param time_t * t the timestamp pointer, if not used, keep NULL. - * - * @return time_t return timestamp current. - * - */ -#pragma module_name = "?time" -#if _DLIB_TIME_ALLOW_64 -time_t __time64(time_t *t) -#else -time_t __time32(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(); -} |
