From nobody Tue Nov 26 22:22:47 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1703603127; cv=none; d=zohomail.com; s=zohoarc; b=SQzcCdL07k9FO/B4H6XoW4rfIEJfwPifl8C+ZhOCNOWeU+m4VQD6TQu8P0YFyZ96WoPqiQ41t5nqMRgBGDUVFU2RZvcI7zFsaU2GxSYdDpIjchZuY140Yf4tJcrssKkHSsQZCvD27dwWEMqa9id+WlDcxa5hQpmIc/V16KygxZU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1703603127; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=53AW3JZnEVBpO4Di77Dp5vOYBvX9VB53tNaqD2ZNzQ4=; b=Vf3+c36XHH/RUHYVPlXtDDJjXl6LEaTpzKLNQYu/OxXHzL7TH/WSHglGIq2L5xgpinSgaDKOqyU/7p5l99fdDSBUl+Hziqml2Pev8l9ZHfGAWBheoWPkfkuUM5BEMwPoTLp+MMapAlXbn3Q/ew6eqnrDbU2QgWg7O6Uace+zRok= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1703603127828447.2544963350938; Tue, 26 Dec 2023 07:05:27 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rI8zD-0002yN-HL; Tue, 26 Dec 2023 10:04:51 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rI8zB-0002y1-Pt for qemu-devel@nongnu.org; Tue, 26 Dec 2023 10:04:49 -0500 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rI8z9-0003Xo-Nc for qemu-devel@nongnu.org; Tue, 26 Dec 2023 10:04:49 -0500 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-40d5ae89c7bso3277645e9.2 for ; Tue, 26 Dec 2023 07:04:47 -0800 (PST) Received: from localhost.localdomain (94.red-95-127-40.staticip.rima-tde.net. [95.127.40.94]) by smtp.gmail.com with ESMTPSA id fl25-20020a05600c0b9900b0040b3e26872dsm29121020wmb.8.2023.12.26.07.04.42 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 26 Dec 2023 07:04:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1703603085; x=1704207885; darn=nongnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=53AW3JZnEVBpO4Di77Dp5vOYBvX9VB53tNaqD2ZNzQ4=; b=nvnnISdFG0jbtFGolUpVypxE62qlH3DUPc7xcdAghEgM6smurOXJph+/blpGXpkCZt uyRS9mUUJEPcrMVJRtawX7KViXf222Rv4dOUPsDc8rgm8B9UrLTLj5ZUFf//X+sHcsLM KD+Ah3wqRYInZwvE4oqeEPex5zTSprHx1DmUxBUwqbOPOjFi+UMHi8PREWD5nJZqLSXR KW6y7tFs3FBfrdacMHrUmoupv0yETfNjwbalYRc8/KmVRd0ow7MMhBuYZu9vUJsg29IJ 8r/YomegX+Za0c15gw28AaWfTLNM0EwrcKrXBtn7UzHEv6peBH52odGc2Vjf4ud4NV5o w0lg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703603085; x=1704207885; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=53AW3JZnEVBpO4Di77Dp5vOYBvX9VB53tNaqD2ZNzQ4=; b=mrFFR30q9Xx3AP9OyuBEicqBA5boDIyN9Sc5DAyvMduyBP4L6Tt1gG3tbnIbefKnzt m5MiR8PXqcXObyD2uJ3wsvlRWHfwAkkkgozGduvpspJOBR6nSL26Utm+iXgub7eJLwpK hoJfi12TuGLB5wuICcvCZyX8pyFKtnn9sJlfrdW8Z9uKVX7JhUnJDEFTrgr3m0ZUPmW0 iRsZ5XZHbQLK2RI1RJkXoDlxyOTkJZ5lIwxAmPnkDylczyPiG1XD9khXByGy16dMRo5S LWCsEVWo8ionmE3tvm/IgLUgWH/FrIwQoLvBwGFD5Zn/9mItZtb3BgCe9ig3p1cvwSzM pPVA== X-Gm-Message-State: AOJu0Ywm9OUmNOZzcs9YZVIYM3vgCdvlUBFmy4+a7o1Q9i4+J/hZ5ENr qsSTvUcRQSJhFZ4PfuUSjpvePdZT/TK79zMLkyG/acygw3o= X-Google-Smtp-Source: AGHT+IHvFNtdAASS4DXDDVjC2zUHo0tK9FJRaH1nqR55Nwa+yDK6SpWGff6zLPXlm6O20Lwq5pTY0Q== X-Received: by 2002:a05:600c:3d0b:b0:40d:5c99:7aaa with SMTP id bh11-20020a05600c3d0b00b0040d5c997aaamr84859wmb.4.1703603085372; Tue, 26 Dec 2023 07:04:45 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Daniel Henrique Barboza , Peter Maydell , "Michael S . Tsirkin" , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Thomas Huth , Anton Johansson , Michael Tokarev , Zhao Liu , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Juan Quintela , David Hildenbrand , Markus Armbruster , Stefan Hajnoczi Subject: [PATCH] docs/devel: Document conventional file prefixes and suffixes Date: Tue, 26 Dec 2023 16:04:41 +0100 Message-ID: <20231226150441.97501-1-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=philmd@linaro.org; helo=mail-wm1-x334.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1703603130141100003 Some header and source file names use common prefix / suffix but we never really ruled a convention. Start doing so with the current patterns from the tree. Suggested-by: Alex Benn=C3=A9e Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- docs/devel/style.rst | 49 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/docs/devel/style.rst b/docs/devel/style.rst index 2f68b50079..4da50eb2ea 100644 --- a/docs/devel/style.rst +++ b/docs/devel/style.rst @@ -162,6 +162,55 @@ pre-processor. Another common suffix is ``_impl``; it = is used for the concrete implementation of a function that will not be called directly, but rather through a macro or an inline function. =20 +File Naming Conventions +----------------------- + +Public headers +~~~~~~~~~~~~~~ + +Headers expected to be access by multiple subsystems must reside in +the ``include/`` folder. Headers local to a subsystem should reside in +the sysbsystem folder, if any (for example ``qobject/qobject-internal.h`` +can only be included by files within the ``qobject/`` folder). + +Header file prefix and suffix hints +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +When headers relate to common concept, it is useful to use a common +prefix or suffix. + +When headers relate to the same (guest) subsystem, the subsystem name is +often used as prefix. If headers are already in a folder named as the +subsystem, prefixing them is optional. + +For example, hardware models related to the Aspeed systems are named +using the ``aspeed_`` prefix. + +Headers related to the same (host) concept can also use a common prefix. +For example OS specific headers use the ``-posix`` and ``-win32`` suffixes. + +Registered file suffixes +~~~~~~~~~~~~~~~~~~~~~~~~ + +* ``.inc`` + + Source files meant to be included by other source files as templates + must use the ``.c.inc`` suffix. Similarly, headers meant to be included + multiple times as template must use the ``.h.inc`` suffix. + +Recommended file prefixes / suffixes +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +* ``target`` and ``common`` suffixes + + Files which are specific to a target should use the ``target`` suffix. + Such ``target`` suffixed headers usually *taint* the files including them + by making them target specific. + + Files common to all targets should use the ``common`` suffix, to provide + a hint that these files can be safely included from common code. + + Block structure =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 --=20 2.41.0