error = copyout(&user_ntv, uap->ntvp, sizeof(user_ntv));
} else {
struct user32_ntptimeval user_ntv = {};
- user_ntv.time.tv_sec = ntv.time.tv_sec;
- user_ntv.time.tv_nsec = ntv.time.tv_nsec;
- user_ntv.maxerror = ntv.maxerror;
- user_ntv.esterror = ntv.esterror;
- user_ntv.tai = ntv.tai;
+ user_ntv.time.tv_sec = (user32_long_t)ntv.time.tv_sec;
+ user_ntv.time.tv_nsec = (user32_long_t)ntv.time.tv_nsec;
+ user_ntv.maxerror = (user32_long_t)ntv.maxerror;
+ user_ntv.esterror = (user32_long_t)ntv.esterror;
+ user_ntv.tai = (user32_long_t)ntv.tai;
user_ntv.time_state = ntv.time_state;
error = copyout(&user_ntv, uap->ntvp, sizeof(user_ntv));
}
struct user64_timex user_ntv;
error = copyin(uap->tp, &user_ntv, sizeof(user_ntv));
ntv.modes = user_ntv.modes;
- ntv.offset = user_ntv.offset;
- ntv.freq = user_ntv.freq;
- ntv.maxerror = user_ntv.maxerror;
- ntv.esterror = user_ntv.esterror;
+ ntv.offset = (long)user_ntv.offset;
+ ntv.freq = (long)user_ntv.freq;
+ ntv.maxerror = (long)user_ntv.maxerror;
+ ntv.esterror = (long)user_ntv.esterror;
ntv.status = user_ntv.status;
- ntv.constant = user_ntv.constant;
- ntv.precision = user_ntv.precision;
- ntv.tolerance = user_ntv.tolerance;
+ ntv.constant = (long)user_ntv.constant;
+ ntv.precision = (long)user_ntv.precision;
+ ntv.tolerance = (long)user_ntv.tolerance;
} else {
struct user32_timex user_ntv;
error = copyin(uap->tp, &user_ntv, sizeof(user_ntv));
return error;
}
-#if DEVELOPEMNT || DEBUG
+#if DEVELOPMENT || DEBUG
if (g_should_log_clock_adjustments) {
os_log(OS_LOG_DEFAULT, "%s: BEFORE modes %u offset %ld freq %ld status %d constant %ld time_adjtime %lld\n",
__func__, ntv.modes, ntv.offset, ntv.freq, ntv.status, ntv.constant, time_adjtime);
ret = ntp_is_time_error(time_status) ? TIME_ERROR : time_state;
-#if DEVELOPEMNT || DEBUG
+#if DEVELOPMENT || DEBUG
if (g_should_log_clock_adjustments) {
os_log(OS_LOG_DEFAULT, "%s: AFTER modes %u offset %lld freq %lld status %d constant %ld time_adjtime %lld\n",
__func__, modes, time_offset, time_freq, time_status, time_constant, time_adjtime);
} else {
user_ntv.offset = L_GINT(time_offset) / 1000;
}
- user_ntv.freq = L_GINT((time_freq / 1000LL) << 16);
+ if (time_freq > 0) {
+ user_ntv.freq = L_GINT(((int64_t)(time_freq / 1000LL)) << 16);
+ } else {
+ user_ntv.freq = -L_GINT(((int64_t)(-(time_freq) / 1000LL)) << 16);
+ }
user_ntv.maxerror = time_maxerror;
user_ntv.esterror = time_esterror;
user_ntv.status = time_status;
} else {
user_ntv.offset = L_GINT(time_offset) / 1000;
}
- user_ntv.freq = L_GINT((time_freq / 1000LL) << 16);
- user_ntv.maxerror = time_maxerror;
- user_ntv.esterror = time_esterror;
+ if (time_freq > 0) {
+ user_ntv.freq = L_GINT((time_freq / 1000LL) << 16);
+ } else {
+ user_ntv.freq = -L_GINT((-(time_freq) / 1000LL) << 16);
+ }
+ user_ntv.maxerror = (user32_long_t)time_maxerror;
+ user_ntv.esterror = (user32_long_t)time_esterror;
user_ntv.status = time_status;
- user_ntv.constant = time_constant;
+ user_ntv.constant = (user32_long_t)time_constant;
if (time_status & STA_NANO) {
- user_ntv.precision = time_precision;
+ user_ntv.precision = (user32_long_t)time_precision;
} else {
- user_ntv.precision = time_precision / 1000;
+ user_ntv.precision = (user32_long_t)(time_precision / 1000);
}
user_ntv.tolerance = MAXFREQ * SCALE_PPM;
} else if (time_adjtime < -500) {
tickrate = -500;
} else {
- tickrate = time_adjtime;
+ tickrate = (int)time_adjtime;
}
time_adjtime -= tickrate;
L_LINT(ftemp, tickrate * 1000);
updated = 0;
}
-#if DEVELOPEMNT || DEBUG
+#if DEVELOPMENT || DEBUG
if (g_should_log_clock_adjustments) {
int64_t nano = (time_adj > 0)? time_adj >> 32 : -((-time_adj) >> 32);
int64_t frac = (time_adj > 0)? ((uint32_t) time_adj) : -((uint32_t) (-time_adj));
NTP_LOCK(enable);
ltr = time_adjtime;
time_adjtime = ltw;
-#if DEVELOPEMNT || DEBUG
+#if DEVELOPMENT || DEBUG
if (g_should_log_clock_adjustments) {
os_log(OS_LOG_DEFAULT, "%s:AFTER offset %lld freq %lld status %d constant %ld time_adjtime %lld\n",
__func__, time_offset, time_freq, time_status, time_constant, time_adjtime);
#endif
NTP_UNLOCK(enable);
- atv.tv_sec = ltr / (int64_t)USEC_PER_SEC;
+ atv.tv_sec = (__darwin_time_t)(ltr / (int64_t)USEC_PER_SEC);
atv.tv_usec = ltr % (int64_t)USEC_PER_SEC;
if (atv.tv_usec < 0) {
atv.tv_usec += (suseconds_t)USEC_PER_SEC;
if (IS_64BIT_PROCESS(p)) {
struct user64_timeval user_atv;
error = copyin(uap->delta, &user_atv, sizeof(user_atv));
- atv.tv_sec = user_atv.tv_sec;
+ atv.tv_sec = (__darwin_time_t)user_atv.tv_sec;
atv.tv_usec = user_atv.tv_usec;
} else {
struct user32_timeval user_atv;
error = copyout(&user_atv, uap->olddelta, sizeof(user_atv));
} else {
struct user32_timeval user_atv = {};
- user_atv.tv_sec = atv.tv_sec;
+ user_atv.tv_sec = (user32_time_t)atv.tv_sec;
user_atv.tv_usec = atv.tv_usec;
error = copyout(&user_atv, uap->olddelta, sizeof(user_atv));
}