Skip to contentSkip to conversation

target: Rename headers using .def extension to .h.inc

PATCH Applied Philippe Mathieu-Daudé 7 participants 18 messages Oct 25, 2022 – Nov 2, 2022 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

cover target: Rename headers using .def extension to .h.inc

We use the .h.inc extension to include C headers. To be consistent with the rest of the codebase, rename the C headers using the .def extension.

IDE/tools using our .editorconfig / .gitattributes will leverage this consistency.

Philippe Mathieu-Daudé (3):
target/m68k: Rename qregs.def -> qregs.h.inc target/s390x: Rename insn-data/format.def -> insn-data/format.h.inc target/tricore: Rename csfr.def -> csfr.h.inc

 target/m68k/{qregs.def => qregs.h.inc}                 |  0
 target/m68k/translate.c                                |  4 ++--
 target/s390x/tcg/{insn-data.def => insn-data.h.inc}    |  2 +-
 .../s390x/tcg/{insn-format.def => insn-format.h.inc}   |  0
 target/s390x/tcg/translate.c                           | 10 +++++-----
 target/tricore/{csfr.def => csfr.h.inc}                |  0
 target/tricore/translate.c                             |  4 ++--
 7 files changed, 10 insertions(+), 10 deletions(-)
 rename target/m68k/{qregs.def => qregs.h.inc} (100%)
 rename target/s390x/tcg/{insn-data.def => insn-data.h.inc} (99%)
 rename target/s390x/tcg/{insn-format.def => insn-format.h.inc} (100%)
 rename target/tricore/{csfr.def => csfr.h.inc} (100%)
Signature · 1 line
2.37.3
#1 lore raw

PATCH 1/3 target/m68k: Rename qregs.def -> qregs.h.inc

We use the .h.inc extension to include C headers. To be consistent with the rest of the codebase, rename the C headers using the .def extension.

IDE/tools using our .editorconfig / .gitattributes will leverage this consistency.

---
 target/m68k/{qregs.def => qregs.h.inc} | 0
 target/m68k/translate.c                | 4 ++--
 2 files changed, 2 insertions(+), 2 deletions(-)
 rename target/m68k/{qregs.def => qregs.h.inc} (100%)
target/m68k/qregs.h.inc renamed from target/m68k/qregs.def +0 -0
similarity index 100%
rename from target/m68k/qregs.def
rename to target/m68k/qregs.h.inc
target/m68k/translate.c +2 -2
index 9df17aa4b2..f018fa9eb0 100644
@@ -39,7 +39,7 @@
 
 #define DEFO32(name, offset) static TCGv QREG_##name;
 #define DEFO64(name, offset) static TCGv_i64 QREG_##name;
-#include "qregs.def"
+#include "qregs.h.inc"
 #undef DEFO32
 #undef DEFO64
 
@@ -75,7 +75,7 @@ void m68k_tcg_init(void)
 #define DEFO64(name, offset) \
     QREG_##name = tcg_global_mem_new_i64(cpu_env, \
         offsetof(CPUM68KState, offset), #name);
-#include "qregs.def"
+#include "qregs.h.inc"
 #undef DEFO32
 #undef DEFO64
 
Signature · 1 line
2.37.3
Reviewed-by on v1 1/3
#2 lore raw

Re: [PATCH 1/3] target/m68k: Rename qregs.def -> qregs.h.inc

Le 26/10/2022 à 01:50, Philippe Mathieu-Daudé a écrit :

Quoted 32 lines

We use the .h.inc extension to include C headers. To be consistent with the rest of the codebase, rename the C headers using the .def extension.

IDE/tools using our .editorconfig / .gitattributes will leverage this consistency.

---
  target/m68k/{qregs.def => qregs.h.inc} | 0
  target/m68k/translate.c                | 4 ++--
  2 files changed, 2 insertions(+), 2 deletions(-)

rename target/m68k/{qregs.def => qregs.h.inc} (100%)

