From 83a1bbf1d3b2051cd6e7ae3377628714f58ad1fa Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Thu, 11 Mar 2021 23:00:29 -0800 Subject: [PATCH] lib: consistently use include guards A lot of the internal library headers don't have include guards because they aren't needed. It might look like a bug, though, and it doesn't hurt to add them. So do this. Update https://github.com/ebiggers/libdeflate/issues/117 --- lib/arm/adler32_impl.h | 5 +++++ lib/arm/crc32_impl.h | 5 +++++ lib/arm/matchfinder_impl.h | 5 +++++ lib/bt_matchfinder.h | 4 ++++ lib/cpu_features_common.h | 5 +++++ lib/hc_matchfinder.h | 5 +++++ lib/x86/adler32_impl.h | 5 +++++ lib/x86/crc32_impl.h | 5 +++++ lib/x86/decompress_impl.h | 5 +++++ lib/x86/matchfinder_impl.h | 5 +++++ 10 files changed, 49 insertions(+) diff --git a/lib/arm/adler32_impl.h b/lib/arm/adler32_impl.h index de52d81..17e56c0 100644 --- a/lib/arm/adler32_impl.h +++ b/lib/arm/adler32_impl.h @@ -25,6 +25,9 @@ * OTHER DEALINGS IN THE SOFTWARE. */ +#ifndef LIB_ARM_ADLER32_IMPL_H +#define LIB_ARM_ADLER32_IMPL_H + #include "cpu_features.h" /* NEON implementation */ @@ -118,3 +121,5 @@ arch_select_adler32_func(void) return NULL; } #endif /* DISPATCH */ + +#endif /* LIB_ARM_ADLER32_IMPL_H */ diff --git a/lib/arm/crc32_impl.h b/lib/arm/crc32_impl.h index e1d94a5..238a85a 100644 --- a/lib/arm/crc32_impl.h +++ b/lib/arm/crc32_impl.h @@ -26,6 +26,9 @@ * OTHER DEALINGS IN THE SOFTWARE. */ +#ifndef LIB_ARM_CRC32_IMPL_H +#define LIB_ARM_CRC32_IMPL_H + #include "cpu_features.h" /* Implementation using ARM CRC32 instructions */ @@ -240,3 +243,5 @@ arch_select_crc32_func(void) return NULL; } #endif /* DISPATCH */ + +#endif /* LIB_ARM_CRC32_IMPL_H */ diff --git a/lib/arm/matchfinder_impl.h b/lib/arm/matchfinder_impl.h index 9e711cc..da0d2fd 100644 --- a/lib/arm/matchfinder_impl.h +++ b/lib/arm/matchfinder_impl.h @@ -25,6 +25,9 @@ * OTHER DEALINGS IN THE SOFTWARE. */ +#ifndef LIB_ARM_MATCHFINDER_IMPL_H +#define LIB_ARM_MATCHFINDER_IMPL_H + #ifdef __ARM_NEON # include static forceinline void @@ -79,3 +82,5 @@ matchfinder_rebase_neon(mf_pos_t *data, size_t size) #define matchfinder_rebase matchfinder_rebase_neon #endif /* __ARM_NEON */ + +#endif /* LIB_ARM_MATCHFINDER_IMPL_H */ diff --git a/lib/bt_matchfinder.h b/lib/bt_matchfinder.h index 546a19d..a994a57 100644 --- a/lib/bt_matchfinder.h +++ b/lib/bt_matchfinder.h @@ -64,6 +64,8 @@ * ---------------------------------------------------------------------------- */ +#ifndef LIB_BT_MATCHFINDER_H +#define LIB_BT_MATCHFINDER_H #include "matchfinder_common.h" @@ -357,3 +359,5 @@ bt_matchfinder_skip_position(struct bt_matchfinder *mf, NULL, false); } + +#endif /* LIB_BT_MATCHFINDER_H */ diff --git a/lib/cpu_features_common.h b/lib/cpu_features_common.h index 0c2cc6e..570b62d 100644 --- a/lib/cpu_features_common.h +++ b/lib/cpu_features_common.h @@ -25,6 +25,9 @@ * OTHER DEALINGS IN THE SOFTWARE. */ +#ifndef LIB_CPU_FEATURES_COMMON_H +#define LIB_CPU_FEATURES_COMMON_H + #if defined(TEST_SUPPORT__DO_NOT_USE) && !defined(FREESTANDING) # define _GNU_SOURCE 1 /* for strdup() and strtok_r() */ # include @@ -81,3 +84,5 @@ disable_cpu_features_for_testing(u32 *features, { } #endif /* !TEST_SUPPORT__DO_NOT_USE */ + +#endif /* LIB_CPU_FEATURES_COMMON_H */ diff --git a/lib/hc_matchfinder.h b/lib/hc_matchfinder.h index becf844..b81d32c 100644 --- a/lib/hc_matchfinder.h +++ b/lib/hc_matchfinder.h @@ -106,6 +106,9 @@ * ---------------------------------------------------------------------------- */ +#ifndef LIB_HC_MATCHFINDER_H +#define LIB_HC_MATCHFINDER_H + #include "matchfinder_common.h" #define HC_MATCHFINDER_HASH3_ORDER 15 @@ -405,3 +408,5 @@ hc_matchfinder_skip_positions(struct hc_matchfinder * const restrict mf, return in_next; } + +#endif /* LIB_HC_MATCHFINDER_H */ diff --git a/lib/x86/adler32_impl.h b/lib/x86/adler32_impl.h index 4b88c01..f89bde5 100644 --- a/lib/x86/adler32_impl.h +++ b/lib/x86/adler32_impl.h @@ -25,6 +25,9 @@ * OTHER DEALINGS IN THE SOFTWARE. */ +#ifndef LIB_X86_ADLER32_IMPL_H +#define LIB_X86_ADLER32_IMPL_H + #include "cpu_features.h" /* @@ -330,3 +333,5 @@ arch_select_adler32_func(void) return NULL; } #endif /* DISPATCH */ + +#endif /* LIB_X86_ADLER32_IMPL_H */ diff --git a/lib/x86/crc32_impl.h b/lib/x86/crc32_impl.h index 0c17700..14a6867 100644 --- a/lib/x86/crc32_impl.h +++ b/lib/x86/crc32_impl.h @@ -25,6 +25,9 @@ * OTHER DEALINGS IN THE SOFTWARE. */ +#ifndef LIB_X86_CRC32_IMPL_H +#define LIB_X86_CRC32_IMPL_H + #include "cpu_features.h" /* @@ -85,3 +88,5 @@ arch_select_crc32_func(void) return NULL; } #endif /* DISPATCH */ + +#endif /* LIB_X86_CRC32_IMPL_H */ diff --git a/lib/x86/decompress_impl.h b/lib/x86/decompress_impl.h index b3d322a..de6d236 100644 --- a/lib/x86/decompress_impl.h +++ b/lib/x86/decompress_impl.h @@ -1,3 +1,6 @@ +#ifndef LIB_X86_DECOMPRESS_IMPL_H +#define LIB_X86_DECOMPRESS_IMPL_H + #include "cpu_features.h" /* Include the BMI2-optimized version? */ @@ -24,3 +27,5 @@ arch_select_decompress_func(void) return NULL; } #endif /* DISPATCH */ + +#endif /* LIB_X86_DECOMPRESS_IMPL_H */ diff --git a/lib/x86/matchfinder_impl.h b/lib/x86/matchfinder_impl.h index 22a6c82..99fbebe 100644 --- a/lib/x86/matchfinder_impl.h +++ b/lib/x86/matchfinder_impl.h @@ -25,6 +25,9 @@ * OTHER DEALINGS IN THE SOFTWARE. */ +#ifndef LIB_X86_MATCHFINDER_IMPL_H +#define LIB_X86_MATCHFINDER_IMPL_H + #ifdef __AVX2__ # include static forceinline void @@ -115,3 +118,5 @@ matchfinder_rebase_sse2(mf_pos_t *data, size_t size) } #define matchfinder_rebase matchfinder_rebase_sse2 #endif /* __SSE2__ */ + +#endif /* LIB_X86_MATCHFINDER_IMPL_H */