Cygwin: mmap: allow remapping part of an existing anonymous mapping
[newlib-cygwin.git] / newlib / libc / time / time.c
blobb431f7ae5609eb88ee482b32ce194e8f328ca0f0
1 /*
2 FUNCTION
3 <<time>>---get current calendar time (as single number)
5 INDEX
6 time
8 SYNOPSIS
9 #include <time.h>
10 time_t time(time_t *<[t]>);
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>>.
17 RETURNS
18 A <<-1>> result means the current time is not available; otherwise the
19 result represents the current time.
21 PORTABILITY
22 ANSI C requires <<time>>.
24 Supporting OS subroutine required: Some implementations require
25 <<gettimeofday>>.
28 /* Most times we have a system call in newlib/libc/sys/.. to do this job */
30 #include <_ansi.h>
31 #include <reent.h>
32 #include <sys/types.h>
33 #include <sys/time.h>
35 time_t
36 time (time_t * t)
38 struct timeval now;
40 now.tv_sec = (time_t) -1;
42 if (_gettimeofday_r (_REENT, &now, NULL) < 0)
43 now.tv_sec = (time_t) -1;
45 if (t)
46 *t = now.tv_sec;
47 return now.tv_sec;