target/m68k/qregs.h.inc renamed from target/m68k/qregs.def +0 -0
similarity index 100%
rename from target/m68k/qregs.def
rename to target/m68k/qregs.h.inc
target/m68k/translate.c +1 -1
index 9df17aa4b2..f018fa9eb0 100644
@@ -39,7 +39,7 @@
 
  #define DEFO32(name, offset) static TCGv QREG_##name;
  #define DEFO64(name, offset) static TCGv_i64 QREG_##name;
-#include "qregs.def"
+#include "qregs.h.inc"
  #undef DEFO32
  #undef DEFO64
 

target/m68k/translate.c void m68k_tcg_init(void) · line 81

Quoted 8 lines
target/m68k/translate.c +1 -1
@@ -75,7 +75,7 @@ void m68k_tcg_init(void)
  #define DEFO64(name, offset) \
      QREG_##name = tcg_global_mem_new_i64(cpu_env, \
          offsetof(CPUM68KState, offset), #name);
-#include "qregs.def"
+#include "qregs.h.inc"
  #undef DEFO32
  #undef DEFO64
 
#3 lore raw

Re: [PATCH 1/3] target/m68k: Rename qregs.def -> qregs.h.inc

In reply to Philippe Mathieu-Daudé

Le 26/10/2022 à 01:50, Philippe Mathieu-Daudé a écrit :

Quoted 32 lines

We use the .h.inc extension to include C headers. To be consistent with the rest of the codebase, rename the C headers using the .def extension.

IDE/tools using our .editorconfig / .gitattributes will leverage this consistency.

---
  target/m68k/{qregs.def => qregs.h.inc} | 0
  target/m68k/translate.c                | 4 ++--
  2 files changed, 2 insertions(+), 2 deletions(-)

rename target/m68k/{qregs.def => qregs.h.inc} (100%)

target/m68k/qregs.h.inc renamed from target/m68k/qregs.def +0 -0
similarity index 100%
rename from target/m68k/qregs.def
rename to target/m68k/qregs.h.inc
target/m68k/translate.c +1 -1
index 9df17aa4b2..f018fa9eb0 100644
@@ -39,7 +39,7 @@
 
  #define DEFO32(name, offset) static TCGv QREG_##name;
  #define DEFO64(name, offset) static TCGv_i64 QREG_##name;
-#include "qregs.def"
+#include "qregs.h.inc"
  #undef DEFO32
  #undef DEFO64
 

target/m68k/translate.c void m68k_tcg_init(void) · line 81

Quoted 8 lines
target/m68k/translate.c +1 -1
@@ -75,7 +75,7 @@ void m68k_tcg_init(void)
  #define DEFO64(name, offset) \
      QREG_##name = tcg_global_mem_new_i64(cpu_env, \
          offsetof(CPUM68KState, offset), #name);
-#include "qregs.def"
+#include "qregs.h.inc"
  #undef DEFO32
  #undef DEFO64
 

Applied to my trivial-patches branch.

Thanks,
Laurent

#4 lore raw

PATCH 2/3 target/s390x: Rename insn-data/format.def -> insn-data/format.h.inc

In reply to Philippe Mathieu-Daudé

We use the .h.inc extension to include C headers. To be consistent with the rest of the codebase, rename the C headers using the .def extension.

IDE/tools using our .editorconfig / .gitattributes will leverage this consistency.

---
 target/s390x/tcg/{insn-data.def => insn-data.h.inc}    |  2 +-
 .../s390x/tcg/{insn-format.def => insn-format.h.inc}   |  0
 target/s390x/tcg/translate.c                           | 10 +++++-----
 3 files changed, 6 insertions(+), 6 deletions(-)
 rename target/s390x/tcg/{insn-data.def => insn-data.h.inc} (99%)
 rename target/s390x/tcg/{insn-format.def => insn-format.h.inc} (100%)
target/s390x/tcg/insn-data.h.inc renamed from target/s390x/tcg/insn-data.def +1 -1
similarity index 99%
rename from target/s390x/tcg/insn-data.def
rename to target/s390x/tcg/insn-data.h.inc
index 6382ceabfc..7e952bdfc8 100644
@@ -8,7 +8,7 @@
  *
  *  OPC  = (op << 8) | op2 where op is the major, op2 the minor opcode
  *  NAME = name of the opcode, used internally
