Rev 4874 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4874 | Rev 4921 | ||
---|---|---|---|
Line 6... | Line 6... | ||
6 | #include |
6 | #include |
7 | #include |
7 | #include |
8 | #include |
8 | #include |
9 | #include |
9 | #include |
10 | #include <_syslist.h> |
10 | #include <_syslist.h> |
11 | #include |
- | |
Line 12... | Line 11... | ||
12 | 11 | ||
13 | /* Some targets provides their own versions of these functions. Those |
12 | /* Some targets provides their own versions of these functions. Those |
Line 14... | Line 13... | ||
14 | targets should define REENTRANT_SYSCALLS_PROVIDED in TARGET_CFLAGS. */ |
13 | targets should define REENTRANT_SYSCALLS_PROVIDED in TARGET_CFLAGS. */ |
Line 25... | Line 24... | ||
25 | 24 | ||
Line 26... | Line 25... | ||
26 | #else |
25 | #else |
27 | 26 | ||
28 | /* We use the errno variable used by the system dependent layer. */ |
27 | /* We use the errno variable used by the system dependent layer. */ |
Line 29... | Line 28... | ||
29 | #undef errno |
28 | #undef errno |
30 | static int errno; |
29 | extern int errno; |
31 | 30 | ||
Line 72... | Line 71... | ||
72 | if ((ret = _gettimeofday (ptimeval, ptimezone)) == -1 && errno != 0) |
71 | if ((ret = _gettimeofday (ptimeval, ptimezone)) == -1 && errno != 0) |
73 | ptr->_errno = errno; |
72 | ptr->_errno = errno; |
74 | return ret; |
73 | return ret; |
75 | } |
74 | } |
Line 76... | Line -... | ||
76 | - | ||
77 | #define BCD_TO_BIN(val) ((val)=((val)&15) + ((val)>>4)*10) |
- | |
78 | - | ||
79 | int |
- | |
80 | _gettimeofday (struct timeval *tv, void *tz) |
- | |
81 | { |
- | |
82 | unsigned int xtmp; |
- | |
83 | struct tm tmblk; |
- | |
84 | - | ||
85 | if( tv ) |
- | |
86 | { |
- | |
87 | tv->tv_usec = 0; |
- | |
88 | - | ||
89 | __asm__ __volatile__("int $0x40":"=a"(xtmp):"0"(3)); |
- | |
90 | tmblk.tm_sec = (xtmp>>16)&0xff; |
- | |
91 | tmblk.tm_min = (xtmp>>8)&0xff; |
- | |
92 | tmblk.tm_hour = xtmp&0xff; |
- | |
93 | BCD_TO_BIN(tmblk.tm_sec); |
- | |
94 | BCD_TO_BIN(tmblk.tm_min); |
- | |
95 | BCD_TO_BIN(tmblk.tm_hour); |
- | |
96 | __asm__ __volatile__("int $0x40":"=a"(xtmp):"0"(29)); |
- | |
97 | tmblk.tm_mday = (xtmp>>16)&0xff; |
- | |
98 | tmblk.tm_mon = ((xtmp>>8)&0xff)-1; |
- | |
99 | tmblk.tm_year = ((xtmp&0xff)+2000)-1900; |
- | |
100 | tmblk.tm_wday = tmblk.tm_yday = 0; |
- | |
101 | tmblk.tm_isdst = -1; |
- | |
102 | tv->tv_sec = mktime(&tmblk); |
- | |
103 | return 0; |
- | |
104 | } |
- | |
105 | else |
- | |
106 | { |
- | |
107 | errno = EINVAL; |
- | |
108 | return -1; |
- | |
109 | }; |
- | |
110 | } |
- | |
111 | - | ||
112 | 75 |