Last change
on this file since 444 was
444,
checked in by satin@…, 6 years ago
|
add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc
|
File size:
918 bytes
|
Rev | Line | |
---|
[444] | 1 | /* |
---|
| 2 | FUNCTION |
---|
| 3 | <<time>>---get current calendar time (as single number) |
---|
| 4 | |
---|
| 5 | INDEX |
---|
| 6 | time |
---|
| 7 | |
---|
| 8 | SYNOPSIS |
---|
| 9 | #include <time.h> |
---|
| 10 | time_t time(time_t *<[t]>); |
---|
| 11 | |
---|
| 12 | DESCRIPTION |
---|
| 13 | <<time>> looks up the best available representation of the current |
---|
| 14 | time and returns it, encoded as a <<time_t>>. It stores the same |
---|
| 15 | value at <[t]> unless the argument is <<NULL>>. |
---|
| 16 | |
---|
| 17 | RETURNS |
---|
| 18 | A <<-1>> result means the current time is not available; otherwise the |
---|
| 19 | result represents the current time. |
---|
| 20 | |
---|
| 21 | PORTABILITY |
---|
| 22 | ANSI C requires <<time>>. |
---|
| 23 | |
---|
| 24 | Supporting OS subroutine required: Some implementations require |
---|
| 25 | <<gettimeofday>>. |
---|
| 26 | */ |
---|
| 27 | |
---|
| 28 | /* Most times we have a system call in newlib/libc/sys/.. to do this job */ |
---|
| 29 | |
---|
| 30 | #include <_ansi.h> |
---|
| 31 | #include <reent.h> |
---|
| 32 | #include <sys/types.h> |
---|
| 33 | #include <sys/time.h> |
---|
| 34 | |
---|
| 35 | time_t |
---|
| 36 | time (time_t * t) |
---|
| 37 | { |
---|
| 38 | struct timeval now; |
---|
| 39 | |
---|
| 40 | if (_gettimeofday_r (_REENT, &now, NULL) < 0) |
---|
| 41 | now.tv_sec = (time_t) -1; |
---|
| 42 | |
---|
| 43 | if (t) |
---|
| 44 | *t = now.tv_sec; |
---|
| 45 | return now.tv_sec; |
---|
| 46 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.