Rev 6293 | Rev 6936 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 6293 | Rev 6934 | ||
---|---|---|---|
Line 199... | Line 199... | ||
199 | 199 | ||
Line 200... | Line 200... | ||
200 | #define might_sleep_if(cond) do { if (cond) might_sleep(); } while (0) |
200 | #define might_sleep_if(cond) do { if (cond) might_sleep(); } while (0) |
201 | 201 | ||
202 | /** |
202 | /** |
- | 203 | * abs - return absolute value of an argument |
|
203 | * abs - return absolute value of an argument |
204 | * @x: the value. If it is unsigned type, it is converted to signed type first. |
204 | * @x: the value. If it is unsigned type, it is converted to signed type first |
205 | * char is treated as if it was signed (regardless of whether it really is) |
205 | * (s64, long or int depending on its size). |
- | |
206 | * |
206 | * but the macro's return type is preserved as char. |
207 | * Return: an absolute value of x. If x is 64-bit, macro's return type is s64, |
207 | * |
208 | * otherwise it is signed long. |
208 | * Return: an absolute value of x. |
209 | */ |
209 | */ |
210 | #define abs(x) __builtin_choose_expr(sizeof(x) == sizeof(s64), ({ \ |
210 | #define abs(x) __abs_choose_expr(x, long long, \ |
211 | s64 __x = (x); \ |
211 | __abs_choose_expr(x, long, \ |
212 | (__x < 0) ? -__x : __x; \ |
212 | __abs_choose_expr(x, int, \ |
213 | }), ({ \ |
213 | __abs_choose_expr(x, short, \ |
214 | long ret; \ |
214 | __abs_choose_expr(x, char, \ |
215 | if (sizeof(x) == sizeof(long)) { \ |
215 | __builtin_choose_expr( \ |
216 | long __x = (x); \ |
216 | __builtin_types_compatible_p(typeof(x), char), \ |
- | 217 | (char)({ signed char __x = (x); __x<0?-__x:__x; }), \ |
|
- | 218 | ((void)0))))))) |
|
- | 219 | ||
217 | ret = (__x < 0) ? -__x : __x; \ |
220 | #define __abs_choose_expr(x, type, other) __builtin_choose_expr( \ |
218 | } else { \ |
221 | __builtin_types_compatible_p(typeof(x), signed type) || \ |
219 | int __x = (x); \ |
- | |
220 | ret = (__x < 0) ? -__x : __x; \ |
- | |
221 | } \ |
- | |
Line 222... | Line 222... | ||
222 | ret; \ |
222 | __builtin_types_compatible_p(typeof(x), unsigned type), \ |
223 | })) |
223 | ({ signed type __x = (x); __x < 0 ? -__x : __x; }), other) |
224 | 224 | ||
225 | /** |
225 | /** |
Line 438... | Line 438... | ||
438 | trace_puts(fmt); \ |
438 | trace_puts(fmt); \ |
439 | } while (0) |
439 | } while (0) |
Line 440... | Line 440... | ||
440 | 440 | ||
441 | #define do_trace_printk(fmt, args...) \ |
441 | #define do_trace_printk(fmt, args...) \ |
442 | do { \ |
442 | do { \ |
443 | static const char *trace_printk_fmt \ |
443 | static const char *trace_printk_fmt __used \ |
444 | __attribute__((section("__trace_printk_fmt"))) = \ |
444 | __attribute__((section("__trace_printk_fmt"))) = \ |
445 | __builtin_constant_p(fmt) ? fmt : NULL; \ |
445 | __builtin_constant_p(fmt) ? fmt : NULL; \ |
446 | \ |
446 | \ |
447 | __trace_printk_check_format(fmt, ##args); \ |
447 | __trace_printk_check_format(fmt, ##args); \ |
Line 482... | Line 482... | ||
482 | * Returns: 0 if nothing was written, positive # if string was. |
482 | * Returns: 0 if nothing was written, positive # if string was. |
483 | * (1 when __trace_bputs is used, strlen(str) when __trace_puts is used) |
483 | * (1 when __trace_bputs is used, strlen(str) when __trace_puts is used) |
484 | */ |
484 | */ |
Line 485... | Line 485... | ||
485 | 485 | ||
486 | #define trace_puts(str) ({ \ |
486 | #define trace_puts(str) ({ \ |
487 | static const char *trace_printk_fmt \ |
487 | static const char *trace_printk_fmt __used \ |
488 | __attribute__((section("__trace_printk_fmt"))) = \ |
488 | __attribute__((section("__trace_printk_fmt"))) = \ |
489 | __builtin_constant_p(str) ? str : NULL; \ |
489 | __builtin_constant_p(str) ? str : NULL; \ |
490 | \ |
490 | \ |
491 | if (__builtin_constant_p(str)) \ |
491 | if (__builtin_constant_p(str)) \ |
Line 504... | Line 504... | ||
504 | * constant. Even with the outer if statement. |
504 | * constant. Even with the outer if statement. |
505 | */ |
505 | */ |
506 | #define ftrace_vprintk(fmt, vargs) \ |
506 | #define ftrace_vprintk(fmt, vargs) \ |
507 | do { \ |
507 | do { \ |
508 | if (__builtin_constant_p(fmt)) { \ |
508 | if (__builtin_constant_p(fmt)) { \ |
509 | static const char *trace_printk_fmt \ |
509 | static const char *trace_printk_fmt __used \ |
510 | __attribute__((section("__trace_printk_fmt"))) = \ |
510 | __attribute__((section("__trace_printk_fmt"))) = \ |
511 | __builtin_constant_p(fmt) ? fmt : NULL; \ |
511 | __builtin_constant_p(fmt) ? fmt : NULL; \ |
512 | \ |
512 | \ |
513 | __ftrace_vbprintk(_THIS_IP_, trace_printk_fmt, vargs); \ |
513 | __ftrace_vbprintk(_THIS_IP_, trace_printk_fmt, vargs); \ |
514 | } else \ |
514 | } else \ |