summaryrefslogtreecommitdiff
path: root/components/libc/compilers/dlib
diff options
context:
space:
mode:
authoryangjie11 <[email protected]>2020-11-18 09:56:35 +0800
committerGitHub <[email protected]>2020-11-18 09:56:35 +0800
commitd4a682e8d97fa131e5a8d795f8c5451d55cdd5b0 (patch)
tree4773b40cb012475c5daf74bfd55707e141477669 /components/libc/compilers/dlib
parent2b98f4720c827ae1850df78299f6b273d568c8c7 (diff)
parent2ef3c9d861f55253620996a94831a4be31ca6620 (diff)
Merge pull request #3 from RT-Thread/master
sync
Diffstat (limited to 'components/libc/compilers/dlib')
-rw-r--r--components/libc/compilers/dlib/README.md7
-rw-r--r--components/libc/compilers/dlib/libc.h10
-rw-r--r--components/libc/compilers/dlib/sys/errno.h5
-rw-r--r--components/libc/compilers/dlib/sys/signal.h (renamed from components/libc/compilers/dlib/termios.h)9
-rw-r--r--components/libc/compilers/dlib/sys/time.h61
-rw-r--r--components/libc/compilers/dlib/sys/types.h6
-rw-r--r--components/libc/compilers/dlib/sys/unistd.h12
-rw-r--r--components/libc/compilers/dlib/time.c89
8 files changed, 31 insertions, 168 deletions
diff --git a/components/libc/compilers/dlib/README.md b/components/libc/compilers/dlib/README.md
index 846eb3f5c0..acd08f9074 100644
--- a/components/libc/compilers/dlib/README.md
+++ b/components/libc/compilers/dlib/README.md
@@ -1,4 +1,9 @@
-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 \ No newline at end of file
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/termios.h b/components/libc/compilers/dlib/sys/signal.h
index 1956121225..22adb1228b 100644
--- a/components/libc/compilers/dlib/termios.h
+++ b/components/libc/compilers/dlib/sys/signal.h
@@ -5,11 +5,12 @@
*
* Change Logs:
* Date Author Notes
+ * 2019-07-08 Bernard The first version
*/
-#ifndef _TERMIOS_H__
-#define _TERMIOS_H__
-#include <sys/types.h>
-#include <posix_termios.h>
+#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 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 <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);
-struct tm *gmtime_r(const time_t *timep, struct tm *r);
-
-#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..9564daba8d 100644
--- a/components/libc/compilers/dlib/sys/unistd.h
+++ b/components/libc/compilers/dlib/sys/unistd.h
@@ -34,14 +34,10 @@
#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
+
+int isatty (int fd);
+char * ttyname (int desc);
+
#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 87574df851..0000000000
--- a/components/libc/compilers/dlib/time.c
+++ /dev/null
@@ -1,89 +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_USES_64
-time_t __time64(time_t *t)
-#else
-/* for IAR 6.2 later Compiler */
-#if defined (__IAR_SYSTEMS_ICC__) && (__VER__) >= 6020000
-time_t __time32(time_t *t)
-#else
-time_t time(time_t *t)
-#endif
-#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();
-}