Message type for PM_ time-related calls

- Message type for PM_CLOCK_SETTIME, PM_CLOCK_GETTIME,
   PM_CLOCK_GETRES, PM_GETTIMEOFDAY, PM_SETTIME.

 - Small adaptation, message only transfert sub-second time in
   nanoseconds, instead of both nano- and micro-seconds. Conversion
   is done in userland, as required.

Change-Id: Ie4a6e0c457cc12626e85d2102c086a95311cf3e7
This commit is contained in:
2014-05-12 23:40:11 +02:00
parent ee2f1ee4cd
commit 1ae60bd2e8
9 changed files with 52 additions and 38 deletions

View File

@@ -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;

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;

View File

@@ -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;
}

View File

@@ -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));
}