* [PATCH] linux/timex.h: cleanup for userspace
@ 2008-10-26 10:37 Mike Frysinger
2008-10-28 3:28 ` Andrew Morton
0 siblings, 1 reply; 7+ messages in thread
From: Mike Frysinger @ 2008-10-26 10:37 UTC (permalink / raw)
To: Roman Zippel; +Cc: linux-kernel, akpm
Move all the kernel-specific defines and includes into the __KERNEL__
section so that they don't get leaked into userspace.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
include/linux/timex.h | 73 +++++++++++++++++++++++++------------------------
1 files changed, 37 insertions(+), 36 deletions(-)
diff --git a/include/linux/timex.h b/include/linux/timex.h
index 9007313..4bbbab5 100644
--- a/include/linux/timex.h
+++ b/include/linux/timex.h
@@ -53,47 +53,11 @@
#ifndef _LINUX_TIMEX_H
#define _LINUX_TIMEX_H
-#include <linux/compiler.h>
#include <linux/time.h>
-#include <asm/param.h>
-
#define NTP_API 4 /* NTP API version */
/*
- * SHIFT_KG and SHIFT_KF establish the damping of the PLL and are chosen
- * for a slightly underdamped convergence characteristic. SHIFT_KH
- * establishes the damping of the FLL and is chosen by wisdom and black
- * art.
- *
- * MAXTC establishes the maximum time constant of the PLL. With the
- * SHIFT_KG and SHIFT_KF values given and a time constant range from
- * zero to MAXTC, the PLL will converge in 15 minutes to 16 hours,
- * respectively.
- */
-#define SHIFT_PLL 4 /* PLL frequency factor (shift) */
-#define SHIFT_FLL 2 /* FLL frequency factor (shift) */
-#define MAXTC 10 /* maximum time constant (shift) */
-
-/*
- * SHIFT_USEC defines the scaling (shift) of the time_freq and
- * time_tolerance variables, which represent the current frequency
- * offset and maximum frequency tolerance.
- */
-#define SHIFT_USEC 16 /* frequency offset scale (shift) */
-#define PPM_SCALE (NSEC_PER_USEC << (NTP_SCALE_SHIFT - SHIFT_USEC))
-#define PPM_SCALE_INV_SHIFT 19
-#define PPM_SCALE_INV ((1ll << (PPM_SCALE_INV_SHIFT + NTP_SCALE_SHIFT)) / \
- PPM_SCALE + 1)
-
-#define MAXPHASE 500000000l /* max phase error (ns) */
-#define MAXFREQ 500000 /* max frequency error (ns/s) */
-#define MAXFREQ_SCALED ((s64)MAXFREQ << NTP_SCALE_SHIFT)
-#define MINSEC 256 /* min interval between updates (s) */
-#define MAXSEC 2048 /* max interval between updates (s) */
-#define NTP_PHASE_LIMIT ((MAXPHASE / NSEC_PER_USEC) << 5) /* beyond max. dispersion */
-
-/*
* syscall interface - used (mainly by NTP daemon)
* to discipline kernel clock oscillator
*/
@@ -199,9 +163,46 @@ struct timex {
#define TIME_BAD TIME_ERROR /* bw compat */
#ifdef __KERNEL__
+#include <linux/compiler.h>
+#include <linux/types.h>
+
+#include <asm/param.h>
#include <asm/timex.h>
/*
+ * SHIFT_KG and SHIFT_KF establish the damping of the PLL and are chosen
+ * for a slightly underdamped convergence characteristic. SHIFT_KH
+ * establishes the damping of the FLL and is chosen by wisdom and black
+ * art.
+ *
+ * MAXTC establishes the maximum time constant of the PLL. With the
+ * SHIFT_KG and SHIFT_KF values given and a time constant range from
+ * zero to MAXTC, the PLL will converge in 15 minutes to 16 hours,
+ * respectively.
+ */
+#define SHIFT_PLL 4 /* PLL frequency factor (shift) */
+#define SHIFT_FLL 2 /* FLL frequency factor (shift) */
+#define MAXTC 10 /* maximum time constant (shift) */
+
+/*
+ * SHIFT_USEC defines the scaling (shift) of the time_freq and
+ * time_tolerance variables, which represent the current frequency
+ * offset and maximum frequency tolerance.
+ */
+#define SHIFT_USEC 16 /* frequency offset scale (shift) */
+#define PPM_SCALE (NSEC_PER_USEC << (NTP_SCALE_SHIFT - SHIFT_USEC))
+#define PPM_SCALE_INV_SHIFT 19
+#define PPM_SCALE_INV ((1ll << (PPM_SCALE_INV_SHIFT + NTP_SCALE_SHIFT)) / \
+ PPM_SCALE + 1)
+
+#define MAXPHASE 500000000l /* max phase error (ns) */
+#define MAXFREQ 500000 /* max frequency error (ns/s) */
+#define MAXFREQ_SCALED ((s64)MAXFREQ << NTP_SCALE_SHIFT)
+#define MINSEC 256 /* min interval between updates (s) */
+#define MAXSEC 2048 /* max interval between updates (s) */
+#define NTP_PHASE_LIMIT ((MAXPHASE / NSEC_PER_USEC) << 5) /* beyond max. dispersion */
+
+/*
* kernel variables
* Note: maximum error = NTP synch distance = dispersion + delay / 2;
* estimated error = NTP dispersion.
--
1.6.0.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] linux/timex.h: cleanup for userspace
2008-10-26 10:37 [PATCH] linux/timex.h: cleanup for userspace Mike Frysinger
@ 2008-10-28 3:28 ` Andrew Morton
2008-10-28 3:31 ` Mike Frysinger
0 siblings, 1 reply; 7+ messages in thread
From: Andrew Morton @ 2008-10-28 3:28 UTC (permalink / raw)
To: Mike Frysinger; +Cc: Roman Zippel, linux-kernel
On Sun, 26 Oct 2008 06:37:31 -0400 Mike Frysinger <vapier@gentoo.org> wrote:
> Move all the kernel-specific defines and includes into the __KERNEL__
> section so that they don't get leaked into userspace.
>
checkpatch correctly instructs us to use linux/param.h, not asm/param.h.
This:
--- a/include/linux/timex.h~linux-timexh-cleanup-for-userspace-checkpatch-fixes
+++ a/include/linux/timex.h
@@ -165,8 +165,8 @@ struct timex {
#ifdef __KERNEL__
#include <linux/compiler.h>
#include <linux/types.h>
+#include <linux/param.h>
-#include <asm/param.h>
#include <asm/timex.h>
/*
_
seems Obviously Safe to me. Do you agree?
(please use checkpatch - sometimes it's useful!)
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] linux/timex.h: cleanup for userspace
2008-10-28 3:28 ` Andrew Morton
@ 2008-10-28 3:31 ` Mike Frysinger
0 siblings, 0 replies; 7+ messages in thread
From: Mike Frysinger @ 2008-10-28 3:31 UTC (permalink / raw)
To: Andrew Morton; +Cc: Roman Zippel, linux-kernel
On Mon, Oct 27, 2008 at 11:28 PM, Andrew Morton wrote:
> On Sun, 26 Oct 2008 06:37:31 -0400 Mike Frysinger wrote:
>> Move all the kernel-specific defines and includes into the __KERNEL__
>> section so that they don't get leaked into userspace.
>
> checkpatch correctly instructs us to use linux/param.h, not asm/param.h.
i was just moving around existing code in an attempt to minimize
possible breakage ;)
> --- a/include/linux/timex.h~linux-timexh-cleanup-for-userspace-checkpatch-fixes
> +++ a/include/linux/timex.h
> @@ -165,8 +165,8 @@ struct timex {
> #ifdef __KERNEL__
> #include <linux/compiler.h>
> #include <linux/types.h>
> +#include <linux/param.h>
>
> -#include <asm/param.h>
> #include <asm/timex.h>
>
> /*
> _
>
> seems Obviously Safe to me. Do you agree?
Acked-by: Mike Frysinger <vapier@gentoo.org>
-mike
-mike
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] linux/timex.h: cleanup for userspace
2008-12-27 6:49 Mike Frysinger
@ 2008-12-29 12:22 ` Mike Frysinger
0 siblings, 0 replies; 7+ messages in thread
From: Mike Frysinger @ 2008-12-29 12:22 UTC (permalink / raw)
To: linux-kernel
On Sat, Dec 27, 2008 at 01:49, Mike Frysinger wrote:
> Move all the kernel-specific defines and includes into the __KERNEL__
> section so that they don't get leaked into userspace.
erp, looks like Ingo already posted this for inclusion in 2.6.29
-mike
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] linux/timex.h: cleanup for userspace
@ 2008-12-27 6:49 Mike Frysinger
2008-12-29 12:22 ` Mike Frysinger
0 siblings, 1 reply; 7+ messages in thread
From: Mike Frysinger @ 2008-12-27 6:49 UTC (permalink / raw)
To: linux-kernel
Move all the kernel-specific defines and includes into the __KERNEL__
section so that they don't get leaked into userspace.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
include/linux/timex.h | 73 +++++++++++++++++++++++++------------------------
1 files changed, 37 insertions(+), 36 deletions(-)
diff --git a/include/linux/timex.h b/include/linux/timex.h
index 9007313..4bbbab5 100644
--- a/include/linux/timex.h
+++ b/include/linux/timex.h
@@ -53,47 +53,11 @@
#ifndef _LINUX_TIMEX_H
#define _LINUX_TIMEX_H
-#include <linux/compiler.h>
#include <linux/time.h>
-#include <asm/param.h>
-
#define NTP_API 4 /* NTP API version */
/*
- * SHIFT_KG and SHIFT_KF establish the damping of the PLL and are chosen
- * for a slightly underdamped convergence characteristic. SHIFT_KH
- * establishes the damping of the FLL and is chosen by wisdom and black
- * art.
- *
- * MAXTC establishes the maximum time constant of the PLL. With the
- * SHIFT_KG and SHIFT_KF values given and a time constant range from
- * zero to MAXTC, the PLL will converge in 15 minutes to 16 hours,
- * respectively.
- */
-#define SHIFT_PLL 4 /* PLL frequency factor (shift) */
-#define SHIFT_FLL 2 /* FLL frequency factor (shift) */
-#define MAXTC 10 /* maximum time constant (shift) */
-
-/*
- * SHIFT_USEC defines the scaling (shift) of the time_freq and
- * time_tolerance variables, which represent the current frequency
- * offset and maximum frequency tolerance.
- */
-#define SHIFT_USEC 16 /* frequency offset scale (shift) */
-#define PPM_SCALE (NSEC_PER_USEC << (NTP_SCALE_SHIFT - SHIFT_USEC))
-#define PPM_SCALE_INV_SHIFT 19
-#define PPM_SCALE_INV ((1ll << (PPM_SCALE_INV_SHIFT + NTP_SCALE_SHIFT)) / \
- PPM_SCALE + 1)
-
-#define MAXPHASE 500000000l /* max phase error (ns) */
-#define MAXFREQ 500000 /* max frequency error (ns/s) */
-#define MAXFREQ_SCALED ((s64)MAXFREQ << NTP_SCALE_SHIFT)
-#define MINSEC 256 /* min interval between updates (s) */
-#define MAXSEC 2048 /* max interval between updates (s) */
-#define NTP_PHASE_LIMIT ((MAXPHASE / NSEC_PER_USEC) << 5) /* beyond max. dispersion */
-
-/*
* syscall interface - used (mainly by NTP daemon)
* to discipline kernel clock oscillator
*/
@@ -199,9 +163,46 @@ struct timex {
#define TIME_BAD TIME_ERROR /* bw compat */
#ifdef __KERNEL__
+#include <linux/compiler.h>
+#include <linux/types.h>
+
+#include <asm/param.h>
#include <asm/timex.h>
/*
+ * SHIFT_KG and SHIFT_KF establish the damping of the PLL and are chosen
+ * for a slightly underdamped convergence characteristic. SHIFT_KH
+ * establishes the damping of the FLL and is chosen by wisdom and black
+ * art.
+ *
+ * MAXTC establishes the maximum time constant of the PLL. With the
+ * SHIFT_KG and SHIFT_KF values given and a time constant range from
+ * zero to MAXTC, the PLL will converge in 15 minutes to 16 hours,
+ * respectively.
+ */
+#define SHIFT_PLL 4 /* PLL frequency factor (shift) */
+#define SHIFT_FLL 2 /* FLL frequency factor (shift) */
+#define MAXTC 10 /* maximum time constant (shift) */
+
+/*
+ * SHIFT_USEC defines the scaling (shift) of the time_freq and
+ * time_tolerance variables, which represent the current frequency
+ * offset and maximum frequency tolerance.
+ */
+#define SHIFT_USEC 16 /* frequency offset scale (shift) */
+#define PPM_SCALE (NSEC_PER_USEC << (NTP_SCALE_SHIFT - SHIFT_USEC))
+#define PPM_SCALE_INV_SHIFT 19
+#define PPM_SCALE_INV ((1ll << (PPM_SCALE_INV_SHIFT + NTP_SCALE_SHIFT)) / \
+ PPM_SCALE + 1)
+
+#define MAXPHASE 500000000l /* max phase error (ns) */
+#define MAXFREQ 500000 /* max frequency error (ns/s) */
+#define MAXFREQ_SCALED ((s64)MAXFREQ << NTP_SCALE_SHIFT)
+#define MINSEC 256 /* min interval between updates (s) */
+#define MAXSEC 2048 /* max interval between updates (s) */
+#define NTP_PHASE_LIMIT ((MAXPHASE / NSEC_PER_USEC) << 5) /* beyond max. dispersion */
+
+/*
* kernel variables
* Note: maximum error = NTP synch distance = dispersion + delay / 2;
* estimated error = NTP dispersion.
--
1.6.0.6
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] linux/timex.h: cleanup for userspace
2008-08-20 2:46 Mike Frysinger
@ 2008-08-21 3:09 ` Roman Zippel
0 siblings, 0 replies; 7+ messages in thread
From: Roman Zippel @ 2008-08-21 3:09 UTC (permalink / raw)
To: Mike Frysinger; +Cc: akpm, linux-kernel
Hi,
On Tue, 19 Aug 2008, Mike Frysinger wrote:
> MAXFREQ_SCALED was tweaked recently to contain a (s64) cast. Assuming this
> is meant for userspace, change it to (__s64) and pull in linux/types.h.
No, it's irrelevant for user space.
Most of it can be moved down into the __KERNEL__ block.
Look at the glibc timex.h for what is currently exported.
bye, Roman
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] linux/timex.h: cleanup for userspace
@ 2008-08-20 2:46 Mike Frysinger
2008-08-21 3:09 ` Roman Zippel
0 siblings, 1 reply; 7+ messages in thread
From: Mike Frysinger @ 2008-08-20 2:46 UTC (permalink / raw)
To: zippel, akpm; +Cc: linux-kernel
MAXFREQ_SCALED was tweaked recently to contain a (s64) cast. Assuming this
is meant for userspace, change it to (__s64) and pull in linux/types.h.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
include/linux/timex.h | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/include/linux/timex.h b/include/linux/timex.h
index fc6035d..07ed536 100644
--- a/include/linux/timex.h
+++ b/include/linux/timex.h
@@ -55,6 +55,7 @@
#include <linux/compiler.h>
#include <linux/time.h>
+#include <linux/types.h>
#include <asm/param.h>
@@ -88,7 +89,7 @@
#define MAXPHASE 500000000l /* max phase error (ns) */
#define MAXFREQ 500000 /* max frequency error (ns/s) */
-#define MAXFREQ_SCALED ((s64)MAXFREQ << NTP_SCALE_SHIFT)
+#define MAXFREQ_SCALED ((__s64)MAXFREQ << NTP_SCALE_SHIFT)
#define MINSEC 256 /* min interval between updates (s) */
#define MAXSEC 2048 /* max interval between updates (s) */
#define NTP_PHASE_LIMIT ((MAXPHASE / NSEC_PER_USEC) << 5) /* beyond max. dispersion */
--
1.5.6.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2008-12-29 12:22 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-26 10:37 [PATCH] linux/timex.h: cleanup for userspace Mike Frysinger
2008-10-28 3:28 ` Andrew Morton
2008-10-28 3:31 ` Mike Frysinger
-- strict thread matches above, loose matches on Subject: below --
2008-12-27 6:49 Mike Frysinger
2008-12-29 12:22 ` Mike Frysinger
2008-08-20 2:46 Mike Frysinger
2008-08-21 3:09 ` Roman Zippel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).