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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [newlib/] [newlib/] [libc/] [sys/] [go32/] [time.c] - Blame information for rev 1774

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

Line No. Rev Author Line
1 39 lampret
/*
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
This function is a wrapper for <<gettimeofday>>; this pollutes the
29
namespace, and should be dealt with in the future.
30
*/
31
 
32
#include <_ansi.h>
33
#include <sys/types.h>
34
#include <sys/time.h>
35
 
36
time_t
37
_DEFUN(time,(t),
38
        time_t *t)
39
{
40
  struct timeval now;
41
 
42
  if (gettimeofday(&now, (struct timezone *)0) >= 0)
43
  {
44
    if (t)
45
    {
46
      *t = now.tv_sec;
47
    }
48
 
49
    return now.tv_sec;
50
 
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.