summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@home.transmeta.com>2002-07-01 00:41:38 -0700
committerLinus Torvalds <torvalds@home.transmeta.com>2002-07-01 00:41:38 -0700
commitf9fc1633c7327e38d44e2303034d88eda325717b (patch)
treef7c021d35baab8e633af5104879549bdd81c0338 /include/linux
parente48f3a586ab5b4262fd37c9cb1c21773549b0fb5 (diff)
Make in-kernel HZ be 1000 on x86, retaining user-level 100 HZ clock_t.
Stop using "struct tms" internally - always use timer ticks (or one of the sane timeval/timespec types) instead. Explicitly convert to clock_t when copying to user space for the old broken interfaces that still use "clock_t". Clean up and unify jiffies<->timeval conversion.
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/sched.h3
-rw-r--r--include/linux/time.h42
-rw-r--r--include/linux/times.h4
3 files changed, 36 insertions, 13 deletions
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 390627c2f1f6..6a83711022f8 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -10,7 +10,6 @@ extern unsigned long event;
#include <linux/threads.h>
#include <linux/kernel.h>
#include <linux/types.h>
-#include <linux/times.h>
#include <linux/timex.h>
#include <linux/jiffies.h>
#include <linux/rbtree.h>
@@ -310,7 +309,7 @@ struct task_struct {
unsigned long it_real_value, it_prof_value, it_virt_value;
unsigned long it_real_incr, it_prof_incr, it_virt_incr;
struct timer_list real_timer;
- struct tms times;
+ unsigned long utime, stime, cutime, cstime;
unsigned long start_time;
long per_cpu_utime[NR_CPUS], per_cpu_stime[NR_CPUS];
/* mm fault and swap info: this can arguably be seen as either mm-specific or thread-specific */
diff --git a/include/linux/time.h b/include/linux/time.h
index e7447958ece1..d9f9c6a340d8 100644
--- a/include/linux/time.h
+++ b/include/linux/time.h
@@ -12,6 +12,16 @@ struct timespec {
};
#endif /* _STRUCT_TIMESPEC */
+struct timeval {
+ time_t tv_sec; /* seconds */
+ suseconds_t tv_usec; /* microseconds */
+};
+
+struct timezone {
+ int tz_minuteswest; /* minutes west of Greenwich */
+ int tz_dsttime; /* type of dst correction */
+};
+
#ifdef __KERNEL__
/*
@@ -48,6 +58,27 @@ jiffies_to_timespec(unsigned long jiffies, struct timespec *value)
value->tv_sec = jiffies / HZ;
}
+/* Same for "timeval" */
+static __inline__ unsigned long
+timeval_to_jiffies(struct timeval *value)
+{
+ unsigned long sec = value->tv_sec;
+ long usec = value->tv_usec;
+
+ if (sec >= (MAX_JIFFY_OFFSET / HZ))
+ return MAX_JIFFY_OFFSET;
+ usec += 1000000L / HZ - 1;
+ usec /= 1000000L / HZ;
+ return HZ * sec + usec;
+}
+
+static __inline__ void
+jiffies_to_timeval(unsigned long jiffies, struct timeval *value)
+{
+ value->tv_usec = (jiffies % HZ) * (1000000L / HZ);
+ value->tv_sec = jiffies / HZ;
+}
+
/* Converts Gregorian date to seconds since 1970-01-01 00:00:00.
* Assumes input in normal date format, i.e. 1980-12-31 23:59:59
@@ -88,17 +119,6 @@ extern struct timeval xtime;
#endif /* __KERNEL__ */
-
-struct timeval {
- time_t tv_sec; /* seconds */
- suseconds_t tv_usec; /* microseconds */
-};
-
-struct timezone {
- int tz_minuteswest; /* minutes west of Greenwich */
- int tz_dsttime; /* type of dst correction */
-};
-
#define NFDBITS __NFDBITS
#ifdef __KERNEL__
diff --git a/include/linux/times.h b/include/linux/times.h
index 569349ef461e..1174e9f88ea2 100644
--- a/include/linux/times.h
+++ b/include/linux/times.h
@@ -1,6 +1,10 @@
#ifndef _LINUX_TIMES_H
#define _LINUX_TIMES_H
+#ifdef __KERNEL__
+# define jiffies_to_clock_t(x) ((x) / (HZ / USER_HZ))
+#endif
+
struct tms {
clock_t tms_utime;
clock_t tms_stime;