189 lines
6.4 KiB
Diff
189 lines
6.4 KiB
Diff
diff --git a/cmake/AwsCFlags.cmake b/cmake/AwsCFlags.cmake
|
|
index 42d146e82..cb9d7f36b 100644
|
|
--- a/cmake/AwsCFlags.cmake
|
|
+++ b/cmake/AwsCFlags.cmake
|
|
@@ -68,6 +68,10 @@ function(aws_set_common_properties target)
|
|
if (LEGACY_COMPILER_SUPPORT)
|
|
list(APPEND AWS_C_FLAGS -Wno-strict-aliasing)
|
|
endif()
|
|
+
|
|
+ if(CMAKE_C_IMPLICIT_LINK_LIBRARIES MATCHES "mingw32")
|
|
+ list(APPEND AWS_C_FLAGS -D__USE_MINGW_ANSI_STDIO=1 -Wno-unused-local-typedefs)
|
|
+ endif()
|
|
endif()
|
|
|
|
check_include_file(stdint.h HAS_STDINT)
|
|
diff --git a/include/aws/common/byte_order.inl b/include/aws/common/byte_order.inl
|
|
index 69ee56792..847e726af 100644
|
|
--- a/include/aws/common/byte_order.inl
|
|
+++ b/include/aws/common/byte_order.inl
|
|
@@ -19,11 +19,11 @@
|
|
#include <aws/common/byte_order.h>
|
|
#include <aws/common/common.h>
|
|
|
|
-#ifdef _MSC_VER
|
|
+#ifdef _WIN32
|
|
# include <stdlib.h>
|
|
#else
|
|
# include <netinet/in.h>
|
|
-#endif /* _MSC_VER */
|
|
+#endif /* _WIN32 */
|
|
|
|
AWS_EXTERN_C_BEGIN
|
|
|
|
@@ -49,7 +49,7 @@ AWS_STATIC_IMPL uint64_t aws_hton64(uint64_t x) {
|
|
uint64_t v;
|
|
__asm__("bswap %q0" : "=r"(v) : "0"(x));
|
|
return v;
|
|
-#elif defined(_MSC_VER)
|
|
+#elif defined(_WIN32)
|
|
return _byteswap_uint64(x);
|
|
#else
|
|
uint32_t low = (uint32_t)x;
|
|
@@ -69,7 +69,7 @@ AWS_STATIC_IMPL uint64_t aws_ntoh64(uint64_t x) {
|
|
* Convert 32 bit integer from host to network byte order.
|
|
*/
|
|
AWS_STATIC_IMPL uint32_t aws_hton32(uint32_t x) {
|
|
-#ifdef _MSC_VER
|
|
+#ifdef _WIN32
|
|
return aws_is_big_endian() ? x : _byteswap_ulong(x);
|
|
#else
|
|
return htonl(x);
|
|
@@ -126,7 +126,7 @@ AWS_STATIC_IMPL double aws_htonf64(double x) {
|
|
* Convert 32 bit integer from network to host byte order.
|
|
*/
|
|
AWS_STATIC_IMPL uint32_t aws_ntoh32(uint32_t x) {
|
|
-#ifdef _MSC_VER
|
|
+#ifdef _WIN32
|
|
return aws_is_big_endian() ? x : _byteswap_ulong(x);
|
|
#else
|
|
return ntohl(x);
|
|
@@ -151,7 +151,7 @@ AWS_STATIC_IMPL double aws_ntohf64(double x) {
|
|
* Convert 16 bit integer from host to network byte order.
|
|
*/
|
|
AWS_STATIC_IMPL uint16_t aws_hton16(uint16_t x) {
|
|
-#ifdef _MSC_VER
|
|
+#ifdef _WIN32
|
|
return aws_is_big_endian() ? x : _byteswap_ushort(x);
|
|
#else
|
|
return htons(x);
|
|
@@ -162,7 +162,7 @@ AWS_STATIC_IMPL uint16_t aws_hton16(uint16_t x) {
|
|
* Convert 16 bit integer from network to host byte order.
|
|
*/
|
|
AWS_STATIC_IMPL uint16_t aws_ntoh16(uint16_t x) {
|
|
-#ifdef _MSC_VER
|
|
+#ifdef _WIN32
|
|
return aws_is_big_endian() ? x : _byteswap_ushort(x);
|
|
#else
|
|
return ntohs(x);
|
|
diff --git a/include/aws/common/logging.h b/include/aws/common/logging.h
|
|
index 8ef813c75..bfef7cfad 100644
|
|
--- a/include/aws/common/logging.h
|
|
+++ b/include/aws/common/logging.h
|
|
@@ -111,7 +111,9 @@ struct aws_logger_vtable {
|
|
aws_log_subject_t subject,
|
|
const char *format,
|
|
...)
|
|
-#if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__)
|
|
+#if defined(__MINGW32__)
|
|
+ __attribute__((format(gnu_printf, 4, 5)))
|
|
+#elif defined(__clang__) || defined(__GNUC__) || defined(__GNUG__)
|
|
__attribute__((format(printf, 4, 5)))
|
|
#endif /* non-ms compilers: TODO - find out what versions format support was added in */
|
|
;
|
|
diff --git a/include/aws/testing/aws_test_harness.h b/include/aws/testing/aws_test_harness.h
|
|
index 88ef03e21..d598e2f97 100644
|
|
--- a/include/aws/testing/aws_test_harness.h
|
|
+++ b/include/aws/testing/aws_test_harness.h
|
|
@@ -365,6 +365,9 @@ struct aws_test_harness {
|
|
};
|
|
|
|
#if defined(_WIN32)
|
|
+# ifdef __MINGW32__
|
|
+# include <winsock2.h>
|
|
+# endif
|
|
# include <windows.h>
|
|
static LONG WINAPI s_test_print_stack_trace(struct _EXCEPTION_POINTERS *exception_pointers) {
|
|
# if !defined(AWS_HEADER_CHECKER)
|
|
diff --git a/source/windows/environment.c b/source/windows/environment.c
|
|
index 8c042ddc5..ae50d0a59 100644
|
|
--- a/source/windows/environment.c
|
|
+++ b/source/windows/environment.c
|
|
@@ -23,12 +23,16 @@ int aws_get_environment_value(
|
|
const struct aws_string *variable_name,
|
|
struct aws_string **value_out) {
|
|
|
|
-#pragma warning(push)
|
|
-#pragma warning(disable : 4996)
|
|
+#ifdef _MSC_VER
|
|
+# pragma warning(push)
|
|
+# pragma warning(disable : 4996)
|
|
+#endif
|
|
|
|
const char *value = getenv(aws_string_c_str(variable_name));
|
|
|
|
-#pragma warning(pop)
|
|
+#ifdef _MSC_VER
|
|
+# pragma warning(pop)
|
|
+#endif
|
|
|
|
if (value == NULL) {
|
|
*value_out = NULL;
|
|
diff --git a/source/windows/system_info.c b/source/windows/system_info.c
|
|
index acbfd97ce..927a81b4a 100644
|
|
--- a/source/windows/system_info.c
|
|
+++ b/source/windows/system_info.c
|
|
@@ -40,7 +40,9 @@ void aws_debug_break(void) {
|
|
}
|
|
|
|
/* If I meet the engineer that wrote the dbghelp.h file for the windows 8.1 SDK we're gonna have words! */
|
|
-#pragma warning(disable : 4091)
|
|
+#ifdef _MSC_VER
|
|
+# pragma warning(disable : 4091)
|
|
+#endif
|
|
#include <dbghelp.h>
|
|
|
|
struct win_symbol_data {
|
|
@@ -124,7 +126,7 @@ static void s_init_dbghelp_impl(void *user_data) {
|
|
return;
|
|
}
|
|
|
|
-static bool s_init_dbghelp() {
|
|
+static bool s_init_dbghelp(void) {
|
|
if (AWS_LIKELY(s_SymInitialize)) {
|
|
return true;
|
|
}
|
|
@@ -188,7 +190,7 @@ char **aws_backtrace_symbols(void *const *stack, size_t num_frames) {
|
|
/* no luck, record the address and last error */
|
|
DWORD last_error = GetLastError();
|
|
int len = snprintf(
|
|
- sym_buf, AWS_ARRAY_SIZE(sym_buf), "at 0x%p: Failed to lookup symbol: error %u", stack[i], last_error);
|
|
+ sym_buf, AWS_ARRAY_SIZE(sym_buf), "at 0x%p: Failed to lookup symbol: error %lu", stack[i], last_error);
|
|
if (len > 0) {
|
|
struct aws_byte_cursor sym_cur = aws_byte_cursor_from_array(sym_buf, len);
|
|
aws_byte_buf_append_dynamic(&symbols, &sym_cur);
|
|
@@ -209,7 +211,7 @@ char **aws_backtrace_addr2line(void *const *frames, size_t stack_depth) {
|
|
void aws_backtrace_print(FILE *fp, void *call_site_data) {
|
|
struct _EXCEPTION_POINTERS *exception_pointers = call_site_data;
|
|
if (exception_pointers) {
|
|
- fprintf(fp, "** Exception 0x%x occured **\n", exception_pointers->ExceptionRecord->ExceptionCode);
|
|
+ fprintf(fp, "** Exception 0x%lx occured **\n", exception_pointers->ExceptionRecord->ExceptionCode);
|
|
}
|
|
|
|
if (!s_init_dbghelp()) {
|
|
diff --git a/tests/atomics_test.c b/tests/atomics_test.c
|
|
index 36dbbd1a5..90f0497e2 100644
|
|
--- a/tests/atomics_test.c
|
|
+++ b/tests/atomics_test.c
|
|
@@ -23,7 +23,9 @@
|
|
|
|
#ifdef _WIN32
|
|
# include <malloc.h>
|
|
-# define alloca _alloca
|
|
+# ifdef _MSC_VER
|
|
+# define alloca _alloca
|
|
+# endif
|
|
#elif defined(__FreeBSD__) || defined(__NetBSD__)
|
|
# include <stdlib.h>
|
|
#else
|