1
0

new-gcc.patch 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. diff -Nur linux-2.6.32.70.orig/include/linux/compiler-gcc.h linux-2.6.32.70/include/linux/compiler-gcc.h
  2. --- linux-2.6.32.70.orig/include/linux/compiler-gcc.h 2016-01-29 22:13:00.000000000 +0100
  3. +++ linux-2.6.32.70/include/linux/compiler-gcc.h 2017-09-26 03:48:39.644239377 +0200
  4. @@ -6,6 +6,10 @@
  5. * Common definitions for all gcc versions go here.
  6. */
  7. +#define GCC_VERSION (__GNUC__ * 10000 \
  8. + + __GNUC_MINOR__ * 100 \
  9. + + __GNUC_PATCHLEVEL__)
  10. +
  11. /* Optimization barrier */
  12. /* The "volatile" is due to gcc bugs */
  13. @@ -79,8 +83,167 @@
  14. #define noinline __attribute__((noinline))
  15. #define __attribute_const__ __attribute__((__const__))
  16. #define __maybe_unused __attribute__((unused))
  17. +#define __always_unused __attribute__((unused))
  18. +
  19. +/* gcc version specific checks */
  20. +
  21. +#if GCC_VERSION < 30200
  22. +# error Sorry, your compiler is too old - please upgrade it.
  23. +#endif
  24. +
  25. +#if GCC_VERSION < 30300
  26. +# define __used __attribute__((__unused__))
  27. +#else
  28. +# define __used __attribute__((__used__))
  29. +#endif
  30. +
  31. +#ifdef CONFIG_GCOV_KERNEL
  32. +# if GCC_VERSION < 30400
  33. +# error "GCOV profiling support for gcc versions below 3.4 not included"
  34. +# endif /* __GNUC_MINOR__ */
  35. +#endif /* CONFIG_GCOV_KERNEL */
  36. +
  37. +#if GCC_VERSION >= 30400
  38. +#define __must_check __attribute__((warn_unused_result))
  39. +#endif
  40. +
  41. +#if GCC_VERSION >= 40000
  42. +
  43. +/* GCC 4.1.[01] miscompiles __weak */
  44. +#ifdef __KERNEL__
  45. +# if GCC_VERSION >= 40100 && GCC_VERSION <= 40101
  46. +# error Your version of gcc miscompiles the __weak directive
  47. +# endif
  48. +#endif
  49. +
  50. +#define __used __attribute__((__used__))
  51. +#define __compiler_offsetof(a, b) \
  52. + __builtin_offsetof(a, b)
  53. +
  54. +#if GCC_VERSION >= 40100 && GCC_VERSION < 40600
  55. +# define __compiletime_object_size(obj) __builtin_object_size(obj, 0)
  56. +#endif
  57. +
  58. +#if GCC_VERSION >= 40300
  59. +/* Mark functions as cold. gcc will assume any path leading to a call
  60. + * to them will be unlikely. This means a lot of manual unlikely()s
  61. + * are unnecessary now for any paths leading to the usual suspects
  62. + * like BUG(), printk(), panic() etc. [but let's keep them for now for
  63. + * older compilers]
  64. + *
  65. + * Early snapshots of gcc 4.3 don't support this and we can't detect this
  66. + * in the preprocessor, but we can live with this because they're unreleased.
  67. + * Maketime probing would be overkill here.
  68. + *
  69. + * gcc also has a __attribute__((__hot__)) to move hot functions into
  70. + * a special section, but I don't see any sense in this right now in
  71. + * the kernel context
  72. + */
  73. +#define __cold __attribute__((__cold__))
  74. +
  75. +#define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__)
  76. +
  77. +#ifndef __CHECKER__
  78. +# define __compiletime_warning(message) __attribute__((warning(message)))
  79. +# define __compiletime_error(message) __attribute__((error(message)))
  80. +#endif /* __CHECKER__ */
  81. +#endif /* GCC_VERSION >= 40300 */
  82. +
  83. +#if GCC_VERSION >= 40500
  84. +/*
  85. + * Mark a position in code as unreachable. This can be used to
  86. + * suppress control flow warnings after asm blocks that transfer
  87. + * control elsewhere.
  88. + *
  89. + * Early snapshots of gcc 4.5 don't support this and we can't detect
  90. + * this in the preprocessor, but we can live with this because they're
  91. + * unreleased. Really, we need to have autoconf for the kernel.
  92. + */
  93. +#define unreachable() __builtin_unreachable()
  94. +
  95. +/* Mark a function definition as prohibited from being cloned. */
  96. +#define __noclone __attribute__((__noclone__, __optimize__("no-tracer")))
  97. +
  98. +#endif /* GCC_VERSION >= 40500 */
  99. +
  100. +#if GCC_VERSION >= 40600
  101. +/*
  102. + * When used with Link Time Optimization, gcc can optimize away C functions or
  103. + * variables which are referenced only from assembly code. __visible tells the
  104. + * optimizer that something else uses this function or variable, thus preventing
  105. + * this.
  106. + */
  107. +#define __visible __attribute__((externally_visible))
  108. +#endif
  109. +
  110. +
  111. +#if GCC_VERSION >= 40900 && !defined(__CHECKER__)
  112. +/*
  113. + * __assume_aligned(n, k): Tell the optimizer that the returned
  114. + * pointer can be assumed to be k modulo n. The second argument is
  115. + * optional (default 0), so we use a variadic macro to make the
  116. + * shorthand.
  117. + *
  118. + * Beware: Do not apply this to functions which may return
  119. + * ERR_PTRs. Also, it is probably unwise to apply it to functions
  120. + * returning extra information in the low bits (but in that case the
  121. + * compiler should see some alignment anyway, when the return value is
  122. + * massaged by 'flags = ptr & 3; ptr &= ~3;').
  123. + */
  124. +#define __assume_aligned(a, ...) __attribute__((__assume_aligned__(a, ## __VA_ARGS__)))
  125. +#endif
  126. +
  127. +/*
  128. + * GCC 'asm goto' miscompiles certain code sequences:
  129. + *
  130. + * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58670
  131. + *
  132. + * Work it around via a compiler barrier quirk suggested by Jakub Jelinek.
  133. + *
  134. + * (asm goto is automatically volatile - the naming reflects this.)
  135. + */
  136. +#define asm_volatile_goto(x...) do { asm goto(x); asm (""); } while (0)
  137. +
  138. +#ifdef CONFIG_ARCH_USE_BUILTIN_BSWAP
  139. +#if GCC_VERSION >= 40400
  140. +#define __HAVE_BUILTIN_BSWAP32__
  141. +#define __HAVE_BUILTIN_BSWAP64__
  142. +#endif
  143. +#if GCC_VERSION >= 40800 || (defined(__powerpc__) && GCC_VERSION >= 40600)
  144. +#define __HAVE_BUILTIN_BSWAP16__
  145. +#endif
  146. +#endif /* CONFIG_ARCH_USE_BUILTIN_BSWAP */
  147. +
  148. +#if GCC_VERSION >= 70000
  149. +#define KASAN_ABI_VERSION 5
  150. +#elif GCC_VERSION >= 50000
  151. +#define KASAN_ABI_VERSION 4
  152. +#elif GCC_VERSION >= 40902
  153. +#define KASAN_ABI_VERSION 3
  154. +#endif
  155. +
  156. +#if GCC_VERSION >= 40902
  157. +/*
  158. + * Tell the compiler that address safety instrumentation (KASAN)
  159. + * should not be applied to that function.
  160. + * Conflicts with inlining: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67368
  161. + */
  162. +#define __no_sanitize_address __attribute__((no_sanitize_address))
  163. +#endif
  164. +
  165. +#endif /* gcc version >= 40000 specific checks */
  166. +
  167. +#if !defined(__noclone)
  168. +#define __noclone /* not needed */
  169. +#endif
  170. +
  171. +#if !defined(__no_sanitize_address)
  172. +#define __no_sanitize_address
  173. +#endif
  174. +
  175. +/*
  176. + * A trick to suppress uninitialized variable warning without generating any
  177. + * code
  178. + */
  179. +#define uninitialized_var(x) x = x
  180. -#define __gcc_header(x) #x
  181. -#define _gcc_header(x) __gcc_header(linux/compiler-gcc##x.h)
  182. -#define gcc_header(x) _gcc_header(x)
  183. -#include gcc_header(__GNUC__)