Back to index

glibc  2.9
Defines | Functions
time.h File Reference
#include <time/sys/time.h>

Go to the source code of this file.

Defines

#define __gettimeofday(tv, tz)   INTUSE(__gettimeofday) (tv, tz)

Functions

int __gettimeofday (struct timeval *__tv, struct timezone *__tz)
int __gettimeofday_internal (struct timeval *__tv, struct timezone *__tz) attribute_hidden
int __settimeofday (__const struct timeval *__tv, __const struct timezone *__tz) attribute_hidden
int __adjtime (__const struct timeval *__delta, struct timeval *__olddelta)
int __getitimer (enum __itimer_which __which, struct itimerval *__value)
int __setitimer (enum __itimer_which __which, __const struct itimerval *__restrict __new, struct itimerval *__restrict __old) attribute_hidden
int __utimes (__const char *__file, const struct timeval __tvp[2]) attribute_hidden
int __futimes (int fd, __const struct timeval tvp[2]) attribute_hidden

Define Documentation

#define __gettimeofday (   tv,
  tz 
)    INTUSE(__gettimeofday) (tv, tz)

Definition at line 26 of file time.h.


Function Documentation

int __adjtime ( __const struct timeval __delta,
struct timeval __olddelta 
)
int __futimes ( int  fd,
__const struct timeval  tvp[2] 
)

Here is the caller graph for this function:

int __getitimer ( enum __itimer_which  __which,
struct itimerval __value 
)

Definition at line 46 of file getitimer.c.

{
  struct itimerval val;
  struct timeval elapsed;

  switch (which)
    {
    default:
      return __hurd_fail (EINVAL);

    case ITIMER_VIRTUAL:
    case ITIMER_PROF:
      return __hurd_fail (ENOSYS);

    case ITIMER_REAL:
      break;
    }

  /* Get the time now.  */
  if (__gettimeofday (&elapsed, NULL) < 0)
    return -1;

  /* Extract the current timer setting; and the time it was set, so we can
     calculate the time elapsed so far.  */
  HURD_CRITICAL_BEGIN;
  __spin_lock (&_hurd_itimer_lock);
  val = _hurd_itimerval;
  subtract_timeval (&elapsed, &_hurd_itimer_started);
  __spin_unlock (&_hurd_itimer_lock);
  HURD_CRITICAL_END;

  if ((val.it_value.tv_sec | val.it_value.tv_usec) != 0)
    {
      /* There is a pending alarm set.  VAL indicates the interval it was
        set for, relative to the time recorded in _hurd_itimer_started.
        Now compensate for the time elapsed since to get the user's
        conception of the current value of the timer (as if the value
        stored decreased every microsecond).  */
      if (timercmp (&val.it_value, &elapsed, <))
       {
         /* Hmm.  The timer should have just gone off, but has not been
            reset.  This is a possible timing glitch.  The alarm will signal
            soon, so fabricate a value for how soon.  */
         val.it_value.tv_sec = 0;
         val.it_value.tv_usec = 10; /* Random.  */
       }
      else
       /* Subtract the time elapsed since the timer was set
          from the current timer value the user sees.  */
       subtract_timeval (&val.it_value, &elapsed);
    }

  *value = val;
  return 0;
}

Here is the call graph for this function:

int __gettimeofday ( struct timeval __tv,
struct timezone *  __tz 
)

Definition at line 47 of file gettimeofday.c.

{
  int ts, tl, tu;

  if (tv == NULL)
    {
      __set_errno (EINVAL);
      return -1;
    }

  ts = rtc_upper ();        /* Seconds.  */
  tl = rtc_lower ();        /* Nanoseconds.  */
  tu = rtc_upper ();        /* Check for a carry from.  */
  if (ts != tu)                    /* The lower reg to the upper.  */
      tl  = rtc_lower ();   /* Recover from the race condition.  */

  tv->tv_sec  = (long int) (tu + (double) tl / 1000000000);
  tv->tv_usec = (long int) ((double) tl / 1000);

  if (tz != NULL)
    {
      const  time_t timer = tv->tv_sec;
      struct tm tm;
      const  struct tm *tmp;

      const long int save_timezone = __timezone;
      const long int save_daylight = __daylight;
      char *save_tzname[2];
      save_tzname[0] = __tzname[0];
      save_tzname[1] = __tzname[1];

      tmp = localtime_r (&timer, &tm);

      tz->tz_minuteswest = __timezone / 60;
      tz->tz_dsttime     = __daylight;

      __timezone  = save_timezone;
      __daylight  = save_daylight;
      __tzname[0] = save_tzname[0];
      __tzname[1] = save_tzname[1];

      if (tmp == NULL)
       return -1;
    }

  return 0;
}

Here is the call graph for this function:

int __gettimeofday_internal ( struct timeval __tv,
struct timezone *  __tz 
)
int __setitimer ( enum __itimer_which  __which,
__const struct itimerval *__restrict  __new,
struct itimerval *__restrict  __old 
)

Here is the caller graph for this function:

int __settimeofday ( __const struct timeval __tv,
__const struct timezone *  __tz 
)

Here is the caller graph for this function:

int __utimes ( __const char *  __file,
const struct timeval  __tvp[2] 
)

Here is the caller graph for this function: