linux-doc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 00/12] Compiler Attributes
@ 2018-09-03 20:33 Miguel Ojeda
  2018-09-03 20:33 ` [PATCH 12/12] Compiler Attributes: add Doc/process/programming-language.rst Miguel Ojeda
  0 siblings, 1 reply; 2+ messages in thread
From: Miguel Ojeda @ 2018-09-03 20:33 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: linux-kernel, Miguel Ojeda, Jonathan Corbet, Rasmus Villemoes,
	Luc Van Oostenryck, Eli Friedman, Christopher Li, Kees Cook,
	Ingo Molnar, Geert Uytterhoeven, Arnd Bergmann,
	Greg Kroah-Hartman, Masahiro Yamada, Joe Perches,
	Dominique Martinet, Nick Desaulniers, linux-sparse, linux-doc

The Compiler Attributes series is an effort to disentangle
the include/linux/compiler*.h headers and bring them up to date.

The main idea behind the series is to use feature checking macros
(i.e. __has_attribute) instead of compiler version checks (e.g. GCC_VERSION),
which are compiler-agnostic (so they can be shared, reducing the size
of compiler-specific headers) and version-agnostic.

Other related improvements have been performed in the headers as well,
which on top of the use of __has_attribute it has amounted to a significant
simplification of these headers (e.g. GCC_VERSION is now only guarding 4
non-attribute macros).

This series should also help the efforts to support compiling the kernel
with clang and icc. A fair amount of documentation and comments have also
been added, clarified or removed; and the headers are now more readable,
which should help kernel developers in general.

The series was triggered due to the move to gcc >= 4.6. In turn, this series
has also triggered Sparse to gain the ability to recognize __has_attribute
on its own.

You can also fetch it from:

  https://github.com/ojeda/linux/tree/compiler-attributes-v3

Enjoy!

Cheers,
Miguel

Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Cc: Eli Friedman <efriedma@codeaurora.org>
Cc: Christopher Li <sparse@chrisli.org>
Cc: Kees Cook <keescook@chromium.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: Joe Perches <joe@perches.com>
Cc: Dominique Martinet <asmadeus@codewreck.org>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: linux-sparse@vger.kernel.org
Cc: linux-doc@vger.kernel.org
Signed-off-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>

v2 -> v3:

  New:

  * Remove duplicated "used" attribute in KENTRY
  * Silence sparse warnings on __has_attribute & simplify the macro block
  * Add Documentation/process/programming-language.rst
  * Improve _attribute.h description
  * Improve some commit descriptions
  * Add Reviewed-by's/Acked-by's/Suggested-by's
    (hopefully I didn't miss anybody!)
  * Rebase on top of v4.19-rc2
  * Cc Rasmus, Luc

  From reviews:

  * Fix __attribute_const__ rename typo (Nick)
  * Add SPDX identifier to _attributes.h (Nick)
  * Add SPDX identifier to _types.h (Greg)
  * Remove __attribute__ uses from compiler.h (Nick)
  * Tweak clang doc comments (Nick)
  * Move __naked out of -gcc.h to be shared (Arnd)
  * Use __name__ syntax instead (Rasmus)
  * Update sparse description (Luc)
  * Remove __CHECKER__ test from __must_be_array (Luc)
  * Add note on __has_attribute regarding sparse (Luc)
  * Cc linux-sparse (Luc)

It is quite a lot of stuff changed this time around, I hope I haven't missed
anything said in the emails. Please take a look!

Compile-tested for a while on (x86_64, gcc-7.3, allmodconfig).

Miguel Ojeda (12):
  Compiler Attributes: remove unused attributes
  Compiler Attributes: always use the extra-underscores syntax
  Compiler Attributes: remove unneeded tests
  Compiler Attributes: homogenize __must_be_array
  Compiler Attributes: naked was fixed in gcc 4.6
  Compiler Attributes: naked can be shared
  Compiler Attributes: remove unneeded sparse (__CHECKER__) tests
  Compiler Attributes: add missing SPDX ID in compiler_types.h
  Compiler Attributes: use feature checks instead of version checks
  Compiler Attributes: KENTRY used twice the "used" attribute
  Compiler Attributes: remove uses of __attribute__ from compiler.h
  Compiler Attributes: add Doc/process/programming-language.rst

 Documentation/process/index.rst               |   1 +
 .../process/programming-language.rst          |  44 ++++
 include/linux/compiler-clang.h                |   5 -
 include/linux/compiler-gcc.h                  |  84 +-----
 include/linux/compiler-intel.h                |   9 -
 include/linux/compiler.h                      |  19 +-
 include/linux/compiler_attributes.h           | 239 ++++++++++++++++++
 include/linux/compiler_types.h                | 101 ++------
 8 files changed, 314 insertions(+), 188 deletions(-)
 create mode 100644 Documentation/process/programming-language.rst
 create mode 100644 include/linux/compiler_attributes.h

-- 
2.17.1


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

* [PATCH 12/12] Compiler Attributes: add Doc/process/programming-language.rst
  2018-09-03 20:33 [PATCH v3 00/12] Compiler Attributes Miguel Ojeda
@ 2018-09-03 20:33 ` Miguel Ojeda
  0 siblings, 0 replies; 2+ messages in thread
