linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] compiler-gcc.h: Introduce __optimize function attribute
@ 2018-02-01 10:21 Geert Uytterhoeven
  2018-02-01 10:21 ` [PATCH 2/3] compiler-gcc.h: __nostackprotector needs gcc-4.4 and up Geert Uytterhoeven
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Geert Uytterhoeven @ 2018-02-01 10:21 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, Christopher Li, Ard Biesheuvel,
	Tom Lendacky
  Cc: Arnd Bergmann, Andrew Morton, linux-crypto, linux-sparse,
	linux-kernel, Geert Uytterhoeven

Create a new function attribute __optimize, which allows to specify an
optimization level on a per-function basis.

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
I assume this is supported as of gcc-4.4:
  - gcc version 4.3.3 (GCC): warning: ‘__optimize__’ attribute directive
    ignored
  - gcc version 4.4.7 (Ubuntu/Linaro 4.4.7-1ubuntu2): OK
---
 include/linux/compiler-gcc.h | 4 ++++
 include/linux/compiler.h     | 4 ++++
 2 files changed, 8 insertions(+)

diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h
index 631354acfa720475..0a278a527944ad2f 100644
--- a/include/linux/compiler-gcc.h
+++ b/include/linux/compiler-gcc.h
@@ -196,6 +196,10 @@
 #endif /* __CHECKER__ */
 #endif /* GCC_VERSION >= 40300 */
 
+#if GCC_VERSION >= 40400
+#define __optimize(level)	__attribute__((__optimize__(level)))
+#endif /* GCC_VERSION >= 40400 */
+
 #if GCC_VERSION >= 40500
 
 #ifndef __CHECKER__
diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index 52e611ab9a6cf6fd..5ff818e9a836e898 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -271,6 +271,10 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s
 
 #endif /* __ASSEMBLY__ */
 
+#ifndef __optimize
+# define __optimize(level)
+#endif
+
 /* Compile time object size, -1 for unknown */
 #ifndef __compiletime_object_size
 # define __compiletime_object_size(obj) -1
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2018-02-01 17:30 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-01 10:21 [PATCH 1/3] compiler-gcc.h: Introduce __optimize function attribute Geert Uytterhoeven
2018-02-01 10:21 ` [PATCH 2/3] compiler-gcc.h: __nostackprotector needs gcc-4.4 and up Geert Uytterhoeven
2018-02-01 11:46   ` Arnd Bergmann
2018-02-01 11:55     ` Geert Uytterhoeven
2018-02-01 15:29       ` Arnd Bergmann
2018-02-01 10:22 ` [PATCH 3/3] crypto: sha3-generic - Use __optimize to support old compilers Geert Uytterhoeven
2018-02-01 17:30   ` Ard Biesheuvel
2018-02-01 17:30 ` [PATCH 1/3] compiler-gcc.h: Introduce __optimize function attribute Ard Biesheuvel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).