Skip to content

Commit 598f0ac

Browse files
david-laightakpm00
authored andcommitted
compiler.h: move __is_constexpr() to compiler.h
Prior to f747e66 __is_constexpr() was in its only user minmax.h. That commit moved it to const.h - but that file just defines ULL(x) and UL(x) so that constants can be defined for .S and .c files. So apart from the word 'const' it wasn't really a good location. Instead move the definition to compiler.h just before the similar is_signed_type() and is_unsigned_type(). This may not be a good long-term home, but the three definitions belong together. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: David Laight <[email protected]> Reviewed-by: Kees Cook <[email protected]> Cc: Arnd Bergmann <[email protected]> Cc: Bart Van Assche <[email protected]> Cc: Nathan Chancellor <[email protected]> Cc: Nick Desaulniers <[email protected]> Cc: Rasmus Villemoes <[email protected]> Cc: Steven Rostedt (Google) <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent fbd126f commit 598f0ac

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed

include/linux/compiler.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,14 @@ static inline void *offset_to_ptr(const int *off)
227227
/* &a[0] degrades to a pointer: a different type from an array */
228228
#define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0]))
229229

230+
/*
231+
* This returns a constant expression while determining if an argument is
232+
* a constant expression, most importantly without evaluating the argument.
233+
* Glory to Martin Uecker <[email protected]>
234+
*/
235+
#define __is_constexpr(x) \
236+
(sizeof(int) == sizeof(*(8 ? ((void *)((long)(x) * 0l)) : (int *)8)))
237+
230238
/*
231239
* Whether 'type' is a signed type or an unsigned type. Supports scalar types,
232240
* bool and also pointer types.

include/linux/const.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,4 @@
33

44
#include <vdso/const.h>
55

6-
/*
7-
* This returns a constant expression while determining if an argument is
8-
* a constant expression, most importantly without evaluating the argument.
9-
* Glory to Martin Uecker <[email protected]>
10-
*/
11-
#define __is_constexpr(x) \
12-
(sizeof(int) == sizeof(*(8 ? ((void *)((long)(x) * 0l)) : (int *)8)))
13-
146
#endif /* _LINUX_CONST_H */

tools/include/linux/compiler.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,14 @@
6363
# define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b))
6464
#endif
6565

66+
/*
67+
* This returns a constant expression while determining if an argument is
68+
* a constant expression, most importantly without evaluating the argument.
69+
* Glory to Martin Uecker <[email protected]>
70+
*/
71+
#define __is_constexpr(x) \
72+
(sizeof(int) == sizeof(*(8 ? ((void *)((long)(x) * 0l)) : (int *)8)))
73+
6674
#ifdef __ANDROID__
6775
/*
6876
* FIXME: Big hammer to get rid of tons of:

tools/include/linux/const.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,4 @@
33

44
#include <vdso/const.h>
55

6-
/*
7-
* This returns a constant expression while determining if an argument is
8-
* a constant expression, most importantly without evaluating the argument.
9-
* Glory to Martin Uecker <[email protected]>
10-
*/
11-
#define __is_constexpr(x) \
12-
(sizeof(int) == sizeof(*(8 ? ((void *)((long)(x) * 0l)) : (int *)8)))
13-
146
#endif /* _LINUX_CONST_H */

0 commit comments

Comments
 (0)