Extending time_t to 64bits.

Change-Id: Ia96b8bfba19cb8179a0237a7d2122d415c24d73f
This commit is contained in:
Lionel Sambuc 2013-09-20 19:47:18 +02:00
parent 42e13282d7
commit 55d9e9954b
19 changed files with 62 additions and 60 deletions

View file

@ -161,12 +161,12 @@ static void vbox_update_time(void)
sizeof(*req)) == VMMDEV_ERR_OK) {
time(&otime); /* old time */
ntime = (unsigned long)(req->time / 1000); /* new time */
ntime = req->time / 1000; /* new time */
/* Make time go forward, if the difference exceeds the drift
* threshold. Never make time go backward.
*/
if ((int) (ntime - otime) >= drift)
if ((ntime - otime) >= drift)
stime(&ntime);
}

View file

@ -437,14 +437,14 @@
#define T_ENDPT m4_l1 /* process to request time info for */
#define T_USER_TIME m4_l1 /* user time consumed by process */
#define T_SYSTEM_TIME m4_l2 /* system time consumed by process */
#define T_BOOTTIME m4_l3 /* Boottime in seconds (also for SYS_STIME) */
#define T_BOOTTIME m4_ll1 /* Boottime in seconds (also for SYS_STIME) */
#define T_REAL_TICKS m4_l4 /* number of wall clock ticks since boottime */
#define T_BOOT_TICKS m4_l5 /* number of hard clock ticks since boottime */
/* Field names for SYS_SETTIME. */
#define T_SETTIME_NOW m4_l2 /* non-zero for immediate, 0 for adjtime */
#define T_CLOCK_ID m4_l3 /* clock to adjust */
#define T_TIME_SEC m4_l4 /* time in seconds since 1970 */
#define T_TIME_SEC m4_ll1 /* time in seconds since 1970 */
#define T_TIME_NSEC m4_l5 /* number of nano seconds */
/* Field names for SYS_TRACE, SYS_PRIVCTL, SYS_STATECTL. */

View file

@ -53,8 +53,9 @@ typedef struct {
_ASSERT_MSG_SIZE(mess_3);
typedef struct {
int64_t m4ll1;
long m4l1, m4l2, m4l3, m4l4, m4l5;
uint8_t padding[36];
uint8_t padding[28];
} mess_4;
_ASSERT_MSG_SIZE(mess_4);
@ -220,6 +221,7 @@ typedef int _ASSERT_message[/* CONSTCOND */sizeof(message) == 64 ?1 : -1];
#define m3_p1 m_u.m_m3.m3p1
#define m3_ca1 m_u.m_m3.m3ca1
#define m4_ll1 m_u.m_m4.m4ll1
#define m4_l1 m_u.m_m4.m4l1
#define m4_l2 m_u.m_m4.m4l2
#define m4_l3 m_u.m_m4.m4l3

View file

@ -4,7 +4,7 @@
* The parameters for this kernel call are:
* m4_l2: T_SETTIME_NOW
* m4_l3: T_CLOCK_ID
* m4_l4: T_TIME_SEC
* m4_ll1: T_TIME_SEC
* m4_l5: T_TIME_NSEC
*/
@ -19,8 +19,7 @@ int do_settime(struct proc * caller, message * m_ptr)
{
clock_t newclock;
int32_t ticks;
time_t timediff;
signed long long timediff_ticks;
time_t timediff, timediff_ticks;
if (m_ptr->T_CLOCK_ID != CLOCK_REALTIME) /* only realtime can change */
return EINVAL;
@ -34,7 +33,7 @@ int do_settime(struct proc * caller, message * m_ptr)
} /* else user wants to set the time */
timediff = m_ptr->T_TIME_SEC - boottime;
timediff_ticks = (signed long long) timediff * system_hz;
timediff_ticks = timediff * system_hz;
/* prevent a negative value for realtime */
if (m_ptr->T_TIME_SEC <= boottime ||

View file

@ -2,7 +2,7 @@
* m_type: SYS_STIME
*
* The parameters for this kernel call are:
* m4_l3: T_BOOTTIME
* m4_ll1: T_BOOTTIME
*/
#include "kernel/system.h"

View file

@ -5,7 +5,7 @@
* m4_l1: T_ENDPT (get info for this process)
* m4_l1: T_USER_TIME (return values ...)
* m4_l2: T_SYSTEM_TIME
* m4_l3: T_BOOTTIME
* m4_ll1: T_BOOTTIME
* m4_l5: T_BOOT_TICKS
*/
@ -37,7 +37,7 @@ int do_times(struct proc * caller, message * m_ptr)
}
m_ptr->T_BOOT_TICKS = get_monotonic();
m_ptr->T_REAL_TICKS = get_realtime();
m_ptr->T_BOOTTIME = boottime;
m_ptr->T_BOOTTIME = boottime;
return(OK);
}

