Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ec0bbef6 authored by Miguel Ojeda's avatar Miguel Ojeda
Browse files

Compiler Attributes: homogenize __must_be_array

Different definitions of __must_be_array:

  * gcc: disabled for __CHECKER__

  * clang: same definition as gcc's, but without __CHECKER__

  * intel: the comment claims __builtin_types_compatible_p()
    is unsupported; but icc seems to support it since 13.0.1
    (released in 2012). See https://godbolt.org/z/S0l6QQ



Therefore, we can remove all of them and have a single definition
in compiler.h

Tested-by: Sedat Dilek <sedat.dilek@gmail.com> # on top of v4.19-rc5, clang 7
Reviewed-by: default avatarNick Desaulniers <ndesaulniers@google.com>
Reviewed-by: default avatarLuc Van Oostenryck <luc.vanoostenryck@gmail.com>
Signed-off-by: default avatarMiguel Ojeda <miguel.ojeda.sandonis@gmail.com>
parent c2c640aa
Loading
Loading
Loading
Loading
+0 −1
Original line number Original line Diff line number Diff line
@@ -41,6 +41,5 @@
 * compilers, like ICC.
 * compilers, like ICC.
 */
 */
#define barrier() __asm__ __volatile__("" : : : "memory")
#define barrier() __asm__ __volatile__("" : : : "memory")
#define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0]))
#define __assume_aligned(a, ...)	\
#define __assume_aligned(a, ...)	\
	__attribute__((__assume_aligned__(a, ## __VA_ARGS__)))
	__attribute__((__assume_aligned__(a, ## __VA_ARGS__)))
+0 −7
Original line number Original line Diff line number Diff line
@@ -68,13 +68,6 @@
 */
 */
#define uninitialized_var(x) x = x
#define uninitialized_var(x) x = x


#ifdef __CHECKER__
#define __must_be_array(a)	0
#else
/* &a[0] degrades to a pointer: a different type from an array */
#define __must_be_array(a)	BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0]))
#endif

#ifdef RETPOLINE
#ifdef RETPOLINE
#define __noretpoline __attribute__((__indirect_branch__("keep")))
#define __noretpoline __attribute__((__indirect_branch__("keep")))
#endif
#endif
+0 −3
Original line number Original line Diff line number Diff line
@@ -29,9 +29,6 @@
 */
 */
#define OPTIMIZER_HIDE_VAR(var) barrier()
#define OPTIMIZER_HIDE_VAR(var) barrier()


/* Intel ECC compiler doesn't support __builtin_types_compatible_p() */
#define __must_be_array(a) 0

#endif
#endif


/* icc has this, but it's called _bswap16 */
/* icc has this, but it's called _bswap16 */
+7 −0
Original line number Original line Diff line number Diff line
@@ -357,4 +357,11 @@ static inline void *offset_to_ptr(const int *off)
	compiletime_assert(__native_word(t),				\
	compiletime_assert(__native_word(t),				\
		"Need native word sized stores/loads for atomicity.")
		"Need native word sized stores/loads for atomicity.")


#ifdef __CHECKER__
#define __must_be_array(a)	0
#else
/* &a[0] degrades to a pointer: a different type from an array */
#define __must_be_array(a)	BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0]))
#endif

#endif /* __LINUX_COMPILER_H */
#endif /* __LINUX_COMPILER_H */