|
2 | 2 | #ifndef _LINUX_MINMAX_H
|
3 | 3 | #define _LINUX_MINMAX_H
|
4 | 4 |
|
| 5 | +#include <linux/compiler_types.h> |
5 | 6 | #include <linux/const.h>
|
6 | 7 | #include <linux/types.h>
|
7 | 8 |
|
|
134 | 135 | */
|
135 | 136 | #define max_t(type, x, y) __careful_cmp((type)(x), (type)(y), >)
|
136 | 137 |
|
137 |
| -/* |
138 |
| - * Remove a const qualifier from integer types |
139 |
| - * _Generic(foo, type-name: association, ..., default: association) performs a |
140 |
| - * comparison against the foo type (not the qualified type). |
141 |
| - * Do not use the const keyword in the type-name as it will not match the |
142 |
| - * unqualified type of foo. |
143 |
| - */ |
144 |
| -#define __unconst_integer_type_cases(type) \ |
145 |
| - unsigned type: (unsigned type)0, \ |
146 |
| - signed type: (signed type)0 |
147 |
| - |
148 |
| -#define __unconst_integer_typeof(x) typeof( \ |
149 |
| - _Generic((x), \ |
150 |
| - char: (char)0, \ |
151 |
| - __unconst_integer_type_cases(char), \ |
152 |
| - __unconst_integer_type_cases(short), \ |
153 |
| - __unconst_integer_type_cases(int), \ |
154 |
| - __unconst_integer_type_cases(long), \ |
155 |
| - __unconst_integer_type_cases(long long), \ |
156 |
| - default: (x))) |
157 |
| - |
158 | 138 | /*
|
159 | 139 | * Do not check the array parameter using __must_be_array().
|
160 | 140 | * In the following legit use-case where the "array" passed is a simple pointer,
|
|
169 | 149 | * 'int *buff' and 'int buff[N]' types.
|
170 | 150 | *
|
171 | 151 | * The array can be an array of const items.
|
172 |
| - * typeof() keeps the const qualifier. Use __unconst_integer_typeof() in order |
| 152 | + * typeof() keeps the const qualifier. Use __unqual_scalar_typeof() in order |
173 | 153 | * to discard the const qualifier for the __element variable.
|
174 | 154 | */
|
175 | 155 | #define __minmax_array(op, array, len) ({ \
|
176 | 156 | typeof(&(array)[0]) __array = (array); \
|
177 | 157 | typeof(len) __len = (len); \
|
178 |
| - __unconst_integer_typeof(__array[0]) __element = __array[--__len]; \ |
| 158 | + __unqual_scalar_typeof(__array[0]) __element = __array[--__len];\ |
179 | 159 | while (__len--) \
|
180 | 160 | __element = op(__element, __array[__len]); \
|
181 | 161 | __element; })
|
|
0 commit comments