summaryrefslogtreecommitdiff
path: root/components/libc
diff options
context:
space:
mode:
authorbernard.xiong <[email protected]>2011-02-21 08:26:35 +0000
committerbernard.xiong <[email protected]>2011-02-21 08:26:35 +0000
commit54228a051852005210ec03e079119bd350376fac (patch)
tree76823f4b270891a45ccce9e3fca87d5d5a99012d /components/libc
parent397efc12520a07d6fe113a656ca1a7d5e9ff15de (diff)
porting pthread to ARMCC compiler;
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1286 bbd45198-f89e-11dd-88c7-29a3b14d5316
Diffstat (limited to 'components/libc')
-rw-r--r--components/libc/newlib/clock_time.c43
-rw-r--r--components/libc/newlib/libc.c91
2 files changed, 0 insertions, 134 deletions
diff --git a/components/libc/newlib/clock_time.c b/components/libc/newlib/clock_time.c
deleted file mode 100644
index c0fd9d82e3..0000000000
--- a/components/libc/newlib/clock_time.c
+++ /dev/null
@@ -1,43 +0,0 @@
-#include <rtthread.h>
-
-#include <time.h>
-#include <errno.h>
-#include "libc.h"
-
-int clock_getres(clockid_t clock_id, struct timespec *res)
-{
- if ((clock_id != CLOCK_REALTIME) || (res == RT_NULL))
- {
- rt_set_errno(EINVAL);
- return -1;
- }
-
- res->tv_sec = 0;
- res->tv_nsec = NANOSECOND_PER_TICK;
-
- return 0;
-}
-
-int clock_gettime(clockid_t clock_id, struct timespec *tp)
-{
- if ((clock_id != CLOCK_REALTIME) || (tp == RT_NULL))
- {
- rt_set_errno(EINVAL);
- return -1;
- }
-
- libc_get_time(tp);
- return 0;
-}
-
-int clock_settime(clockid_t clock_id, const struct timespec *tp)
-{
- if ((clock_id != CLOCK_REALTIME) || (tp == RT_NULL))
- {
- rt_set_errno(EINVAL);
- return -1;
- }
-
- libc_set_time(tp);
- return 0;
-}
diff --git a/components/libc/newlib/libc.c b/components/libc/newlib/libc.c
index de8523a1f6..fcdc961f08 100644
--- a/components/libc/newlib/libc.c
+++ b/components/libc/newlib/libc.c
@@ -5,95 +5,6 @@
#include <sys/time.h>
#include "libc.h"
-struct timeval _timevalue;
-static void libc_system_time_init()
-{
- 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;
-}
-
-int libc_get_time(struct timespec *time)
-{
- rt_tick_t tick;
- RT_ASSERT(time != RT_NULL);
-
- /* 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) * NANOSECOND_PER_TICK) * 1000;
-
- return 0;
-}
-
-int libc_set_time(const struct timespec *time)
-{
- int second;
- rt_tick_t tick;
- rt_device_t device;
-
- second = time->tv_sec;
- device = rt_device_find("rtc");
- if (device != RT_NULL)
- {
- /* get realtime seconds */
- rt_device_control(device, RT_DEVICE_CTRL_RTC_SET_TIME, &second);
- }
- else return -1;
-
- /* get tick */
- tick = rt_tick_get();
-
- /* update timevalue */
- _timevalue.tv_usec = MICROSECOND_PER_SECOND - (tick % RT_TICK_PER_SECOND) * MICROSECOND_PER_TICK;
- _timevalue.tv_sec = second - tick/RT_TICK_PER_SECOND - 1;
-
- return 0;
-}
-
-int libc_time_to_tick(const struct timespec *time)
-{
- int tick;
- int microsecond, second;
-
- RT_ASSERT(time != RT_NULL);
-
- tick = RT_WAITING_FOREVER;
- if (time != NULL)
- {
- if ((time->tv_nsec/1000 - _timevalue.tv_usec) < 0)
- {
- microsecond = (1000000UL + time->tv_nsec/1000) - _timevalue.tv_usec;
- second = time->tv_sec - 1;
- }
- else
- {
- microsecond = time->tv_nsec/1000 - _timevalue.tv_usec;
- second = time->tv_sec;
- }
-
- tick = second * RT_TICK_PER_SECOND + microsecond * RT_TICK_PER_SECOND / MICROSECOND_PER_SECOND;
- if (tick < 0) tick = 0;
- }
-
- return tick;
-}
-
void libc_system_init(const char* tty_name)
{
int fd;
@@ -115,8 +26,6 @@ void libc_system_init(const char* tty_name)
putenv("PATH=/");
putenv("HOME=/");
- /* initialize system time */
- libc_system_time_init();
#ifdef RT_USING_PTHREADS
pthread_system_init();
#endif