Ejemplo n.º 1
0
int gettimeofday(struct timeval *tvp)

{
/* Documented, supported MPE functions. */
extern void GETPRIVMODE(void);
extern void GETUSERMODE(void);

/* Undocumented, unsupported MPE functions. */
extern long long get_time(void);
extern void get_time_change_info(long long *, char *, char *);
extern long long ticks_to_micro(long long);

char pwf_since_boot, recover_pwf_time;
long long mpetime, offset_ticks, offset_usec;

GETPRIVMODE();
mpetime = get_time(); /* MPE local time usecs since Jan 1 1970 */
get_time_change_info(&offset_ticks, &pwf_since_boot, &recover_pwf_time);
offset_usec = ticks_to_micro(offset_ticks);  /* UTC offset usecs */
GETUSERMODE();

mpetime = mpetime - offset_usec;  /* Convert from local time to UTC */
tvp->tv_sec = mpetime / 1000000LL;
tvp->tv_usec = mpetime % 1000000LL;

return 0;
}
Ejemplo n.º 2
0
int settimeofday(struct timeval *tvp)

{
/* Documented, supported MPE functions. */
extern void GETPRIVMODE(void);
extern void GETUSERMODE(void);

/* Undocumented, unsupported MPE functions. */
extern void get_time_change_info(long long *, char *, char *);
extern void initialize_system_time(long long, int);
extern void set_time_correction(long long, int, int);
extern long long ticks_to_micro(long long);

char pwf_since_boot, recover_pwf_time;
long long big_sec, big_usec, mpetime, offset_ticks, offset_usec;

big_sec = tvp->tv_sec;
big_usec = tvp->tv_usec;
mpetime = (big_sec * 1000000LL) + big_usec;  /* Desired UTC microseconds */

GETPRIVMODE();
set_time_correction(0LL,0,0); /* Cancel previous time correction, if any */
get_time_change_info(&offset_ticks, &pwf_since_boot, &recover_pwf_time);
offset_usec = ticks_to_micro(offset_ticks); /* UTC offset microseconds */
mpetime = mpetime + offset_usec; /* Convert from UTC to local time */
initialize_system_time(mpetime,1);
GETUSERMODE();

return 0;
}
Ejemplo n.º 3
0
int adjtime(struct timeval *delta, struct timeval *olddelta)

{
/* Documented, supported MPE system intrinsics. */

extern void GETPRIVMODE(void);
extern void GETUSERMODE(void);

/* Undocumented, unsupported MPE internal functions. */

extern long long current_correction_usecs(void);
extern long long get_time(void);
extern void get_time_change_info(long long *, char *, char *);
extern long long pdc_time(int *);
extern void set_time_correction(long long, int, int);
extern long long ticks_to_micro(long long);

long long big_sec, big_usec, new_correction = 0LL;
long long prev_correction;

if (delta != NULL) {
  /* Adjustment required.  Convert delta to 64-bit microseconds. */
  big_sec = (long)delta->tv_sec;
  big_usec = delta->tv_usec;
  new_correction = (big_sec * 1000000LL) + big_usec;
}

GETPRIVMODE();

/* Determine how much of a previous correction (if any) we're interrupting. */
prev_correction = current_correction_usecs();

if (delta != NULL) {
  /* Adjustment required. */

#if 0
  /* Speculative code disabled until bug SR 5003462838 is fixed.  This bug
     prevents accurate time slewing, and indeed renders ntpd inoperable. */

  if (prev_correction != 0LL) {
    /* A previous adjustment did not complete.  Since the PDC UTC clock was
    immediately jumped at the start of the previous adjustment, we must
    explicitly reset it to the value of the MPE local time clock minus the
    time zone offset. */

    char pwf_since_boot, recover_pwf_time;
    long long offset_ticks, offset_usecs, pdc_usecs_current, pdc_usecs_wanted;
    int hpe_status;

    get_time_change_info(&offset_ticks, &pwf_since_boot, &recover_pwf_time);
    offset_usecs = ticks_to_micro(offset_ticks);
    pdc_usecs_wanted = get_time() - offset_usecs;
    pdc_usecs_current = pdc_time(&hpe_status);
    if (hpe_status == 0) 
      /* Force new PDC time by starting an extra correction. */
      set_time_correction(pdc_usecs_wanted - pdc_usecs_current,0,1);
  }
#endif /* 0 */
    
  /* Immediately jump the PDC time to the new value, and then initiate a 
     gradual MPE time correction slew. */
  set_time_correction(new_correction,0,1);
}

GETUSERMODE();

if (olddelta != NULL) {
  /* Caller wants to know remaining amount of previous correction. */
  (long)olddelta->tv_sec = prev_correction / 1000000LL;
  olddelta->tv_usec = prev_correction % 1000000LL;
}

return 0;
}