From 19085ff193c7745f9fb99c4b62c6764be16191de Mon Sep 17 00:00:00 2001 From: Waqar Ahmed Khan Date: Fri, 18 Oct 2024 14:13:53 -0700 Subject: [PATCH 1/2] don't include in extern c --- include/aws/common/array_list.h | 2 +- include/aws/common/atomics.h | 4 +++- include/aws/common/atomics.inl | 2 +- include/aws/common/byte_order.h | 2 +- include/aws/common/clock.h | 4 +++- include/aws/common/encoding.h | 3 ++- include/aws/common/error.h | 5 +++-- include/aws/common/linked_list.h | 2 +- include/aws/common/math.h | 2 +- include/aws/common/math.inl | 5 ++++- include/aws/common/ring_buffer.h | 3 ++- include/aws/common/string.h | 4 +++- include/aws/common/zero.h | 3 ++- 13 files changed, 27 insertions(+), 14 deletions(-) diff --git a/include/aws/common/array_list.h b/include/aws/common/array_list.h index 4ef924456..4cd05bb7d 100644 --- a/include/aws/common/array_list.h +++ b/include/aws/common/array_list.h @@ -231,11 +231,11 @@ void aws_array_list_swap(struct aws_array_list *AWS_RESTRICT list, size_t a, siz AWS_COMMON_API void aws_array_list_sort(struct aws_array_list *AWS_RESTRICT list, aws_array_list_comparator_fn *compare_fn); +AWS_EXTERN_C_END #ifndef AWS_NO_STATIC_IMPL # include #endif /* AWS_NO_STATIC_IMPL */ -AWS_EXTERN_C_END AWS_POP_SANE_WARNING_LEVEL #endif /* AWS_COMMON_ARRAY_LIST_H */ diff --git a/include/aws/common/atomics.h b/include/aws/common/atomics.h index 7f5445334..45002d23c 100644 --- a/include/aws/common/atomics.h +++ b/include/aws/common/atomics.h @@ -318,11 +318,13 @@ size_t aws_atomic_fetch_xor(volatile struct aws_atomic_var *var, size_t n); AWS_STATIC_IMPL void aws_atomic_thread_fence(enum aws_memory_order order); + +AWS_EXTERN_C_END + #ifndef AWS_NO_STATIC_IMPL # include #endif /* AWS_NO_STATIC_IMPL */ -AWS_EXTERN_C_END AWS_POP_SANE_WARNING_LEVEL #endif diff --git a/include/aws/common/atomics.inl b/include/aws/common/atomics.inl index 3763fb4d5..54efdb6f5 100644 --- a/include/aws/common/atomics.inl +++ b/include/aws/common/atomics.inl @@ -127,6 +127,7 @@ AWS_STATIC_IMPL size_t aws_atomic_fetch_xor(volatile struct aws_atomic_var *var, size_t n) { return aws_atomic_fetch_xor_explicit(var, n, aws_memory_order_seq_cst); } +AWS_EXTERN_C_END /* Include the backend implementation now, because we'll use its typedefs and #defines below */ #if defined(__GNUC__) || defined(__clang__) @@ -143,6 +144,5 @@ size_t aws_atomic_fetch_xor(volatile struct aws_atomic_var *var, size_t n) { #include -AWS_EXTERN_C_END #endif /* AWS_COMMON_ATOMICS_INL */ diff --git a/include/aws/common/byte_order.h b/include/aws/common/byte_order.h index b42f7a666..c2bd0d1b5 100644 --- a/include/aws/common/byte_order.h +++ b/include/aws/common/byte_order.h @@ -66,11 +66,11 @@ AWS_STATIC_IMPL uint16_t aws_hton16(uint16_t x); */ AWS_STATIC_IMPL uint16_t aws_ntoh16(uint16_t x); +AWS_EXTERN_C_END #ifndef AWS_NO_STATIC_IMPL # include #endif /* AWS_NO_STATIC_IMPL */ -AWS_EXTERN_C_END AWS_POP_SANE_WARNING_LEVEL #endif /* AWS_COMMON_BYTE_ORDER_H */ diff --git a/include/aws/common/clock.h b/include/aws/common/clock.h index f1ca14877..0fe423afb 100644 --- a/include/aws/common/clock.h +++ b/include/aws/common/clock.h @@ -54,11 +54,13 @@ int aws_high_res_clock_get_ticks(uint64_t *timestamp); AWS_COMMON_API int aws_sys_clock_get_ticks(uint64_t *timestamp); +AWS_EXTERN_C_END + #ifndef AWS_NO_STATIC_IMPL # include #endif /* AWS_NO_STATIC_IMPL */ -AWS_EXTERN_C_END + AWS_POP_SANE_WARNING_LEVEL #endif /* AWS_COMMON_CLOCK_H */ diff --git a/include/aws/common/encoding.h b/include/aws/common/encoding.h index b5f4d88e3..89e4df2e6 100644 --- a/include/aws/common/encoding.h +++ b/include/aws/common/encoding.h @@ -224,11 +224,12 @@ AWS_COMMON_API int aws_utf8_decoder_update(struct aws_utf8_decoder *decoder, str */ AWS_COMMON_API int aws_utf8_decoder_finalize(struct aws_utf8_decoder *decoder); +AWS_EXTERN_C_END + #ifndef AWS_NO_STATIC_IMPL # include #endif /* AWS_NO_STATIC_IMPL */ -AWS_EXTERN_C_END AWS_POP_SANE_WARNING_LEVEL #endif /* AWS_COMMON_ENCODING_H */ diff --git a/include/aws/common/error.h b/include/aws/common/error.h index a798b6677..805c6f840 100644 --- a/include/aws/common/error.h +++ b/include/aws/common/error.h @@ -149,12 +149,13 @@ int aws_translate_and_raise_io_error_or(int error_no, int fallback_aws_error_cod AWS_COMMON_API int aws_translate_and_raise_io_error(int error_no); + + +AWS_EXTERN_C_END #ifndef AWS_NO_STATIC_IMPL # include #endif /* AWS_NO_STATIC_IMPL */ -AWS_EXTERN_C_END - enum aws_common_error { AWS_ERROR_SUCCESS = AWS_ERROR_ENUM_BEGIN_RANGE(AWS_C_COMMON_PACKAGE_ID), AWS_ERROR_OOM, diff --git a/include/aws/common/linked_list.h b/include/aws/common/linked_list.h index cb0ce655c..bd2e5d891 100644 --- a/include/aws/common/linked_list.h +++ b/include/aws/common/linked_list.h @@ -186,11 +186,11 @@ AWS_STATIC_IMPL void aws_linked_list_move_all_front( * Returns true if the node is currently in a list, false otherwise. */ AWS_STATIC_IMPL bool aws_linked_list_node_is_in_list(struct aws_linked_list_node *node); +AWS_EXTERN_C_END #ifndef AWS_NO_STATIC_IMPL # include #endif /* AWS_NO_STATIC_IMPL */ -AWS_EXTERN_C_END AWS_POP_SANE_WARNING_LEVEL #endif /* AWS_COMMON_LINKED_LIST_H */ diff --git a/include/aws/common/math.h b/include/aws/common/math.h index 7d0f97b61..8a8a00118 100644 --- a/include/aws/common/math.h +++ b/include/aws/common/math.h @@ -200,11 +200,11 @@ AWS_STATIC_IMPL float aws_max_float(float a, float b); AWS_STATIC_IMPL double aws_min_double(double a, double b); AWS_STATIC_IMPL double aws_max_double(double a, double b); +AWS_EXTERN_C_END #ifndef AWS_NO_STATIC_IMPL # include #endif /* AWS_NO_STATIC_IMPL */ -AWS_EXTERN_C_END AWS_POP_SANE_WARNING_LEVEL #endif /* AWS_COMMON_MATH_H */ diff --git a/include/aws/common/math.inl b/include/aws/common/math.inl index ad3590623..6a88ab733 100644 --- a/include/aws/common/math.inl +++ b/include/aws/common/math.inl @@ -13,7 +13,7 @@ #include #include -AWS_EXTERN_C_BEGIN + #if defined(AWS_HAVE_GCC_OVERFLOW_MATH_EXTENSIONS) && (defined(__clang__) || !defined(__cplusplus)) /* @@ -48,6 +48,8 @@ AWS_EXTERN_C_BEGIN # include #endif +AWS_EXTERN_C_BEGIN + #ifdef _MSC_VER # pragma warning(push) # pragma warning(disable : 4127) /*Disable "conditional expression is constant" */ @@ -58,6 +60,7 @@ AWS_EXTERN_C_BEGIN # endif #endif + AWS_STATIC_IMPL uint64_t aws_sub_u64_saturating(uint64_t a, uint64_t b) { return a <= b ? 0 : a - b; } diff --git a/include/aws/common/ring_buffer.h b/include/aws/common/ring_buffer.h index 24cddd09f..e798d5d1d 100644 --- a/include/aws/common/ring_buffer.h +++ b/include/aws/common/ring_buffer.h @@ -93,11 +93,12 @@ AWS_COMMON_API bool aws_ring_buffer_buf_belongs_to_pool( const struct aws_ring_buffer *ring_buffer, const struct aws_byte_buf *buf); +AWS_EXTERN_C_END + #ifndef AWS_NO_STATIC_IMPL # include #endif /* AWS_NO_STATIC_IMPL */ -AWS_EXTERN_C_END AWS_POP_SANE_WARNING_LEVEL #endif /* AWS_COMMON_RING_BUFFER_H */ diff --git a/include/aws/common/string.h b/include/aws/common/string.h index da4482abf..e77b7a141 100644 --- a/include/aws/common/string.h +++ b/include/aws/common/string.h @@ -373,11 +373,13 @@ bool aws_c_string_is_valid(const char *str); AWS_STATIC_IMPL bool aws_char_is_space(uint8_t c); +AWS_EXTERN_C_END + #ifndef AWS_NO_STATIC_IMPL # include #endif /* AWS_NO_STATIC_IMPL */ -AWS_EXTERN_C_END + AWS_POP_SANE_WARNING_LEVEL #endif /* AWS_COMMON_STRING_H */ diff --git a/include/aws/common/zero.h b/include/aws/common/zero.h index e83cf454b..f04f5a84d 100644 --- a/include/aws/common/zero.h +++ b/include/aws/common/zero.h @@ -56,11 +56,12 @@ bool aws_is_mem_zeroed(const void *buf, size_t bufsize); AWS_COMMON_API void aws_secure_zero(void *pBuf, size_t bufsize); +AWS_EXTERN_C_END + #ifndef AWS_NO_STATIC_IMPL # include #endif /* AWS_NO_STATIC_IMPL */ -AWS_EXTERN_C_END AWS_POP_SANE_WARNING_LEVEL #endif /* AWS_COMMON_ZERO_H */ From 220324f664896190dc66d87c718759c53c4992fb Mon Sep 17 00:00:00 2001 From: Waqar Ahmed Khan Date: Fri, 18 Oct 2024 14:22:41 -0700 Subject: [PATCH 2/2] lint --- include/aws/common/atomics.h | 1 - include/aws/common/atomics.inl | 1 - include/aws/common/clock.h | 1 - include/aws/common/error.h | 2 -- include/aws/common/math.inl | 3 --- include/aws/common/string.h | 1 - 6 files changed, 9 deletions(-) diff --git a/include/aws/common/atomics.h b/include/aws/common/atomics.h index 45002d23c..a4fa72e38 100644 --- a/include/aws/common/atomics.h +++ b/include/aws/common/atomics.h @@ -318,7 +318,6 @@ size_t aws_atomic_fetch_xor(volatile struct aws_atomic_var *var, size_t n); AWS_STATIC_IMPL void aws_atomic_thread_fence(enum aws_memory_order order); - AWS_EXTERN_C_END #ifndef AWS_NO_STATIC_IMPL diff --git a/include/aws/common/atomics.inl b/include/aws/common/atomics.inl index 54efdb6f5..306504fb1 100644 --- a/include/aws/common/atomics.inl +++ b/include/aws/common/atomics.inl @@ -144,5 +144,4 @@ AWS_EXTERN_C_END #include - #endif /* AWS_COMMON_ATOMICS_INL */ diff --git a/include/aws/common/clock.h b/include/aws/common/clock.h index 0fe423afb..d385cb46b 100644 --- a/include/aws/common/clock.h +++ b/include/aws/common/clock.h @@ -60,7 +60,6 @@ AWS_EXTERN_C_END # include #endif /* AWS_NO_STATIC_IMPL */ - AWS_POP_SANE_WARNING_LEVEL #endif /* AWS_COMMON_CLOCK_H */ diff --git a/include/aws/common/error.h b/include/aws/common/error.h index 805c6f840..b8ecdc88b 100644 --- a/include/aws/common/error.h +++ b/include/aws/common/error.h @@ -149,8 +149,6 @@ int aws_translate_and_raise_io_error_or(int error_no, int fallback_aws_error_cod AWS_COMMON_API int aws_translate_and_raise_io_error(int error_no); - - AWS_EXTERN_C_END #ifndef AWS_NO_STATIC_IMPL # include diff --git a/include/aws/common/math.inl b/include/aws/common/math.inl index 6a88ab733..002ff8178 100644 --- a/include/aws/common/math.inl +++ b/include/aws/common/math.inl @@ -13,8 +13,6 @@ #include #include - - #if defined(AWS_HAVE_GCC_OVERFLOW_MATH_EXTENSIONS) && (defined(__clang__) || !defined(__cplusplus)) /* * GCC and clang have these super convenient overflow checking builtins... @@ -60,7 +58,6 @@ AWS_EXTERN_C_BEGIN # endif #endif - AWS_STATIC_IMPL uint64_t aws_sub_u64_saturating(uint64_t a, uint64_t b) { return a <= b ? 0 : a - b; } diff --git a/include/aws/common/string.h b/include/aws/common/string.h index e77b7a141..37ec2f99e 100644 --- a/include/aws/common/string.h +++ b/include/aws/common/string.h @@ -379,7 +379,6 @@ AWS_EXTERN_C_END # include #endif /* AWS_NO_STATIC_IMPL */ - AWS_POP_SANE_WARNING_LEVEL #endif /* AWS_COMMON_STRING_H */