Version:  2.0.40 2.2.26 2.4.37 3.13 3.14 3.15 3.16 3.17 3.18 3.19 4.0 4.1 4.2 4.3 4.4 4.5 4.6 4.7 4.8 4.9 4.10

Linux/include/linux/kernel.h

  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 
 10 #include <stdarg.h>
 11 #include <linux/linkage.h>
 12 #include <linux/stddef.h>
 13 #include <linux/types.h>
 14 #include <linux/compiler.h>
 15 #include <asm/byteorder.h>
 16 
 17 /* Optimization barrier */
 18 /* The "volatile" is due to gcc bugs */
 19 #define barrier() __asm__ __volatile__("": : :"memory")
 20 
 21 #define INT_MAX         ((int)(~0U>>1))
 22 #define INT_MIN         (-INT_MAX - 1)
 23 #define UINT_MAX        (~0U)
 24 #define LONG_MAX        ((long)(~0UL>>1))
 25 #define LONG_MIN        (-LONG_MAX - 1)
 26 #define ULONG_MAX       (~0UL)
 27 
 28 #define STACK_MAGIC     0xdeadbeef
 29 
 30 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
 31 
 32 #define KERN_EMERG      "<0>"   /* system is unusable                   */
 33 #define KERN_ALERT      "<1>"   /* action must be taken immediately     */
 34 #define KERN_CRIT       "<2>"   /* critical conditions                  */
 35 #define KERN_ERR        "<3>"   /* error conditions                     */
 36 #define KERN_WARNING    "<4>"   /* warning conditions                   */
 37 #define KERN_NOTICE     "<5>"   /* normal but significant condition     */
 38 #define KERN_INFO       "<6>"   /* informational                        */
 39 #define KERN_DEBUG      "<7>"   /* debug-level messages                 */
 40 
 41 extern int console_printk[];
 42 
 43 #define console_loglevel (console_printk[0])
 44 #define default_message_loglevel (console_printk[1])
 45 #define minimum_console_loglevel (console_printk[2])
 46 #define default_console_loglevel (console_printk[3])
 47 
 48 # define NORET_TYPE    /**/
 49 # define ATTRIB_NORET  __attribute__((noreturn))
 50 # define NORET_AND     noreturn,
 51 
 52 #ifdef __i386__
 53 #define FASTCALL(x)     x __attribute__((regparm(3)))
 54 #define fastcall        __attribute__((regparm(3)))
 55 #else
 56 #define FASTCALL(x)     x
 57 #define fastcall
 58 #endif
 59 
 60 struct completion;
 61 
 62 extern struct notifier_block *panic_notifier_list;
 63 NORET_TYPE void panic(const char * fmt, ...)
 64         __attribute__ ((NORET_AND format (printf, 1, 2)));
 65 asmlinkage NORET_TYPE void do_exit(long error_code)
 66         ATTRIB_NORET;
 67 NORET_TYPE void complete_and_exit(struct completion *, long)
 68         ATTRIB_NORET;
 69 extern int abs(int);
 70 extern unsigned long simple_strtoul(const char *,char **,unsigned int);
 71 extern long simple_strtol(const char *,char **,unsigned int);
 72 extern unsigned long long simple_strtoull(const char *,char **,unsigned int);
 73 extern long long simple_strtoll(const char *,char **,unsigned int);
 74 extern int sprintf(char * buf, const char * fmt, ...)
 75         __attribute__ ((format (printf, 2, 3)));
 76 extern int vsprintf(char *buf, const char *, va_list)
 77         __attribute__ ((format (printf, 2, 0)));
 78 extern int snprintf(char * buf, size_t size, const char * fmt, ...)
 79         __attribute__ ((format (printf, 3, 4)));
 80 extern int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
 81         __attribute__ ((format (printf, 3, 0)));
 82 
 83 extern int sscanf(const char *, const char *, ...)
 84         __attribute__ ((format (scanf, 2, 3)));
 85 extern int vsscanf(const char *, const char *, va_list)
 86         __attribute__ ((format (scanf, 2, 0)));
 87 
 88 extern int get_option(char **str, int *pint);
 89 extern char *get_options(char *str, int nints, int *ints);
 90 extern unsigned long long memparse(char *ptr, char **retptr);
 91 extern void dev_probe_lock(void);
 92 extern void dev_probe_unlock(void);
 93 
 94 extern int session_of_pgrp(int pgrp);
 95 
 96 asmlinkage int printk(const char * fmt, ...)
 97         __attribute__ ((format (printf, 1, 2)));
 98 
 99 static inline void console_silent(void)
