Rev 5272 | Rev 6102 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5272 | Rev 6082 | ||
---|---|---|---|
Line 100... | Line 100... | ||
100 | ((typeof(divisor))-1) > 0 || (__x) > 0) ? \ |
100 | ((typeof(divisor))-1) > 0 || (__x) > 0) ? \ |
101 | (((__x) + ((__d) / 2)) / (__d)) : \ |
101 | (((__x) + ((__d) / 2)) / (__d)) : \ |
102 | (((__x) - ((__d) / 2)) / (__d)); \ |
102 | (((__x) - ((__d) / 2)) / (__d)); \ |
103 | } \ |
103 | } \ |
104 | ) |
104 | ) |
- | 105 | /* |
|
- | 106 | * Same as above but for u64 dividends. divisor must be a 32-bit |
|
- | 107 | * number. |
|
- | 108 | */ |
|
- | 109 | #define DIV_ROUND_CLOSEST_ULL(x, divisor)( \ |
|
- | 110 | { \ |
|
- | 111 | typeof(divisor) __d = divisor; \ |
|
- | 112 | unsigned long long _tmp = (x) + (__d) / 2; \ |
|
- | 113 | do_div(_tmp, __d); \ |
|
- | 114 | _tmp; \ |
|
- | 115 | } \ |
|
- | 116 | ) |
|
Line 105... | Line 117... | ||
105 | 117 | ||
106 | /* |
118 | /* |
107 | * Multiplies an integer by a fraction, while avoiding unnecessary |
119 | * Multiplies an integer by a fraction, while avoiding unnecessary |
108 | * overflow or loss of precision. |
120 | * overflow or loss of precision. |
Line 147... | Line 159... | ||
147 | * lower_32_bits - return bits 0-31 of a number |
159 | * lower_32_bits - return bits 0-31 of a number |
148 | * @n: the number we're accessing |
160 | * @n: the number we're accessing |
149 | */ |
161 | */ |
150 | #define lower_32_bits(n) ((u32)(n)) |
162 | #define lower_32_bits(n) ((u32)(n)) |
Line -... | Line 163... | ||
- | 163 | ||
- | 164 | #ifdef CONFIG_PREEMPT_VOLUNTARY |
|
- | 165 | extern int _cond_resched(void); |
|
- | 166 | # define might_resched() _cond_resched() |
|
- | 167 | #else |
|
- | 168 | # define might_resched() do { } while (0) |
|
Line -... | Line 169... | ||
- | 169 | #endif |
|
- | 170 | ||
- | 171 | #ifdef CONFIG_DEBUG_ATOMIC_SLEEP |
|
151 | 172 | void ___might_sleep(const char *file, int line, int preempt_offset); |
|
- | 173 | void __might_sleep(const char *file, int line, int preempt_offset); |
|
- | 174 | /** |
|
152 | 175 | * might_sleep - annotation for functions that can sleep |
|
153 | /* |
176 | * |
- | 177 | * this macro will print a stack trace if it is executed in an atomic |
|
- | 178 | * context (spinlock, irq-handler, ...). |
|
154 | * abs() handles unsigned and signed longs, ints, shorts and chars. For all |
179 | * |
155 | * input types abs() returns a signed long. |
180 | * This is a useful debugging help to be able to catch problems early and not |
- | 181 | * be bitten later when the calling function happens to sleep when it is not |
|
- | 182 | * supposed to. |
|
- | 183 | */ |
|
- | 184 | # define might_sleep() \ |
|
- | 185 | do { __might_sleep(__FILE__, __LINE__, 0); might_resched(); } while (0) |
|
- | 186 | # define sched_annotate_sleep() (current->task_state_change = 0) |
|
- | 187 | #else |
|
- | 188 | static inline void ___might_sleep(const char *file, int line, |
|
- | 189 | int preempt_offset) { } |
|
- | 190 | static inline void __might_sleep(const char *file, int line, |
|
- | 191 | int preempt_offset) { } |
|
- | 192 | # define might_sleep() do { might_resched(); } while (0) |
|
- | 193 | # define sched_annotate_sleep() do { } while (0) |
|
- | 194 | #endif |
|
- | 195 | ||
- | 196 | #define might_sleep_if(cond) do { if (cond) might_sleep(); } while (0) |
|
- | 197 | ||
- | 198 | /** |
|
- | 199 | * abs - return absolute value of an argument |
|
- | 200 | * @x: the value. If it is unsigned type, it is converted to signed type first |
|
- | 201 | * (s64, long or int depending on its size). |
|
- | 202 | * |
|
156 | * abs() should not be used for 64-bit types (s64, u64, long long) - use abs64() |
203 | * Return: an absolute value of x. If x is 64-bit, macro's return type is s64, |
- | 204 | * otherwise it is signed long. |
|
157 | * for those. |
205 | */ |
- | 206 | #define abs(x) __builtin_choose_expr(sizeof(x) == sizeof(s64), ({ \ |
|
- | 207 | s64 __x = (x); \ |
|
158 | */ |
208 | (__x < 0) ? -__x : __x; \ |
159 | #define abs(x) ({ \ |
209 | }), ({ \ |
160 | long ret; \ |
210 | long ret; \ |
161 | if (sizeof(x) == sizeof(long)) { \ |
211 | if (sizeof(x) == sizeof(long)) { \ |
162 | long __x = (x); \ |
212 | long __x = (x); \ |
163 | ret = (__x < 0) ? -__x : __x; \ |
213 | ret = (__x < 0) ? -__x : __x; \ |
164 | } else { \ |
214 | } else { \ |
165 | int __x = (x); \ |
215 | int __x = (x); \ |
166 | ret = (__x < 0) ? -__x : __x; \ |
216 | ret = (__x < 0) ? -__x : __x; \ |
167 | } \ |
217 | } \ |
Line -... | Line 218... | ||
- | 218 | ret; \ |
|
- | 219 | })) |
|
- | 220 | ||
- | 221 | /** |
|
- | 222 | * reciprocal_scale - "scale" a value into range [0, ep_ro) |
|
- | 223 | * @val: value |
|
- | 224 | * @ep_ro: right open interval endpoint |
|
- | 225 | * |
|
- | 226 | * Perform a "reciprocal multiplication" in order to "scale" a value into |
|
- | 227 | * range [0, ep_ro), where the upper interval endpoint is right-open. |
|
- | 228 | * This is useful, e.g. for accessing a index of an array containing |
|
- | 229 | * ep_ro elements, for example. Think of it as sort of modulus, only that |
|
168 | ret; \ |
230 | * the result isn't that of modulo. ;) Note that if initial input is a |
- | 231 | * small value, then result will return 0. |
|
- | 232 | * |
|
- | 233 | * Return: a result based on val in interval [0, ep_ro). |
|
169 | }) |
234 | */ |
- | 235 | static inline u32 reciprocal_scale(u32 val, u32 ep_ro) |
|
- | 236 | { |
|
- | 237 | return (u32)(((u64) val * ep_ro) >> 32); |
|
- | 238 | } |
|
170 | 239 | ||
- | 240 | #if defined(CONFIG_MMU) && \ |
|
- | 241 | (defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_DEBUG_ATOMIC_SLEEP)) |
|
- | 242 | #define might_fault() __might_fault(__FILE__, __LINE__) |
|
171 | #define abs64(x) ({ \ |
243 | void __might_fault(const char *file, int line); |
Line 172... | Line 244... | ||
172 | s64 __x = (x); \ |
244 | #else |
173 | (__x < 0) ? -__x : __x; \ |
245 | static inline void might_fault(void) { } |
174 | }) |
246 | #endif |
175 | 247 | ||
176 | #define KERN_EMERG "<0>" /* system is unusable */ |
248 | #define KERN_EMERG "<0>" /* system is unusable */ |
177 | #define KERN_ALERT "<1>" /* action must be taken immediately */ |
249 | #define KERN_ALERT "<1>" /* action must be taken immediately */ |
178 | #define KERN_CRIT "<2>" /* critical conditions */ |
250 | #define KERN_CRIT "<2>" /* critical conditions */ |
179 | #define KERN_ERR "<3>" /* error conditions */ |
251 | #define KERN_ERR "<3>" /* error conditions */ |
- | 252 | #define KERN_WARNING "<4>" /* warning conditions */ |
|
- | 253 | #define KERN_NOTICE "<5>" /* normal but significant condition */ |
|
- | 254 | #define KERN_INFO "<6>" /* informational */ |
|
- | 255 | #define KERN_DEBUG "<7>" /* debug-level messages */ |
|
- | 256 | extern unsigned long simple_strtoul(const char *,char **,unsigned int); |
|
- | 257 | extern long simple_strtol(const char *,char **,unsigned int); |
|
- | 258 | extern unsigned long long simple_strtoull(const char *,char **,unsigned int); |
|
- | 259 | extern long long simple_strtoll(const char *,char **,unsigned int); |
|
- | 260 | ||
180 | #define KERN_WARNING "<4>" /* warning conditions */ |
261 | extern int num_to_str(char *buf, int size, unsigned long long num); |
181 | #define KERN_NOTICE "<5>" /* normal but significant condition */ |
262 | |
182 | #define KERN_INFO "<6>" /* informational */ |
263 | /* lib/printf utilities */ |
183 | #define KERN_DEBUG "<7>" /* debug-level messages */ |
264 | |
184 | extern __printf(2, 3) int sprintf(char *buf, const char * fmt, ...); |
265 | extern __printf(2, 3) int sprintf(char *buf, const char * fmt, ...); |
Line 191... | Line 272... | ||
191 | int scnprintf(char *buf, size_t size, const char *fmt, ...); |
272 | int scnprintf(char *buf, size_t size, const char *fmt, ...); |
192 | extern __printf(3, 0) |
273 | extern __printf(3, 0) |
193 | int vscnprintf(char *buf, size_t size, const char *fmt, va_list args); |
274 | int vscnprintf(char *buf, size_t size, const char *fmt, va_list args); |
194 | extern __printf(2, 3) |
275 | extern __printf(2, 3) |
195 | char *kasprintf(gfp_t gfp, const char *fmt, ...); |
276 | char *kasprintf(gfp_t gfp, const char *fmt, ...); |
- | 277 | extern __printf(2, 0) |
|
196 | extern char *kvasprintf(gfp_t gfp, const char *fmt, va_list args); |
278 | char *kvasprintf(gfp_t gfp, const char *fmt, va_list args); |
- | 279 | extern __printf(2, 0) |
|
- | 280 | const char *kvasprintf_const(gfp_t gfp, const char *fmt, va_list args); |
|
- | 281 | ||
- | 282 | extern __scanf(2, 3) |
|
- | 283 | int sscanf(const char *, const char *, ...); |
|
- | 284 | extern __scanf(2, 0) |
|
- | 285 | int vsscanf(const char *, const char *, va_list); |
|
- | 286 | extern int oops_in_progress; /* If set, an oops, panic(), BUG() or die() is in progress */ |
|
197 | enum lockdep_ok { |
287 | enum lockdep_ok { |
198 | LOCKDEP_STILL_OK, |
288 | LOCKDEP_STILL_OK, |
199 | LOCKDEP_NOW_UNRELIABLE |
289 | LOCKDEP_NOW_UNRELIABLE |
200 | }; |
290 | }; |
201 | extern void add_taint(unsigned flag, enum lockdep_ok); |
291 | extern void add_taint(unsigned flag, enum lockdep_ok); |
Line 227... | Line 317... | ||
227 | #define TAINT_CRAP 10 |
317 | #define TAINT_CRAP 10 |
228 | #define TAINT_FIRMWARE_WORKAROUND 11 |
318 | #define TAINT_FIRMWARE_WORKAROUND 11 |
229 | #define TAINT_OOT_MODULE 12 |
319 | #define TAINT_OOT_MODULE 12 |
230 | #define TAINT_UNSIGNED_MODULE 13 |
320 | #define TAINT_UNSIGNED_MODULE 13 |
231 | #define TAINT_SOFTLOCKUP 14 |
321 | #define TAINT_SOFTLOCKUP 14 |
- | 322 | #define TAINT_LIVEPATCH 15 |
|
Line 232... | Line 323... | ||
232 | 323 | ||
233 | extern const char hex_asc[]; |
324 | extern const char hex_asc[]; |
234 | #define hex_asc_lo(x) hex_asc[((x) & 0x0f)] |
325 | #define hex_asc_lo(x) hex_asc[((x) & 0x0f)] |
Line 275... | Line 366... | ||
275 | * trace is not enough, but tracing must actually stop because things |
366 | * trace is not enough, but tracing must actually stop because things |
276 | * like calling smp_processor_id() may crash the system. |
367 | * like calling smp_processor_id() may crash the system. |
277 | * |
368 | * |
278 | * Most likely, you want to use tracing_on/tracing_off. |
369 | * Most likely, you want to use tracing_on/tracing_off. |
279 | */ |
370 | */ |
280 | #ifdef CONFIG_RING_BUFFER |
- | |
281 | /* trace_off_permanent stops recording with no way to bring it back */ |
- | |
282 | void tracing_off_permanent(void); |
- | |
283 | #else |
- | |
284 | static inline void tracing_off_permanent(void) { } |
- | |
285 | #endif |
- | |
Line 286... | Line 371... | ||
286 | 371 | ||
287 | enum ftrace_dump_mode { |
372 | enum ftrace_dump_mode { |
288 | DUMP_NONE, |
373 | DUMP_NONE, |
289 | DUMP_ALL, |
374 | DUMP_ALL, |
Line 424... | Line 509... | ||
424 | __ftrace_vbprintk(_THIS_IP_, trace_printk_fmt, vargs); \ |
509 | __ftrace_vbprintk(_THIS_IP_, trace_printk_fmt, vargs); \ |
425 | } else \ |
510 | } else \ |
426 | __ftrace_vprintk(_THIS_IP_, fmt, vargs); \ |
511 | __ftrace_vprintk(_THIS_IP_, fmt, vargs); \ |
427 | } while (0) |
512 | } while (0) |
Line 428... | Line 513... | ||
428 | 513 | ||
429 | extern int |
514 | extern __printf(2, 0) int |
Line 430... | Line 515... | ||
430 | __ftrace_vbprintk(unsigned long ip, const char *fmt, va_list ap); |
515 | __ftrace_vbprintk(unsigned long ip, const char *fmt, va_list ap); |
431 | 516 | ||
Line 432... | Line 517... | ||
432 | extern int |
517 | extern __printf(2, 0) int |
433 | __ftrace_vprintk(unsigned long ip, const char *fmt, va_list ap); |
518 | __ftrace_vprintk(unsigned long ip, const char *fmt, va_list ap); |
434 | 519 | ||
Line 447... | Line 532... | ||
447 | static inline __printf(1, 2) |
532 | static inline __printf(1, 2) |
448 | int trace_printk(const char *fmt, ...) |
533 | int trace_printk(const char *fmt, ...) |
449 | { |
534 | { |
450 | return 0; |
535 | return 0; |
451 | } |
536 | } |
452 | static inline int |
537 | static __printf(1, 0) inline int |
453 | ftrace_vprintk(const char *fmt, va_list ap) |
538 | ftrace_vprintk(const char *fmt, va_list ap) |
454 | { |
539 | { |
455 | return 0; |
540 | return 0; |
456 | } |
541 | } |
457 | static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { } |
542 | static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { } |
Line 564... | Line 649... | ||
564 | 649 | ||
565 | /* Permissions on a sysfs file: you didn't miss the 0 prefix did you? */ |
650 | /* Permissions on a sysfs file: you didn't miss the 0 prefix did you? */ |
566 | #define VERIFY_OCTAL_PERMISSIONS(perms) \ |
651 | #define VERIFY_OCTAL_PERMISSIONS(perms) \ |
567 | (BUILD_BUG_ON_ZERO((perms) < 0) + \ |
652 | (BUILD_BUG_ON_ZERO((perms) < 0) + \ |
568 | BUILD_BUG_ON_ZERO((perms) > 0777) + \ |
653 | BUILD_BUG_ON_ZERO((perms) > 0777) + \ |
569 | /* User perms >= group perms >= other perms */ \ |
654 | /* USER_READABLE >= GROUP_READABLE >= OTHER_READABLE */ \ |
570 | BUILD_BUG_ON_ZERO(((perms) >> 6) < (((perms) >> 3) & 7)) + \ |
655 | BUILD_BUG_ON_ZERO((((perms) >> 6) & 4) < (((perms) >> 3) & 4)) + \ |
- | 656 | BUILD_BUG_ON_ZERO((((perms) >> 3) & 4) < ((perms) & 4)) + \ |
|
- | 657 | /* USER_WRITABLE >= GROUP_WRITABLE */ \ |
|
571 | BUILD_BUG_ON_ZERO((((perms) >> 3) & 7) < ((perms) & 7)) + \ |
658 | BUILD_BUG_ON_ZERO((((perms) >> 6) & 2) < (((perms) >> 3) & 2)) + \ |
572 | /* Other writable? Generally considered a bad idea. */ \ |
659 | /* OTHER_WRITABLE? Generally considered a bad idea. */ \ |
573 | BUILD_BUG_ON_ZERO((perms) & 2) + \ |
660 | BUILD_BUG_ON_ZERO((perms) & 2) + \ |
Line 574... | Line 661... | ||
574 | (perms)) |
661 | (perms)) |
Line 589... | Line 676... | ||
589 | }; |
676 | }; |
Line 590... | Line 677... | ||
590 | 677 | ||
591 | struct vm_area_struct {}; |
678 | struct vm_area_struct {}; |
Line 592... | Line -... | ||
592 | struct address_space {}; |
- | |
593 | - | ||
594 | struct device |
- | |
595 | { |
- | |
596 | struct device *parent; |
- | |
597 | void *driver_data; |
- | |
598 | }; |
- | |
599 | - | ||
600 | static inline void dev_set_drvdata(struct device *dev, void *data) |
- | |
601 | { |
- | |
602 | dev->driver_data = data; |
- | |
603 | } |
- | |
604 | - | ||
605 | static inline void *dev_get_drvdata(struct device *dev) |
- | |
606 | { |
- | |
607 | return dev->driver_data; |
- | |
Line 608... | Line 679... | ||
608 | } |
679 | struct address_space {}; |
Line 609... | Line 680... | ||
609 | 680 | ||
Line 726... | Line 797... | ||
726 | #define pci_unmap_page(dev, dma_address, size, direction) |
797 | #define pci_unmap_page(dev, dma_address, size, direction) |
Line 727... | Line 798... | ||
727 | 798 | ||
Line 728... | Line -... | ||
728 | #define IS_ENABLED(a) 0 |
- | |
729 | - | ||
730 | - | ||
Line 731... | Line 799... | ||
731 | #define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x)) |
799 | #define IS_ENABLED(a) 0 |
Line 732... | Line 800... | ||
732 | 800 | ||
Line 769... | Line 837... | ||
769 | 837 | ||
770 | __builtin_memcpy((void __force *)to, from, n); |
838 | __builtin_memcpy((void __force *)to, from, n); |
771 | return 0; |
839 | return 0; |
Line 772... | Line -... | ||
772 | } |
- | |
773 | - | ||
774 | struct seq_file; |
840 | } |
775 | 841 | ||
776 | void *kmap(struct page *page); |
842 | void *kmap(struct page *page); |
777 | void *kmap_atomic(struct page *page); |
843 | void *kmap_atomic(struct page *page); |
Line 785... | Line 851... | ||
785 | 851 | ||
Line 786... | Line 852... | ||
786 | #define __init |
852 | #define __init |
Line 787... | Line -... | ||
787 | - | ||
788 | #define CONFIG_PAGE_OFFSET 0 |
853 |