aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/kernel.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/kernel.h')
-rw-r--r--include/linux/kernel.h29
1 files changed, 26 insertions, 3 deletions
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 9ddf25c21538..45353d757cd0 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -35,11 +35,22 @@ extern const char linux_proc_banner[];
35#define ALIGN(x,a) __ALIGN_MASK(x,(typeof(x))(a)-1) 35#define ALIGN(x,a) __ALIGN_MASK(x,(typeof(x))(a)-1)
36#define __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask)) 36#define __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask))
37 37
38#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) 38#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
39
39#define FIELD_SIZEOF(t, f) (sizeof(((t*)0)->f)) 40#define FIELD_SIZEOF(t, f) (sizeof(((t*)0)->f))
40#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d)) 41#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
41#define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y)) 42#define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y))
42 43
44/**
45 * upper_32_bits - return bits 32-63 of a number
46 * @n: the number we're accessing
47 *
48 * A basic shift-right of a 64- or 32-bit quantity. Use this to suppress
49 * the "right shift count >= width of type" warning when that quantity is
50 * 32-bits.
51 */
52#define upper_32_bits(n) ((u32)(((n) >> 16) >> 16))
53
43#define KERN_EMERG "<0>" /* system is unusable */ 54#define KERN_EMERG "<0>" /* system is unusable */
44#define KERN_ALERT "<1>" /* action must be taken immediately */ 55#define KERN_ALERT "<1>" /* action must be taken immediately */
45#define KERN_CRIT "<2>" /* critical conditions */ 56#define KERN_CRIT "<2>" /* critical conditions */
@@ -121,6 +132,7 @@ extern int vscnprintf(char *buf, size_t size, const char *fmt, va_list args)
121 __attribute__ ((format (printf, 3, 0))); 132 __attribute__ ((format (printf, 3, 0)));
122extern char *kasprintf(gfp_t gfp, const char *fmt, ...) 133extern char *kasprintf(gfp_t gfp, const char *fmt, ...)
123 __attribute__ ((format (printf, 2, 3))); 134 __attribute__ ((format (printf, 2, 3)));
135extern char *kvasprintf(gfp_t gfp, const char *fmt, va_list args);
124 136
125extern int sscanf(const char *, const char *, ...) 137extern int sscanf(const char *, const char *, ...)
126 __attribute__ ((format (scanf, 2, 3))); 138 __attribute__ ((format (scanf, 2, 3)));
@@ -201,6 +213,17 @@ extern enum system_states {
201 213
202extern void dump_stack(void); 214extern void dump_stack(void);
203 215
216enum {
217 DUMP_PREFIX_NONE,
218 DUMP_PREFIX_ADDRESS,
219 DUMP_PREFIX_OFFSET
220};
221extern void hex_dump_to_buffer(const void *buf, size_t len, char *linebuf,
222 size_t linebuflen);
223extern void print_hex_dump(const char *level, int prefix_type,
224 void *buf, size_t len);
225#define hex_asc(x) "0123456789abcdef"[x]
226
204#ifdef DEBUG 227#ifdef DEBUG
205/* If you are writing a driver, please use dev_dbg instead */ 228/* If you are writing a driver, please use dev_dbg instead */
206#define pr_debug(fmt,arg...) \ 229#define pr_debug(fmt,arg...) \
@@ -287,8 +310,8 @@ static inline int __attribute__ ((format (printf, 1, 2))) pr_debug(const char *
287 * 310 *
288 */ 311 */
289#define container_of(ptr, type, member) ({ \ 312#define container_of(ptr, type, member) ({ \
290 const typeof( ((type *)0)->member ) *__mptr = (ptr); \ 313 const typeof( ((type *)0)->member ) *__mptr = (ptr); \
291 (type *)( (char *)__mptr - offsetof(type,member) );}) 314 (type *)( (char *)__mptr - offsetof(type,member) );})
292 315
293/* 316/*
294 * Check at compile time that something is of a particular type. 317 * Check at compile time that something is of a particular type.