Skip to content

Commit

Permalink
meson: rename included C source files to .c.inc
Browse files Browse the repository at this point in the history
With Makefiles that have automatically generated dependencies, you
generated includes are set as dependencies of the Makefile, so that they
are built before everything else and they are available when first
building the .c files.

Alternatively you can use a fine-grained dependency, e.g.

        target/arm/translate.o: target/arm/decode-neon-shared.inc.c

With Meson you have only one choice and it is a third option, namely
"build at the beginning of the corresponding target"; the way you
express it is to list the includes in the sources of that target.

The problem is that Meson decides if something is a source vs. a
generated include by looking at the extension: '.c', '.cc', '.m', '.C'
are sources, while everything else is considered an include---including
'.inc.c'.

Use '.c.inc' to avoid this, as it is consistent with our other convention
of using '.rst.inc' for included reStructuredText files.  The editorconfig
file is adjusted.

Signed-off-by: Paolo Bonzini <[email protected]>
  • Loading branch information
bonzini committed Aug 21, 2020
1 parent 243af02 commit 139c183
Show file tree
Hide file tree
Showing 99 changed files with 175 additions and 174 deletions.
3 changes: 2 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ indent_style = tab
indent_size = 8
file_type_emacs = makefile

[*.{c,h}]
[*.{c,h,c.inc,h.inc}]
indent_style = space
indent_size = 4
file_type_emacs = c

