source: GPL/trunk/include/linux/kernel.h@ 679

Last change on this file since 679 was 679, checked in by David Azarewicz, 4 years ago

Merge changes from Paul's uniaud32next branch.

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