Back to index

glibc  2.9
Defines | Functions
adjtime.c File Reference
#include <errno.h>
#include <limits.h>
#include <sys/time.h>
#include <sys/timex.h>
#include <kernel-features.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define MAX_SEC   (INT_MAX / 1000000L - 2)
#define MIN_SEC   (INT_MIN / 1000000L + 2)
#define modes   mode
#define TIMEVAL   timeval
#define TIMEX   timex
#define ADJTIME   __adjtime
#define NO_LOCAL_ADJTIME
#define ADJTIMEX(x)   INTUSE(__adjtimex) (x)
#define LINKAGE

Functions

int INTUSE() __adjtimex (struct timex *__ntx)
LINKAGE int ADJTIME (const struct TIMEVAL *itv, struct TIMEVAL *otv)

Define Documentation

#define ADJTIME   __adjtime

Definition at line 43 of file adjtime.c.

#define ADJTIMEX (   x)    INTUSE(__adjtimex) (x)

Definition at line 48 of file adjtime.c.

#define LINKAGE

Definition at line 53 of file adjtime.c.

#define MAX_SEC   (INT_MAX / 1000000L - 2)

Definition at line 27 of file adjtime.c.

#define MIN_SEC   (INT_MIN / 1000000L + 2)

Definition at line 28 of file adjtime.c.

#define modes   mode

Definition at line 31 of file adjtime.c.

Definition at line 47 of file adjtime.c.

#define TIMEVAL   timeval

Definition at line 35 of file adjtime.c.

#define TIMEX   timex

Definition at line 39 of file adjtime.c.


Function Documentation

int INTUSE() __adjtimex ( struct timex __ntx)

Here is the caller graph for this function:

LINKAGE int ADJTIME ( const struct TIMEVAL itv,
struct TIMEVAL otv 
)

Definition at line 57 of file adjtime.c.

{
  struct TIMEX tntx;

  if (itv)
    {
      struct TIMEVAL tmp;

      /* We will do some check here. */
      tmp.tv_sec = itv->tv_sec + itv->tv_usec / 1000000L;
      tmp.tv_usec = itv->tv_usec % 1000000L;
      if (tmp.tv_sec > MAX_SEC || tmp.tv_sec < MIN_SEC)
       {
         __set_errno (EINVAL);
         return -1;
       }
      tntx.offset = tmp.tv_usec + tmp.tv_sec * 1000000L;
      tntx.modes = ADJ_OFFSET_SINGLESHOT;
    }
  else
    {
#ifdef ADJ_OFFSET_SS_READ
      tntx.modes = ADJ_OFFSET_SS_READ;
#else
      tntx.modes = 0;
#endif
    }

#if defined ADJ_OFFSET_SS_READ && !defined __ASSUME_ADJ_OFFSET_SS_READ
 again:
#endif
  if (__builtin_expect (ADJTIMEX (&tntx) < 0, 0))
    {
#if defined ADJ_OFFSET_SS_READ && !defined __ASSUME_ADJ_OFFSET_SS_READ
      if (itv && errno == EINVAL && tntx.modes == ADJ_OFFSET_SS_READ)
       {
         tntx.modes = ADJ_OFFSET_SINGLESHOT;
         goto again;
       }
#endif
      return -1;
    }

  if (otv)
    {
      if (tntx.offset < 0)
       {
         otv->tv_usec = -(-tntx.offset % 1000000);
         otv->tv_sec  = -(-tntx.offset / 1000000);
       }
      else
       {
         otv->tv_usec = tntx.offset % 1000000;
         otv->tv_sec  = tntx.offset / 1000000;
       }
    }
  return 0;
}