[*.sh]
indent_style = space
Expand Down
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
/ui/shader/texture-blit-frag.h
/ui/shader/texture-blit-vert.h
/ui/shader/texture-blit-flip-vert.h
/ui/input-keymap-*.c
/ui/input-keymap-*.c.inc
*-timestamp
/*-softmmu
/*-darwin-user
Expand Down Expand Up @@ -161,4 +161,4 @@ trace-dtrace-root.h
trace-dtrace-root.dtrace
trace-ust-all.h
trace-ust-all.c
/target/arm/decode-sve.inc.c
/target/arm/decode-sve.c.inc
36 changes: 18 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -289,28 +289,28 @@ KEYCODEMAP_GEN = $(SRC_PATH)/ui/keycodemapdb/tools/keymap-gen
KEYCODEMAP_CSV = $(SRC_PATH)/ui/keycodemapdb/data/keymaps.csv

KEYCODEMAP_FILES = \
ui/input-keymap-atset1-to-qcode.c \
ui/input-keymap-linux-to-qcode.c \
ui/input-keymap-qcode-to-atset1.c \
ui/input-keymap-qcode-to-atset2.c \
ui/input-keymap-qcode-to-atset3.c \
ui/input-keymap-qcode-to-linux.c \
ui/input-keymap-qcode-to-qnum.c \
ui/input-keymap-qcode-to-sun.c \
ui/input-keymap-qnum-to-qcode.c \
ui/input-keymap-usb-to-qcode.c \
ui/input-keymap-win32-to-qcode.c \
ui/input-keymap-x11-to-qcode.c \
ui/input-keymap-xorgevdev-to-qcode.c \
ui/input-keymap-xorgkbd-to-qcode.c \
ui/input-keymap-xorgxquartz-to-qcode.c \
ui/input-keymap-xorgxwin-to-qcode.c \
ui/input-keymap-osx-to-qcode.c \
ui/input-keymap-atset1-to-qcode.c.inc \
ui/input-keymap-linux-to-qcode.c.inc \
ui/input-keymap-qcode-to-atset1.c.inc \
ui/input-keymap-qcode-to-atset2.c.inc \
ui/input-keymap-qcode-to-atset3.c.inc \
ui/input-keymap-qcode-to-linux.c.inc \
ui/input-keymap-qcode-to-qnum.c.inc \
ui/input-keymap-qcode-to-sun.c.inc \
ui/input-keymap-qnum-to-qcode.c.inc \
ui/input-keymap-usb-to-qcode.c.inc \
ui/input-keymap-win32-to-qcode.c.inc \
ui/input-keymap-x11-to-qcode.c.inc \
ui/input-keymap-xorgevdev-to-qcode.c.inc \
ui/input-keymap-xorgkbd-to-qcode.c.inc \
ui/input-keymap-xorgxquartz-to-qcode.c.inc \
ui/input-keymap-xorgxwin-to-qcode.c.inc \
ui/input-keymap-osx-to-qcode.c.inc \
$(NULL)

generated-files-$(CONFIG_SOFTMMU) += $(KEYCODEMAP_FILES)

ui/input-keymap-%.c: $(KEYCODEMAP_GEN) $(KEYCODEMAP_CSV) $(SRC_PATH)/ui/Makefile.objs
ui/input-keymap-%.c.inc: $(KEYCODEMAP_GEN) $(KEYCODEMAP_CSV) $(SRC_PATH)/ui/Makefile.objs
$(call quiet-command,\
stem=$* && src=$${stem%-to-*} dst=$${stem#*-to-} && \
test -e $(KEYCODEMAP_GEN) && \
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion accel/tcg/cputlb.c
Original file line number Diff line number Diff line change
Expand Up @@ -2354,7 +2354,7 @@ void cpu_stq_le_data(CPUArchState *env, target_ulong ptr, uint64_t val)
#define ATOMIC_MMU_CLEANUP
#define ATOMIC_MMU_IDX get_mmuidx(oi)

#include "atomic_common.inc.c"
#include "atomic_common.c.inc"

#define DATA_SIZE 1
#include "atomic_template.h"
Expand Down
2 changes: 1 addition & 1 deletion accel/tcg/user-exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -1189,7 +1189,7 @@ static void *atomic_mmu_lookup(CPUArchState *env, target_ulong addr,
#define ATOMIC_NAME(X) HELPER(glue(glue(atomic_ ## X, SUFFIX), END))
#define EXTRA_ARGS

#include "atomic_common.inc.c"
#include "atomic_common.c.inc"

#define DATA_SIZE 1
#include "atomic_template.h"
Expand Down
2 changes: 1 addition & 1 deletion contrib/gitdm/filetypes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ order build,interface,tests,code,documentation,devel-doc,blobs
# (most common languages first
#
filetype code \.c$ # C
filetype code \.inc.c$ # C
filetype code \.c.inc$ # C
filetype code \.C$ # C++
filetype code \.cpp$ # C++
filetype code \.c\+\+$ # C++
Expand Down
4 changes: 2 additions & 2 deletions exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -3659,7 +3659,7 @@ void cpu_physical_memory_unmap(void *buffer, hwaddr len,
#define TRANSLATE(...) address_space_translate(as, __VA_ARGS__)
#define RCU_READ_LOCK(...) rcu_read_lock()
#define RCU_READ_UNLOCK(...) rcu_read_unlock()
#include "memory_ldst.inc.c"
#include "memory_ldst.c.inc"

int64_t address_space_cache_init(MemoryRegionCache *cache,
AddressSpace *as,
Expand Down Expand Up @@ -3795,7 +3795,7 @@ address_space_write_cached_slow(MemoryRegionCache *cache, hwaddr addr,
#define TRANSLATE(...) address_space_translate_cached(cache, __VA_ARGS__)
#define RCU_READ_LOCK() ((void)0)
#define RCU_READ_UNLOCK() ((void)0)
#include "memory_ldst.inc.c"
#include "memory_ldst.c.inc"

/* virtual memory access for debug (includes writing to ROM) */
int cpu_memory_rw_debug(CPUState *cpu, target_ulong addr,
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion fpu/softfloat.c
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ static inline float64 float64_pack_raw(FloatParts p)
| are propagated from function inputs to output. These details are target-
| specific.
*----------------------------------------------------------------------------*/
#include "softfloat-specialize.inc.c"
#include "softfloat-specialize.c.inc"

/* Canonicalize EXP and FRAC, setting CLS. */
static FloatParts sf_canonicalize(FloatParts part, const FloatFmt *parm,
Expand Down
2 changes: 1 addition & 1 deletion include/tcg/tcg.h
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ struct TCGContext {
/* Track which vCPU triggers events */
CPUState *cpu; /* *_trans */

/* These structures are private to tcg-target.inc.c. */
/* These structures are private to tcg-target.c.inc. */
#ifdef TCG_TARGET_NEED_LDST_LABELS
QSIMPLEQ_HEAD(, TCGLabelQemuLdst) ldst_labels;
#endif
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion scripts/clean-includes
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ EOT

for f in "$@"; do
case "$f" in
*.inc.c)
*.c.inc)
# These aren't standalone C source files
echo "SKIPPING $f (not a standalone source file)"
continue
Expand Down
40 changes: 20 additions & 20 deletions target/arm/Makefile.objs
Original file line number Diff line number Diff line change
Expand Up @@ -13,66 +13,66 @@ obj-$(call lnot,$(CONFIG_KVM)) += kvm-stub.o

DECODETREE = $(SRC_PATH)/scripts/decodetree.py

target/arm/decode-sve.inc.c: $(SRC_PATH)/target/arm/sve.decode $(DECODETREE)
target/arm/decode-sve.c.inc: $(SRC_PATH)/target/arm/sve.decode $(DECODETREE)
$(call quiet-command,\
$(PYTHON) $(DECODETREE) --decode disas_sve -o $@ $<,\
"GEN", $(TARGET_DIR)$@)

target/arm/decode-neon-shared.inc.c: $(SRC_PATH)/target/arm/neon-shared.decode $(DECODETREE)
target/arm/decode-neon-shared.c.inc: $(SRC_PATH)/target/arm/neon-shared.decode $(DECODETREE)
$(call quiet-command,\
$(PYTHON) $(DECODETREE) --static-decode disas_neon_shared -o $@ $<,\
"GEN", $(TARGET_DIR)$@)

target/arm/decode-neon-dp.inc.c: $(SRC_PATH)/target/arm/neon-dp.decode $(DECODETREE)
target/arm/decode-neon-dp.c.inc: $(SRC_PATH)/target/arm/neon-dp.decode $(DECODETREE)
$(call quiet-command,\
$(PYTHON) $(DECODETREE) --static-decode disas_neon_dp -o $@ $<,\
"GEN", $(TARGET_DIR)$@)

target/arm/decode-neon-ls.inc.c: $(SRC_PATH)/target/arm/neon-ls.decode $(DECODETREE)
target/arm/decode-neon-ls.c.inc: $(SRC_PATH)/target/arm/neon-ls.decode $(DECODETREE)
$(call quiet-command,\
$(PYTHON) $(DECODETREE) --static-decode disas_neon_ls -o $@ $<,\
"GEN", $(TARGET_DIR)$@)

target/arm/decode-vfp.inc.c: $(SRC_PATH)/target/arm/vfp.decode $(DECODETREE)
target/arm/decode-vfp.c.inc: $(SRC_PATH)/target/arm/vfp.decode $(DECODETREE)
$(call quiet-command,\
$(PYTHON) $(DECODETREE) --static-decode disas_vfp -o $@ $<,\
"GEN", $(TARGET_DIR)$@)

target/arm/decode-vfp-uncond.inc.c: $(SRC_PATH)/target/arm/vfp-uncond.decode $(DECODETREE)
target/arm/decode-vfp-uncond.c.inc: $(SRC_PATH)/target/arm/vfp-uncond.decode $(DECODETREE)
$(call quiet-command,\
$(PYTHON) $(DECODETREE) --static-decode disas_vfp_uncond -o $@ $<,\
"GEN", $(TARGET_DIR)$@)

target/arm/decode-a32.inc.c: $(SRC_PATH)/target/arm/a32.decode $(DECODETREE)
target/arm/decode-a32.c.inc: $(SRC_PATH)/target/arm/a32.decode $(DECODETREE)
$(call quiet-command,\
$(PYTHON) $(DECODETREE) --static-decode disas_a32 -o $@ $<,\
"GEN", $(TARGET_DIR)$@)

target/arm/decode-a32-uncond.inc.c: $(SRC_PATH)/target/arm/a32-uncond.decode $(DECODETREE)
target/arm/decode-a32-uncond.c.inc: $(SRC_PATH)/target/arm/a32-uncond.decode $(DECODETREE)
$(call quiet-command,\
$(PYTHON) $(DECODETREE) --static-decode disas_a32_uncond -o $@ $<,\
"GEN", $(TARGET_DIR)$@)

target/arm/decode-t32.inc.c: $(SRC_PATH)/target/arm/t32.decode $(DECODETREE)
target/arm/decode-t32.c.inc: $(SRC_PATH)/target/arm/t32.decode $(DECODETREE)
$(call quiet-command,\
$(PYTHON) $(DECODETREE) --static-decode disas_t32 -o $@ $<,\
"GEN", $(TARGET_DIR)$@)

target/arm/decode-t16.inc.c: $(SRC_PATH)/target/arm/t16.decode $(DECODETREE)
target/arm/decode-t16.c.inc: $(SRC_PATH)/target/arm/t16.decode $(DECODETREE)
$(call quiet-command,\
$(PYTHON) $(DECODETREE) -w 16 --static-decode disas_t16 -o $@ $<,\
"GEN", $(TARGET_DIR)$@)

target/arm/translate-sve.o: target/arm/decode-sve.inc.c
target/arm/translate.o: target/arm/decode-neon-shared.inc.c
target/arm/translate.o: target/arm/decode-neon-dp.inc.c
target/arm/translate.o: target/arm/decode-neon-ls.inc.c
target/arm/translate.o: target/arm/decode-vfp.inc.c
target/arm/translate.o: target/arm/decode-vfp-uncond.inc.c
target/arm/translate.o: target/arm/decode-a32.inc.c
target/arm/translate.o: target/arm/decode-a32-uncond.inc.c
target/arm/translate.o: target/arm/decode-t32.inc.c
target/arm/translate.o: target/arm/decode-t16.inc.c
target/arm/translate-sve.o: target/arm/decode-sve.c.inc
target/arm/translate.o: target/arm/decode-neon-shared.c.inc
target/arm/translate.o: target/arm/decode-neon-dp.c.inc
target/arm/translate.o: target/arm/decode-neon-ls.c.inc
target/arm/translate.o: target/arm/decode-vfp.c.inc
target/arm/translate.o: target/arm/decode-vfp-uncond.c.inc
target/arm/translate.o: target/arm/decode-a32.c.inc
target/arm/translate.o: target/arm/decode-a32-uncond.c.inc
target/arm/translate.o: target/arm/decode-t32.c.inc
target/arm/translate.o: target/arm/decode-t16.c.inc

obj-y += tlb_helper.o debug_helper.o
obj-y += translate.o op_helper.o
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ static inline int rsub_8(DisasContext *s, int x)
}