100 {
101         console_loglevel = 0;
102 }
103 
104 static inline void console_verbose(void)
105 {
106         if (console_loglevel)
107                 console_loglevel = 15;
108 }
109 
110 extern void bust_spinlocks(int yes);
111 extern int oops_in_progress;            /* If set, an oops, panic(), BUG() or die() is in progress */
112 
113 extern int tainted;
114 extern const char *print_tainted(void);
115 
116 extern void dump_stack(void);
117 
118 #if DEBUG
119 #define pr_debug(fmt,arg...) \
120         printk(KERN_DEBUG fmt,##arg)
121 #else
122 #define pr_debug(fmt,arg...) \
123         do { } while (0)
124 #endif
125 
126 #define pr_info(fmt,arg...) \
127         printk(KERN_INFO fmt,##arg)
128 
129 /*
130  *      Display an IP address in readable format.
131  */
132 
133 #define NIPQUAD(addr) \
134         ((unsigned char *)&addr)[0], \
135         ((unsigned char *)&addr)[1], \
136         ((unsigned char *)&addr)[2], \
137         ((unsigned char *)&addr)[3]
138 
139 #if defined(__LITTLE_ENDIAN)
140 #define HIPQUAD(addr) \
141         ((unsigned char *)&addr)[3], \
142         ((unsigned char *)&addr)[2], \
143         ((unsigned char *)&addr)[1], \
144         ((unsigned char *)&addr)[0]
145 #elif defined(__BIG_ENDIAN)
146 #define HIPQUAD NIPQUAD
147 #else
148 #error "Please fix asm/byteorder.h"
149 #endif /* __LITTLE_ENDIAN */
150 
151 /*
152  * min()/max() macros that also do
153  * strict type-checking.. See the
154  * "unnecessary" pointer comparison.
155  */
156 #define min(x,y) ({ \
157         const typeof(x) _x = (x);       \
158         const typeof(y) _y = (y);       \
159         (void) (&_x == &_y);            \
160         _x < _y ? _x : _y; })
161 
162 #define max(x,y) ({ \
163         const typeof(x) _x = (x);       \
164         const typeof(y) _y = (y);       \
165         (void) (&_x == &_y);            \
166         _x > _y ? _x : _y; })
167 
168 /*
169  * ..and if you can't take the strict
170  * types, you can specify one yourself.
171  *
172  * Or not use min/max at all, of course.
173  */
174 #define min_t(type,x,y) \
175         ({ type __x = (x); type __y = (y); __x < __y ? __x: __y; })
176 #define max_t(type,x,y) \
177         ({ type __x = (x); type __y = (y); __x > __y ? __x: __y; })
178 
179 extern void __out_of_line_bug(int line) ATTRIB_NORET;
180 #define out_of_line_bug() __out_of_line_bug(__LINE__)
181 
182 #endif /* __KERNEL__ */
183 
184 #define SI_LOAD_SHIFT   16
185 struct sysinfo {
186         long uptime;                    /* Seconds since boot */
187         unsigned long loads[3];         /* 1, 5, and 15 minute load averages */
188         unsigned long totalram;         /* Total usable main memory size */
189         unsigned long freeram;          /* Available memory size */
190         unsigned long sharedram;        /* Amount of shared memory */
191         unsigned long bufferram;        /* Memory used by buffers */
192         unsigned long totalswap;        /* Total swap space size */
193         unsigned long freeswap;         /* swap space still available */
194         unsigned short procs;           /* Number of current processes */
195         unsigned short pad;             /* explicit padding for m68k */
196         unsigned long totalhigh;        /* Total high memory size */
197         unsigned long freehigh;         /* Available high memory size */
198         unsigned int mem_unit;          /* Memory unit size in bytes */
199         char _f[20-2*sizeof(long)-sizeof(int)]; /* Padding: libc5 uses this.. */
200 };
201 
202 #define BUG_ON(condition) do { if (unlikely((condition)!=0)) BUG(); } while(0)
203 
204 #define WARN_ON(condition) do { \
205         if (unlikely((condition)!=0)) { \
206                 printk("Badness in %s at %s:%d\n", __FUNCTION__, __FILE__, __LINE__); \
207                 dump_stack(); \
208         } \
209 } while (0)
210 
211 #endif /* _LINUX_KERNEL_H */
212 

This page was automatically generated by LXR 0.3.1 (source).  •  Linux is a registered trademark of Linus Torvalds  •  Contact us