From: Miguel Ojeda @ 2018-09-03 20:33 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: linux-kernel, Miguel Ojeda, Jonathan Corbet, Rasmus Villemoes,
	Luc Van Oostenryck, Eli Friedman, Christopher Li, Kees Cook,
	Ingo Molnar, Geert Uytterhoeven, Arnd Bergmann,
	Greg Kroah-Hartman, Masahiro Yamada, Joe Perches,
	Dominique Martinet, Nick Desaulniers, linux-sparse, linux-doc

Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Cc: Eli Friedman <efriedma@codeaurora.org>
Cc: Christopher Li <sparse@chrisli.org>
Cc: Kees Cook <keescook@chromium.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: Joe Perches <joe@perches.com>
Cc: Dominique Martinet <asmadeus@codewreck.org>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: linux-sparse@vger.kernel.org
Cc: linux-doc@vger.kernel.org
Signed-off-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
---
 Documentation/process/index.rst               |  1 +
 .../process/programming-language.rst          | 44 +++++++++++++++++++
 2 files changed, 45 insertions(+)
 create mode 100644 Documentation/process/programming-language.rst

diff --git a/Documentation/process/index.rst b/Documentation/process/index.rst
index 37bd0628b6ee..c56f24a22d2a 100644
--- a/Documentation/process/index.rst
+++ b/Documentation/process/index.rst
@@ -23,6 +23,7 @@ Below are the essential guides that every developer should read.
    code-of-conflict
    development-process
    submitting-patches
+   programming-language
    coding-style
    maintainer-pgp-guide
    email-clients
diff --git a/Documentation/process/programming-language.rst b/Documentation/process/programming-language.rst
new file mode 100644
index 000000000000..674f28ae7f73
--- /dev/null
+++ b/Documentation/process/programming-language.rst
@@ -0,0 +1,44 @@
+.. _programming_language:
+
+Programming Language
+====================
+
+The kernel is written in the C programming language [c-language]_.
+More precisely, the kernel is typically compiled with ``gcc`` [gcc]_
+under ``-std=gnu89`` [gcc-c-dialect-options]_: the GNU dialect of ISO C90
+(including some C99 features).
+
+This dialect contains many extensions to the language [gnu-extensions]_,
+and many of them are used within the kernel as a matter of course.
+
+There is some support for compiling the kernel with ``clang`` [clang]_
+and ``icc`` [icc]_ for several of the architectures, although at the time
+of writing it is not completed, requiring third-party patches.
+
+Attributes
+----------
+
+One of the common extensions used throughout the kernel are attributes
+[gcc-attribute-syntax]_. Attributes allow to introduce
+implementation-defined semantics to language entities (like variables,
+functions or types) without having to make significant syntactic changes
+to the language (e.g. adding a new keyword) [n2049]_.
+
+In some cases, attributes are optional (i.e. a compiler not supporting them
+should still produce proper code, even if it is slower or does not perform
+as many compile-time checks/diagnostics).
+
+The kernel defines pseudo-keywords (e.g. ``__pure``) instead of using
+directly the GNU attribute syntax (e.g. ``__attribute__((pure))``).
+
+Please refer to ``include/linux/compiler_attributes.h`` for more information.
+
+.. [c-language] http://www.open-std.org/jtc1/sc22/wg14/www/standards
+.. [gcc] https://gcc.gnu.org
+.. [clang] https://clang.llvm.org
+.. [icc] https://software.intel.com/en-us/c-compilers
+.. [gcc-c-dialect-options] https://gcc.gnu.org/onlinedocs/gcc/C-Dialect-Options.html
+.. [gnu-extensions] https://gcc.gnu.org/onlinedocs/gcc/C-Extensions.html
+.. [gcc-attribute-syntax] https://gcc.gnu.org/onlinedocs/gcc/Attribute-Syntax.html
+.. [n2049] http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2049.pdf
+
-- 
2.17.1


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

end of thread, other threads:[~2018-09-03 20:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-09-03 20:33 [PATCH v3 00/12] Compiler Attributes Miguel Ojeda
2018-09-03 20:33 ` [PATCH 12/12] Compiler Attributes: add Doc/process/programming-language.rst Miguel Ojeda

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).