OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [newlib-1.10.0/] [newlib/] [libc/] [time/] [time.c] - Blame information for rev 1773

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1010 ivang
/* FIXME: doc says "not avail" due to #if 0.
2
          DELETE that line if inappropriate! */
3
/*
4
FUNCTION
5
<<time>>---get current calendar time (as single number)
6
 
7
INDEX
8
        time
9
 
10
ANSI_SYNOPSIS
11
        #include <time.h>
12
        time_t time(time_t *<[t]>);
13
 
14
TRAD_SYNOPSIS
15
        #include <time.h>
16
        time_t time(<[t]>)
17
        time_t *<[t]>;
18
 
19
DESCRIPTION
20
<<time>> looks up the best available representation of the current
21
time and returns it, encoded as a <<time_t>>.  It stores the same
22
value at <[t]> unless the argument is <<NULL>>.
23
 
24
RETURNS
25
A <<-1>> result means the current time is not available; otherwise the
26
result represents the current time.
27
 
28
PORTABILITY
29
ANSI C requires <<time>>.
30
 
31
Supporting OS subroutine required: Some implementations require
32
<<gettimeofday>>.
33
*/
34
 
35
#ifdef HAVE_GETTIMEOFDAY
36
 
37
/* Most times we have a system call in newlib/libc/sys/.. to do this job */
38
 
39
#include <_ansi.h>
40
#include <reent.h>
41
#include <sys/types.h>
42
#include <sys/time.h>
43
 
44
time_t
45
_DEFUN (time, (t),
46
        time_t * t)
47
{
48
  struct timeval now;
49
 
50
  if (_gettimeofday_r (_REENT, &now, (struct timezone *) 0) >= 0)
51
    {
52
      if (t)
53
        *t = now.tv_sec;
54
      return now.tv_sec;
55
    }
56
  return -1;
57
}
58
 
59
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.