/* Include the generated Neon decoder */
#include "decode-neon-dp.inc.c"
#include "decode-neon-ls.inc.c"
#include "decode-neon-shared.inc.c"
#include "decode-neon-dp.c.inc"
#include "decode-neon-ls.c.inc"
#include "decode-neon-shared.c.inc"

/* Return the offset of a 2**SIZE piece of a NEON register, at index ELE,
* where 0 is the least significant end of the register.
Expand Down
2 changes: 1 addition & 1 deletion target/arm/translate-sve.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ static inline int msz_dtype(DisasContext *s, int msz)
* Include the generated decoder.
*/

#include "decode-sve.inc.c"
#include "decode-sve.c.inc"

/*
* Implement all of the translator functions referenced by the decoder.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
*/

/* Include the generated VFP decoder */
#include "decode-vfp.inc.c"
#include "decode-vfp-uncond.inc.c"
#include "decode-vfp.c.inc"
#include "decode-vfp-uncond.c.inc"

/*
* The imm8 encodes the sign bit, enough bits to represent an exponent in
Expand Down
12 changes: 6 additions & 6 deletions target/arm/translate.c
Original file line number Diff line number Diff line change
Expand Up @@ -1176,8 +1176,8 @@ static TCGv_ptr vfp_reg_ptr(bool dp, int reg)
#define ARM_CP_RW_BIT (1 << 20)

/* Include the VFP and Neon decoders */
#include "translate-vfp.inc.c"
#include "translate-neon.inc.c"
#include "translate-vfp.c.inc"
#include "translate-neon.c.inc"

