From 55d9e9954bb11f6977bf1be2d810601f379cbdf4 Mon Sep 17 00:00:00 2001 From: Lionel Sambuc Date: Fri, 20 Sep 2013 19:47:18 +0200 Subject: [PATCH] Extending time_t to 64bits. Change-Id: Ia96b8bfba19cb8179a0237a7d2122d415c24d73f --- drivers/vbox/vbox.c | 4 ++-- include/minix/com.h | 4 ++-- include/minix/ipc.h | 4 +++- kernel/system/do_settime.c | 7 +++---- kernel/system/do_stime.c | 2 +- kernel/system/do_times.c | 4 ++-- lib/libc/sys-minix/adjtime.c | 4 ++-- lib/libc/sys-minix/clock_getres.c | 4 ++-- lib/libc/sys-minix/futimens.c | 9 +++++---- lib/libc/sys-minix/futimes.c | 8 ++++---- lib/libc/sys-minix/lutimes.c | 9 +++++---- lib/libc/sys-minix/utimensat.c | 9 +++++---- lib/libc/sys-minix/utimes.c | 9 +++++---- lib/libsys/sys_settime.c | 22 +++++++++------------- servers/pm/time.c | 14 ++++++++------ servers/vfs/utility.c | 2 +- sys/arch/arm/include/ansi.h | 3 +-- sys/arch/i386/include/ansi.h | 2 +- usr.bin/top/top.c | 2 +- 19 files changed, 62 insertions(+), 60 deletions(-) diff --git a/drivers/vbox/vbox.c b/drivers/vbox/vbox.c index f19def098..ac199cbd8 100644 --- a/drivers/vbox/vbox.c +++ b/drivers/vbox/vbox.c @@ -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); } diff --git a/include/minix/com.h b/include/minix/com.h index 0fb5502a1..4bb5075ed 100644 --- a/include/minix/com.h +++ b/include/minix/com.h @@ -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. */ diff --git a/include/minix/ipc.h b/include/minix/ipc.h index 6f8416ded..3290a9dcf 100644 --- a/include/minix/ipc.h +++ b/include/minix/ipc.h @@ -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 diff --git a/kernel/system/do_settime.c b/kernel/system/do_settime.c index c28b45e56..e21836eb8 100644 --- a/kernel/system/do_settime.c +++ b/kernel/system/do_settime.c @@ -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 || diff --git a/kernel/system/do_stime.c b/kernel/system/do_stime.c index 3c1d1c822..db6b6652a 100644 --- a/kernel/system/do_stime.c +++ b/kernel/system/do_stime.c @@ -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" diff --git a/kernel/system/do_times.c b/kernel/system/do_times.c index 0205cf62c..b5d5cef25 100644 --- a/kernel/system/do_times.c +++ b/kernel/system/do_times.c @@ -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); } diff --git a/lib/libc/sys-minix/adjtime.c b/lib/libc/sys-minix/adjtime.c index fac50499f..a8526e411 100644 --- a/lib/libc/sys-minix/adjtime.c +++ b/lib/libc/sys-minix/adjtime.c @@ -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; diff --git a/lib/libc/sys-minix/clock_getres.c b/lib/libc/sys-minix/clock_getres.c index 41b45ac28..c25da3efd 100644 --- a/lib/libc/sys-minix/clock_getres.c +++ b/lib/libc/sys-minix/clock_getres.c @@ -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; } diff --git a/lib/libc/sys-minix/futimens.c b/lib/libc/sys-minix/futimens.c index 08fdfe407..7621e0bd8 100644 --- a/lib/libc/sys-minix/futimens.c +++ b/lib/libc/sys-minix/futimens.c @@ -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; diff --git a/lib/libc/sys-minix/futimes.c b/lib/libc/sys-minix/futimes.c index c5c4e4070..1b4dce6a2 100644 --- a/lib/libc/sys-minix/futimes.c +++ b/lib/libc/sys-minix/futimes.c @@ -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; diff --git a/lib/libc/sys-minix/lutimes.c b/lib/libc/sys-minix/lutimes.c index 688ab3146..7fed0ee7c 100644 --- a/lib/libc/sys-minix/lutimes.c +++ b/lib/libc/sys-minix/lutimes.c @@ -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; diff --git a/lib/libc/sys-minix/utimensat.c b/lib/libc/sys-minix/utimensat.c index f7eeca04c..c6409b424 100644 --- a/lib/libc/sys-minix/utimensat.c +++ b/lib/libc/sys-minix/utimensat.c @@ -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)); diff --git a/lib/libc/sys-minix/utimes.c b/lib/libc/sys-minix/utimes.c index db3005b38..6da24aec0 100644 --- a/lib/libc/sys-minix/utimes.c +++ b/lib/libc/sys-minix/utimes.c @@ -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; diff --git a/lib/libsys/sys_settime.c b/lib/libsys/sys_settime.c index 6199791a3..acb491a2a 100644 --- a/lib/libsys/sys_settime.c +++ b/lib/libsys/sys_settime.c @@ -1,20 +1,16 @@ #include "syslib.h" #include -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; } diff --git a/servers/pm/time.c b/servers/pm/time.c index cbfd858a9..cac0c48c0 100644 --- a/servers/pm/time.c +++ b/servers/pm/time.c @@ -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) diff --git a/servers/vfs/utility.c b/servers/vfs/utility.c index 91a93f5e5..b3437edbe 100644 --- a/servers/vfs/utility.c +++ b/servers/vfs/utility.c @@ -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; diff --git a/sys/arch/arm/include/ansi.h b/sys/arch/arm/include/ansi.h index 13ca1bac4..0a0acf758 100644 --- a/sys/arch/arm/include/ansi.h +++ b/sys/arch/arm/include/ansi.h @@ -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 */ diff --git a/sys/arch/i386/include/ansi.h b/sys/arch/i386/include/ansi.h index a7fe07d42..77a27bd32 100644 --- a/sys/arch/i386/include/ansi.h +++ b/sys/arch/i386/include/ansi.h @@ -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 */ diff --git a/usr.bin/top/top.c b/usr.bin/top/top.c index 49f604f1e..14fda34fe 100644 --- a/usr.bin/top/top.c +++ b/usr.bin/top/top.c @@ -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) { -- 2.44.0