- *  FMT  = format of the opcode (defined in insn-format.def)
+ *  FMT  = format of the opcode (defined in insn-format.h.inc)
  *  FAC  = facility the opcode is available in (defined in DisasFacility)
  *  I1   = func in1_xx fills o->in1
  *  I2   = func in2_xx fills o->in2
target/s390x/tcg/insn-format.h.inc renamed from target/s390x/tcg/insn-format.def +0 -0
similarity index 100%
rename from target/s390x/tcg/insn-format.def
rename to target/s390x/tcg/insn-format.h.inc
target/s390x/tcg/translate.c +5 -5
index 1d2dddab1c..f378e1a633 100644
@@ -1011,7 +1011,7 @@ static void free_compare(DisasCompare *c)
 #define F6(N, X1, X2, X3, X4, X5, X6) F0(N)
 
 typedef enum {
-#include "insn-format.def"
+#include "insn-format.h.inc"
 } DisasFormat;
 
 #undef F0
@@ -1076,7 +1076,7 @@ typedef struct DisasFormatInfo {
 #define F6(N, X1, X2, X3, X4, X5, X6)       { { X1, X2, X3, X4, X5, X6 } },
 
 static const DisasFormatInfo format_info[] = {
-#include "insn-format.def"
+#include "insn-format.h.inc"
 };
 
 #undef F0
@@ -6143,7 +6143,7 @@ static void in2_insn(DisasContext *s, DisasOps *o)
 #define E(OPC, NM, FT, FC, I1, I2, P, W, OP, CC, D, FL) insn_ ## NM,
 
 enum DisasInsnEnum {
-#include "insn-data.def"
+#include "insn-data.h.inc"
 };
 
 #undef E
@@ -6223,7 +6223,7 @@ enum DisasInsnEnum {
 #define FAC_MIE3        S390_FEAT_MISC_INSTRUCTION_EXT3 /* miscellaneous-instruction-extensions facility 3 */
 
 static const DisasInsn insn_info[] = {
-#include "insn-data.def"
+#include "insn-data.h.inc"
 };
 
 #undef E
@@ -6233,7 +6233,7 @@ static const DisasInsn insn_info[] = {
 static const DisasInsn *lookup_opc(uint16_t opc)
 {
     switch (opc) {
-#include "insn-data.def"
+#include "insn-data.h.inc"
     default:
         return NULL;
     }
Signature · 1 line
2.37.3
Reviewed-by on v1 2/3
#5 lore raw

Re: [PATCH 2/3] target/s390x: Rename insn-data/format.def -> insn-data/format.h.inc

Quoted 7 lines · Philippe Mathieu-Daudé

We use the .h.inc extension to include C headers. To be consistent with the rest of the codebase, rename the C headers using the .def extension.

IDE/tools using our .editorconfig / .gitattributes will leverage this consistency.

Quoted 8 lines
---
  target/s390x/tcg/{insn-data.def => insn-data.h.inc}    |  2 +-
  .../s390x/tcg/{insn-format.def => insn-format.h.inc}   |  0
  target/s390x/tcg/translate.c                           | 10 +++++-----
  3 files changed, 6 insertions(+), 6 deletions(-)

rename target/s390x/tcg/{insn-data.def => insn-data.h.inc} (99%) rename target/s390x/tcg/{insn-format.def => insn-format.h.inc} (100%)

#6 lore raw

Re: [PATCH 2/3] target/s390x: Rename insn-data/format.def -> insn-data/format.h.inc

In reply to Philippe Mathieu-Daudé

Le 26/10/2022 à 01:50, Philippe Mathieu-Daudé a écrit :

Quoted 77 lines

We use the .h.inc extension to include C headers. To be consistent with the rest of the codebase, rename the C headers using the .def extension.

IDE/tools using our .editorconfig / .gitattributes will leverage this consistency.

---
  target/s390x/tcg/{insn-data.def => insn-data.h.inc}    |  2 +-
  .../s390x/tcg/{insn-format.def => insn-format.h.inc}   |  0
  target/s390x/tcg/translate.c                           | 10 +++++-----
  3 files changed, 6 insertions(+), 6 deletions(-)

rename target/s390x/tcg/{insn-data.def => insn-data.h.inc} (99%) rename target/s390x/tcg/{insn-format.def => insn-format.h.inc} (100%)

target/s390x/tcg/insn-data.h.inc renamed from target/s390x/tcg/insn-data.def +1 -1
similarity index 99%
rename from target/s390x/tcg/insn-data.def
rename to target/s390x/tcg/insn-data.h.inc
index 6382ceabfc..7e952bdfc8 100644
@@ -8,7 +8,7 @@
   *
   *  OPC  = (op << 8) | op2 where op is the major, op2 the minor opcode
   *  NAME = name of the opcode, used internally
- *  FMT  = format of the opcode (defined in insn-format.def)
+ *  FMT  = format of the opcode (defined in insn-format.h.inc)
   *  FAC  = facility the opcode is available in (defined in DisasFacility)
   *  I1   = func in1_xx fills o->in1
   *  I2   = func in2_xx fills o->in2
target/s390x/tcg/insn-format.h.inc renamed from target/s390x/tcg/insn-format.def +0 -0
similarity index 100%
rename from target/s390x/tcg/insn-format.def
rename to target/s390x/tcg/insn-format.h.inc
target/s390x/tcg/translate.c +4 -4
index 1d2dddab1c..f378e1a633 100644
@@ -1011,7 +1011,7 @@ static void free_compare(DisasCompare *c)
  #define F6(N, X1, X2, X3, X4, X5, X6) F0(N)
 
  typedef enum {
-#include "insn-format.def"
+#include "insn-format.h.inc"
  } DisasFormat;
 
  #undef F0
@@ -1076,7 +1076,7 @@ typedef struct DisasFormatInfo {
  #define F6(N, X1, X2, X3, X4, X5, X6)       { { X1, X2, X3, X4, X5, X6 } },
 
  static const DisasFormatInfo format_info[] = {
-#include "insn-format.def"
+#include "insn-format.h.inc"
  };
 
  #undef F0
@@ -6143,7 +6143,7 @@ static void in2_insn(DisasContext *s, DisasOps *o)
  #define E(OPC, NM, FT, FC, I1, I2, P, W, OP, CC, D, FL) insn_ ## NM,
 
  enum DisasInsnEnum {
-#include "insn-data.def"
+#include "insn-data.h.inc"
  };
 
  #undef E
@@ -6223,7 +6223,7 @@ enum DisasInsnEnum {
  #define FAC_MIE3        S390_FEAT_MISC_INSTRUCTION_EXT3 /* miscellaneous-instruction-extensions facility 3 */
 
  static const DisasInsn insn_info[] = {
-#include "insn-data.def"
+#include "insn-data.h.inc"
  };
 
  #undef E

target/s390x/tcg/translate.c static const DisasInsn insn_info[] = { · line 6239

Quoted 8 lines
target/s390x/tcg/translate.c +1 -1
@@ -6233,7 +6233,7 @@ static const DisasInsn insn_info[] = {
  static const DisasInsn *lookup_opc(uint16_t opc)
  {
      switch (opc) {
-#include "insn-data.def"
+#include "insn-data.h.inc"
      default:
          return NULL;
      }

Applied to my trivial-patches branch.

Thanks,
Laurent

#7 lore raw

PATCH 3/3 target/tricore: Rename csfr.def -> csfr.h.inc

In reply to Philippe Mathieu-Daudé

We use the .h.inc extension to include C headers. To be consistent with the rest of the codebase, rename the C headers using the .def extension.

IDE/tools using our .editorconfig / .gitattributes will leverage this consistency.

---
 target/tricore/{csfr.def => csfr.h.inc} | 0
 target/tricore/translate.c              | 4 ++--
 2 files changed, 2 insertions(+), 2 deletions(-)
 rename target/tricore/{csfr.def => csfr.h.inc} (100%)
target/tricore/csfr.h.inc renamed from target/tricore/csfr.def +0 -0
similarity index 100%
rename from target/tricore/csfr.def
rename to target/tricore/csfr.h.inc
target/tricore/translate.c +2 -2
index a0558ead71..f02090945d 100644
@@ -388,7 +388,7 @@ static inline void gen_mfcr(DisasContext *ctx, TCGv ret, int32_t offset)
         gen_helper_psw_read(ret, cpu_env);
     } else {
         switch (offset) {
-#include "csfr.def"
+#include "csfr.h.inc"
         }
     }
 }
@@ -418,7 +418,7 @@ static inline void gen_mtcr(DisasContext *ctx, TCGv r1,
             gen_helper_psw_write(cpu_env, r1);
         } else {
             switch (offset) {
-#include "csfr.def"
+#include "csfr.h.inc"
             }
         }
     } else {
Signature · 1 line
2.37.3
Reviewed-by on v1 3/3
#8 lore raw

Re: [PATCH 3/3] target/tricore: Rename csfr.def -> csfr.h.inc

Quoted 7 lines · Philippe Mathieu-Daudé

We use the .h.inc extension to include C headers. To be consistent with the rest of the codebase, rename the C headers using the .def extension.

IDE/tools using our .editorconfig / .gitattributes will leverage this consistency.

Quoted 6 lines
---
 target/tricore/{csfr.def => csfr.h.inc} | 0
 target/tricore/translate.c              | 4 ++--
 2 files changed, 2 insertions(+), 2 deletions(-)
 rename target/tricore/{csfr.def => csfr.h.inc} (100%)

Cheers,
Bastian

#9 lore raw

Re: [PATCH 3/3] target/tricore: Rename csfr.def -> csfr.h.inc

In reply to Philippe Mathieu-Daudé

Le 26/10/2022 à 01:50, Philippe Mathieu-Daudé a écrit :

Quoted 32 lines

We use the .h.inc extension to include C headers. To be consistent with the rest of the codebase, rename the C headers using the .def extension.

IDE/tools using our .editorconfig / .gitattributes will leverage this consistency.

---
  target/tricore/{csfr.def => csfr.h.inc} | 0
  target/tricore/translate.c              | 4 ++--
  2 files changed, 2 insertions(+), 2 deletions(-)

rename target/tricore/{csfr.def => csfr.h.inc} (100%)

target/tricore/csfr.h.inc renamed from target/tricore/csfr.def +0 -0
similarity index 100%
rename from target/tricore/csfr.def
rename to target/tricore/csfr.h.inc
target/tricore/translate.c +1 -1
index a0558ead71..f02090945d 100644
@@ -388,7 +388,7 @@ static inline void gen_mfcr(DisasContext *ctx, TCGv ret, int32_t offset)
          gen_helper_psw_read(ret, cpu_env);
      } else {
          switch (offset) {
-#include "csfr.def"
+#include "csfr.h.inc"
          }
      }
  }

target/tricore/translate.c static inline void gen_mtcr(DisasContext *ctx, TCGv r1, · line 424

Quoted 8 lines
target/tricore/translate.c +1 -1
@@ -418,7 +418,7 @@ static inline void gen_mtcr(DisasContext *ctx, TCGv r1,
              gen_helper_psw_write(cpu_env, r1);
          } else {
              switch (offset) {
-#include "csfr.def"
+#include "csfr.h.inc"
              }
          }
      } else {

Applied to my trivial-patches branch.

Thanks,
Laurent

Reviewed-by on the v1 series
#10 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 6 lines · Philippe Mathieu-Daudé

We use the .h.inc extension to include C headers. To be consistent with the rest of the codebase, rename the C headers using the .def extension.

IDE/tools using our .editorconfig / .gitattributes will leverage this consistency.

Signature · 1 line
Alex Bennée

A message that is not in the archive (sent off-list or not yet received): [email protected]

#12 lore raw
Quoted 9 lines · Thomas Huth
Quoted 6 lines · Philippe Mathieu-Daudé

We use the .h.inc extension to include C headers. To be consistent with the rest of the codebase, rename the C headers using the .def extension.

IDE/tools using our .editorconfig / .gitattributes will leverage this consistency.

Ack for this series, but I've got a meta-question: Does anybody remember why we are using .h.inc and not .inc.h for such headers? .h.inc has to be manually configured in most editors for supporting syntax highlighting here - with .inc.h most editors would get it right by default instead...

Daniel synthesized the reason here:
https://lore.kernel.org/qemu-devel/[email protected]/

Quoted 2 lines
Quoted 2 lines

IIRC, we need to use c.inc, because Meson has specific semantics around a file ending in ".c" that we don't want.

First explanation from Paolo:

https://lore.kernel.org/qemu-devel/[email protected]/

See also for generic .*.inc admitted as convention:
https://lore.kernel.org/qemu-devel/CAFEAcA-kOs3dKhh3SRchg6Ne8QL8kwyz+2ihDC6ND2v-seuRfw@mail.gmail.com/

Could be worth mentioning in docs/devel/build-system.rst...

Regards,

Phil.

#13 lore raw
Quoted 19 lines · Philippe Mathieu-Daudé
Quoted 9 lines · Thomas Huth
Quoted 6 lines · Philippe Mathieu-Daudé

We use the .h.inc extension to include C headers. To be consistent with the rest of the codebase, rename the C headers using the .def extension.

IDE/tools using our .editorconfig / .gitattributes will leverage this consistency.

Ack for this series, but I've got a meta-question: Does anybody remember why we are using .h.inc and not .inc.h for such headers? .h.inc has to be manually configured in most editors for supporting syntax highlighting here - with .inc.h most editors would get it right by default instead...

Daniel synthesized the reason here:
https://lore.kernel.org/qemu-devel/[email protected]/

Quoted 2 lines
Quoted 2 lines

IIRC, we need to use  c.inc, because Meson has specific semantics around a file ending in ".c" that we don't want.

First explanation from Paolo:

Quoted 7 lines

https://lore.kernel.org/qemu-devel/[email protected]/

See also for generic .*.inc admitted as convention:
https://lore.kernel.org/qemu-devel/CAFEAcA-kOs3dKhh3SRchg6Ne8QL8kwyz+2ihDC6ND2v-seuRfw@mail.gmail.com/

Could be worth mentioning in docs/devel/build-system.rst...

Thanks for the summary! ... now if someone (who feels confident about all of this) could add some sentences to build-system.rst, that would be really great...

Thomas

#14 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 12 lines · Philippe Mathieu-Daudé

We use the .h.inc extension to include C headers. To be consistent with the rest of the codebase, rename the C headers using the .def extension.

IDE/tools using our .editorconfig / .gitattributes will leverage this consistency.

Philippe Mathieu-Daudé (3):
target/m68k: Rename qregs.def -> qregs.h.inc target/s390x: Rename insn-data/format.def -> insn-data/format.h.inc target/tricore: Rename csfr.def -> csfr.h.inc

Quoted 12 lines
 target/m68k/{qregs.def => qregs.h.inc}                 |  0
 target/m68k/translate.c                                |  4 ++--
 target/s390x/tcg/{insn-data.def => insn-data.h.inc}    |  2 +-
 .../s390x/tcg/{insn-format.def => insn-format.h.inc}   |  0
 target/s390x/tcg/translate.c                           | 10 +++++-----
 target/tricore/{csfr.def => csfr.h.inc}                |  0
 target/tricore/translate.c                             |  4 ++--
 7 files changed, 10 insertions(+), 10 deletions(-)
 rename target/m68k/{qregs.def => qregs.h.inc} (100%)
 rename target/s390x/tcg/{insn-data.def => insn-data.h.inc} (99%)
 rename target/s390x/tcg/{insn-format.def => insn-format.h.inc} (100%)
 rename target/tricore/{csfr.def => csfr.h.inc} (100%)

I wonder why we use any of .def, .h.inc, .inc.h, .c.inc, .inc.c. Why not .h and call it a day? No need to configure each and every editor to tread these as C code.

#15 lore raw
Quoted 3 lines · Markus Armbruster

I wonder why we use any of .def, .h.inc, .inc.h, .c.inc, .inc.c. Why not .h and call it a day? No need to configure each and every editor to tread these as C code.

It says "this isn't actually a header in the usual sense". That's useful for automated scripted checks (eg we don't want scripts/clean-header-guards.pl to add the standard #include header guards to this sort of file) and for humans (if you see one of these files included as part of the normal #include block at the top of a .c file that's probably a mistake; if you see it being used then you know there's likely multiple-inclusion shenanigans going on.)

thanks
-- PMM

#16 lore raw
Quoted 5 lines · Peter Maydell
Quoted 3 lines · Markus Armbruster

I wonder why we use any of .def, .h.inc, .inc.h, .c.inc, .inc.c. Why not .h and call it a day? No need to configure each and every editor to tread these as C code.

Quoted 7 lines

It says "this isn't actually a header in the usual sense". That's useful for automated scripted checks (eg we don't want scripts/clean-header-guards.pl to add the standard #include header guards to this sort of file) and for humans (if you see one of these files included as part of the normal #include block at the top of a .c file that's probably a mistake; if you see it being used then you know there's likely multiple-inclusion shenanigans going on.)

scripts/clean-header-guards.pl needs exclude patterns anyway.

Comments would likely work better for humans than obscure naming conventions.

Make them stylized, and they work for scripts, too.

#17 lore raw
Quoted 16 lines · Markus Armbruster
Quoted 5 lines · Peter Maydell
Quoted 3 lines · Markus Armbruster

I wonder why we use any of .def, .h.inc, .inc.h, .c.inc, .inc.c. Why not .h and call it a day? No need to configure each and every editor to tread these as C code.

Quoted 7 lines

It says "this isn't actually a header in the usual sense". That's useful for automated scripted checks (eg we don't want scripts/clean-header-guards.pl to add the standard #include header guards to this sort of file) and for humans (if you see one of these files included as part of the normal #include block at the top of a .c file that's probably a mistake; if you see it being used then you know there's likely multiple-inclusion shenanigans going on.)

Quoted 1 line

scripts/clean-header-guards.pl needs exclude patterns anyway.

Yes, in theory instead of having a systematic convention for filenames we could instead give the files names that don't let you easily distinguish them from plain old header files and require every use like this to update clean-header-guards.pl, but that seems to me to be clearly worse than maintaining the filename convention that we already have.

Quoted 4 lines

Comments would likely work better for humans than obscure naming conventions.

Make them stylized, and they work for scripts, too.

We already have a stylized convention, it's the filename... Comments inside the .inc file are also helpful, of course.

-- PMM

#18 lore raw
Quoted 17 lines · Peter Maydell
Quoted 16 lines · Markus Armbruster
Quoted 12 lines · Peter Maydell
Quoted 3 lines · Markus Armbruster

I wonder why we use any of .def, .h.inc, .inc.h, .c.inc, .inc.c. Why not .h and call it a day? No need to configure each and every editor to tread these as C code.

It says "this isn't actually a header in the usual sense". That's useful for automated scripted checks (eg we don't want scripts/clean-header-guards.pl to add the standard #include header guards to this sort of file) and for humans (if you see one of these files included as part of the normal #include block at the top of a .c file that's probably a mistake; if you see it being used then you know there's likely multiple-inclusion shenanigans going on.)

Quoted 8 lines
Quoted 1 line

scripts/clean-header-guards.pl needs exclude patterns anyway.

Yes, in theory instead of having a systematic convention for filenames we could instead give the files names that don't let you easily distinguish them from plain old header files and require every use like this to update clean-header-guards.pl, but that seems to me to be clearly worse than maintaining the filename convention that we already have.

Handle that just like for plain .h: when you re-run the script, you fix its complaints either by fixing the header or by adding it to the exclude pattern.

Quoted 6 lines
Quoted 4 lines

Comments would likely work better for humans than obscure naming conventions.

Make them stylized, and they work for scripts, too.

We already have a stylized convention, it's the filename...

True. But its opaque both for tools (editors mostly) and humans. Tools need to be configured, and humans need to be taught.

Moreover, we don't have *a* stylized convention, we have *two*: funny filenames (several patterns, but that's fixable), and exclude patterns.

Quoted 1 line

Comments inside the .inc file are also helpful, of course.

Let's add a third! Stylized comments!

I'll shut up now :)