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

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-newlib/] [newlib-1.17.0/] [newlib/] [libc/] [time/] [time.c] - Blame information for rev 9

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 9 jlechner
/*
2
FUNCTION
3
<<time>>---get current calendar time (as single number)
4
 
5
INDEX
6
        time
7
 
8
ANSI_SYNOPSIS
9
        #include <time.h>
10
        time_t time(time_t *<[t]>);
11
 
12
TRAD_SYNOPSIS
13
        #include <time.h>
14
        time_t time(<[t]>)
15
        time_t *<[t]>;
16
 
17
DESCRIPTION
18
<<time>> looks up the best available representation of the current
19
time and returns it, encoded as a <<time_t>>.  It stores the same
20
value at <[t]> unless the argument is <<NULL>>.
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 <<time>>.
28
 
29
Supporting OS subroutine required: Some implementations require
30
<<gettimeofday>>.
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 <reent.h>
37
#include <sys/types.h>
38
#include <sys/time.h>
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
}

powered by: WebSVN 2.1.0

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