Go to most recent revision | Details | 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)); |
||
30 | tmblk.tm_mday = (xtmp>>16)&0xff; |
||
31 | tmblk.tm_mon = ((xtmp>>8)&0xff)-1; |
||
32 | tmblk.tm_year = ((xtmp&0xff)+2000)-1900; |
||
33 | tmblk.tm_wday = tmblk.tm_yday = 0; |
||
34 | tmblk.tm_isdst = -1; |
||
35 | ptimeval->tv_sec = mktime(&tmblk); |
||
36 | return 0; |
||
37 | } |
||
38 | else |
||
39 | { |
||
40 | errno = EINVAL; |
||
41 | return -1; |
||
42 | }; |
||
43 | |||
44 | } |
||
45 |