diff --git a/dev/x86_64/meta.h b/dev/x86_64/meta.h index ead52f0aaf..44eb8e0748 100644 --- a/dev/x86_64/meta.h +++ b/dev/x86_64/meta.h @@ -31,7 +31,6 @@ #define MLD_USE_NATIVE_POLYVECL_POINTWISE_ACC_MONTGOMERY_L7 #if !defined(__ASSEMBLER__) -#include #include "../../common.h" #include "../api.h" #include "src/arith_native_x86_64.h" diff --git a/dev/x86_64/src/arith_native_x86_64.h b/dev/x86_64/src/arith_native_x86_64.h index 70bc00c94c..7474a9f0ad 100644 --- a/dev/x86_64/src/arith_native_x86_64.h +++ b/dev/x86_64/src/arith_native_x86_64.h @@ -6,7 +6,6 @@ #ifndef MLD_NATIVE_X86_64_SRC_ARITH_NATIVE_X86_64_H #define MLD_NATIVE_X86_64_SRC_ARITH_NATIVE_X86_64_H #include "../../../common.h" - #include "consts.h" #define MLD_AVX2_REJ_UNIFORM_BUFLEN \ diff --git a/mldsa/src/context.h b/mldsa/src/context.h index f5e582d7c5..487f5a0743 100644 --- a/mldsa/src/context.h +++ b/mldsa/src/context.h @@ -10,6 +10,7 @@ #if !defined(__ASSEMBLER__) #include + #include "cbmc.h" #include "sys.h" diff --git a/mldsa/src/debug.c b/mldsa/src/debug.c index 9d09231110..0f19f3bd53 100644 --- a/mldsa/src/debug.c +++ b/mldsa/src/debug.c @@ -15,6 +15,7 @@ #include #include #include + #include "debug.h" #define MLD_DEBUG_ERROR_HEADER "[ERROR:%s:%04d] " diff --git a/mldsa/src/fips202/fips202.h b/mldsa/src/fips202/fips202.h index c97628e282..0664d3b704 100644 --- a/mldsa/src/fips202/fips202.h +++ b/mldsa/src/fips202/fips202.h @@ -6,6 +6,7 @@ #define MLD_FIPS202_FIPS202_H #include + #include "../cbmc.h" #include "../common.h" diff --git a/mldsa/src/native/x86_64/meta.h b/mldsa/src/native/x86_64/meta.h index ead52f0aaf..44eb8e0748 100644 --- a/mldsa/src/native/x86_64/meta.h +++ b/mldsa/src/native/x86_64/meta.h @@ -31,7 +31,6 @@ #define MLD_USE_NATIVE_POLYVECL_POINTWISE_ACC_MONTGOMERY_L7 #if !defined(__ASSEMBLER__) -#include #include "../../common.h" #include "../api.h" #include "src/arith_native_x86_64.h" diff --git a/mldsa/src/native/x86_64/src/arith_native_x86_64.h b/mldsa/src/native/x86_64/src/arith_native_x86_64.h index 70bc00c94c..7474a9f0ad 100644 --- a/mldsa/src/native/x86_64/src/arith_native_x86_64.h +++ b/mldsa/src/native/x86_64/src/arith_native_x86_64.h @@ -6,7 +6,6 @@ #ifndef MLD_NATIVE_X86_64_SRC_ARITH_NATIVE_X86_64_H #define MLD_NATIVE_X86_64_SRC_ARITH_NATIVE_X86_64_H #include "../../../common.h" - #include "consts.h" #define MLD_AVX2_REJ_UNIFORM_BUFLEN \ diff --git a/mldsa/src/packing.c b/mldsa/src/packing.c index 0219466f17..2165add471 100644 --- a/mldsa/src/packing.c +++ b/mldsa/src/packing.c @@ -3,7 +3,6 @@ * SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT */ #include "packing.h" - #include "common.h" #include "poly.h" #include "polyvec.h" diff --git a/mldsa/src/poly.c b/mldsa/src/poly.c index 4153d80b8d..46c3338c2a 100644 --- a/mldsa/src/poly.c +++ b/mldsa/src/poly.c @@ -19,7 +19,6 @@ */ #include "poly.h" - #include "common.h" #include "ct.h" #include "debug.h" diff --git a/mldsa/src/poly_kl.c b/mldsa/src/poly_kl.c index 95241c08a5..868c08805a 100644 --- a/mldsa/src/poly_kl.c +++ b/mldsa/src/poly_kl.c @@ -19,7 +19,6 @@ */ #include "poly_kl.h" - #include "ct.h" #include "debug.h" #include "rounding.h" diff --git a/mldsa/src/polyvec.c b/mldsa/src/polyvec.c index be13ae3f91..f56bcb2cb6 100644 --- a/mldsa/src/polyvec.c +++ b/mldsa/src/polyvec.c @@ -13,7 +13,6 @@ */ #include "polyvec.h" - #include "debug.h" #include "polyvec_lazy.h" diff --git a/mldsa/src/polyvec_lazy.c b/mldsa/src/polyvec_lazy.c index dab3ce96a9..cc2c307a64 100644 --- a/mldsa/src/polyvec_lazy.c +++ b/mldsa/src/polyvec_lazy.c @@ -13,7 +13,6 @@ */ #include "polyvec_lazy.h" - #include "debug.h" /* This namespacing is not done at the top to avoid a naming conflict diff --git a/mldsa/src/sign.c b/mldsa/src/sign.c index 48dac1184b..15075c562c 100644 --- a/mldsa/src/sign.c +++ b/mldsa/src/sign.c @@ -35,7 +35,6 @@ */ #include "sign.h" - #include "cbmc.h" #include "ct.h" #include "debug.h" diff --git a/mldsa/src/sign.h b/mldsa/src/sign.h index dea6810ff9..6c596d93fc 100644 --- a/mldsa/src/sign.h +++ b/mldsa/src/sign.h @@ -16,6 +16,7 @@ #define MLD_SIGN_H #include + #include "cbmc.h" #include "common.h" #include "poly.h" diff --git a/scripts/autogen b/scripts/autogen index 6f783c32a8..800a8ecee7 100755 --- a/scripts/autogen +++ b/scripts/autogen @@ -113,9 +113,12 @@ def finalize_format_batch(batch): # Skip files scheduled for deletion if content is None: continue - with tempfile.NamedTemporaryFile(mode="w", suffix=".c", delete=False) as f: + # Keep the file name: clang-format uses it to identify the main + # include, which it sorts first. + temp_path = os.path.join(tempfile.mkdtemp(), os.path.basename(filename)) + with open(temp_path, "w") as f: f.write(content) - temp_files.append((f.name, filename)) + temp_files.append((temp_path, filename)) # Call clang-format with -i to update files in-place clang_format_file = os.path.join( @@ -141,6 +144,7 @@ def finalize_format_batch(batch): finally: for temp_path, _ in temp_files: os.unlink(temp_path) + os.rmdir(os.path.dirname(temp_path)) def finalize_file(item, dry_run):