[PATCH 13/14] kernel.h: Kernel address utility aggregation and other neatening

From: Joe Perches
Date: Wed Dec 16 2009 - 03:11:26 EST


Group the address utilities
Move upper_32_bits and lower_32_bits to math and limits group
Add a few new group headers
panic and oops
shutdown
string parsing
sysinfo

Signed-off-by: Joe Perches <joe@xxxxxxxxxxx>
---
include/linux/kernel.h | 69 +++++++++++++++++++++++++++++++----------------
1 files changed, 45 insertions(+), 24 deletions(-)

diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 7d7f7e2..0fd5949 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -32,8 +32,6 @@
#define LLONG_MIN (-LLONG_MAX - 1)
#define ULLONG_MAX (~0ULL)

-#define STACK_MAGIC 0xdeadbeef
-
#define __ALIGN_MASK(x, mask) (((x) + (mask)) & ~(mask))
#define ALIGN(x, a) __ALIGN_MASK(x, (typeof(x))(a) - 1)
#define PTR_ALIGN(p, a) ((typeof(p))ALIGN((unsigned long)(p), (a)))
@@ -51,9 +49,6 @@
(((x) + ((__divisor) / 2)) / (__divisor)); \
})

-#define _RET_IP_ (unsigned long)__builtin_return_address(0)
-#define _THIS_IP_ ({ __label__ __here; __here: (unsigned long)&&__here; })
-
#ifdef CONFIG_LBDAF
# include <asm/div64.h>
# define sector_div(a, b) do_div(a, b)
@@ -67,22 +62,6 @@
})
#endif

-/**
- * upper_32_bits - return bits 32-63 of a number
- * @n: the number we're accessing
- *
- * A basic shift-right of a 64- or 32-bit quantity. Use this to suppress
- * the "right shift count >= width of type" warning when that quantity is
- * 32-bits.
- */
-#define upper_32_bits(n) ((u32)(((n) >> 16) >> 16))
-
-/**
- * lower_32_bits - return bits 0-31 of a number
- * @n: the number we're accessing
- */
-#define lower_32_bits(n) ((u32)(n))
-
struct completion;
struct pt_regs;
struct user;
@@ -124,6 +103,9 @@ static inline void might_fault(void)
}
#endif

+/*
+ * panic and oops support
+ */
extern struct atomic_notifier_head panic_notifier_list;
extern long (*panic_blink)(long time);
extern void panic(const char *fmt, ...)
@@ -131,6 +113,10 @@ extern void panic(const char *fmt, ...)
extern void oops_enter(void);
extern void oops_exit(void);
extern int oops_may_print(void);
+
+/*
+ * shutdown support
+ */
extern void do_exit(long code)
__attribute__ ((noreturn));
extern void complete_and_exit(struct completion *comp, long code)
@@ -176,15 +162,28 @@ extern int sscanf(const char *buf, const char *fmt, ...)
extern int vsscanf(const char *buf, const char *fmt, va_list)
__attribute__ ((format (scanf, 2, 0)));

+/*
+ * String parsing
+ */
extern int get_option(char **str, int *pint);
extern char *get_options(const char *str, int nints, int *ints);
extern unsigned long long memparse(const char *ptr, char **retptr);
+ /*parse a string with mem suffixes into a number */

+/*
+ * Kernel address utils
+ */
extern int core_kernel_text(unsigned long addr);
extern int __kernel_text_address(unsigned long addr);
extern int kernel_text_address(unsigned long addr);
extern int func_ptr_is_kernel_text(void *ptr);
+#define _RET_IP_ (unsigned long)__builtin_return_address(0)
+#define _THIS_IP_ ({ __label__ __here; __here: (unsigned long)&&__here; })
+#define STACK_MAGIC 0xdeadbeef

+/*
+ * Process ID and process group
+ */
struct pid;
extern struct pid *session_of_pgrp(struct pid *pgrp);

@@ -221,6 +220,9 @@ extern int panic_on_unrecovered_nmi;
extern int panic_on_io_nmi;
extern int root_mountflags;

+/*
+ * Hex to ascii helpers
+ */

extern const char hex_asc[];
#define hex_asc_lo(x) hex_asc[((x) & 0x0f)]
@@ -244,6 +246,22 @@ static inline char *pack_hex_byte(char *buf, u8 byte)

unsigned long int_sqrt(unsigned long);

+/**
+ * upper_32_bits - return bits 32-63 of a number
+ * @n: the number we're accessing
+ *
+ * A basic shift-right of a 64- or 32-bit quantity. Use this to suppress
+ * the "right shift count >= width of type" warning when that quantity is
+ * 32-bits.
+ */
+#define upper_32_bits(n) ((u32)(((n) >> 16) >> 16))
+
+/**
+ * lower_32_bits - return bits 0-31 of a number
+ * @n: the number we're accessing
+ */
+#define lower_32_bits(n) ((u32)(n))
+
/*
* min()/max()/clamp() macros that also do
* strict type-checking.. See the
@@ -362,9 +380,6 @@ unsigned long int_sqrt(unsigned long);
(type *)((char *)__mptr - offsetof(type, member)); \
})

-struct sysinfo;
-extern int do_sysinfo(struct sysinfo *info);
-
/*
* Console and logging support
*/
@@ -776,6 +791,12 @@ ftrace_vprintk(const char *fmt, va_list ap)
static inline void ftrace_dump(void) { }
#endif /* CONFIG_TRACING */

+/*
+ * sysinfo support
+ */
+struct sysinfo;
+extern int do_sysinfo(struct sysinfo *info);
+
#endif /* __KERNEL__ */

#ifndef __EXPORTED_HEADERS__
--
1.6.6.rc0.57.gad7a

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/