- Andries Brouwer: final isofs pieces.
[davej-history.git] / include / linux / kernel.h
blobee3e8906c5d6e26efd2ba2fab2423256f9935e9b
1 #ifndef _LINUX_KERNEL_H
2 #define _LINUX_KERNEL_H
4 /*
5 * 'kernel.h' contains some often-used function prototypes etc
6 */
8 #ifdef __KERNEL__
10 #include <stdarg.h>
11 #include <linux/linkage.h>
12 #include <linux/stddef.h>
14 /* Optimization barrier */
15 /* The "volatile" is due to gcc bugs */
16 #define barrier() __asm__ __volatile__("": : :"memory")
18 #define INT_MAX ((int)(~0U>>1))
19 #define INT_MIN (-INT_MAX - 1)
20 #define UINT_MAX (~0U)
21 #define LONG_MAX ((long)(~0UL>>1))
22 #define LONG_MIN (-LONG_MAX - 1)
23 #define ULONG_MAX (~0UL)
25 #define STACK_MAGIC 0xdeadbeef
27 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
29 #define KERN_EMERG "<0>" /* system is unusable */
30 #define KERN_ALERT "<1>" /* action must be taken immediately */
31 #define KERN_CRIT "<2>" /* critical conditions */
32 #define KERN_ERR "<3>" /* error conditions */
33 #define KERN_WARNING "<4>" /* warning conditions */
34 #define KERN_NOTICE "<5>" /* normal but significant condition */
35 #define KERN_INFO "<6>" /* informational */
36 #define KERN_DEBUG "<7>" /* debug-level messages */
38 # define NORET_TYPE /**/
39 # define ATTRIB_NORET __attribute__((noreturn))
40 # define NORET_AND noreturn,
42 #ifdef __i386__
43 #define FASTCALL(x) x __attribute__((regparm(3)))
44 #else
45 #define FASTCALL(x) x
46 #endif
48 struct semaphore;
50 extern struct notifier_block *panic_notifier_list;
51 NORET_TYPE void panic(const char * fmt, ...)
52 __attribute__ ((NORET_AND format (printf, 1, 2)));
53 NORET_TYPE void do_exit(long error_code)
54 ATTRIB_NORET;
55 NORET_TYPE void up_and_exit(struct semaphore *, long)
56 ATTRIB_NORET;
57 extern unsigned long simple_strtoul(const char *,char **,unsigned int);
58 extern long simple_strtol(const char *,char **,unsigned int);
59 extern unsigned long long simple_strtoull(const char *,char **,unsigned int);
60 extern long long simple_strtoll(const char *,char **,unsigned int);
61 extern int sprintf(char * buf, const char * fmt, ...);
62 extern int vsprintf(char *buf, const char *, va_list);
63 extern int get_option(char **str, int *pint);
64 extern char *get_options(char *str, int nints, int *ints);
65 extern unsigned long memparse(char *ptr, char **retptr);
67 extern int session_of_pgrp(int pgrp);
69 asmlinkage int printk(const char * fmt, ...)
70 __attribute__ ((format (printf, 1, 2)));
72 extern int console_loglevel;
74 static inline void console_silent(void)
76 console_loglevel = 0;
79 static inline void console_verbose(void)
81 if (console_loglevel)
82 console_loglevel = 15;
85 #if DEBUG
86 #define pr_debug(fmt,arg...) \
87 printk(KERN_DEBUG fmt,##arg)
88 #else
89 #define pr_debug(fmt,arg...) \
90 do { } while (0)
91 #endif
93 #define pr_info(fmt,arg...) \
94 printk(KERN_INFO fmt,##arg)
97 * Display an IP address in readable format.
100 #define NIPQUAD(addr) \
101 ((unsigned char *)&addr)[0], \
102 ((unsigned char *)&addr)[1], \
103 ((unsigned char *)&addr)[2], \
104 ((unsigned char *)&addr)[3]
106 #define HIPQUAD(addr) \
107 ((unsigned char *)&addr)[3], \
108 ((unsigned char *)&addr)[2], \
109 ((unsigned char *)&addr)[1], \
110 ((unsigned char *)&addr)[0]
112 #endif /* __KERNEL__ */
114 #define SI_LOAD_SHIFT 16
115 struct sysinfo {
116 long uptime; /* Seconds since boot */
117 unsigned long loads[3]; /* 1, 5, and 15 minute load averages */
118 unsigned long totalram; /* Total usable main memory size */
119 unsigned long freeram; /* Available memory size */
120 unsigned long sharedram; /* Amount of shared memory */
121 unsigned long bufferram; /* Memory used by buffers */
122 unsigned long totalswap; /* Total swap space size */
123 unsigned long freeswap; /* swap space still available */
124 unsigned short procs; /* Number of current processes */
125 unsigned long totalhigh; /* Total high memory size */
126 unsigned long freehigh; /* Available high memory size */
127 unsigned int mem_unit; /* Memory unit size in bytes */
128 char _f[20-2*sizeof(long)-sizeof(int)]; /* Padding: libc5 uses this.. */
131 #endif