[32] | 1 | #ifndef _LINUX_KERNEL_H
|
---|
| 2 | #define _LINUX_KERNEL_H
|
---|
| 3 |
|
---|
| 4 | /*
|
---|
| 5 | * 'kernel.h' contains some often-used function prototypes etc
|
---|
| 6 | */
|
---|
| 7 |
|
---|
| 8 | #ifdef __KERNEL__
|
---|
| 9 |
|
---|
[123] | 10 | #include <stdlib.h>
|
---|
[32] | 11 | #include <stdarg.h>
|
---|
| 12 | //#include <linux/linkage.h>
|
---|
[679] | 13 | #include <linux/bitops.h>
|
---|
| 14 | #include <linux/gfp.h>
|
---|
| 15 | #include <linux/types.h>
|
---|
| 16 | #include <linux/log2.h>
|
---|
[772] | 17 | #include <linux/string.h>
|
---|
| 18 | #include <linux/math.h>
|
---|
| 19 | #include <linux/minmax.h>
|
---|
| 20 | #include <linux/export.h>
|
---|
[32] | 21 |
|
---|
| 22 | /* Optimization barrier */
|
---|
| 23 | /* The "volatile" is due to gcc bugs */
|
---|
| 24 | //#define barrier() __asm__ __volatile__("": : :"memory")
|
---|
| 25 | #define barrier()
|
---|
| 26 |
|
---|
| 27 | #define STACK_MAGIC 0xdeadbeef
|
---|
| 28 |
|
---|
| 29 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
---|
| 30 |
|
---|
| 31 | #define KERN_EMERG "<0>" /* system is unusable */
|
---|
| 32 | #define KERN_ALERT "<1>" /* action must be taken immediately */
|
---|
| 33 | #define KERN_CRIT "<2>" /* critical conditions */
|
---|
| 34 | #define KERN_ERR "<3>" /* error conditions */
|
---|
| 35 | #define KERN_WARNING "<4>" /* warning conditions */
|
---|
| 36 | #define KERN_NOTICE "<5>" /* normal but significant condition */
|
---|
| 37 | #define KERN_INFO "<6>" /* informational */
|
---|
| 38 | #define KERN_DEBUG "<7>" /* debug-level messages */
|
---|
| 39 |
|
---|
| 40 | # define NORET_TYPE /**/
|
---|
| 41 | # define ATTRIB_NORET __attribute__((noreturn))
|
---|
| 42 | # define NORET_AND noreturn,
|
---|
| 43 |
|
---|
| 44 | #ifdef __i386__
|
---|
| 45 | #define FASTCALL(x) x __attribute__((regparm(3)))
|
---|
| 46 | #else
|
---|
| 47 | #define FASTCALL(x) x
|
---|
| 48 | #endif
|
---|
| 49 |
|
---|
| 50 | extern void math_error(void);
|
---|
| 51 | extern struct notifier_block *panic_notifier_list;
|
---|
| 52 | NORET_TYPE void panic(const char * fmt, ...);
|
---|
| 53 |
|
---|
| 54 | NORET_TYPE void do_exit(long error_code);
|
---|
| 55 |
|
---|
[122] | 56 | #define simple_strtoul strtoul
|
---|
[32] | 57 | extern long simple_strtol(const char *,char **,unsigned int);
|
---|
| 58 | extern int sprintf(char * buf, const char * fmt, ...);
|
---|
| 59 | extern int vsprintf(char *buf, const char *, va_list);
|
---|
| 60 | extern int get_option(char **str, int *pint);
|
---|
| 61 | extern char *get_options(char *str, int nints, int *ints);
|
---|
| 62 |
|
---|
| 63 | extern int session_of_pgrp(int pgrp);
|
---|
| 64 |
|
---|
| 65 | int cdecl printk(const char * fmt, ...);
|
---|
| 66 |
|
---|
| 67 |
|
---|
| 68 | /*
|
---|
| 69 | * Display an IP address in readable format.
|
---|
| 70 | */
|
---|
| 71 |
|
---|
| 72 | #define NIPQUAD(addr) \
|
---|
| 73 | ((unsigned char *)&addr)[0], \
|
---|
| 74 | ((unsigned char *)&addr)[1], \
|
---|
| 75 | ((unsigned char *)&addr)[2], \
|
---|
| 76 | ((unsigned char *)&addr)[3]
|
---|
| 77 |
|
---|
| 78 | #endif /* __KERNEL__ */
|
---|
| 79 |
|
---|
| 80 | #define SI_LOAD_SHIFT 16
|
---|
| 81 | struct sysinfo {
|
---|
| 82 | long uptime; /* Seconds since boot */
|
---|
| 83 | unsigned long loads[3]; /* 1, 5, and 15 minute load averages */
|
---|
| 84 | unsigned long totalram; /* Total usable main memory size */
|
---|
| 85 | unsigned long freeram; /* Available memory size */
|
---|
| 86 | unsigned long sharedram; /* Amount of shared memory */
|
---|
| 87 | unsigned long bufferram; /* Memory used by buffers */
|
---|
| 88 | unsigned long totalswap; /* Total swap space size */
|
---|
| 89 | unsigned long freeswap; /* swap space still available */
|
---|
| 90 | unsigned short procs; /* Number of current processes */
|
---|
| 91 | unsigned long totalhigh; /* Total high memory size */
|
---|
| 92 | unsigned long freehigh; /* Available high memory size */
|
---|
| 93 | unsigned int mem_unit; /* Memory unit size in bytes */
|
---|
| 94 | char _f[20-2*sizeof(long)-sizeof(int)]; /* Padding: libc5 uses this.. */
|
---|
| 95 | };
|
---|
| 96 |
|
---|
[319] | 97 | static void complete_and_exit(struct completion *, long);
|
---|
[441] | 98 | #define printk_ratelimit() 1
|
---|
| 99 | #define ALIGN(x,a) (((x)+(a)-1)&~((a)-1))
|
---|
| 100 | #define dump_stack()
|
---|
| 101 | #define upper_32_bits(n) ((u32)(((n) >> 16) >> 16))
|
---|
[442] | 102 | #define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y))
|
---|
[598] | 103 | int strict_strtoul(const char *, unsigned int, unsigned long *);
|
---|
[319] | 104 |
|
---|
[679] | 105 | #define BUG_ON(condition)
|
---|
| 106 | #define WARN_ON(condition) (void)0
|
---|
| 107 | #define WARN_ON_ONCE(condition) (void)0
|
---|
| 108 | #define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
|
---|
| 109 | #define SIZE_MAX (~(size_t)0)
|
---|
| 110 | _WCRTLINK extern int vsnprintf( char *__s, size_t __bufsize,
|
---|
| 111 | const char *__format, __va_list __arg );
|
---|
| 112 | char *kasprintf(gfp_t gfp, const char *fmt, ...);
|
---|
| 113 |
|
---|
| 114 | char *kvasprintf(gfp_t gfp, const char *fmt, va_list args);
|
---|
[777] | 115 | int vscnprintf(char *buf, size_t size, const char *fmt, va_list args);
|
---|
[679] | 116 | extern int hex_to_bin(char ch);
|
---|
| 117 | #define __ALIGN_MASK(x, mask) __ALIGN_KERNEL_MASK((x), (mask))
|
---|
| 118 | #define __ALIGN_KERNEL_MASK(x, mask) (((x) + (mask)) & ~(mask))
|
---|
| 119 |
|
---|
| 120 | /**
|
---|
| 121 | * container_of - cast a member of a structure out to the containing structure
|
---|
| 122 | * @ptr: the pointer to the member.
|
---|
| 123 | * @type: the type of the container struct this is embedded in.
|
---|
| 124 | * @member: the name of the member within the struct.
|
---|
| 125 | *
|
---|
| 126 | */
|
---|
| 127 | #define container_of(ptr, type, member) \
|
---|
| 128 | ( (type *)( (char *)ptr - offsetof(type,member) ) )
|
---|
| 129 |
|
---|
| 130 | _WCRTLINK extern int sscanf( const char *__s, const char *__format, ... );
|
---|
[777] | 131 | typedef void *acpi_handle; /* Actually a ptr to a NS Node */
|
---|
| 132 | typedef
|
---|
| 133 | void (*acpi_notify_handler) (acpi_handle device, u32 value, void *context);
|
---|
[32] | 134 | #endif
|
---|