View file

@ -17,8 +17,8 @@ int adjtime(const struct timeval *delta, struct timeval *olddelta)
memset(&m, 0, sizeof(m));
m.PM_TIME_CLK_ID = (clockid_t) CLOCK_REALTIME;
m.PM_TIME_NOW = 0; /* use adjtime() method to slowly adjust the clock. */
m.PM_TIME_SEC = (time_t) delta->tv_sec;
m.PM_TIME_NSEC = (long) delta->tv_usec * 1000; /* convert usec to nsec */
m.PM_TIME_SEC = (int32_t)delta->tv_sec;
m.PM_TIME_NSEC = (int32_t)delta->tv_usec * 1000; /* convert usec to nsec */
if (_syscall(PM_PROC_NR, PM_CLOCK_SETTIME, &m) < 0)
return -1;

View file

@ -19,8 +19,8 @@ int clock_getres(clockid_t clock_id, struct timespec *res)
if (_syscall(PM_PROC_NR, PM_CLOCK_GETRES, &m) < 0)
return -1;
res->tv_sec = (time_t) m.PM_TIME_SEC;
res->tv_nsec = (long) m.PM_TIME_NSEC;
res->tv_sec = m.PM_TIME_SEC;
res->tv_nsec = m.PM_TIME_NSEC;
return 0;
}

View file

@ -14,10 +14,11 @@ int futimens(int fd, const struct timespec tv[2])
memset(&m, 0, sizeof(m));
m.VFS_UTIMENS_FD = fd;
m.VFS_UTIMENS_ATIME = tv[0].tv_sec;
m.VFS_UTIMENS_MTIME = tv[1].tv_sec;
m.VFS_UTIMENS_ANSEC = tv[0].tv_nsec;
m.VFS_UTIMENS_MNSEC = tv[1].tv_nsec;
/* For now just truncate to 32bit time_t values. */
m.VFS_UTIMENS_ATIME = (int32_t)tv[0].tv_sec;
m.VFS_UTIMENS_MTIME = (int32_t)tv[1].tv_sec;
m.VFS_UTIMENS_ANSEC = (int32_t)tv[0].tv_nsec;
m.VFS_UTIMENS_MNSEC = (int32_t)tv[1].tv_nsec;
m.VFS_UTIMENS_NAME = NULL;
m.VFS_UTIMENS_FLAGS = 0;

View file

@ -21,10 +21,10 @@ int futimes(int fd, const struct timeval tv[2])
m.VFS_UTIMENS_ANSEC = m.VFS_UTIMENS_MNSEC = UTIME_NOW;
}
else {
m.VFS_UTIMENS_ATIME = tv[0].tv_sec;
m.VFS_UTIMENS_MTIME = tv[1].tv_sec;
m.VFS_UTIMENS_ANSEC = tv[0].tv_usec * 1000;
m.VFS_UTIMENS_MNSEC = tv[1].tv_usec * 1000;
m.VFS_UTIMENS_ATIME = (int32_t)tv[0].tv_sec;
m.VFS_UTIMENS_MTIME = (int32_t)tv[1].tv_sec;
m.VFS_UTIMENS_ANSEC = (int32_t)tv[0].tv_usec * 1000;
m.VFS_UTIMENS_MNSEC = (int32_t)tv[1].tv_usec * 1000;
}
m.VFS_UTIMENS_NAME = NULL;
m.VFS_UTIMENS_FLAGS = 0;

View file

