diff --git a/include/minix/callnr.h b/include/minix/callnr.h index 4e5f0ed3a..1f674f673 100644 --- a/include/minix/callnr.h +++ b/include/minix/callnr.h @@ -64,14 +64,6 @@ /* Field names for the exit(2) call. */ #define PM_EXIT_STATUS m1_i1 /* int */ -/* Field names for the gettimeofday(2), clock_*(2), adjtime(2), stime(2) calls. - */ -#define PM_TIME_CLK_ID m2_i1 /* clockid_t */ -#define PM_TIME_NOW m2_i2 /* int */ -#define PM_TIME_SEC m2_ll1 /* time_t */ -#define PM_TIME_USEC m2_l2 /* long */ -#define PM_TIME_NSEC m2_l2 /* long */ - /* Field names for the ptrace(2) call. */ #define PM_PTRACE_PID m2_i1 /* pid_t */ #define PM_PTRACE_REQ m2_i2 /* int */ diff --git a/include/minix/ipc.h b/include/minix/ipc.h index 0239e2f99..cff4bfa2d 100644 --- a/include/minix/ipc.h +++ b/include/minix/ipc.h @@ -145,6 +145,26 @@ typedef struct { } mess_sigcalls; _ASSERT_MSG_SIZE(mess_sigcalls); +typedef struct { + time_t sec; + + clockid_t clk_id; + int now; + long nsec; + + uint8_t padding[36]; +} mess_lc_pm_time; +_ASSERT_MSG_SIZE(mess_lc_pm_time); + +typedef struct { + time_t sec; + + long nsec; + + uint8_t padding[44]; +} mess_pm_lc_time; +_ASSERT_MSG_SIZE(mess_pm_lc_time); + typedef struct { pid_t pid; int options; @@ -902,6 +922,7 @@ typedef struct { mess_fs_vfs_readsuper m_fs_vfs_readsuper; mess_fs_vfs_readwrite m_fs_vfs_readwrite; + mess_lc_pm_time m_lc_pm_time; mess_lc_pm_waitpid m_lc_pm_waitpid; mess_lc_vfs_chown m_lc_vfs_chown; @@ -936,6 +957,7 @@ typedef struct { mess_lsys_vfs_copyfd m_lsys_vfs_copyfd; mess_lsys_vfs_mapdriver m_lsys_vfs_mapdriver; + mess_pm_lc_time m_pm_lc_time; mess_pm_lc_waitpid m_pm_lc_waitpid; mess_pm_lsys_getepinfo m_pm_lsys_getepinfo; diff --git a/lib/libc/sys-minix/adjtime.c b/lib/libc/sys-minix/adjtime.c index 2aaa17b67..37db1aa0b 100644 --- a/lib/libc/sys-minix/adjtime.c +++ b/lib/libc/sys-minix/adjtime.c @@ -15,10 +15,10 @@ int adjtime(const struct timeval *delta, struct timeval *olddelta) message m; 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 = delta->tv_sec; - m.PM_TIME_NSEC = delta->tv_usec * 1000; /* convert usec to nsec */ + m.m_lc_pm_time.clk_id = CLOCK_REALTIME; + m.m_lc_pm_time.now = 0; /* use adjtime() method to slowly adjust the clock. */ + m.m_lc_pm_time.sec = delta->tv_sec; + m.m_lc_pm_time.nsec = 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 3e58be7c6..5c19d8c37 100644 --- a/lib/libc/sys-minix/clock_getres.c +++ b/lib/libc/sys-minix/clock_getres.c @@ -14,13 +14,13 @@ int clock_getres(clockid_t clock_id, struct timespec *res) message m; memset(&m, 0, sizeof(m)); - m.PM_TIME_CLK_ID = clock_id; + m.m_lc_pm_time.clk_id = clock_id; if (_syscall(PM_PROC_NR, PM_CLOCK_GETRES, &m) < 0) return -1; - res->tv_sec = m.PM_TIME_SEC; - res->tv_nsec = m.PM_TIME_NSEC; + res->tv_sec = m.m_pm_lc_time.sec; + res->tv_nsec = m.m_pm_lc_time.nsec; return 0; } diff --git a/lib/libc/sys-minix/clock_gettime.c b/lib/libc/sys-minix/clock_gettime.c index bef4a063a..cad496c70 100644 --- a/lib/libc/sys-minix/clock_gettime.c +++ b/lib/libc/sys-minix/clock_gettime.c @@ -14,13 +14,13 @@ int clock_gettime(clockid_t clock_id, struct timespec *res) message m; memset(&m, 0, sizeof(m)); - m.PM_TIME_CLK_ID = clock_id; + m.m_lc_pm_time.clk_id = clock_id; if (_syscall(PM_PROC_NR, PM_CLOCK_GETTIME, &m) < 0) return -1; - res->tv_sec = m.PM_TIME_SEC; - res->tv_nsec = m.PM_TIME_NSEC; + res->tv_sec = m.m_pm_lc_time.sec; + res->tv_nsec = m.m_pm_lc_time.nsec; return 0; } diff --git a/lib/libc/sys-minix/clock_settime.c b/lib/libc/sys-minix/clock_settime.c index 0b18ef5c3..6e4d1fc00 100644 --- a/lib/libc/sys-minix/clock_settime.c +++ b/lib/libc/sys-minix/clock_settime.c @@ -14,10 +14,10 @@ int clock_settime(clockid_t clock_id, const struct timespec *ts) message m; memset(&m, 0, sizeof(m)); - m.PM_TIME_CLK_ID = clock_id; - m.PM_TIME_NOW = 1; /* set time immediately. don't use adjtime() method. */ - m.PM_TIME_SEC = ts->tv_sec; - m.PM_TIME_NSEC = ts->tv_nsec; + m.m_lc_pm_time.clk_id = clock_id; + m.m_lc_pm_time.now = 1; /* set time immediately. don't use adjtime() method. */ + m.m_lc_pm_time.sec = ts->tv_sec; + m.m_lc_pm_time.nsec = ts->tv_nsec; if (_syscall(PM_PROC_NR, PM_CLOCK_SETTIME, &m) < 0) return -1; diff --git a/lib/libc/sys-minix/gettimeofday.c b/lib/libc/sys-minix/gettimeofday.c index 4c851fdba..a7ecf4844 100644 --- a/lib/libc/sys-minix/gettimeofday.c +++ b/lib/libc/sys-minix/gettimeofday.c @@ -18,8 +18,8 @@ int gettimeofday(struct timeval *__restrict tp, void *__restrict tzp) if (_syscall(PM_PROC_NR, PM_GETTIMEOFDAY, &m) < 0) return -1; - tp->tv_sec = m.PM_TIME_SEC; - tp->tv_usec = m.PM_TIME_USEC; + tp->tv_sec = m.m_pm_lc_time.sec; + tp->tv_usec = m.m_pm_lc_time.nsec / 1000; return 0; } diff --git a/lib/libc/sys-minix/stime.c b/lib/libc/sys-minix/stime.c index 6846be834..67527dd83 100644 --- a/lib/libc/sys-minix/stime.c +++ b/lib/libc/sys-minix/stime.c @@ -12,6 +12,6 @@ int stime(time_t *top) message m; memset(&m, 0, sizeof(m)); - m.PM_TIME_SEC = *top; + m.m_lc_pm_time.sec = *top; return(_syscall(PM_PROC_NR, PM_STIME, &m)); } diff --git a/servers/pm/time.c b/servers/pm/time.c index dcc610fd0..c002ba671 100644 --- a/servers/pm/time.c +++ b/servers/pm/time.c @@ -27,7 +27,7 @@ int do_gettime() if ( (s=getuptime(&ticks, &realtime, &boottime)) != OK) panic("do_time couldn't get uptime: %d", s); - switch (m_in.PM_TIME_CLK_ID) { + switch (m_in.m_lc_pm_time.clk_id) { case CLOCK_REALTIME: clock = realtime; break; @@ -38,8 +38,8 @@ int do_gettime() return EINVAL; /* invalid/unsupported clock_id */ } - mp->mp_reply.PM_TIME_SEC = boottime + (clock / system_hz); - mp->mp_reply.PM_TIME_NSEC = + mp->mp_reply.m_pm_lc_time.sec = boottime + (clock / system_hz); + mp->mp_reply.m_pm_lc_time.nsec = (uint32_t) ((clock % system_hz) * 1000000000ULL / system_hz); return(OK); @@ -50,12 +50,12 @@ int do_gettime() *===========================================================================*/ int do_getres() { - switch (m_in.PM_TIME_CLK_ID) { + switch (m_in.m_lc_pm_time.clk_id) { case CLOCK_REALTIME: case CLOCK_MONOTONIC: /* tv_sec is always 0 since system_hz is an int */ - mp->mp_reply.PM_TIME_SEC = 0; - mp->mp_reply.PM_TIME_NSEC = 1000000000 / system_hz; + mp->mp_reply.m_pm_lc_time.sec = 0; + mp->mp_reply.m_pm_lc_time.nsec = 1000000000 / system_hz; return(OK); default: return EINVAL; /* invalid/unsupported clock_id */ @@ -73,10 +73,10 @@ int do_settime() return(EPERM); } - switch (m_in.PM_TIME_CLK_ID) { + switch (m_in.m_lc_pm_time.clk_id) { case CLOCK_REALTIME: - s= sys_settime(m_in.PM_TIME_NOW, m_in.PM_TIME_CLK_ID, - m_in.PM_TIME_SEC, m_in.PM_TIME_NSEC); + s = sys_settime(m_in.m_lc_pm_time.now, m_in.m_lc_pm_time.clk_id, + m_in.m_lc_pm_time.sec, m_in.m_lc_pm_time.nsec); return(s); case CLOCK_MONOTONIC: /* monotonic cannot be changed */ default: @@ -101,9 +101,9 @@ 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 = boottime + (realtime / system_hz); - mp->mp_reply.PM_TIME_USEC = - (uint32_t) ((realtime % system_hz) * 1000000ULL / system_hz); + mp->mp_reply.m_pm_lc_time.sec = boottime + (realtime / system_hz); + mp->mp_reply.m_pm_lc_time.nsec = + (uint32_t) ((realtime % system_hz) * 1000000000ULL / system_hz); return(OK); } @@ -124,7 +124,7 @@ int do_stime() } if ( (s=getuptime(&uptime, &realtime, &boottime)) != OK) panic("do_stime couldn't get uptime: %d", s); - boottime = m_in.PM_TIME_SEC - (realtime/system_hz); + boottime = m_in.m_lc_pm_time.sec - (realtime/system_hz); s= sys_stime(boottime); /* Tell kernel about boottime */ if (s != OK)