summaryrefslogtreecommitdiff
path: root/components/libc
diff options
context:
space:
mode:
authorBernard Xiong <[email protected]>2021-02-11 22:37:26 +0800
committerGitHub <[email protected]>2021-02-11 22:37:26 +0800
commitff9ef1a5276432e1f37d8f28e0381c2b7ec9176f (patch)
tree5bd865fc37de1716b578c08c6782f8c27281d21e /components/libc
parentacda6bbccb35f3e86763acee12800610fbedb3f5 (diff)
parentdbe1a9c2dcc517e0d99ad5cfdfab12a4ebe357d7 (diff)
Merge pull request #4331 from mysterywolf/syscall
[libc][newlib]remove _gettimeofday_r() and _times_r()
Diffstat (limited to 'components/libc')
-rw-r--r--components/libc/compilers/newlib/libc.h19
-rw-r--r--components/libc/compilers/newlib/syscalls.c121
2 files changed, 9 insertions, 131 deletions
diff --git a/components/libc/compilers/newlib/libc.h b/components/libc/compilers/newlib/libc.h
index fdf2ab4f60..9a76ffb79f 100644
--- a/components/libc/compilers/newlib/libc.h
+++ b/components/libc/compilers/newlib/libc.h
@@ -10,23 +10,10 @@
#ifndef __RTT_LIBC_H__
#define __RTT_LIBC_H__
-#include <stdio.h>
-#include <stdint.h>
-#include <string.h>
-#include <sys/time.h>
-
#ifndef _EXFUN
-#define _EXFUN(name, proto) name proto
+#define _EXFUN(name, proto) name proto
#endif
-#define MILLISECOND_PER_SECOND 1000UL
-#define MICROSECOND_PER_SECOND 1000000UL
-#define NANOSECOND_PER_SECOND 1000000000UL
-
-#define MILLISECOND_PER_TICK (MILLISECOND_PER_SECOND / RT_TICK_PER_SECOND)
-#define MICROSECOND_PER_TICK (MICROSECOND_PER_SECOND / RT_TICK_PER_SECOND)
-#define NANOSECOND_PER_TICK (NANOSECOND_PER_SECOND / RT_TICK_PER_SECOND)
-
#ifdef __cplusplus
extern "C" {
#endif
@@ -34,10 +21,6 @@ int libc_system_init(void);
int libc_stdio_set_console(const char* device_name, int mode);
int libc_stdio_get_console(void);
-/* some time related function */
-int libc_set_time(const struct timespec* time);
-int libc_get_time(struct timespec* time);
-int libc_time_to_tick(const struct timespec* time);
#ifdef __cplusplus
}
#endif
diff --git a/components/libc/compilers/newlib/syscalls.c b/components/libc/compilers/newlib/syscalls.c
index 228fa0d140..193080c926 100644
--- a/components/libc/compilers/newlib/syscalls.c
+++ b/components/libc/compilers/newlib/syscalls.c
@@ -5,7 +5,9 @@
*
* Change Logs:
* Date Author Notes
+ * 2021-02-11 Meco Man remove _gettimeofday_r() and _times_r()
*/
+
#include <reent.h>
#include <sys/errno.h>
#include <sys/time.h>
@@ -190,14 +192,6 @@ _stat_r(struct _reent *ptr, const char *file, struct stat *pstat)
#endif
}
-_CLOCK_T_
-_times_r(struct _reent *ptr, struct tms *ptms)
-{
- /* return "not supported" */
- ptr->_errno = ENOTSUP;
- return -1;
-}
-
int
_unlink_r(struct _reent *ptr, const char *file)
{
@@ -243,111 +237,6 @@ _write_r(struct _reent *ptr, int fd, const void *buf, size_t nbytes)
}
#endif
-#ifdef RT_USING_PTHREADS
-
-#include <clock_time.h>
-/* POSIX timer provides clock_gettime function */
-#include <time.h>
-int
-_gettimeofday_r(struct _reent *ptr, struct timeval *__tp, void *__tzp)
-{
- struct timespec tp;
-
- if (clock_gettime(CLOCK_REALTIME, &tp) == 0)
- {
- if (__tp != RT_NULL)
- {
- __tp->tv_sec = tp.tv_sec;
- __tp->tv_usec = tp.tv_nsec / 1000UL;
- }
-
- return tp.tv_sec;
- }
-
- /* return "not supported" */
- ptr->_errno = ENOTSUP;
- return -1;
-}
-
-#else
-
-#define MILLISECOND_PER_SECOND 1000UL
-#define MICROSECOND_PER_SECOND 1000000UL
-#define NANOSECOND_PER_SECOND 1000000000UL
-
-#define MILLISECOND_PER_TICK (MILLISECOND_PER_SECOND / RT_TICK_PER_SECOND)
-#define MICROSECOND_PER_TICK (MICROSECOND_PER_SECOND / RT_TICK_PER_SECOND)
-#define NANOSECOND_PER_TICK (NANOSECOND_PER_SECOND / RT_TICK_PER_SECOND)
-
-struct timeval _timevalue = {0};
-#ifdef RT_USING_DEVICE
-static void libc_system_time_init(void)
-{
- time_t time;
- rt_tick_t tick;
- rt_device_t device;
-
- time = 0;
- device = rt_device_find("rtc");
- if (device != RT_NULL)
- {
- /* get realtime seconds */
- rt_device_control(device, RT_DEVICE_CTRL_RTC_GET_TIME, &time);
- }
-
- /* get tick */
- tick = rt_tick_get();
-
- _timevalue.tv_usec = MICROSECOND_PER_SECOND - (tick%RT_TICK_PER_SECOND) * MICROSECOND_PER_TICK;
- _timevalue.tv_sec = time - tick/RT_TICK_PER_SECOND - 1;
-}
-#endif
-
-int libc_get_time(struct timespec *time)
-{
- rt_tick_t tick;
- static rt_bool_t inited = 0;
-
- RT_ASSERT(time != RT_NULL);
-
- /* initialize system time */
- if (inited == 0)
- {
- libc_system_time_init();
- inited = 1;
- }
-
- /* get tick */
- tick = rt_tick_get();
-
- time->tv_sec = _timevalue.tv_sec + tick / RT_TICK_PER_SECOND;
- time->tv_nsec = (_timevalue.tv_usec + (tick % RT_TICK_PER_SECOND) * MICROSECOND_PER_TICK) * 1000;
-
- return 0;
-}
-
-int
-_gettimeofday_r(struct _reent *ptr, struct timeval *__tp, void *__tzp)
-{
- struct timespec tp;
-
- if (libc_get_time(&tp) == 0)
- {
- if (__tp != RT_NULL)
- {
- __tp->tv_sec = tp.tv_sec;
- __tp->tv_usec = tp.tv_nsec / 1000UL;
- }
-
- return tp.tv_sec;
- }
-
- /* return "not supported" */
- ptr->_errno = ENOTSUP;
- return -1;
-}
-#endif
-
/* Memory routine */
void *
_malloc_r (struct _reent *ptr, size_t size)
@@ -453,3 +342,9 @@ int flock(int fd, int operation)
{
return 0;
}
+
+/*
+These functions will be implemented and replaced by the 'common/time.c' file
+int _gettimeofday_r(struct _reent *ptr, struct timeval *__tp, void *__tzp);
+_CLOCK_T_ _times_r(struct _reent *ptr, struct tms *ptms);
+*/