@ -32,10 +32,11 @@ int lutimes(const char *name, const struct timeval tv[2])
m.VFS_UTIMENS_ANSEC = m.VFS_UTIMENS_MNSEC = UTIME_NOW;
}
else {
m.VFS_UTIMENS_ATIME = tv[0].tv_sec;
m.VFS_UTIMENS_MTIME = tv[1].tv_sec;
m.VFS_UTIMENS_ANSEC = tv[0].tv_usec * 1000;
m.VFS_UTIMENS_MNSEC = tv[1].tv_usec * 1000;
/* For now just truncate time_t values to 32bits. */
m.VFS_UTIMENS_ATIME = (int32_t)tv[0].tv_sec;
m.VFS_UTIMENS_MTIME = (int32_t)tv[1].tv_sec;
m.VFS_UTIMENS_ANSEC = (int32_t)tv[0].tv_usec * 1000;
m.VFS_UTIMENS_MNSEC = (int32_t)tv[1].tv_usec * 1000;
}
m.VFS_UTIMENS_FLAGS = AT_SYMLINK_NOFOLLOW;

View file

@ -46,10 +46,11 @@ int utimensat(int fd, const char *name, const struct timespec tv[2],
memset(&m, 0, sizeof(m));
m.VFS_UTIMENS_LEN = strlen(name) + 1;
m.VFS_UTIMENS_NAME = (char *) __UNCONST(name);
m.VFS_UTIMENS_ATIME = tv[0].tv_sec;
m.VFS_UTIMENS_MTIME = tv[1].tv_sec;
m.VFS_UTIMENS_ANSEC = tv[0].tv_nsec;
m.VFS_UTIMENS_MNSEC = tv[1].tv_nsec;
/* For now just truncate time_t values to 32bits. */
m.VFS_UTIMENS_ATIME = (int32_t)tv[0].tv_sec;
m.VFS_UTIMENS_MTIME = (int32_t)tv[1].tv_sec;
m.VFS_UTIMENS_ANSEC = (int32_t)tv[0].tv_nsec;
m.VFS_UTIMENS_MNSEC = (int32_t)tv[1].tv_nsec;
m.VFS_UTIMENS_FLAGS = flags;
return(_syscall(VFS_PROC_NR, VFS_UTIMENS, &m));

View file

@ -31,10 +31,11 @@ int utimes(const char *name, const struct timeval tv[2])
m.VFS_UTIMENS_ANSEC = m.VFS_UTIMENS_MNSEC = UTIME_NOW;
}
else {
m.VFS_UTIMENS_ATIME = tv[0].tv_sec;
m.VFS_UTIMENS_MTIME = tv[1].tv_sec;
m.VFS_UTIMENS_ANSEC = tv[0].tv_usec * 1000;
m.VFS_UTIMENS_MNSEC = tv[1].tv_usec * 1000;
/* For now just truncate time_t values to 32bits. */
m.VFS_UTIMENS_ATIME = (int32_t)tv[0].tv_sec;
m.VFS_UTIMENS_MTIME = (int32_t)tv[1].tv_sec;
m.VFS_UTIMENS_ANSEC = (int32_t)tv[0].tv_usec * 1000;
m.VFS_UTIMENS_MNSEC = (int32_t)tv[1].tv_usec * 1000;
}
m.VFS_UTIMENS_FLAGS = 0;

View file

@ -1,20 +1,16 @@
#include "syslib.h"
#include <time.h>
int sys_settime(now, clk_id, sec, nsec)
int now;
clockid_t clk_id;
time_t sec;
long nsec;
int sys_settime(int now, clockid_t clk_id, time_t sec, long nsec)
{
message m;
int r;
message m;
int r;
m.T_SETTIME_NOW = now;
m.T_CLOCK_ID = clk_id;
m.T_TIME_SEC = sec;
m.T_TIME_NSEC = nsec;
m.T_SETTIME_NOW = now;
m.T_CLOCK_ID = clk_id;
m.T_TIME_SEC = sec;
m.T_TIME_NSEC = nsec;
r = _kernel_call(SYS_SETTIME, &m);
return(r);
r = _kernel_call(SYS_SETTIME, &m);
return r;
}

View file

