From 8cfb520efb8a73c86aac71e5c86099a6e40f377a Mon Sep 17 00:00:00 2001 From: Guillaume Chatelet Date: Mon, 25 Sep 2023 07:35:53 +0000 Subject: [PATCH] [NFC] clang-format the code base --- include/cpuinfo_loongarch.h | 7 ++-- include/cpuinfo_mips.h | 28 ++++++++-------- include/cpuinfo_s390x.h | 53 +++++++++++++++--------------- include/cpuinfo_x86.h | 4 +-- src/impl_aarch64_macos_or_iphone.c | 3 +- src/impl_aarch64_windows.c | 1 - src/impl_loongarch_linux.c | 29 ++++++++-------- src/impl_ppc_linux.c | 2 +- src/impl_s390x_linux.c | 51 ++++++++++++++-------------- src/impl_x86_windows.c | 4 +-- src/utils/list_cpu_features.c | 16 ++++----- 11 files changed, 101 insertions(+), 97 deletions(-) diff --git a/include/cpuinfo_loongarch.h b/include/cpuinfo_loongarch.h index d166223..4dcff80 100644 --- a/include/cpuinfo_loongarch.h +++ b/include/cpuinfo_loongarch.h @@ -26,7 +26,7 @@ CPU_FEATURES_START_CPP_NAMESPACE typedef struct { // Base - int CPUCFG : 1; // Instruction for Identify CPU Features + int CPUCFG : 1; // Instruction for Identify CPU Features // Extension int LAM : 1; // Extension for Atomic Memory Access Instructions @@ -36,7 +36,8 @@ typedef struct { int LASX : 1; // Extension for Loongson Advanced SIMD eXtension int CRC32 : 1; // Extension for Cyclic Redundancy Check Instructions int COMPLEX : 1; // Extension for Complex Vector Operation Instructions - int CRYPTO : 1; // Extension for Encryption And Decryption Vector Instructions + int CRYPTO : 1; // Extension for Encryption And Decryption Vector + // Instructions int LVZ : 1; // Extension for Virtualization int LBT_X86 : 1; // Extension for X86 Binary Translation Extension int LBT_ARM : 1; // Extension for ARM Binary Translation Extension @@ -69,7 +70,7 @@ typedef enum { LoongArchInfo GetLoongArchInfo(void); int GetLoongArchFeaturesEnumValue(const LoongArchFeatures* features, - LoongArchFeaturesEnum value); + LoongArchFeaturesEnum value); const char* GetLoongArchFeaturesEnumName(LoongArchFeaturesEnum); CPU_FEATURES_END_CPP_NAMESPACE diff --git a/include/cpuinfo_mips.h b/include/cpuinfo_mips.h index 321d3c8..d567b11 100644 --- a/include/cpuinfo_mips.h +++ b/include/cpuinfo_mips.h @@ -21,20 +21,20 @@ CPU_FEATURES_START_CPP_NAMESPACE typedef struct { - int msa : 1; // MIPS SIMD Architecture - // https://www.mips.com/products/architectures/ase/simd/ - int eva : 1; // Enhanced Virtual Addressing - // https://www.mips.com/products/architectures/mips64/ - int r6 : 1; // True if is release 6 of the processor. - int mips16 : 1; // Compressed instructions - int mdmx : 1; // MIPS Digital Media Extension - int mips3d : 1; // 3D graphics acceleration - // MIPS(r) Architecture for Programmers, Volume IV-c - int smart : 1; // Smart-card cryptography - // MIPS(r) Architecture for Programmers, Volume IV-d - int dsp : 1; // Digital Signal Processing - // MIPS(r) Architecture for Programmers, Volume IV-e - // https://www.mips.com/products/architectures/ase/dsp/ + int msa : 1; // MIPS SIMD Architecture + // https://www.mips.com/products/architectures/ase/simd/ + int eva : 1; // Enhanced Virtual Addressing + // https://www.mips.com/products/architectures/mips64/ + int r6 : 1; // True if is release 6 of the processor. + int mips16 : 1; // Compressed instructions + int mdmx : 1; // MIPS Digital Media Extension + int mips3d : 1; // 3D graphics acceleration + // MIPS(r) Architecture for Programmers, Volume IV-c + int smart : 1; // Smart-card cryptography + // MIPS(r) Architecture for Programmers, Volume IV-d + int dsp : 1; // Digital Signal Processing + // MIPS(r) Architecture for Programmers, Volume IV-e + // https://www.mips.com/products/architectures/ase/dsp/ // Make sure to update MipsFeaturesEnum below if you add a field here. } MipsFeatures; diff --git a/include/cpuinfo_s390x.h b/include/cpuinfo_s390x.h index 48864de..19511b4 100644 --- a/include/cpuinfo_s390x.h +++ b/include/cpuinfo_s390x.h @@ -21,29 +21,29 @@ CPU_FEATURES_START_CPP_NAMESPACE typedef struct { - int esan3: 1; // instructions named N3, "backported" to esa-mode - int zarch: 1; // z/Architecture mode active - int stfle: 1; // store-facility-list-extended - int msa: 1; // message-security assist - int ldisp: 1; // long-displacement - int eimm: 1; // extended-immediate - int dfp: 1; // decimal floating point & perform floating point operation - int edat: 1; // huge page support - int etf3eh: 1; // extended-translation facility 3 enhancement - int highgprs: 1; // 64-bit register support for 31-bit processes - int te: 1; // transactional execution - int vx: 1; // vector extension facility - int vxd: 1; // vector-packed-decimal facility - int vxe: 1; // vector-enhancement facility 1 - int gs: 1; // guarded-storage facility - int vxe2: 1; // vector-enhancements facility 2 - int vxp: 1; // vector-packed-decimal-enhancement facility - int sort: 1; // enhanced-sort facility - int dflt: 1; // deflate-conversion facility - int vxp2: 1; // vector-packed-decimal-enhancement facility 2 - int nnpa: 1; // neural network processing assist facility - int pcimio: 1; // PCI mio facility - int sie: 1; // virtualization support + int esan3 : 1; // instructions named N3, "backported" to esa-mode + int zarch : 1; // z/Architecture mode active + int stfle : 1; // store-facility-list-extended + int msa : 1; // message-security assist + int ldisp : 1; // long-displacement + int eimm : 1; // extended-immediate + int dfp : 1; // decimal floating point & perform floating point operation + int edat : 1; // huge page support + int etf3eh : 1; // extended-translation facility 3 enhancement + int highgprs : 1; // 64-bit register support for 31-bit processes + int te : 1; // transactional execution + int vx : 1; // vector extension facility + int vxd : 1; // vector-packed-decimal facility + int vxe : 1; // vector-enhancement facility 1 + int gs : 1; // guarded-storage facility + int vxe2 : 1; // vector-enhancements facility 2 + int vxp : 1; // vector-packed-decimal-enhancement facility + int sort : 1; // enhanced-sort facility + int dflt : 1; // deflate-conversion facility + int vxp2 : 1; // vector-packed-decimal-enhancement facility 2 + int nnpa : 1; // neural network processing assist facility + int pcimio : 1; // PCI mio facility + int sie : 1; // virtualization support // Make sure to update S390XFeaturesEnum below if you add a field here. } S390XFeatures; @@ -55,11 +55,11 @@ typedef struct { S390XInfo GetS390XInfo(void); typedef struct { - char platform[64]; // 0 terminated string + char platform[64]; // 0 terminated string } S390XPlatformTypeStrings; typedef struct { - int num_processors; // -1 if N/A + int num_processors; // -1 if N/A S390XPlatformTypeStrings type; } S390XPlatformStrings; @@ -95,7 +95,8 @@ typedef enum { S390X_LAST_, } S390XFeaturesEnum; -int GetS390XFeaturesEnumValue(const S390XFeatures* features, S390XFeaturesEnum value); +int GetS390XFeaturesEnumValue(const S390XFeatures* features, + S390XFeaturesEnum value); const char* GetS390XFeaturesEnumName(S390XFeaturesEnum); diff --git a/include/cpuinfo_x86.h b/include/cpuinfo_x86.h index 796d3f3..7d1d5d4 100644 --- a/include/cpuinfo_x86.h +++ b/include/cpuinfo_x86.h @@ -109,8 +109,8 @@ typedef struct { int fs_rep_stosb : 1; // Fast short REP STOSB int fs_rep_cmpsb_scasb : 1; // Fast short REP CMPSB/SCASB - int lam: 1; // Intel Linear Address Mask - int uai: 1; // AMD Upper Address Ignore + int lam : 1; // Intel Linear Address Mask + int uai : 1; // AMD Upper Address Ignore // Make sure to update X86FeaturesEnum below if you add a field here. } X86Features; diff --git a/src/impl_aarch64_macos_or_iphone.c b/src/impl_aarch64_macos_or_iphone.c index 7b97896..d7f55a3 100644 --- a/src/impl_aarch64_macos_or_iphone.c +++ b/src/impl_aarch64_macos_or_iphone.c @@ -60,7 +60,8 @@ Aarch64Info GetAarch64Info(void) { info.features.crc32 = GetDarwinSysCtlByName("hw.optional.armv8_crc32"); info.features.atomics = GetDarwinSysCtlByName("hw.optional.arm.FEAT_LSE"); info.features.fphp = GetDarwinSysCtlByName("hw.optional.arm.FEAT_FP16"); - info.features.asimdhp = GetDarwinSysCtlByName("hw.optional.arm.AdvSIMD_HPFPCvt"); + info.features.asimdhp = + GetDarwinSysCtlByName("hw.optional.arm.AdvSIMD_HPFPCvt"); info.features.asimdrdm = GetDarwinSysCtlByName("hw.optional.arm.FEAT_RDM"); info.features.jscvt = GetDarwinSysCtlByName("hw.optional.arm.FEAT_JSCVT"); info.features.fcma = GetDarwinSysCtlByName("hw.optional.arm.FEAT_FCMA"); diff --git a/src/impl_aarch64_windows.c b/src/impl_aarch64_windows.c index f103909..371f392 100644 --- a/src/impl_aarch64_windows.c +++ b/src/impl_aarch64_windows.c @@ -124,7 +124,6 @@ Aarch64Info GetAarch64Info(void) { info.features.atomics = GetWindowsIsProcessorFeaturePresent( PF_ARM_V81_ATOMIC_INSTRUCTIONS_AVAILABLE); - bool is_crypto_available = GetWindowsIsProcessorFeaturePresent( PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE); info.features.aes = is_crypto_available; diff --git a/src/impl_loongarch_linux.c b/src/impl_loongarch_linux.c index b9cea7b..da3e8cf 100644 --- a/src/impl_loongarch_linux.c +++ b/src/impl_loongarch_linux.c @@ -22,19 +22,19 @@ //////////////////////////////////////////////////////////////////////////////// // Definitions for introspection. //////////////////////////////////////////////////////////////////////////////// -#define INTROSPECTION_TABLE \ - LINE(LOONGARCH_CPUCFG, CPUCFG, "cfg", HWCAP_LOONGARCH_CPUCFG, 0) \ - LINE(LOONGARCH_LAM, LAM, "lam", HWCAP_LOONGARCH_LAM, 0) \ - LINE(LOONGARCH_UAL, UAL, "ual", HWCAP_LOONGARCH_UAL, 0) \ - LINE(LOONGARCH_FPU, FPU, "fpu", HWCAP_LOONGARCH_FPU, 0) \ - LINE(LOONGARCH_LSX, LSX, "lsx", HWCAP_LOONGARCH_LSX, 0) \ - LINE(LOONGARCH_LASX, LASX, "lasx", HWCAP_LOONGARCH_LASX, 0) \ - LINE(LOONGARCH_CRC32, CRC32, "crc32", HWCAP_LOONGARCH_CRC32, 0) \ - LINE(LOONGARCH_COMPLEX, COMPLEX, "complex", HWCAP_LOONGARCH_COMPLEX, 0) \ - LINE(LOONGARCH_CRYPTO, CRYPTO, "crypto", HWCAP_LOONGARCH_CRYPTO, 0) \ - LINE(LOONGARCH_LVZ, LVZ, "lvz", HWCAP_LOONGARCH_LVZ, 0) \ - LINE(LOONGARCH_LBT_X86, LBT_X86, "lbt_x86", HWCAP_LOONGARCH_LBT_X86, 0) \ - LINE(LOONGARCH_LBT_ARM, LBT_ARM, "lbt_arm", HWCAP_LOONGARCH_LBT_ARM, 0) \ +#define INTROSPECTION_TABLE \ + LINE(LOONGARCH_CPUCFG, CPUCFG, "cfg", HWCAP_LOONGARCH_CPUCFG, 0) \ + LINE(LOONGARCH_LAM, LAM, "lam", HWCAP_LOONGARCH_LAM, 0) \ + LINE(LOONGARCH_UAL, UAL, "ual", HWCAP_LOONGARCH_UAL, 0) \ + LINE(LOONGARCH_FPU, FPU, "fpu", HWCAP_LOONGARCH_FPU, 0) \ + LINE(LOONGARCH_LSX, LSX, "lsx", HWCAP_LOONGARCH_LSX, 0) \ + LINE(LOONGARCH_LASX, LASX, "lasx", HWCAP_LOONGARCH_LASX, 0) \ + LINE(LOONGARCH_CRC32, CRC32, "crc32", HWCAP_LOONGARCH_CRC32, 0) \ + LINE(LOONGARCH_COMPLEX, COMPLEX, "complex", HWCAP_LOONGARCH_COMPLEX, 0) \ + LINE(LOONGARCH_CRYPTO, CRYPTO, "crypto", HWCAP_LOONGARCH_CRYPTO, 0) \ + LINE(LOONGARCH_LVZ, LVZ, "lvz", HWCAP_LOONGARCH_LVZ, 0) \ + LINE(LOONGARCH_LBT_X86, LBT_X86, "lbt_x86", HWCAP_LOONGARCH_LBT_X86, 0) \ + LINE(LOONGARCH_LBT_ARM, LBT_ARM, "lbt_arm", HWCAP_LOONGARCH_LBT_ARM, 0) \ LINE(LOONGARCH_LBT_MIPS, LBT_MIPS, "lbt_mips", HWCAP_LOONGARCH_LBT_MIPS, 0) \ LINE(LOONGARCH_PTW, PTW, "ptw", HWCAP_LOONGARCH_PTW, 0) #define INTROSPECTION_PREFIX LoongArch @@ -53,7 +53,8 @@ static const LoongArchInfo kEmptyLoongArchInfo; -static bool HandleLoongArchLine(const LineResult result, LoongArchInfo* const info) { +static bool HandleLoongArchLine(const LineResult result, + LoongArchInfo* const info) { StringView line = result.line; StringView key, value; if (CpuFeatures_StringView_GetAttributeKeyValue(line, &key, &value)) { diff --git a/src/impl_ppc_linux.c b/src/impl_ppc_linux.c index 46a72d7..b45c0f7 100644 --- a/src/impl_ppc_linux.c +++ b/src/impl_ppc_linux.c @@ -69,7 +69,7 @@ LINE(PPC_SCV, scv, "scv", 0, PPC_FEATURE2_SCV) \ LINE(PPC_HTM_NO_SUSPEND, htm_no_suspend, "htm-no-suspend", 0, \ PPC_FEATURE2_HTM_NO_SUSPEND) -#undef PPC // Remove conflict with compiler generated preprocessor +#undef PPC // Remove conflict with compiler generated preprocessor #define INTROSPECTION_PREFIX PPC #define INTROSPECTION_ENUM_PREFIX PPC #include "define_introspection_and_hwcaps.inl" diff --git a/src/impl_s390x_linux.c b/src/impl_s390x_linux.c index 2b8b865..5ced7d5 100644 --- a/src/impl_s390x_linux.c +++ b/src/impl_s390x_linux.c @@ -22,29 +22,29 @@ //////////////////////////////////////////////////////////////////////////////// // Definitions for introspection. //////////////////////////////////////////////////////////////////////////////// -#define INTROSPECTION_TABLE \ - LINE(S390_ESAN3, esan3, "esan3", HWCAP_S390_ESAN3, 0) \ - LINE(S390_ZARCH, zarch, "zarch", HWCAP_S390_ZARCH, 0) \ - LINE(S390_STFLE, stfle, "stfle", HWCAP_S390_STFLE, 0) \ - LINE(S390_MSA, msa, "msa", HWCAP_S390_MSA, 0) \ - LINE(S390_LDISP, ldisp, "ldisp", HWCAP_S390_LDISP, 0) \ - LINE(S390_EIMM, eimm, "eimm", HWCAP_S390_EIMM, 0) \ - LINE(S390_DFP, dfp, "dfp", HWCAP_S390_DFP, 0) \ - LINE(S390_EDAT, edat, "edat", HWCAP_S390_HPAGE, 0) \ - LINE(S390_ETF3EH, etf3eh, "etf3eh", HWCAP_S390_ETF3EH, 0) \ - LINE(S390_HIGHGPRS, highgprs, "highgprs", HWCAP_S390_HIGH_GPRS, 0) \ - LINE(S390_TE, te, "te", HWCAP_S390_TE, 0) \ - LINE(S390_VX, vx, "vx", HWCAP_S390_VXRS, 0) \ - LINE(S390_VXD, vxd, "vxd", HWCAP_S390_VXRS_BCD, 0) \ - LINE(S390_VXE, vxe, "vxe", HWCAP_S390_VXRS_EXT, 0) \ - LINE(S390_GS, gs, "gs", HWCAP_S390_GS, 0) \ - LINE(S390_VXE2, vxe2, "vxe2", HWCAP_S390_VXRS_EXT2, 0) \ - LINE(S390_VXP, vxp, "vxp", HWCAP_S390_VXRS_PDE, 0) \ - LINE(S390_SORT, sort, "sort", HWCAP_S390_SORT, 0) \ - LINE(S390_DFLT, dflt, "dflt", HWCAP_S390_DFLT, 0) \ - LINE(S390_VXP2, vxp2, "vxp2", HWCAP_S390_VXRS_PDE2, 0) \ - LINE(S390_NNPA, nnpa, "nnpa", HWCAP_S390_NNPA, 0) \ - LINE(S390_PCIMIO, pcimio, "pcimio", HWCAP_S390_PCI_MIO, 0) \ +#define INTROSPECTION_TABLE \ + LINE(S390_ESAN3, esan3, "esan3", HWCAP_S390_ESAN3, 0) \ + LINE(S390_ZARCH, zarch, "zarch", HWCAP_S390_ZARCH, 0) \ + LINE(S390_STFLE, stfle, "stfle", HWCAP_S390_STFLE, 0) \ + LINE(S390_MSA, msa, "msa", HWCAP_S390_MSA, 0) \ + LINE(S390_LDISP, ldisp, "ldisp", HWCAP_S390_LDISP, 0) \ + LINE(S390_EIMM, eimm, "eimm", HWCAP_S390_EIMM, 0) \ + LINE(S390_DFP, dfp, "dfp", HWCAP_S390_DFP, 0) \ + LINE(S390_EDAT, edat, "edat", HWCAP_S390_HPAGE, 0) \ + LINE(S390_ETF3EH, etf3eh, "etf3eh", HWCAP_S390_ETF3EH, 0) \ + LINE(S390_HIGHGPRS, highgprs, "highgprs", HWCAP_S390_HIGH_GPRS, 0) \ + LINE(S390_TE, te, "te", HWCAP_S390_TE, 0) \ + LINE(S390_VX, vx, "vx", HWCAP_S390_VXRS, 0) \ + LINE(S390_VXD, vxd, "vxd", HWCAP_S390_VXRS_BCD, 0) \ + LINE(S390_VXE, vxe, "vxe", HWCAP_S390_VXRS_EXT, 0) \ + LINE(S390_GS, gs, "gs", HWCAP_S390_GS, 0) \ + LINE(S390_VXE2, vxe2, "vxe2", HWCAP_S390_VXRS_EXT2, 0) \ + LINE(S390_VXP, vxp, "vxp", HWCAP_S390_VXRS_PDE, 0) \ + LINE(S390_SORT, sort, "sort", HWCAP_S390_SORT, 0) \ + LINE(S390_DFLT, dflt, "dflt", HWCAP_S390_DFLT, 0) \ + LINE(S390_VXP2, vxp2, "vxp2", HWCAP_S390_VXRS_PDE2, 0) \ + LINE(S390_NNPA, nnpa, "nnpa", HWCAP_S390_NNPA, 0) \ + LINE(S390_PCIMIO, pcimio, "pcimio", HWCAP_S390_PCI_MIO, 0) \ LINE(S390_SIE, sie, "sie", HWCAP_S390_SIE, 0) #define INTROSPECTION_PREFIX S390X #define INTROSPECTION_ENUM_PREFIX S390X @@ -63,12 +63,13 @@ #include "internal/string_view.h" static bool HandleS390XLine(const LineResult result, - S390XPlatformStrings* const strings) { + S390XPlatformStrings* const strings) { StringView line = result.line; StringView key, value; if (CpuFeatures_StringView_GetAttributeKeyValue(line, &key, &value)) { if (CpuFeatures_StringView_IsEquals(key, str("# processors"))) { - strings->num_processors = CpuFeatures_StringView_ParsePositiveNumber(value); + strings->num_processors = + CpuFeatures_StringView_ParsePositiveNumber(value); } } return !result.eof; diff --git a/src/impl_x86_windows.c b/src/impl_x86_windows.c index 8a82823..061e325 100644 --- a/src/impl_x86_windows.c +++ b/src/impl_x86_windows.c @@ -50,8 +50,8 @@ static void DetectFeaturesFromOs(X86Info* info, X86Features* features) { features->sse4_2 = GetWindowsIsProcessorFeaturePresent(PF_SSE4_2_INSTRUCTIONS_AVAILABLE); -// do not bother checking PF_AVX* -// cause AVX enabled processor will have XCR0 be exposed and this function will be skipped at all + // Do not bother checking PF_AVX* : AVX enabled processor will have their XCR0 + // register exposed and this function will be skipped altogether. } #endif // CPU_FEATURES_OS_WINDOWS diff --git a/src/utils/list_cpu_features.c b/src/utils/list_cpu_features.c index 83cd387..a173f86 100644 --- a/src/utils/list_cpu_features.c +++ b/src/utils/list_cpu_features.c @@ -212,14 +212,14 @@ DEFINE_ADD_FLAGS(GetMipsFeaturesEnumValue, GetMipsFeaturesEnumName, DEFINE_ADD_FLAGS(GetPPCFeaturesEnumValue, GetPPCFeaturesEnumName, PPCFeatures, PPC_LAST_) #elif defined(CPU_FEATURES_ARCH_S390X) -DEFINE_ADD_FLAGS(GetS390XFeaturesEnumValue, GetS390XFeaturesEnumName, S390XFeatures, - S390X_LAST_) +DEFINE_ADD_FLAGS(GetS390XFeaturesEnumValue, GetS390XFeaturesEnumName, + S390XFeatures, S390X_LAST_) #elif defined(CPU_FEATURES_ARCH_RISCV) -DEFINE_ADD_FLAGS(GetRiscvFeaturesEnumValue, GetRiscvFeaturesEnumName, RiscvFeatures, - RISCV_LAST_) +DEFINE_ADD_FLAGS(GetRiscvFeaturesEnumValue, GetRiscvFeaturesEnumName, + RiscvFeatures, RISCV_LAST_) #elif defined(CPU_FEATURES_ARCH_LOONGARCH) -DEFINE_ADD_FLAGS(GetLoongArchFeaturesEnumValue, GetLoongArchFeaturesEnumName, LoongArchFeatures, - LOONGARCH_LAST_) +DEFINE_ADD_FLAGS(GetLoongArchFeaturesEnumValue, GetLoongArchFeaturesEnumName, + LoongArchFeatures, LOONGARCH_LAST_) #endif // Prints a json string with characters escaping. @@ -436,11 +436,11 @@ static Node* CreateTree(void) { AddMapEntry(root, "arch", CreateString("risc-v")); AddMapEntry(root, "vendor", CreateString(info.vendor)); AddMapEntry(root, "microarchitecture", CreateString(info.uarch)); - AddFlags(root, &info.features); + AddFlags(root, &info.features); #elif defined(CPU_FEATURES_ARCH_LOONGARCH) const LoongArchInfo info = GetLoongArchInfo(); AddMapEntry(root, "arch", CreateString("loongarch")); - AddFlags(root, &info.features); + AddFlags(root, &info.features); #endif return root; }