- Stephen Rothwell: APM updates
[davej-history.git] / include / linux / kernel.h
blob50ee124718961a928ba1ac3f0d929c7d487aa7d4
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);
66 extern void dev_probe_lock(void);
67 extern void dev_probe_unlock(void);
69 extern int session_of_pgrp(int pgrp);
71 asmlinkage int printk(const char * fmt, ...)
72 __attribute__ ((format (printf, 1, 2)));
74 extern int console_loglevel;
76 static inline void console_silent(void)
78 console_loglevel = 0;
81 static inline void console_verbose(void)
83 if (console_loglevel)
84 console_loglevel = 15;
87 #if DEBUG
88 #define pr_debug(fmt,arg...) \
89 printk(KERN_DEBUG fmt,##arg)
90 #else
91 #define pr_debug(fmt,arg...) \
92 do { } while (0)
93 #endif
95 #define pr_info(fmt,arg...) \
96 printk(KERN_INFO fmt,##arg)
99 * Display an IP address in readable format.
102 #define NIPQUAD(addr) \
103 ((unsigned char *)&addr)[0], \
104 ((unsigned char *)&addr)[1], \
105 ((unsigned char *)&addr)[2], \
106 ((unsigned char *)&addr)[3]
108 #define HIPQUAD(addr) \
109 ((unsigned char *)&addr)[3], \
110 ((unsigned char *)&addr)[2], \
111 ((unsigned char *)&addr)[1], \
112 ((unsigned char *)&addr)[0]
114 #endif /* __KERNEL__ */
116 #define SI_LOAD_SHIFT 16
117 struct sysinfo {
118 long uptime; /* Seconds since boot */
119 unsigned long loads[3]; /* 1, 5, and 15 minute load averages */
120 unsigned long totalram; /* Total usable main memory size */
121 unsigned long freeram; /* Available memory size */
122 unsigned long sharedram; /* Amount of shared memory */
123 unsigned long bufferram; /* Memory used by buffers */
124 unsigned long totalswap; /* Total swap space size */
125 unsigned long freeswap; /* swap space still available */
126 unsigned short procs; /* Number of current processes */
127 unsigned long totalhigh; /* Total high memory size */
128 unsigned long freehigh; /* Available high memory size */
129 unsigned int mem_unit; /* Memory unit size in bytes */
130 char _f[20-2*sizeof(long)-sizeof(int)]; /* Padding: libc5 uses this.. */
133 #endif