diff options
| author | Stephen Rothwell <sfr@canb.auug.org.au> | 2002-12-14 20:16:06 -0800 |
|---|---|---|
| committer | Linus Torvalds <torvalds@home.transmeta.com> | 2002-12-14 20:16:06 -0800 |
| commit | a9ff25c88198b789ac3b1f294dd878408629ef88 (patch) | |
| tree | 156f46c17208351495e3a450c7311b51b0f0ad0d | |
| parent | 136839a1b4597a6b99a4286586d04a16b5d30295 (diff) | |
[PATCH] consolidate sys32_times - architecture independent
This patch creates compat_sys_times and a few more compability types.
| -rw-r--r-- | include/linux/compat.h | 13 | ||||
| -rw-r--r-- | kernel/compat.c | 20 |
2 files changed, 31 insertions, 2 deletions
diff --git a/include/linux/compat.h b/include/linux/compat.h index 5aa29316f9d8..228bd4b13365 100644 --- a/include/linux/compat.h +++ b/include/linux/compat.h @@ -1,8 +1,8 @@ #ifndef _LINUX_COMPAT_H #define _LINUX_COMPAT_H /* - * These are the type definitions for the arhitecure sepcific - * compatibility layer. + * These are the type definitions for the architecture specific + * syscall compatibility layer. */ #include <linux/config.h> @@ -10,6 +10,8 @@ #include <asm/compat.h> +#define compat_jiffies_to_clock_t(x) ((x) / (HZ / COMPAT_USER_HZ)) + struct compat_utimbuf { compat_time_t actime; compat_time_t modtime; @@ -20,5 +22,12 @@ struct compat_itimerval { struct compat_timeval it_value; }; +struct compat_tms { + compat_clock_t tms_utime; + compat_clock_t tms_stime; + compat_clock_t tms_cutime; + compat_clock_t tms_cstime; +}; + #endif /* CONFIG_COMPAT */ #endif /* _LINUX_COMPAT_H */ diff --git a/kernel/compat.c b/kernel/compat.c index f4da56c960f8..701e39120b22 100644 --- a/kernel/compat.c +++ b/kernel/compat.c @@ -156,3 +156,23 @@ asmlinkage long compat_sys_setitimer(int which, struct compat_itimerval *in, return -EFAULT; return 0; } + +asmlinkage long compat_sys_times(struct compat_tms *tbuf) +{ + /* + * In the SMP world we might just be unlucky and have one of + * the times increment as we use it. Since the value is an + * atomically safe type this is just fine. Conceptually its + * as if the syscall took an instant longer to occur. + */ + if (tbuf) { + struct compat_tms tmp; + tmp.tms_utime = compat_jiffies_to_clock_t(current->utime); + tmp.tms_stime = compat_jiffies_to_clock_t(current->stime); + tmp.tms_cutime = compat_jiffies_to_clock_t(current->cutime); + tmp.tms_cstime = compat_jiffies_to_clock_t(current->cstime); + if (copy_to_user(tbuf, &tmp, sizeof(tmp))) + return -EFAULT; + } + return compat_jiffies_to_clock_t(jiffies); +} |
