From patchwork Thu Sep 20 17:22:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miguel Ojeda X-Patchwork-Id: 10608285 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 BABD515E8 for ; Thu, 20 Sep 2018 17:24:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A218F2E283 for ; Thu, 20 Sep 2018 17:24:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 951382E29A; Thu, 20 Sep 2018 17:24:31 +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=unavailable 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 24B782E283 for ; Thu, 20 Sep 2018 17:24:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388165AbeITXIT (ORCPT ); Thu, 20 Sep 2018 19:08:19 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:35991 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388146AbeITXIS (ORCPT ); Thu, 20 Sep 2018 19:08:18 -0400 Received: by mail-wm1-f65.google.com with SMTP id j192-v6so361818wmj.1; Thu, 20 Sep 2018 10:23:46 -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=twtedPeeZz5KoysBQfVb1d5EctHONCIBWFDY7XlqfhI=; b=Ol6KQSWwqMxHMW2MGqYxwKMBZm7Reg5Kt+juHiMq2fr/oMpj+P2D1f0Ni2rNfAiKrG vjCI0EymqDtrplAJF2kOUWMKzLtbb3wXTtLHb6RiSn/DmsqphXqRZdfwEgQyFVXmkHJn MQL33oRe1OpABvhCBuH3ckMIibCCrVjPhvfQeOCpQm6a6q3mDsXj1I7ZreBpPPHeysRl ThKCSonsCXsjnz4FkAkt6nm/ig8qQ/zJA1L8Ludb51eySowy0M/9703DlqMieClzoDzu mUlalCmHfzfMIQ8dH04wi6TyMriIcQuJt3pMF5cmsvGMf+vZ4cdsS/bQP9RtK19oe9E+ CB0g== 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=twtedPeeZz5KoysBQfVb1d5EctHONCIBWFDY7XlqfhI=; b=joSfW0GS35oaL+djOgr5DimHJQuEP/Ra6owLDq4DhVBZ9v86wmLhlDN+2ewHVfv78z XhTX86Lz03E4NSnw6iFYpOOb0/uW3r+mtY8KlUV5ffgVRgSSha2pWOgiVHhZqaGR8OsM FwFVt1ooJWz6gnepSVcJMlBRUTQyyQ9Gl3jPSEeAI2AXHr+r3SvlABJhbUdDARayIaWK yXy6l81IDmnTJFsefzoRWv0ZEfJ1hXENmWv8ypyVNd7CUcvLNoWhowur7rBKYR3bGAx6 tIzNUeLvvk+NmfS6ymFYG2Uyk348GaakcykDBFfQ8aOvPIWg7WA/sBWR7tb2suKUBixM AyRQ== X-Gm-Message-State: APzg51ClTSPL9M0DEl+ynmztQFWwNL3Zj+pw/EgTRiClO8Dsee8DuKEP eqavtwoIeQhi6N/dPDRDONg= X-Google-Smtp-Source: ACcGV62jh5I3d0SxFnA3UY6WCKlfBUKZh/iZ3//O8F1vh1odvSENoZlxyzoI2PON3pJIksQWNhU1Tg== X-Received: by 2002:a1c:cf8a:: with SMTP id f132-v6mr3820080wmg.0.1537464226338; Thu, 20 Sep 2018 10:23:46 -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 q200-v6sm3466562wmd.2.2018.09.20.10.23.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Sep 2018 10:23:45 -0700 (PDT) From: Miguel Ojeda To: Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, Miguel Ojeda , Andreas Dilger , Masahiro Yamada , Michal Marek , Steven Rostedt , Mauro Carvalho Chehab , Olof Johansson , Konstantin Ryabitsev , "David S . Miller" , Andrey Ryabinin , Kees Cook , Thomas Gleixner , Ingo Molnar , Paul Lawrence , Sandipan Das , Andrey Konovalov , David Woodhouse , Will Deacon , Philippe Ombredanne , Paul Burton , David Rientjes , Willy Tarreau , Martin Sebor , Christopher Li , Jonathan Corbet , Theodore Ts'o , Geert Uytterhoeven , Rasmus Villemoes , Joe Perches , Arnd Bergmann , Dominique Martinet , Stefan Agner , Luc Van Oostenryck , Nick Desaulniers , Andrew Morton , Linus Torvalds , linux-doc@vger.kernel.org, linux-ext4@vger.kernel.org, linux-sparse@vger.kernel.org, linux-kbuild@vger.kernel.org Subject: [PATCH v5 10/15] Compiler Attributes: add Doc/process/programming-language.rst Date: Thu, 20 Sep 2018 19:22:56 +0200 Message-Id: <20180920172301.21868-11-miguel.ojeda.sandonis@gmail.com> In-Reply-To: <20180920172301.21868-1-miguel.ojeda.sandonis@gmail.com> References: <20180920172301.21868-1-miguel.ojeda.sandonis@gmail.com> Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Reviewed-by: Nick Desaulniers Reviewed-by: Luc Van Oostenryck Signed-off-by: Miguel Ojeda --- Documentation/process/index.rst | 1 + .../process/programming-language.rst | 45 +++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 Documentation/process/programming-language.rst diff --git a/Documentation/process/index.rst b/Documentation/process/index.rst index 9ae3e317bddf..00558b6d2649 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-conduct 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..e5f5f065dc24 --- /dev/null +++ b/Documentation/process/programming-language.rst @@ -0,0 +1,45 @@ +.. _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 +