Rev 4874 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4349 | Serge | 1 | /* |
2 | FUNCTION |
||
3 | < |
||
4 | |||
5 | INDEX |
||
6 | time |
||
7 | |||
8 | ANSI_SYNOPSIS |
||
9 | #include |
||
10 | time_t time(time_t *<[t]>); |
||
11 | |||
12 | TRAD_SYNOPSIS |
||
13 | #include |
||
14 | time_t time(<[t]>) |
||
15 | time_t *<[t]>; |
||
16 | |||
17 | DESCRIPTION |
||
18 | < |
||
19 | time and returns it, encoded as a < |
||
20 | value at <[t]> unless the argument is < |
||
21 | |||
22 | RETURNS |
||
23 | A <<-1>> result means the current time is not available; otherwise the |
||
24 | result represents the current time. |
||
25 | |||
26 | PORTABILITY |
||
27 | ANSI C requires < |
||
28 | |||
29 | Supporting OS subroutine required: Some implementations require |
||
30 | < |
||
31 | */ |
||
32 | |||
33 | /* Most times we have a system call in newlib/libc/sys/.. to do this job */ |
||
34 | |||
35 | #include <_ansi.h> |
||
36 | #include |
||
37 | #include |
||
38 | #include |
||
39 | |||
40 | time_t |
||
41 | _DEFUN (time, (t), |
||
42 | time_t * t) |
||
43 | { |
||
44 | struct timeval now; |
||
45 | |||
46 | if (_gettimeofday_r (_REENT, &now, NULL) >= 0) |
||
47 | { |
||
48 | if (t) |
||
49 | *t = now.tv_sec; |
||
50 | return now.tv_sec; |
||
51 | } |
||
52 | return -1; |
||
53 | } |