Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1938025imm; Mon, 3 Sep 2018 13:35:32 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbQ8KBc6OXfpLuYjm3OLOcP43zbQIxK3yKmGddy6MV6m/4YyJxZW1B74ytQ3hD47QSMTDWD X-Received: by 2002:a62:c218:: with SMTP id l24-v6mr31208303pfg.185.1536006932666; Mon, 03 Sep 2018 13:35:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536006932; cv=none; d=google.com; s=arc-20160816; b=koqUanbfMdTV4T44B+JAksYwlBmxQrTU7LxNYS8HRcjnW4+tzHzR4wv+NP6kdJsjmi W5QLT1bKOP06ALUSN4yFfqngjh1trLFNA5Fx0rC6/Z2Zpgdc6YksXYPD+ED/Y2jZR6gX OtyyD3Y4Lr//OdY9QXcGMVzWZMwy9sdv6By7Wd9rdT3DMC0vF813vgi4EGGH29z2GfGA W12vYjCtfxnawTnQPOzP0NQ8ZBQqAF6c/iNjw+33P+v6SAQJiHf2OApvvWoE9cE2Aj7f xHIBmY3d5HUp69FavVR7Uwmy7Le+UmfXjWKCyc9O5trxsODnDbbeNJr0wWPnV8fQ4Pxa aiLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=znhKATxSpbkpApPLKvpo/RP4a7pgZj+EIzOmJtisvm4=; b=vAD43pUWLLiMA+huNDsOVg7hXC+Ud9e+Li2feMANMbxODugmSXCeFIrl1ng/+FP3Wa NCe6zn72aqPU5+uB87WhJicLE1Yv9PDGYljA9mTehlc2t0O16pxjwf86PgZitoVNfxZx POGjMqv3kSYhmGYTStgJXhfXDyDbWarhsQ5QbFJ2cnjZmH5wrY/A4AU8HDVQ69VPlLX5 Wfm2NGWq5U1fSN8ritCxqy8p6XERFtkJZufr9cB4SqYXGEYqstdaVKYwtkRuN3NKCrNr 1KGRBhJ+GscFL3HtsN4ZA/O3H/QpxL+qoWflrw+yK/Qo8hhw62bo0udZ6pxa+f67eFZ3 E1rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=G3fGzuJ8; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f25-v6si11104408pgv.572.2018.09.03.13.35.18; Mon, 03 Sep 2018 13:35:32 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=G3fGzuJ8; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729192AbeIDAz6 (ORCPT + 99 others); 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-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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 + -- 2.17.1