From patchwork Tue Dec 26 15:04:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 758375 Delivered-To: patch@linaro.org Received: by 2002:a5d:67c6:0:b0:336:6142:bf13 with SMTP id n6csp3106455wrw; Tue, 26 Dec 2023 07:05:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IG8kHqOKGLPQV5UOv7XuXKQYVuC6i3owIeneoGP+i6uCMTn9d9uNjbNjeIJm76nFQx52gcy X-Received: by 2002:a05:622a:60f:b0:413:3384:d43f with SMTP id z15-20020a05622a060f00b004133384d43fmr10137706qta.11.1703603127210; Tue, 26 Dec 2023 07:05:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703603127; cv=none; d=google.com; s=arc-20160816; b=Z8tdlx8EAV+EOEgLnUjMsrWyl9gPbKah6atz8DRTna6qHkQ0GYS5pfkl0Y2D+EbffI VW3m0F4FptdcrGbHjqa1J63kI9zjr970UZbVl8/F0IcZtPOwJSc4wEeooYCSK+4um9m5 omouY/eB2Pw+O5Axl2bmM5Jb+QpFntX6vr3vYvCGvwOiOVYqodKiy612ZGno4LhyY/hs QNC24QzvZHPu/JppmBKKUA0aG5hjtcR63pdXkjbTgMwrM24Ysdusp8dMoagLeRPrRdqe 79ACf2bqa7THZALym/h9XVGGfuvOXGpEiPZWyAP6zt2RerEhC4nMooVoo7jgwWTlew/R XWnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=53AW3JZnEVBpO4Di77Dp5vOYBvX9VB53tNaqD2ZNzQ4=; fh=BZd+iQlHoqPPRBjzhJPm54nVfYPWG/7VRakk9f5b2ps=; b=YombAs8nyWTASKtunNcOMi5fk9TPf/c9NERluup+SGGrvPFX5CNjGXUV5u0JiGj5aq +WTzms4L+SMD0u1TozW4EqyA1at+nGG0GbvxN4NDXK/F7kf/Y0/xbvI6Uky/T+NXu46L vrCna0Zw1CQ5s0QlEY1X92cmrNeUoR8zE2jhzEwkyQCglFQ4v0QK79f/D6RAzqUlPJYb GH0/RkWhMzDIhq3RJd5XIMfkSz2c1m3rKw7If/29EFT29fwXa7lew07S9DuOT656ANHQ OcD8rWWV1Xkm535+ER5arcBP3Hjp9oTDCMsGES2wtLSxnLXlhT5QKV6YgqDLjdKi8ub4 YtwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nvnnISdF; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d17-20020a05622a05d100b00423987299fdsi12382453qtb.665.2023.12.26.07.05.27 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 26 Dec 2023 07:05:27 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nvnnISdF; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Daniel Henrique Barboza , Peter Maydell , "Michael S . Tsirkin" , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Thomas Huth , Anton Johansson , Michael Tokarev , Zhao Liu , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Daniel_P?= =?utf-8?q?=2E_Berrang=C3=A9?= , =?utf-8?q?Philippe_Mat?= =?utf-8?q?hieu-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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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ée Signed-off-by: Philippe Mathieu-Daudé --- 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. +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 ===============