Back to index

glibc  2.9
Classes | Defines | Functions | Variables
adjtime.c File Reference
#include <shlib-compat.h>
#include <sysdep.h>
#include <sys/time.h>
#include <kernel-features.h>
#include <sysdeps/unix/sysv/linux/adjtime.c>
#include <stdbool.h>

Go to the source code of this file.

Classes

struct  timeval32
struct  timex32

Defines

#define TIMEVAL   timeval32
#define TIMEX   timex32
#define ADJTIME   attribute_compat_text_section __adjtime_tv32
#define ADJTIMEX(x)   INLINE_SYSCALL (old_adjtimex, 1, x)
#define ADJTIMEX32(x)   INLINE_SYSCALL (old_adjtimex, 1, x)
#define LINKAGE   static
#define TIMEVAL   timeval
#define TIMEX   timex
#define ADJTIMEX(x)   INLINE_SYSCALL (adjtimex, 1, x)
#define LINKAGE   static
#define ADJTIME   __adjtime_tv64

Functions

LINKAGE int ADJTIME (const struct TIMEVAL *itv, struct TIMEVAL *otv)
int __adjtime (struct timeval *itv, struct timeval *otv) const
 versioned_symbol (libc, __adjtime, adjtime, GLIBC_2_1)
int __adjtimex_tv64 (struct timex *tx)
 strong_alias (__adjtimex_tv64, __adjtimex_internal)
 strong_alias (__adjtimex_tv64, __adjtimex_tv64p)
 weak_alias (__adjtimex_tv64, ntp_adjtime)
 versioned_symbol (libc, __adjtimex_tv64, __adjtimex, GLIBC_2_1)
 versioned_symbol (libc, __adjtimex_tv64p, adjtimex, GLIBC_2_1)

Variables

static bool missing_adjtimex

Class Documentation

struct timeval32

Definition at line 25 of file adjtime.c.

Class Members
int tv_sec
int tv_usec
struct timex32

Definition at line 30 of file adjtime.c.

Class Members
int __pad0__:32
int __pad10__:32
int __pad11__:32
int __pad1__:32
int __pad2__:32
int __pad3__:32
int __pad4__:32
int __pad5__:32
int __pad6__:32
int __pad7__:32
int __pad8__:32
int __pad9__:32
long calcnt
long constant
long errcnt
long esterror
long freq
long jitcnt
long jitter
long maxerror
unsigned int modes
long offset
long ppsfreq
long precision
int shift
long stabil
int status
long stbcnt
long tick
long tolerance

Define Documentation

#define ADJTIME   attribute_compat_text_section __adjtime_tv32

Definition at line 97 of file adjtime.c.

#define ADJTIME   __adjtime_tv64

Definition at line 97 of file adjtime.c.

#define ADJTIMEX (   x)    INLINE_SYSCALL (old_adjtimex, 1, x)

Definition at line 91 of file adjtime.c.

#define ADJTIMEX (   x)    INLINE_SYSCALL (adjtimex, 1, x)

Definition at line 91 of file adjtime.c.

#define ADJTIMEX32 (   x)    INLINE_SYSCALL (old_adjtimex, 1, x)

Definition at line 63 of file adjtime.c.

#define LINKAGE   static

Definition at line 96 of file adjtime.c.

#define LINKAGE   static

Definition at line 96 of file adjtime.c.

#define TIMEVAL   timeval32

Definition at line 87 of file adjtime.c.

#define TIMEVAL   timeval

Definition at line 87 of file adjtime.c.

#define TIMEX   timex32

Definition at line 89 of file adjtime.c.

#define TIMEX   timex

Definition at line 89 of file adjtime.c.


Function Documentation

int __adjtime ( struct timeval itv,
struct timeval otv 
) const

Definition at line 107 of file adjtime.c.

{
  struct timeval32 itv32, otv32;
  int ret;

  switch (missing_adjtimex)
    {
    case false:
      ret = __adjtime_tv64 (itv, otv);
      if (ret && errno == ENOSYS)
       missing_adjtimex = 1;
      else
       break;

      /* FALLTHRU */

    default:
      itv32.tv_sec = itv->tv_sec;
      itv32.tv_usec = itv->tv_usec;
      ret = __adjtime_tv32 (&itv32, &otv32);
      if (ret == 0)
       {
         otv->tv_sec = otv32.tv_sec;
         otv->tv_usec = otv32.tv_usec;
       }
      break;
    }

  return ret;
}
int __adjtimex_tv64 ( struct timex tx)

Definition at line 144 of file adjtime.c.

{
#if defined __ASSUME_TIMEVAL64
  return ADJTIMEX (tx);
#else
  struct timex32 tx32;
  int ret;

  switch (missing_adjtimex)
    {
    case false:
      ret = ADJTIMEX (tx);
      if (ret && errno == ENOSYS)
       missing_adjtimex = 1;
      else
       break;

      /* FALLTHRU */

    default:
      tx32.modes = tx->modes;
      tx32.offset = tx->offset;
      tx32.freq = tx->freq;
      tx32.maxerror = tx->maxerror;
      tx32.esterror = tx->esterror;
      tx32.status = tx->status;
      tx32.constant = tx->constant;
      tx32.precision = tx->precision;
      tx32.tolerance = tx->tolerance;
      tx32.time.tv_sec = tx->time.tv_sec;
      tx32.time.tv_sec = tx->time.tv_usec;
      tx32.tick = tx->tick;
      tx32.ppsfreq = tx->ppsfreq;
      tx32.jitter = tx->jitter;
      tx32.shift = tx->shift;
      tx32.stabil = tx->stabil;
      tx32.jitcnt = tx->jitcnt;
      tx32.calcnt = tx->calcnt;
      tx32.errcnt = tx->errcnt;
      tx32.stbcnt = tx->stbcnt;

      ret = ADJTIMEX32 (&tx32);
      if (ret == 0)
       {
         tx->modes = tx32.modes;
         tx->offset = tx32.offset;
         tx->freq = tx32.freq;
         tx->maxerror = tx32.maxerror;
         tx->esterror = tx32.esterror;
         tx->status = tx32.status;
         tx->constant = tx32.constant;
         tx->precision = tx32.precision;
         tx->tolerance = tx32.tolerance;
         tx->time.tv_sec = tx32.time.tv_sec;
         tx->time.tv_usec = tx32.time.tv_sec;
         tx->tick = tx32.tick;
         tx->ppsfreq = tx32.ppsfreq;
         tx->jitter = tx32.jitter;
         tx->shift = tx32.shift;
         tx->stabil = tx32.stabil;
         tx->jitcnt = tx32.jitcnt;
         tx->calcnt = tx32.calcnt;
         tx->errcnt = tx32.errcnt;
         tx->stbcnt = tx32.stbcnt;
       }
      break;
    }

  return ret;
#endif
}
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;
}
strong_alias ( __adjtimex_tv64  ,
__adjtimex_internal   
)
strong_alias ( __adjtimex_tv64  ,
__adjtimex_tv64p   
)
versioned_symbol ( libc  ,
__adjtime  ,
adjtime  ,
GLIBC_2_1   
)
versioned_symbol ( libc  ,
__adjtimex_tv64  ,
__adjtimex  ,
GLIBC_2_1   
)
versioned_symbol ( libc  ,
__adjtimex_tv64p  ,
adjtimex  ,
GLIBC_2_1   
)

Variable Documentation

bool missing_adjtimex [static]

Definition at line 104 of file adjtime.c.