DEFINE(UM_THREAD_SIZE, THREAD_SIZE);
DEFINE(UM_HZ, HZ);
+
+DEFINE(UM_USEC_PER_SEC, USEC_PER_SEC);
+DEFINE(UM_NSEC_PER_SEC, NSEC_PER_SEC);
+DEFINE(UM_NSEC_PER_USEC, NSEC_PER_USEC);
extern void os_dump_core(void);
/* time.c */
-#define BILLION (1000 * 1000 * 1000)
-
extern void idle_sleep(unsigned long long nsecs);
extern int set_interval(void);
extern int timer_one_shot(int ticks);
*/
unsigned long long sched_clock(void)
{
- return (unsigned long long)jiffies_64 * (1000000000 / HZ);
+ return (unsigned long long)jiffies_64 * (NSEC_PER_SEC / HZ);
}
void timer_handler(int sig, struct uml_pt_regs *regs)
timer_init();
nsecs = os_nsecs();
- set_normalized_timespec(&wall_to_monotonic, -nsecs / BILLION,
- -nsecs % BILLION);
- set_normalized_timespec(&xtime, nsecs / BILLION, nsecs % BILLION);
+ set_normalized_timespec(&wall_to_monotonic, -nsecs / NSEC_PER_SEC,
+ -nsecs % NSEC_PER_SEC);
+ set_normalized_timespec(&xtime, nsecs / NSEC_PER_SEC,
+ nsecs % NSEC_PER_SEC);
late_time_init = setup_itimer;
}
if (getitimer(ITIMER_VIRTUAL, &timer))
printk("Failed to get itimer, errno = %d\n", errno);
- nsecs = timer.it_value.tv_sec * BILLION +
- timer.it_value.tv_usec * 1000;
+ nsecs = timer.it_value.tv_sec * UM_NSEC_PER_SEC +
+ timer.it_value.tv_usec * UM_NSEC_PER_USEC;
nsecs += os_nsecs();
while (1) {
block_signals();
(*sig_info[sig])(sig, regs);
unblock_signals();
- nsecs = timer.it_value.tv_sec * BILLION +
- timer.it_value.tv_usec * 1000;
+ nsecs = timer.it_value.tv_sec *
+ UM_NSEC_PER_SEC +
+ timer.it_value.tv_usec *
+ UM_NSEC_PER_USEC;
nsecs += os_nsecs();
break;
case SIGIO:
int copy_context_skas0(unsigned long new_stack, int pid)
{
- struct timeval tv = { .tv_sec = 0, .tv_usec = 1000000 / UM_HZ };
+ struct timeval tv = { .tv_sec = 0, .tv_usec = UM_USEC_PER_SEC / UM_HZ };
int err;
unsigned long current_stack = current_stub_stack();
struct stub_data *data = (struct stub_data *) current_stack;
int set_interval(void)
{
- int usec = 1000000/UM_HZ;
+ int usec = UM_USEC_PER_SEC / UM_HZ;
struct itimerval interval = ((struct itimerval) { { 0, usec },
{ 0, usec } });
int timer_one_shot(int ticks)
{
- unsigned long usec = ticks * 1000000 / UM_HZ;
- unsigned long sec = usec / 1000000;
+ unsigned long usec = ticks * UM_USEC_PER_SEC / UM_HZ;
+ unsigned long sec = usec / UM_USEC_PER_SEC;
struct itimerval interval;
- usec %= 1000000;
+ usec %= UM_USEC_PER_SEC;
interval = ((struct itimerval) { { 0, 0 }, { sec, usec } });
if (setitimer(ITIMER_VIRTUAL, &interval, NULL) == -1)
void idle_sleep(unsigned long long nsecs)
{
- struct timespec ts = { .tv_sec = nsecs / BILLION,
- .tv_nsec = nsecs % BILLION };
+ struct timespec ts = { .tv_sec = nsecs / UM_NSEC_PER_SEC,
+ .tv_nsec = nsecs % UM_NSEC_PER_SEC };
if (nanosleep(&ts, &ts) == 0)
alarm_handler(SIGVTALRM, NULL);