@ -38,9 +38,10 @@ int do_gettime()
return EINVAL; /* invalid/unsupported clock_id */
}
mp->mp_reply.PM_TIME_SEC = (time_t) (boottime + (clock / system_hz));
/* For now simply truncate time to a 32b value. */
mp->mp_reply.PM_TIME_SEC = (int32_t) (boottime + (clock / system_hz));
mp->mp_reply.PM_TIME_NSEC =
(long) ((clock % system_hz) * 1000000000ULL / system_hz);
(uint32_t) ((clock % system_hz) * 1000000000ULL / system_hz);
return(OK);
}
@ -54,7 +55,7 @@ int do_getres()
case CLOCK_REALTIME:
case CLOCK_MONOTONIC:
/* tv_sec is always 0 since system_hz is an int */
mp->mp_reply.PM_TIME_SEC = (time_t) 0;
mp->mp_reply.PM_TIME_SEC = 0;
mp->mp_reply.PM_TIME_NSEC = 1000000000 / system_hz;
return(OK);
default:
@ -101,9 +102,10 @@ int do_time()
if ( (s=getuptime(&ticks, &realtime, &boottime)) != OK)
panic("do_time couldn't get uptime: %d", s);
mp->mp_reply.PM_TIME_SEC = (time_t) (boottime + (realtime / system_hz));
/* For now simply truncate time to a 32b value. */
mp->mp_reply.PM_TIME_SEC = (int32_t) (boottime + (realtime / system_hz));
mp->mp_reply.PM_TIME_USEC =
(long) ((realtime % system_hz) * 1000000ULL / system_hz);
(uint32_t) ((realtime % system_hz) * 1000000ULL / system_hz);
return(OK);
}
@ -124,7 +126,7 @@ int do_stime()
}
if ( (s=getuptime(&uptime, &realtime, &boottime)) != OK)
panic("do_stime couldn't get uptime: %d", s);
boottime = (long) m_in.PM_TIME_SEC - (realtime/system_hz);
boottime = (time_t)m_in.PM_TIME_SEC - (realtime/system_hz);
s= sys_stime(boottime); /* Tell kernel about boottime */
if (s != OK)

View file

@ -144,7 +144,7 @@ struct timespec clock_timespec(void)
if (r != OK)
panic("clock_timespec err: %d", r);
tv.tv_sec = (time_t) (boottime + (realtime/system_hz));
tv.tv_sec = boottime + (realtime/system_hz);
/* We do not want to overflow, and system_hz can be as high as 50kHz */
assert(system_hz < LONG_MAX/40000);
tv.tv_nsec = (realtime%system_hz) * 40000 / system_hz * 25000;

View file

@ -31,7 +31,6 @@
* from: @(#)ansi.h 8.2 (Berkeley) 1/4/94
*/
/* These types are Minix specific. */
#ifndef _ANSI_H_
#define _ANSI_H_
@ -53,7 +52,7 @@
#define _BSD_PTRDIFF_T_ int /* ptr1 - ptr2 */
#define _BSD_SIZE_T_ unsigned int /* sizeof() */
#define _BSD_SSIZE_T_ int /* byte count or error */
#define _BSD_TIME_T_ int /* time() */
#define _BSD_TIME_T_ __int64_t /* time() */
#define _BSD_CLOCKID_T_ int /* clockid_t */
#define _BSD_TIMER_T_ int /* timer_t */
#define _BSD_SUSECONDS_T_ int /* suseconds_t */

View file

@ -52,7 +52,7 @@
#define _BSD_PTRDIFF_T_ int /* ptr1 - ptr2 */
#define _BSD_SIZE_T_ unsigned int /* sizeof() */
#define _BSD_SSIZE_T_ int /* byte count or error */
#define _BSD_TIME_T_ int /* time() */
#define _BSD_TIME_T_ __int64_t /* time() */
#define _BSD_CLOCKID_T_ int /* clockid_t */
#define _BSD_TIMER_T_ int /* timer_t */
#define _BSD_SUSECONDS_T_ int /* suseconds_t */

View file

@ -132,7 +132,7 @@ static void parse_file(pid_t pid)
p->p_endpoint = endpt;
p->p_pid = pid;
if (fscanf(fp, " %255s %c %d %d %u %*u %lu %lu",
if (fscanf(fp, " %255s %c %d %d %llu %*u %lu %lu",
name, &state, &p->p_blocked, &p->p_priority,
&p->p_user_time, &cycles_hi, &cycles_lo) != 7) {