Rev 4921 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4921 | Serge | 1 | #include <_ansi.h> |
2 | #include |
||
3 | #include |
||
4 | #include |
||
5 | #include |
||
6 | #include |
||
7 | |||
8 | #define BCD_TO_BIN(val) ((val)=((val)&15) + ((val)>>4)*10) |
||
9 | |||
10 | int |
||
11 | _DEFUN (gettimeofday, (ptimeval, ptimezone), |
||
12 | struct timeval *ptimeval _AND |
||
13 | void *ptimezone) |
||
14 | { |
||
15 | unsigned int xtmp; |
||
16 | struct tm tmblk; |
||
17 | |||
18 | if( ptimeval ) |
||
19 | { |
||
20 | ptimeval->tv_usec = 0; |
||
21 | |||
22 | __asm__ __volatile__("int $0x40":"=a"(xtmp):"0"(3)); |
||
23 | tmblk.tm_sec = (xtmp>>16)&0xff; |
||
24 | tmblk.tm_min = (xtmp>>8)&0xff; |
||
25 | tmblk.tm_hour = xtmp&0xff; |
||
26 | BCD_TO_BIN(tmblk.tm_sec); |
||
27 | BCD_TO_BIN(tmblk.tm_min); |
||
28 | BCD_TO_BIN(tmblk.tm_hour); |
||
29 | __asm__ __volatile__("int $0x40":"=a"(xtmp):"0"(29)); |
||
8573 | superturbo | 30 | |
31 | int bcd_day = (xtmp >> 16); |
||
32 | int bcd_mon = ((xtmp & 0xFF00) >> 8); |
||
33 | int bcd_year = (xtmp & 0xFF); |
||
34 | |||
35 | tmblk.tm_mday = ((bcd_day & 0xF0)>>4)*10 + (bcd_day & 0x0F); |
||
36 | tmblk.tm_mon = ((bcd_mon & 0xF0)>>4)*10 + (bcd_mon & 0x0F) - 1; |
||
37 | tmblk.tm_year = ((bcd_year & 0xF0)>>4)*10 + (bcd_year & 0x0F) + 100; |
||
38 | |||
39 | tmblk.tm_wday = tmblk.tm_yday = tmblk.tm_isdst = -1; |
||
4921 | Serge | 40 | ptimeval->tv_sec = mktime(&tmblk); |
41 | return 0; |
||
42 | } |
||
43 | else |
||
44 | { |
||
45 | errno = EINVAL; |
||
46 | return -1; |
||
47 | }; |
||
48 | |||
49 | } |
||
50 |