aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/kernel.h
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2015-02-10 14:35:36 -0500
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2015-02-10 14:35:36 -0500
commit4ba24fef3eb3b142197135223b90ced2f319cd53 (patch)
treea20c125b27740ec7b4c761b11d801108e1b316b2 /include/linux/kernel.h
parent47c1ffb2b6b630894e9a16442611c056ab21c057 (diff)
parent98a4a59ee31a12105a2b84f5b8b515ac2cb208ef (diff)
Merge branch 'next' into for-linus
Prepare first round of input updates for 3.20.
Diffstat (limited to 'include/linux/kernel.h')
-rw-r--r--include/linux/kernel.h71
1 files changed, 20 insertions, 51 deletions
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 95624bed87ef..5449d2f4a1ef 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -162,6 +162,7 @@ extern int _cond_resched(void);
162#endif 162#endif
163 163
164#ifdef CONFIG_DEBUG_ATOMIC_SLEEP 164#ifdef CONFIG_DEBUG_ATOMIC_SLEEP
165 void ___might_sleep(const char *file, int line, int preempt_offset);
165 void __might_sleep(const char *file, int line, int preempt_offset); 166 void __might_sleep(const char *file, int line, int preempt_offset);
166/** 167/**
167 * might_sleep - annotation for functions that can sleep 168 * might_sleep - annotation for functions that can sleep
@@ -175,10 +176,14 @@ extern int _cond_resched(void);
175 */ 176 */
176# define might_sleep() \ 177# define might_sleep() \
177 do { __might_sleep(__FILE__, __LINE__, 0); might_resched(); } while (0) 178 do { __might_sleep(__FILE__, __LINE__, 0); might_resched(); } while (0)
179# define sched_annotate_sleep() __set_current_state(TASK_RUNNING)
178#else 180#else
181 static inline void ___might_sleep(const char *file, int line,
182 int preempt_offset) { }
179 static inline void __might_sleep(const char *file, int line, 183 static inline void __might_sleep(const char *file, int line,
180 int preempt_offset) { } 184 int preempt_offset) { }
181# define might_sleep() do { might_resched(); } while (0) 185# define might_sleep() do { might_resched(); } while (0)
186# define sched_annotate_sleep() do { } while (0)
182#endif 187#endif
183 188
184#define might_sleep_if(cond) do { if (cond) might_sleep(); } while (0) 189#define might_sleep_if(cond) do { if (cond) might_sleep(); } while (0)
@@ -376,10 +381,6 @@ extern unsigned long simple_strtoul(const char *,char **,unsigned int);
376extern long simple_strtol(const char *,char **,unsigned int); 381extern long simple_strtol(const char *,char **,unsigned int);
377extern unsigned long long simple_strtoull(const char *,char **,unsigned int); 382extern unsigned long long simple_strtoull(const char *,char **,unsigned int);
378extern long long simple_strtoll(const char *,char **,unsigned int); 383extern long long simple_strtoll(const char *,char **,unsigned int);
379#define strict_strtoul kstrtoul
380#define strict_strtol kstrtol
381#define strict_strtoull kstrtoull
382#define strict_strtoll kstrtoll
383 384
384extern int num_to_str(char *buf, int size, unsigned long long num); 385extern int num_to_str(char *buf, int size, unsigned long long num);
385 386
@@ -407,6 +408,7 @@ int vsscanf(const char *, const char *, va_list);
407extern int get_option(char **str, int *pint); 408extern int get_option(char **str, int *pint);
408extern char *get_options(const char *str, int nints, int *ints); 409extern char *get_options(const char *str, int nints, int *ints);
409extern unsigned long long memparse(const char *ptr, char **retptr); 410extern unsigned long long memparse(const char *ptr, char **retptr);
411extern bool parse_option_str(const char *str, const char *option);
410 412
411extern int core_kernel_text(unsigned long addr); 413extern int core_kernel_text(unsigned long addr);
412extern int core_kernel_data(unsigned long addr); 414extern int core_kernel_data(unsigned long addr);
@@ -414,9 +416,6 @@ extern int __kernel_text_address(unsigned long addr);
414extern int kernel_text_address(unsigned long addr); 416extern int kernel_text_address(unsigned long addr);
415extern int func_ptr_is_kernel_text(void *ptr); 417extern int func_ptr_is_kernel_text(void *ptr);
416 418
417struct pid;
418extern struct pid *session_of_pgrp(struct pid *pgrp);
419
420unsigned long int_sqrt(unsigned long); 419unsigned long int_sqrt(unsigned long);
421 420
422extern void bust_spinlocks(int yes); 421extern void bust_spinlocks(int yes);
@@ -425,6 +424,7 @@ extern int panic_timeout;
425extern int panic_on_oops; 424extern int panic_on_oops;
426extern int panic_on_unrecovered_nmi; 425extern int panic_on_unrecovered_nmi;
427extern int panic_on_io_nmi; 426extern int panic_on_io_nmi;
427extern int panic_on_warn;
428extern int sysctl_panic_on_stackoverflow; 428extern int sysctl_panic_on_stackoverflow;
429/* 429/*
430 * Only to be used by arch init code. If the user over-wrote the default 430 * Only to be used by arch init code. If the user over-wrote the default
@@ -496,6 +496,7 @@ static inline char *hex_byte_pack_upper(char *buf, u8 byte)
496 496
497extern int hex_to_bin(char ch); 497extern int hex_to_bin(char ch);
498extern int __must_check hex2bin(u8 *dst, const char *src, size_t count); 498extern int __must_check hex2bin(u8 *dst, const char *src, size_t count);
499extern char *bin2hex(char *dst, const void *src, size_t count);
499 500
500bool mac_pton(const char *s, u8 *mac); 501bool mac_pton(const char *s, u8 *mac);
501 502
@@ -715,23 +716,8 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { }
715 (void) (&_max1 == &_max2); \ 716 (void) (&_max1 == &_max2); \
716 _max1 > _max2 ? _max1 : _max2; }) 717 _max1 > _max2 ? _max1 : _max2; })
717 718
718#define min3(x, y, z) ({ \ 719#define min3(x, y, z) min((typeof(x))min(x, y), z)
719 typeof(x) _min1 = (x); \ 720#define max3(x, y, z) max((typeof(x))max(x, y), z)
720 typeof(y) _min2 = (y); \
721 typeof(z) _min3 = (z); \
722 (void) (&_min1 == &_min2); \
723 (void) (&_min1 == &_min3); \
724 _min1 < _min2 ? (_min1 < _min3 ? _min1 : _min3) : \
725 (_min2 < _min3 ? _min2 : _min3); })
726
727#define max3(x, y, z) ({ \
728 typeof(x) _max1 = (x); \
729 typeof(y) _max2 = (y); \
730 typeof(z) _max3 = (z); \
731 (void) (&_max1 == &_max2); \
732 (void) (&_max1 == &_max3); \
733 _max1 > _max2 ? (_max1 > _max3 ? _max1 : _max3) : \
734 (_max2 > _max3 ? _max2 : _max3); })
735 721
736/** 722/**
737 * min_not_zero - return the minimum that is _not_ zero, unless both are zero 723 * min_not_zero - return the minimum that is _not_ zero, unless both are zero
@@ -746,20 +732,13 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { }
746/** 732/**
747 * clamp - return a value clamped to a given range with strict typechecking 733 * clamp - return a value clamped to a given range with strict typechecking
748 * @val: current value 734 * @val: current value
749 * @min: minimum allowable value 735 * @lo: lowest allowable value
750 * @max: maximum allowable value 736 * @hi: highest allowable value
751 * 737 *
752 * This macro does strict typechecking of min/max to make sure they are of the 738 * This macro does strict typechecking of lo/hi to make sure they are of the
753 * same type as val. See the unnecessary pointer comparisons. 739 * same type as val. See the unnecessary pointer comparisons.
754 */ 740 */
755#define clamp(val, min, max) ({ \ 741#define clamp(val, lo, hi) min((typeof(val))max(val, lo), hi)
756 typeof(val) __val = (val); \
757 typeof(min) __min = (min); \
758 typeof(max) __max = (max); \
759 (void) (&__val == &__min); \
760 (void) (&__val == &__max); \
761 __val = __val < __min ? __min: __val; \
762 __val > __max ? __max: __val; })
763 742
764/* 743/*
765 * ..and if you can't take the strict 744 * ..and if you can't take the strict
@@ -781,36 +760,26 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { }
781 * clamp_t - return a value clamped to a given range using a given type 760 * clamp_t - return a value clamped to a given range using a given type
782 * @type: the type of variable to use 761 * @type: the type of variable to use
783 * @val: current value 762 * @val: current value
784 * @min: minimum allowable value 763 * @lo: minimum allowable value
785 * @max: maximum allowable value 764 * @hi: maximum allowable value
786 * 765 *
787 * This macro does no typechecking and uses temporary variables of type 766 * This macro does no typechecking and uses temporary variables of type
788 * 'type' to make all the comparisons. 767 * 'type' to make all the comparisons.
789 */ 768 */
790#define clamp_t(type, val, min, max) ({ \ 769#define clamp_t(type, val, lo, hi) min_t(type, max_t(type, val, lo), hi)
791 type __val = (val); \
792 type __min = (min); \
793 type __max = (max); \
794 __val = __val < __min ? __min: __val; \
795 __val > __max ? __max: __val; })
796 770
797/** 771/**
798 * clamp_val - return a value clamped to a given range using val's type 772 * clamp_val - return a value clamped to a given range using val's type
799 * @val: current value 773 * @val: current value
800 * @min: minimum allowable value 774 * @lo: minimum allowable value
801 * @max: maximum allowable value 775 * @hi: maximum allowable value
802 * 776 *
803 * This macro does no typechecking and uses temporary variables of whatever 777 * This macro does no typechecking and uses temporary variables of whatever
804 * type the input argument 'val' is. This is useful when val is an unsigned 778 * type the input argument 'val' is. This is useful when val is an unsigned
805 * type and min and max are literals that will otherwise be assigned a signed 779 * type and min and max are literals that will otherwise be assigned a signed
806 * integer type. 780 * integer type.
807 */ 781 */
808#define clamp_val(val, min, max) ({ \ 782#define clamp_val(val, lo, hi) clamp_t(typeof(val), val, lo, hi)
809 typeof(val) __val = (val); \
810 typeof(val) __min = (min); \
811 typeof(val) __max = (max); \
812 __val = __val < __min ? __min: __val; \
813 __val > __max ? __max: __val; })
814 783
815 784
816/* 785/*