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.h52
1 files changed, 18 insertions, 34 deletions
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 4d46e299afb..fdbbf72ca2e 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -14,6 +14,8 @@
14#include <linux/compiler.h> 14#include <linux/compiler.h>
15#include <linux/bitops.h> 15#include <linux/bitops.h>
16#include <linux/log2.h> 16#include <linux/log2.h>
17#include <linux/typecheck.h>
18#include <linux/ratelimit.h>
17#include <asm/byteorder.h> 19#include <asm/byteorder.h>
18#include <asm/bug.h> 20#include <asm/bug.h>
19 21
@@ -46,6 +48,9 @@ extern const char linux_proc_banner[];
46#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d)) 48#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
47#define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y)) 49#define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y))
48 50
51#define _RET_IP_ (unsigned long)__builtin_return_address(0)
52#define _THIS_IP_ ({ __label__ __here; __here: (unsigned long)&&__here; })
53
49#ifdef CONFIG_LBD 54#ifdef CONFIG_LBD
50# include <asm/div64.h> 55# include <asm/div64.h>
51# define sector_div(a, b) do_div(a, b) 56# define sector_div(a, b) do_div(a, b)
@@ -184,15 +189,9 @@ asmlinkage int vprintk(const char *fmt, va_list args)
184 __attribute__ ((format (printf, 1, 0))); 189 __attribute__ ((format (printf, 1, 0)));
185asmlinkage int printk(const char * fmt, ...) 190asmlinkage int printk(const char * fmt, ...)
186 __attribute__ ((format (printf, 1, 2))) __cold; 191 __attribute__ ((format (printf, 1, 2))) __cold;
187extern int log_buf_get_len(void);
188extern int log_buf_read(int idx);
189extern int log_buf_copy(char *dest, int idx, int len);
190 192
191extern int printk_ratelimit_jiffies; 193extern struct ratelimit_state printk_ratelimit_state;
192extern int printk_ratelimit_burst;
193extern int printk_ratelimit(void); 194extern int printk_ratelimit(void);
194extern int __ratelimit(int ratelimit_jiffies, int ratelimit_burst);
195extern int __printk_ratelimit(int ratelimit_jiffies, int ratelimit_burst);
196extern bool printk_timed_ratelimit(unsigned long *caller_jiffies, 195extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
197 unsigned int interval_msec); 196 unsigned int interval_msec);
198#else 197#else
@@ -202,18 +201,13 @@ static inline int vprintk(const char *s, va_list args) { return 0; }
202static inline int printk(const char *s, ...) 201static inline int printk(const char *s, ...)
203 __attribute__ ((format (printf, 1, 2))); 202 __attribute__ ((format (printf, 1, 2)));
204static inline int __cold printk(const char *s, ...) { return 0; } 203static inline int __cold printk(const char *s, ...) { return 0; }
205static inline int log_buf_get_len(void) { return 0; }
206static inline int log_buf_read(int idx) { return 0; }
207static inline int log_buf_copy(char *dest, int idx, int len) { return 0; }
208static inline int printk_ratelimit(void) { return 0; } 204static inline int printk_ratelimit(void) { return 0; }
209static inline int __printk_ratelimit(int ratelimit_jiffies, \
210 int ratelimit_burst) { return 0; }
211static inline bool printk_timed_ratelimit(unsigned long *caller_jiffies, \ 205static inline bool printk_timed_ratelimit(unsigned long *caller_jiffies, \
212 unsigned int interval_msec) \ 206 unsigned int interval_msec) \
213 { return false; } 207 { return false; }
214#endif 208#endif
215 209
216extern void __attribute__((format(printf, 1, 2))) 210extern void asmlinkage __attribute__((format(printf, 1, 2)))
217 early_printk(const char *fmt, ...); 211 early_printk(const char *fmt, ...);
218 212
219unsigned long int_sqrt(unsigned long); 213unsigned long int_sqrt(unsigned long);
@@ -276,7 +270,17 @@ extern void print_hex_dump(const char *level, const char *prefix_str,
276 const void *buf, size_t len, bool ascii); 270 const void *buf, size_t len, bool ascii);
277extern void print_hex_dump_bytes(const char *prefix_str, int prefix_type, 271extern void print_hex_dump_bytes(const char *prefix_str, int prefix_type,
278 const void *buf, size_t len); 272 const void *buf, size_t len);
279#define hex_asc(x) "0123456789abcdef"[x] 273
274extern const char hex_asc[];
275#define hex_asc_lo(x) hex_asc[((x) & 0x0f)]
276#define hex_asc_hi(x) hex_asc[((x) & 0xf0) >> 4]
277
278static inline char *pack_hex_byte(char *buf, u8 byte)
279{
280 *buf++ = hex_asc_hi(byte);
281 *buf++ = hex_asc_lo(byte);
282 return buf;
283}
280 284
281#define pr_emerg(fmt, arg...) \ 285#define pr_emerg(fmt, arg...) \
282 printk(KERN_EMERG fmt, ##arg) 286 printk(KERN_EMERG fmt, ##arg)
@@ -434,26 +438,6 @@ extern void print_hex_dump_bytes(const char *prefix_str, int prefix_type,
434 const typeof( ((type *)0)->member ) *__mptr = (ptr); \ 438 const typeof( ((type *)0)->member ) *__mptr = (ptr); \
435 (type *)( (char *)__mptr - offsetof(type,member) );}) 439 (type *)( (char *)__mptr - offsetof(type,member) );})
436 440
437/*
438 * Check at compile time that something is of a particular type.
439 * Always evaluates to 1 so you may use it easily in comparisons.
440 */
441#define typecheck(type,x) \
442({ type __dummy; \
443 typeof(x) __dummy2; \
444 (void)(&__dummy == &__dummy2); \
445 1; \
446})
447
448/*
449 * Check at compile time that 'function' is a certain type, or is a pointer
450 * to that type (needs to use typedef for the function type.)
451 */
452#define typecheck_fn(type,function) \
453({ typeof(type) __tmp = function; \
454 (void)__tmp; \
455})
456
457struct sysinfo; 441struct sysinfo;
458extern int do_sysinfo(struct sysinfo *info); 442extern int do_sysinfo(struct sysinfo *info);
459 443