static inline void iwmmxt_load_reg(TCGv_i64 var, int reg)
{
Expand Down Expand Up @@ -5217,10 +5217,10 @@ static int t16_pop_list(DisasContext *s, int x)
* Include the generated decoders.
*/

#include "decode-a32.inc.c"
#include "decode-a32-uncond.inc.c"
#include "decode-t32.inc.c"
#include "decode-t16.inc.c"
#include "decode-a32.c.inc"
#include "decode-a32-uncond.c.inc"
#include "decode-t32.c.inc"
#include "decode-t16.c.inc"

/* Helpers to swap operands for reverse-subtract. */
static void gen_rsb(TCGv_i32 dst, TCGv_i32 a, TCGv_i32 b)
Expand Down
4 changes: 2 additions & 2 deletions target/avr/Makefile.objs
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
DECODETREE = $(SRC_PATH)/scripts/decodetree.py
decode-y = $(SRC_PATH)/target/avr/insn.decode

target/avr/decode_insn.inc.c: $(decode-y) $(DECODETREE)
target/avr/decode_insn.c.inc: $(decode-y) $(DECODETREE)
$(call quiet-command, \
$(PYTHON) $(DECODETREE) -o $@ --decode decode_insn --insnwidth 16 $<, \
"GEN", $(TARGET_DIR)$@)

target/avr/translate.o: target/avr/decode_insn.inc.c
target/avr/translate.o: target/avr/decode_insn.c.inc

obj-y += translate.o cpu.o helper.o
obj-y += gdbstub.o
Expand Down
2 changes: 1 addition & 1 deletion target/avr/disas.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ static int append_16(DisasContext *ctx, int x)

/* Include the auto-generated decoder. */
static bool decode_insn(DisasContext *ctx, uint16_t insn);
#include "decode_insn.inc.c"
#include "decode_insn.c.inc"

#define output(mnemonic, format, ...) \
(pctx->info->fprintf_func(pctx->info->stream, "%-9s " format, \
Expand Down
2 changes: 1 addition & 1 deletion target/avr/translate.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ static bool avr_have_feature(DisasContext *ctx, int feature)
}

static bool decode_insn(DisasContext *ctx, uint16_t insn);
#include "decode_insn.inc.c"
#include "decode_insn.c.inc"

/*
* Arithmetic Instructions
Expand Down
2 changes: 1 addition & 1 deletion target/cris/translate.c
Original file line number Diff line number Diff line change
Expand Up @@ -3037,7 +3037,7 @@ static unsigned int crisv32_decoder(CPUCRISState *env, DisasContext *dc)
return insn_len;
}

#include "translate_v10.inc.c"
#include "translate_v10.c.inc"

/*
* Delay slots on QEMU/CRIS.
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions target/hppa/Makefile.objs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ obj-$(CONFIG_SOFTMMU) += machine.o

DECODETREE = $(SRC_PATH)/scripts/decodetree.py

target/hppa/decode.inc.c: $(SRC_PATH)/target/hppa/insns.decode $(DECODETREE)
target/hppa/decode.c.inc: $(SRC_PATH)/target/hppa/insns.decode $(DECODETREE)
$(call quiet-command,\
$(PYTHON) $(DECODETREE) -o $@ $<, "GEN", $(TARGET_DIR)$@)

target/hppa/translate.o: target/hppa/decode.inc.c
target/hppa/translate.o: target/hppa/decode.c.inc
2 changes: 1 addition & 1 deletion target/hppa/translate.c
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ static int expand_shl11(DisasContext *ctx, int val)


/* Include the auto-generated decoder. */
#include "decode.inc.c"
#include "decode.c.inc"

/* We are not using a goto_tb (for whatever reason), but have updated
the iaq (for whatever reason), so don't do it again on exit. */
Expand Down
2 changes: 1 addition & 1 deletion target/mips/translate.c
Original file line number Diff line number Diff line change
Expand Up @@ -31322,7 +31322,7 @@ void mips_tcg_init(void)
#endif
}

#include "translate_init.inc.c"
#include "translate_init.c.inc"

void cpu_mips_realize_env(CPUMIPSState *env)
{
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions target/openrisc/Makefile.objs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ obj-y += gdbstub.o

DECODETREE = $(SRC_PATH)/scripts/decodetree.py

target/openrisc/decode.inc.c: \
target/openrisc/decode.c.inc: \
$(SRC_PATH)/target/openrisc/insns.decode $(DECODETREE)
$(call quiet-command,\
$(PYTHON) $(DECODETREE) -o $@ $<, "GEN", $(TARGET_DIR)$@)

target/openrisc/translate.o: target/openrisc/decode.inc.c
target/openrisc/disas.o: target/openrisc/decode.inc.c
target/openrisc/translate.o: target/openrisc/decode.c.inc
target/openrisc/disas.o: target/openrisc/decode.c.inc
2 changes: 1 addition & 1 deletion target/openrisc/disas.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
typedef disassemble_info DisasContext;

/* Include the auto-generated decoder. */
#include "decode.inc.c"
#include "decode.c.inc"

#define output(mnemonic, format, ...) \
(info->fprintf_func(info->stream, "%-9s " format, \
Expand Down
2 changes: 1 addition & 1 deletion target/openrisc/translate.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ static inline bool is_user(DisasContext *dc)
}

/* Include the auto-generated decoder. */
#include "decode.inc.c"
#include "decode.c.inc"

static TCGv cpu_sr;
static TCGv cpu_regs[32];
Expand Down
Loading

0 comments on commit 139c183

Please sign in to comment.