| 1 | /* $Id: kernel.h,v 1.1.1.1 2003/07/02 13:57:00 eleph Exp $ */ | 
|---|
| 2 |  | 
|---|
| 3 | #ifndef _LINUX_KERNEL_H | 
|---|
| 4 | #define _LINUX_KERNEL_H | 
|---|
| 5 |  | 
|---|
| 6 | /* | 
|---|
| 7 | * 'kernel.h' contains some often-used function prototypes etc | 
|---|
| 8 | */ | 
|---|
| 9 |  | 
|---|
| 10 | #ifdef __KERNEL__ | 
|---|
| 11 |  | 
|---|
| 12 | #include <stdlib.h> | 
|---|
| 13 | #include <stdarg.h> | 
|---|
| 14 | //#include <linux/linkage.h> | 
|---|
| 15 |  | 
|---|
| 16 | /* Optimization barrier */ | 
|---|
| 17 | /* The "volatile" is due to gcc bugs */ | 
|---|
| 18 | //#define barrier() __asm__ __volatile__("": : :"memory") | 
|---|
| 19 | #define barrier() | 
|---|
| 20 |  | 
|---|
| 21 | #define STACK_MAGIC     0xdeadbeef | 
|---|
| 22 |  | 
|---|
| 23 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) | 
|---|
| 24 |  | 
|---|
| 25 | #define KERN_EMERG      "<0>"   /* system is unusable                   */ | 
|---|
| 26 | #define KERN_ALERT      "<1>"   /* action must be taken immediately     */ | 
|---|
| 27 | #define KERN_CRIT       "<2>"   /* critical conditions                  */ | 
|---|
| 28 | #define KERN_ERR        "<3>"   /* error conditions                     */ | 
|---|
| 29 | #define KERN_WARNING    "<4>"   /* warning conditions                   */ | 
|---|
| 30 | #define KERN_NOTICE     "<5>"   /* normal but significant condition     */ | 
|---|
| 31 | #define KERN_INFO       "<6>"   /* informational                        */ | 
|---|
| 32 | #define KERN_DEBUG      "<7>"   /* debug-level messages                 */ | 
|---|
| 33 |  | 
|---|
| 34 | # define NORET_TYPE    /**/ | 
|---|
| 35 | # define ATTRIB_NORET  __attribute__((noreturn)) | 
|---|
| 36 | # define NORET_AND     noreturn, | 
|---|
| 37 |  | 
|---|
| 38 | #ifdef __i386__ | 
|---|
| 39 | #define FASTCALL(x)     x __attribute__((regparm(3))) | 
|---|
| 40 | #else | 
|---|
| 41 | #define FASTCALL(x)     x | 
|---|
| 42 | #endif | 
|---|
| 43 |  | 
|---|
| 44 | extern void math_error(void); | 
|---|
| 45 | extern struct notifier_block *panic_notifier_list; | 
|---|
| 46 | NORET_TYPE void panic(const char * fmt, ...); | 
|---|
| 47 |  | 
|---|
| 48 | NORET_TYPE void do_exit(long error_code); | 
|---|
| 49 |  | 
|---|
| 50 | #define simple_strtoul strtoul | 
|---|
| 51 | extern long simple_strtol(const char *,char **,unsigned int); | 
|---|
| 52 | extern int sprintf(char * buf, const char * fmt, ...); | 
|---|
| 53 | extern int vsprintf(char *buf, const char *, va_list); | 
|---|
| 54 | extern int get_option(char **str, int *pint); | 
|---|
| 55 | extern char *get_options(char *str, int nints, int *ints); | 
|---|
| 56 |  | 
|---|
| 57 | extern int session_of_pgrp(int pgrp); | 
|---|
| 58 |  | 
|---|
| 59 | int cdecl printk(const char * fmt, ...); | 
|---|
| 60 |  | 
|---|
| 61 |  | 
|---|
| 62 | #if DEBUG | 
|---|
| 63 | #define pr_debug(fmt,arg) | 
|---|
| 64 | #else | 
|---|
| 65 | #define pr_debug(fmt,arg) | 
|---|
| 66 | #endif | 
|---|
| 67 |  | 
|---|
| 68 | #define pr_info(fmt,arg) \ | 
|---|
| 69 | printk(KERN_INFO fmt,##arg) | 
|---|
| 70 |  | 
|---|
| 71 | /* | 
|---|
| 72 | *      Display an IP address in readable format. | 
|---|
| 73 | */ | 
|---|
| 74 |  | 
|---|
| 75 | #define NIPQUAD(addr) \ | 
|---|
| 76 | ((unsigned char *)&addr)[0], \ | 
|---|
| 77 | ((unsigned char *)&addr)[1], \ | 
|---|
| 78 | ((unsigned char *)&addr)[2], \ | 
|---|
| 79 | ((unsigned char *)&addr)[3] | 
|---|
| 80 |  | 
|---|
| 81 | #endif /* __KERNEL__ */ | 
|---|
| 82 |  | 
|---|
| 83 | #define SI_LOAD_SHIFT   16 | 
|---|
| 84 | struct sysinfo { | 
|---|
| 85 | long uptime;                    /* Seconds since boot */ | 
|---|
| 86 | unsigned long loads[3];         /* 1, 5, and 15 minute load averages */ | 
|---|
| 87 | unsigned long totalram;         /* Total usable main memory size */ | 
|---|
| 88 | unsigned long freeram;          /* Available memory size */ | 
|---|
| 89 | unsigned long sharedram;        /* Amount of shared memory */ | 
|---|
| 90 | unsigned long bufferram;        /* Memory used by buffers */ | 
|---|
| 91 | unsigned long totalswap;        /* Total swap space size */ | 
|---|
| 92 | unsigned long freeswap;         /* swap space still available */ | 
|---|
| 93 | unsigned short procs;           /* Number of current processes */ | 
|---|
| 94 | unsigned long totalhigh;        /* Total high memory size */ | 
|---|
| 95 | unsigned long freehigh;         /* Available high memory size */ | 
|---|
| 96 | unsigned int mem_unit;          /* Memory unit size in bytes */ | 
|---|
| 97 | char _f[20-2*sizeof(long)-sizeof(int)]; /* Padding: libc5 uses this.. */ | 
|---|
| 98 | }; | 
|---|
| 99 |  | 
|---|
| 100 | #endif | 
|---|