From patchwork Mon Sep 3 20:33:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miguel Ojeda X-Patchwork-Id: 10586365 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EB9DC139B for ; Mon, 3 Sep 2018 20:34:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DD2AF2931D for ; Mon, 3 Sep 2018 20:34:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D0DE129323; Mon, 3 Sep 2018 20:34:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E16672931D for ; Mon, 3 Sep 2018 20:34:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729172AbeIDAz6 (ORCPT ); Mon, 3 Sep 2018 20:55:58 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:33207 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727784AbeIDAz5 (ORCPT ); Mon, 3 Sep 2018 20:55:57 -0400 Received: by mail-wm0-f65.google.com with SMTP id r1-v6so7523335wmh.0; Mon, 03 Sep 2018 13:34:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=znhKATxSpbkpApPLKvpo/RP4a7pgZj+EIzOmJtisvm4=; b=G3fGzuJ8YAXjLEgorIVa9LBuBMxP2AmACUEmpXHr0Mqnx5H2P1f33bsFU1ybS0lOO6 O7+9jJ4Z7dJswrHEowKjhOcQTo+BLcCmsYDjOxVttJ+BckBlS2T+70ppRKepIIVNdqNi Pwv79Jk1uTaroUYgt6zECHd0Gx0fQOEG9sPPbOTnqvH5nLGZRbTq0UIOnlVxPbWFtETT iSYEmXBROtc1nUFXKFEih3n+DVI8XsjUMM/uLvCtbwqy5+63sQRFFCeIDAGSHhRLFm1w ndMvVMqiF/5iLo28uZMs8Iz3lOpGeBLODyND76efpcjWailAsYvlovXTDznxtgWcIc4D XJ9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=znhKATxSpbkpApPLKvpo/RP4a7pgZj+EIzOmJtisvm4=; b=IOqZAO9FMuWz4PKMWqifW9xPtGjgALWmbMX5EaOgklTIWwKtxi2n7tcDC2xwxeyN8M P8fb/HmD5fP2+aobs67GLePDuWjJEmzXKjqJA8aZlYdK887tTP9z6NqFQDFyz2TpWH5N NyZkTLhxMKtlRxjthfvpOJ1vSlA07PMr6FpMvrE+zN9Kt99//Lm3bxwcJ1mpvHNzxsgD TNRUlIUZ2+hdM+udVZHQ0kcF0pYnZ1TYTkQJUVmyuaLIar31MvjHb+LGcm/TJTPV2sDL 0tsx5j4H7oR/m2k0qIJegGk2omLeECPkJiTRCPkG3xxOFNQTvWh8ZGehxeuwLCotHH6u CN5w== X-Gm-Message-State: APzg51D8WavOw1j3tnB0SvmRc6JFhI2csEsF4TPlyWtSyjOirgTZqyum 1J5iIp77VALoKumxFxeCBwu1X6fuHIc= X-Google-Smtp-Source: ANB0VdaNuTgx+ecVabi+TjVYZ6aXQsJrRDw08xQeVKWcudJG4q4jgYmVtaln+97uR+FQX99cZVHD4g== X-Received: by 2002:a1c:230f:: with SMTP id j15-v6mr629820wmj.124.1536006844302; Mon, 03 Sep 2018 13:34:04 -0700 (PDT) Received: from localhost.localdomain (62.83.35.8.dyn.user.ono.com. [62.83.35.8]) by smtp.gmail.com with ESMTPSA id 132-v6sm12354870wmd.13.2018.09.03.13.34.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Sep 2018 13:34:03 -0700 (PDT) From: Miguel Ojeda To: Linus Torvalds Cc: linux-kernel@vger.kernel.org, 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@vger.kernel.org, linux-doc@vger.kernel.org Subject: [PATCH 12/12] Compiler Attributes: add Doc/process/programming-language.rst Date: Mon, 3 Sep 2018 22:33:16 +0200 Message-Id: <20180903203316.16183-13-miguel.ojeda.sandonis@gmail.com> In-Reply-To: <20180903203316.16183-1-miguel.ojeda.sandonis@gmail.com> References: <20180903203316.16183-1-miguel.ojeda.sandonis@gmail.com> Sender: linux-sparse-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Cc: Jonathan Corbet Cc: Rasmus Villemoes Cc: Luc Van Oostenryck Cc: Eli Friedman Cc: Christopher Li Cc: Kees Cook Cc: Ingo Molnar Cc: Geert Uytterhoeven Cc: Arnd Bergmann Cc: Greg Kroah-Hartman Cc: Masahiro Yamada Cc: Joe Perches Cc: Dominique Martinet Cc: Nick Desaulniers Cc: Linus Torvalds Cc: linux-sparse@vger.kernel.org Cc: linux-doc@vger.kernel.org Signed-off-by: Miguel Ojeda --- 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 +