Commit e468f5c0 authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge tag 'compiler-attributes-for-linus-4.20-rc1' of https://github.com/ojeda/linux

Pull compiler attribute updates from Miguel Ojeda:
 "This 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 a few 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.

  Finally, the __nonstring variable attribute series has been also
  applied on top; plus two related patches from Nick Desaulniers for
  unreachable() that came a bit afterwards"

* tag 'compiler-attributes-for-linus-4.20-rc1' of https://github.com/ojeda/linux:
  compiler-gcc: remove comment about gcc 4.5 from unreachable()
  compiler.h: update definition of unreachable()
  Compiler Attributes: ext4: remove local __nonstring definition
  Compiler Attributes: auxdisplay: panel: use __nonstring
  Compiler Attributes: enable -Wstringop-truncation on W=1 (gcc >= 8)
  Compiler Attributes: add support for __nonstring (gcc >= 8)
  Compiler Attributes: add MAINTAINERS entry
  Compiler Attributes: add Doc/process/programming-language.rst
  Compiler Attributes: remove uses of __attribute__ from compiler.h
  Compiler Attributes: KENTRY used twice the "used" attribute
  Compiler Attributes: use feature checks instead of version checks
  Compiler Attributes: add missing SPDX ID in compiler_types.h
  Compiler Attributes: remove unneeded sparse (__CHECKER__) tests
  Compiler Attributes: homogenize __must_be_array
  Compiler Attributes: remove unneeded tests
  Compiler Attributes: always use the extra-underscores syntax
  Compiler Attributes: remove unused attributes
parents baa888d2 1ff2fea5
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -25,6 +25,7 @@ Below are the essential guides that every developer should read.
   code-of-conduct-interpretation
   code-of-conduct-interpretation
   development-process
   development-process
   submitting-patches
   submitting-patches
   programming-language
   coding-style
   coding-style
   maintainer-pgp-guide
   maintainer-pgp-guide
   email-clients
   email-clients
+45 −0
Original line number Original line Diff line number Diff line
.. _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__))``)
in order to feature detect which ones can be used and/or to shorten the code.

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
+5 −0
Original line number Original line Diff line number Diff line
@@ -3737,6 +3737,11 @@ L: platform-driver-x86@vger.kernel.org
S:	Maintained
S:	Maintained
F:	drivers/platform/x86/compal-laptop.c
F:	drivers/platform/x86/compal-laptop.c


COMPILER ATTRIBUTES
M:	Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
S:	Maintained
F:	include/linux/compiler_attributes.h

CONEXANT ACCESSRUNNER USB DRIVER
CONEXANT ACCESSRUNNER USB DRIVER
L:	accessrunner-general@lists.sourceforge.net
L:	accessrunner-general@lists.sourceforge.net
W:	http://accessrunner.sourceforge.net/
W:	http://accessrunner.sourceforge.net/
+3 −4
Original line number Original line Diff line number Diff line
@@ -155,10 +155,9 @@ struct logical_input {
			int release_data;
			int release_data;
		} std;
		} std;
		struct {	/* valid when type == INPUT_TYPE_KBD */
		struct {	/* valid when type == INPUT_TYPE_KBD */
			/* strings can be non null-terminated */
			char press_str[sizeof(void *) + sizeof(int)] __nonstring;
			char press_str[sizeof(void *) + sizeof(int)];
			char repeat_str[sizeof(void *) + sizeof(int)] __nonstring;
			char repeat_str[sizeof(void *) + sizeof(int)];
			char release_str[sizeof(void *) + sizeof(int)] __nonstring;
			char release_str[sizeof(void *) + sizeof(int)];
		} kbd;
		} kbd;
	} u;
	} u;
};
};
+0 −9
Original line number Original line Diff line number Diff line
@@ -45,15 +45,6 @@


#include <linux/compiler.h>
#include <linux/compiler.h>


/* Until this gets included into linux/compiler-gcc.h */
#ifndef __nonstring
#if defined(GCC_VERSION) && (GCC_VERSION >= 80000)
#define __nonstring __attribute__((nonstring))
#else
#define __nonstring
#endif
#endif

/*
/*
 * The fourth extended filesystem constants/structures
 * The fourth extended filesystem constants/structures
 */
 */
Loading