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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [newlib-1.10.0/] [newlib/] [libc/] [time/] [time.c] - Diff between revs 1010 and 1765

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 1010 Rev 1765
/* FIXME: doc says "not avail" due to #if 0.
/* FIXME: doc says "not avail" due to #if 0.
          DELETE that line if inappropriate! */
          DELETE that line if inappropriate! */
/*
/*
FUNCTION
FUNCTION
<<time>>---get current calendar time (as single number)
<<time>>---get current calendar time (as single number)
 
 
INDEX
INDEX
        time
        time
 
 
ANSI_SYNOPSIS
ANSI_SYNOPSIS
        #include <time.h>
        #include <time.h>
        time_t time(time_t *<[t]>);
        time_t time(time_t *<[t]>);
 
 
TRAD_SYNOPSIS
TRAD_SYNOPSIS
        #include <time.h>
        #include <time.h>
        time_t time(<[t]>)
        time_t time(<[t]>)
        time_t *<[t]>;
        time_t *<[t]>;
 
 
DESCRIPTION
DESCRIPTION
<<time>> looks up the best available representation of the current
<<time>> looks up the best available representation of the current
time and returns it, encoded as a <<time_t>>.  It stores the same
time and returns it, encoded as a <<time_t>>.  It stores the same
value at <[t]> unless the argument is <<NULL>>.
value at <[t]> unless the argument is <<NULL>>.
 
 
RETURNS
RETURNS
A <<-1>> result means the current time is not available; otherwise the
A <<-1>> result means the current time is not available; otherwise the
result represents the current time.
result represents the current time.
 
 
PORTABILITY
PORTABILITY
ANSI C requires <<time>>.
ANSI C requires <<time>>.
 
 
Supporting OS subroutine required: Some implementations require
Supporting OS subroutine required: Some implementations require
<<gettimeofday>>.
<<gettimeofday>>.
*/
*/
 
 
#ifdef HAVE_GETTIMEOFDAY
#ifdef HAVE_GETTIMEOFDAY
 
 
/* Most times we have a system call in newlib/libc/sys/.. to do this job */
/* Most times we have a system call in newlib/libc/sys/.. to do this job */
 
 
#include <_ansi.h>
#include <_ansi.h>
#include <reent.h>
#include <reent.h>
#include <sys/types.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/time.h>
 
 
time_t
time_t
_DEFUN (time, (t),
_DEFUN (time, (t),
        time_t * t)
        time_t * t)
{
{
  struct timeval now;
  struct timeval now;
 
 
  if (_gettimeofday_r (_REENT, &now, (struct timezone *) 0) >= 0)
  if (_gettimeofday_r (_REENT, &now, (struct timezone *) 0) >= 0)
    {
    {
      if (t)
      if (t)
        *t = now.tv_sec;
        *t = now.tv_sec;
      return now.tv_sec;
      return now.tv_sec;
    }
    }
  return -1;
  return -1;
}
}
 
 
#endif
#endif
 
 

powered by: WebSVN 2.1.0

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