From ce98087f7ebcd31d2ab3dfc3c710b332ce853259 Mon Sep 17 00:00:00 2001 From: Anton Kolesnyk <41349689+antkmsft@users.noreply.github.com> Date: Fri, 4 Dec 2020 11:55:59 -0800 Subject: [PATCH] Don't use WINDOWS/POSIX/NOMINMAX macros defined in cmake, move them to source code instead (#1070) --- CMakeLists.txt | 3 -- cmake-modules/DefinePlatform.cmake | 21 ---------- .../inc/azure/core/http/body_stream.hpp | 22 +++++------ .../azure-core/inc/azure/core/platform.hpp | 15 +++++++ sdk/core/azure-core/src/datetime.cpp | 13 +++++-- sdk/core/azure-core/src/http/body_stream.cpp | 26 ++++++------- sdk/core/azure-core/src/http/curl/curl.cpp | 28 ++++++------- .../azure-core/src/http/telemetry_policy.cpp | 12 ++++-- .../e2e/azure_core_with_curl_bodyBuffer.cpp | 23 +++++------ .../test/ut/transport_adapter_base.cpp | 39 ++++++++++++------- sdk/storage/CMakeLists.txt | 6 --- .../inc/azure/storage/common/file_io.hpp | 16 ++++++-- .../azure-storage-common/src/crypt.cpp | 14 ++++--- .../azure-storage-common/src/file_io.cpp | 7 ++-- .../src/storage_per_retry_policy.cpp | 5 ++- .../azure-storage-common/test/test_base.cpp | 14 ++++--- 16 files changed, 141 insertions(+), 123 deletions(-) delete mode 100644 cmake-modules/DefinePlatform.cmake create mode 100644 sdk/core/azure-core/inc/azure/core/platform.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 1d4cfa7bb..10d359aac 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,9 +29,6 @@ if(DEFINED ENV{VCPKG_DEFAULT_TRIPLET} AND NOT DEFINED VCPKG_TARGET_TRIPLET) set(VCPKG_TARGET_TRIPLET "$ENV{VCPKG_DEFAULT_TRIPLET}" CACHE STRING "") endif() -# Define WINDOWS of POSIX for specific code implementations like FileStream -include(DefinePlatform) - # Project definition project(az LANGUAGES CXX) set(CMAKE_CXX_STANDARD 14) diff --git a/cmake-modules/DefinePlatform.cmake b/cmake-modules/DefinePlatform.cmake deleted file mode 100644 index 618ba7ebf..000000000 --- a/cmake-modules/DefinePlatform.cmake +++ /dev/null @@ -1,21 +0,0 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. -# SPDX-License-Identifier: MIT -# -# Cmake variables: -# UNIX : is TRUE on all UNIX-like OS's, including Apple OS X and CygWin - -# WIN32 : is TRUE on Windows. Prior to 2.8.4 this included CygWin -# MINGW : is TRUE when using the MinGW compiler in Windows -# MSYS : is TRUE when using the MSYS developer environment in Windows -# CYGWIN : is TRUE on Windows when using the CygWin version of cmake - -# APPLE : is TRUE on Apple systems. Note this does not imply the -# system is Mac OS X, only that APPLE is #defined in C/C++ -# header files. - -if (WIN32 OR MINGW OR MSYS OR CYGWIN) - add_compile_definitions(WINDOWS) -endif () -if (UNIX) - add_compile_definitions(POSIX) -endif () diff --git a/sdk/core/azure-core/inc/azure/core/http/body_stream.hpp b/sdk/core/azure-core/inc/azure/core/http/body_stream.hpp index 6f75b8df9..90af9a3db 100644 --- a/sdk/core/azure-core/inc/azure/core/http/body_stream.hpp +++ b/sdk/core/azure-core/inc/azure/core/http/body_stream.hpp @@ -8,17 +8,19 @@ #pragma once -#ifdef POSIX -#include -#endif +#include -#ifdef WINDOWS +#ifdef AZ_PLATFORM_POSIX +#include +#elif defined(AZ_PLATFORM_WINDOWS) +#ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN +#endif #ifndef NOMINMAX #define NOMINMAX #endif -#include -#endif // Windows +#include +#endif #include "azure/core/context.hpp" @@ -168,7 +170,7 @@ namespace Azure { namespace Core { namespace Http { } }; -#ifdef POSIX +#ifdef AZ_PLATFORM_POSIX /** * @brief #BodyStream providing its data from a file. */ @@ -201,9 +203,7 @@ namespace Azure { namespace Core { namespace Http { int64_t Length() const override { return this->m_length; }; }; -#endif - -#ifdef WINDOWS +#elif defined(AZ_PLATFORM_WINDOWS) /** * @brief #BodyStream providing its data from a file. */ @@ -236,7 +236,7 @@ namespace Azure { namespace Core { namespace Http { int64_t Length() const override { return this->m_length; }; }; -#endif // Windows +#endif /** * @brief #BodyStream that provides its data from another #BodyStream. diff --git a/sdk/core/azure-core/inc/azure/core/platform.hpp b/sdk/core/azure-core/inc/azure/core/platform.hpp new file mode 100644 index 000000000..3b13903bd --- /dev/null +++ b/sdk/core/azure-core/inc/azure/core/platform.hpp @@ -0,0 +1,15 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// SPDX-License-Identifier: MIT + +/** + * @file + * @brief Defines platform-specific macros. + */ + +#pragma once + +#ifdef _WIN32 +#define AZ_PLATFORM_WINDOWS +#elif defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)) +#define AZ_PLATFORM_POSIX +#endif diff --git a/sdk/core/azure-core/src/datetime.cpp b/sdk/core/azure-core/src/datetime.cpp index 9b3afdb71..57108470f 100644 --- a/sdk/core/azure-core/src/datetime.cpp +++ b/sdk/core/azure-core/src/datetime.cpp @@ -2,17 +2,22 @@ // SPDX-License-Identifier: MIT #include "azure/core/datetime.hpp" +#include #include #include #include #include -#ifdef _WIN32 +#ifdef AZ_PLATFORM_WINDOWS +#ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN +#endif +#ifndef NOMINMAX #define NOMINMAX +#endif #include -#else +#elif defined(AZ_PLATFORM_POSIX) #include #endif @@ -20,7 +25,7 @@ using namespace Azure::Core; DateTime DateTime::Now() { -#ifdef _WIN32 +#ifdef AZ_PLATFORM_WINDOWS FILETIME fileTime = {}; GetSystemTimeAsFileTime(&fileTime); @@ -29,7 +34,7 @@ DateTime DateTime::Now() largeInt.HighPart = fileTime.dwHighDateTime; return DateTime(Duration(largeInt.QuadPart)); -#else +#elif defined(AZ_PLATFORM_POSIX) static constexpr int64_t WindowsToPosixOffsetSeconds = 11644473600LL; struct timeval time = {}; diff --git a/sdk/core/azure-core/src/http/body_stream.cpp b/sdk/core/azure-core/src/http/body_stream.cpp index c7994dc1c..a5226e9d0 100644 --- a/sdk/core/azure-core/src/http/body_stream.cpp +++ b/sdk/core/azure-core/src/http/body_stream.cpp @@ -1,16 +1,20 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#ifdef POSIX +#include + +#ifdef AZ_PLATFORM_POSIX #include #include -#endif - -#ifdef WINDOWS +#elif defined(AZ_PLATFORM_WINDOWS) +#ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN +#endif +#ifndef NOMINMAX #define NOMINMAX -#include -#endif // Windows +#endif +#include +#endif #include "azure/core/context.hpp" #include "azure/core/http/body_stream.hpp" @@ -79,8 +83,7 @@ int64_t MemoryBodyStream::Read(Context const& context, uint8_t* buffer, int64_t return copy_length; } -#ifdef POSIX - +#ifdef AZ_PLATFORM_POSIX int64_t FileBodyStream::Read(Azure::Core::Context const& context, uint8_t* buffer, int64_t count) { context.ThrowIfCanceled(); @@ -99,10 +102,7 @@ int64_t FileBodyStream::Read(Azure::Core::Context const& context, uint8_t* buffe this->m_offset += result; return result; } -#endif - -#ifdef WINDOWS - +#elif defined(AZ_PLATFORM_WINDOWS) int64_t FileBodyStream::Read(Azure::Core::Context const& context, uint8_t* buffer, int64_t count) { context.ThrowIfCanceled(); @@ -134,7 +134,7 @@ int64_t FileBodyStream::Read(Azure::Core::Context const& context, uint8_t* buffe this->m_offset += numberOfBytesRead; return numberOfBytesRead; } -#endif // Windows +#endif int64_t LimitBodyStream::Read(Context const& context, uint8_t* buffer, int64_t count) { diff --git a/sdk/core/azure-core/src/http/curl/curl.cpp b/sdk/core/azure-core/src/http/curl/curl.cpp index 51027a679..9ff74dfb2 100644 --- a/sdk/core/azure-core/src/http/curl/curl.cpp +++ b/sdk/core/azure-core/src/http/curl/curl.cpp @@ -6,16 +6,16 @@ #include "azure/core/http/policy.hpp" #include "azure/core/http/transport.hpp" #include "azure/core/internal/log.hpp" +#include // Private incude #include "curl_connection_pool_private.hpp" #include "curl_connection_private.hpp" #include "curl_session_private.hpp" -#ifdef POSIX +#ifdef AZ_PLATFORM_POSIX #include // for poll() -#endif -#ifdef WINDOWS +#elif defined(AZ_PLATFORM_WINDOWS) #include // for WSAPoll(); #endif @@ -67,12 +67,9 @@ int pollSocketUntilEventOrTimeout( PollSocketDirection direction, long timeout) { - -#ifndef POSIX -#ifndef WINDOWS +#if !defined(AZ_PLATFORM_WINDOWS) && !defined(AZ_PLATFORM_POSIX) // platform does not support Poll(). throw TransportException("Error while sending request. Platform does not support Poll()"); -#endif #endif struct pollfd poller; @@ -105,10 +102,9 @@ int pollSocketUntilEventOrTimeout( { // check cancelation context.ThrowIfCanceled(); -#ifdef POSIX +#ifdef AZ_PLATFORM_POSIX result = poll(&poller, 1, interval); -#endif -#ifdef WINDOWS +#elif defined(AZ_PLATFORM_WINDOWS) result = WSAPoll(&poller, 1, interval); #endif } @@ -116,7 +112,7 @@ int pollSocketUntilEventOrTimeout( return result; } -#ifdef WINDOWS +#ifdef AZ_PLATFORM_WINDOWS // Windows needs this after every write to socket or performance would be reduced to 1/4 for // uploading operation. // https://github.com/Azure/azure-sdk-for-cpp/issues/644 @@ -137,7 +133,7 @@ void WinSocketSetBuffSize(curl_socket_t socket) + " result = " + std::to_string(result)); } } -#endif // WINDOWS +#endif } // namespace using Azure::Core::Context; @@ -375,9 +371,9 @@ CURLcode CurlConnection::SendBuffer( } }; } -#ifdef WINDOWS +#ifdef AZ_PLATFORM_WINDOWS WinSocketSetBuffSize(m_curlSocket); -#endif // WINDOWS +#endif return CURLE_OK; } @@ -756,9 +752,9 @@ int64_t CurlConnection::ReadFromSocket(Context const& context, uint8_t* buffer, } } } -#ifdef WINDOWS +#ifdef AZ_PLATFORM_WINDOWS WinSocketSetBuffSize(m_curlSocket); -#endif // WINDOWS +#endif return readBytes; } diff --git a/sdk/core/azure-core/src/http/telemetry_policy.cpp b/sdk/core/azure-core/src/http/telemetry_policy.cpp index 3e1f4d2ec..0ee7e22d3 100644 --- a/sdk/core/azure-core/src/http/telemetry_policy.cpp +++ b/sdk/core/azure-core/src/http/telemetry_policy.cpp @@ -2,14 +2,20 @@ // SPDX-License-Identifier: MIT #include "azure/core/http/policy.hpp" +#include #include #include -#ifdef _WIN32 +#ifdef AZ_PLATFORM_WINDOWS -#define NOMINMAX +#ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN +#endif +#ifndef NOMINMAX +#define NOMINMAX +#endif + #include namespace { @@ -72,7 +78,7 @@ std::string GetOSVersion() } // namespace -#else +#elif defined(AZ_PLATFORM_POSIX) #include diff --git a/sdk/core/azure-core/test/e2e/azure_core_with_curl_bodyBuffer.cpp b/sdk/core/azure-core/test/e2e/azure_core_with_curl_bodyBuffer.cpp index 1fea18fed..c912ecbd7 100644 --- a/sdk/core/azure-core/test/e2e/azure_core_with_curl_bodyBuffer.cpp +++ b/sdk/core/azure-core/test/e2e/azure_core_with_curl_bodyBuffer.cpp @@ -7,16 +7,19 @@ */ #include +#include -#ifdef POSIX +#ifdef AZ_PLATFORM_POSIX #include -#endif // Posix - -#ifdef WINDOWS +#elif defined(AZ_PLATFORM_WINDOWS) +#ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN +#endif +#ifndef NOMINMAX #define NOMINMAX -#include -#endif // Windows +#endif +#include +#endif #include #include @@ -69,7 +72,7 @@ int main() return 0; } -#ifdef POSIX +#ifdef AZ_PLATFORM_POSIX void doFileRequest(Context const& context, HttpPipeline& pipeline) { @@ -101,9 +104,7 @@ void doFileRequest(Context const& context, HttpPipeline& pipeline) auto body = Http::BodyStream::ReadToEnd(context, limitedResponse); cout << body.data() << endl << body.size() << endl; } -#endif // Posix - -#ifdef WINDOWS +#elif defined(AZ_PLATFORM_WINDOWS) void doFileRequest(Context const& context, HttpPipeline& pipeline) { (void)pipeline; @@ -128,7 +129,7 @@ void doFileRequest(Context const& context, HttpPipeline& pipeline) CloseHandle(hFile); } -#endif // Windows +#endif void doGetRequest(Context const& context, HttpPipeline& pipeline) { diff --git a/sdk/core/azure-core/test/ut/transport_adapter_base.cpp b/sdk/core/azure-core/test/ut/transport_adapter_base.cpp index 865e90b4c..3ab66b4ff 100644 --- a/sdk/core/azure-core/test/ut/transport_adapter_base.cpp +++ b/sdk/core/azure-core/test/ut/transport_adapter_base.cpp @@ -1,15 +1,19 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#ifdef POSIX -#include -#endif // Posix +#include -#ifdef WINDOWS +#ifdef AZ_PLATFORM_POSIX +#include +#elif defined(AZ_PLATFORM_WINDOWS) +#ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN +#endif +#ifndef NOMINMAX #define NOMINMAX -#include -#endif // Windows +#endif +#include +#endif #include "transport_adapter_base.hpp" #include @@ -434,11 +438,10 @@ namespace Azure { namespace Core { namespace Test { Azure::Core::Http::Url host("http://httpbin.org/put"); std::string testDataPath(AZURE_TEST_DATA_PATH); -#ifdef POSIX +#ifdef AZ_PLATFORM_POSIX testDataPath.append("/fileData"); int f = open(testDataPath.data(), O_RDONLY); -#endif -#ifdef WINDOWS +#elif defined(AZ_PLATFORM_WINDOWS) testDataPath.append("\\fileData"); HANDLE f = CreateFile( testDataPath.data(), @@ -448,6 +451,8 @@ namespace Azure { namespace Core { namespace Test { OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, NULL); +#else +#error "Unknown platform" #endif auto requestBodyStream = Azure::Core::Http::FileBodyStream(f, 0, Azure::Core::Test::Datails::c_fileSize); @@ -469,11 +474,10 @@ namespace Azure { namespace Core { namespace Test { Azure::Core::Http::Url host("http://httpbin.org/put"); std::string testDataPath(AZURE_TEST_DATA_PATH); -#ifdef POSIX +#ifdef AZ_PLATFORM_POSIX testDataPath.append("/fileData"); int f = open(testDataPath.data(), O_RDONLY); -#endif -#ifdef WINDOWS +#elif defined(AZ_PLATFORM_WINDOWS) testDataPath.append("\\fileData"); HANDLE f = CreateFile( testDataPath.data(), @@ -483,7 +487,10 @@ namespace Azure { namespace Core { namespace Test { OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, NULL); +#else +#error "Unknown platform" #endif + auto requestBodyStream = Azure::Core::Http::FileBodyStream(f, 0, Azure::Core::Test::Datails::c_fileSize); auto request = Azure::Core::Http::Request( @@ -503,11 +510,10 @@ namespace Azure { namespace Core { namespace Test { Azure::Core::Http::Url host("http://httpbin.org/put"); std::string testDataPath(AZURE_TEST_DATA_PATH); -#ifdef POSIX +#ifdef AZ_PLATFORM_POSIX testDataPath.append("/fileData"); int f = open(testDataPath.data(), O_RDONLY); -#endif -#ifdef WINDOWS +#elif defined(AZ_PLATFORM_WINDOWS) testDataPath.append("\\fileData"); HANDLE f = CreateFile( testDataPath.data(), @@ -517,7 +523,10 @@ namespace Azure { namespace Core { namespace Test { OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, NULL); +#else +#error "Unknown platform" #endif + auto requestBodyStream = Azure::Core::Http::FileBodyStream(f, 0, Azure::Core::Test::Datails::c_fileSize); auto request = Azure::Core::Http::Request( diff --git a/sdk/storage/CMakeLists.txt b/sdk/storage/CMakeLists.txt index c488d5fc7..06cbca670 100644 --- a/sdk/storage/CMakeLists.txt +++ b/sdk/storage/CMakeLists.txt @@ -10,12 +10,6 @@ set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) option(BUILD_STORAGE_SAMPLES "Build storage sample codes" ON) - -if(MSVC) - add_compile_definitions(NOMINMAX) -endif() - - add_executable(azure-storage-test) if(BUILD_TESTING) set_target_properties(azure-storage-test PROPERTIES EXCLUDE_FROM_ALL FALSE) diff --git a/sdk/storage/azure-storage-common/inc/azure/storage/common/file_io.hpp b/sdk/storage/azure-storage-common/inc/azure/storage/common/file_io.hpp index 759c940ca..e596f3576 100644 --- a/sdk/storage/azure-storage-common/inc/azure/storage/common/file_io.hpp +++ b/sdk/storage/azure-storage-common/inc/azure/storage/common/file_io.hpp @@ -3,8 +3,16 @@ #pragma once -#ifdef _WIN32 -#include +#include + +#ifdef AZ_PLATFORM_WINDOWS +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#endif +#ifndef NOMINMAX +#define NOMINMAX +#endif +#include #endif #include @@ -12,9 +20,9 @@ namespace Azure { namespace Storage { namespace Details { -#ifdef _WIN32 +#ifdef AZ_PLATFORM_WINDOWS using FileHandle = HANDLE; -#else +#elif defined(AZ_PLATFORM_POSIX) using FileHandle = int; #endif diff --git a/sdk/storage/azure-storage-common/src/crypt.cpp b/sdk/storage/azure-storage-common/src/crypt.cpp index 6d95fda87..697924635 100644 --- a/sdk/storage/azure-storage-common/src/crypt.cpp +++ b/sdk/storage/azure-storage-common/src/crypt.cpp @@ -1,12 +1,16 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT +#include #include "azure/storage/common/crypt.hpp" -#ifdef _WIN32 -#include +#ifdef AZ_PLATFORM_WINDOWS +#ifndef NOMINMAX +#define NOMINMAX +#endif +#include #include -#else +#elif defined(AZ_PLATFORM_POSIX) #include #include #include @@ -71,7 +75,7 @@ namespace Azure { namespace Storage { } } // namespace Details -#ifdef _WIN32 +#ifdef AZ_PLATFORM_WINDOWS namespace Details { @@ -345,7 +349,7 @@ namespace Azure { namespace Storage { return decoded; } -#else +#elif defined(AZ_PLATFORM_POSIX) namespace Details { diff --git a/sdk/storage/azure-storage-common/src/file_io.cpp b/sdk/storage/azure-storage-common/src/file_io.cpp index 7b1608abd..ba664ce1f 100644 --- a/sdk/storage/azure-storage-common/src/file_io.cpp +++ b/sdk/storage/azure-storage-common/src/file_io.cpp @@ -1,9 +1,10 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT +#include #include "azure/storage/common/file_io.hpp" -#ifndef _WIN32 +#ifdef AZ_PLATFORM_POSIX #include #include #include @@ -15,7 +16,7 @@ namespace Azure { namespace Storage { namespace Details { -#ifdef _WIN32 +#ifdef AZ_PLATFORM_WINDOWS FileReader::FileReader(const std::string& filename) { m_handle = CreateFile( @@ -80,7 +81,7 @@ namespace Azure { namespace Storage { namespace Details { throw std::runtime_error("failed to write file"); } } -#else +#elif defined(AZ_PLATFORM_POSIX) FileReader::FileReader(const std::string& filename) { m_handle = open(filename.data(), O_RDONLY); diff --git a/sdk/storage/azure-storage-common/src/storage_per_retry_policy.cpp b/sdk/storage/azure-storage-common/src/storage_per_retry_policy.cpp index f2554033d..93e0810cc 100644 --- a/sdk/storage/azure-storage-common/src/storage_per_retry_policy.cpp +++ b/sdk/storage/azure-storage-common/src/storage_per_retry_policy.cpp @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT +#include #include "azure/storage/common/storage_per_retry_policy.hpp" #include @@ -22,9 +23,9 @@ namespace Azure { namespace Storage { namespace Details { // TODO: call helper function provided by Azure Core when they provide one. time_t t = std::time(nullptr); struct tm ct; -#ifdef _WIN32 +#ifdef AZ_PLATFORM_WINDOWS gmtime_s(&ct, &t); -#else +#elif defined(AZ_PLATFORM_POSIX) gmtime_r(&t, &ct); #endif static const char* weekdays[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}; diff --git a/sdk/storage/azure-storage-common/test/test_base.cpp b/sdk/storage/azure-storage-common/test/test_base.cpp index b1635cee8..db7a65860 100644 --- a/sdk/storage/azure-storage-common/test/test_base.cpp +++ b/sdk/storage/azure-storage-common/test/test_base.cpp @@ -1,6 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT +#include + #ifdef _MSC_VER #define _CRT_SECURE_NO_WARNINGS #endif @@ -240,9 +242,9 @@ namespace Azure { namespace Storage { namespace Test { { std::time_t epoch_seconds = std::chrono::system_clock::to_time_t(timePoint); struct tm ct; -#ifdef _WIN32 +#ifdef AZ_PLATFORM_WINDOWS gmtime_s(&ct, &epoch_seconds); -#else +#elif defined(AZ_PLATFORM_POSIX) gmtime_r(&epoch_seconds, &ct); #endif std::string time_str; @@ -269,9 +271,9 @@ namespace Azure { namespace Storage { namespace Test { { std::time_t epoch_seconds = std::chrono::system_clock::to_time_t(timePoint); struct tm ct; -#ifdef _WIN32 +#ifdef AZ_PLATFORM_WINDOWS gmtime_s(&ct, &epoch_seconds); -#else +#elif defined(AZ_PLATFORM_POSIX) gmtime_r(&epoch_seconds, &ct); #endif std::stringstream ss; @@ -286,9 +288,9 @@ namespace Azure { namespace Storage { namespace Test { std::stringstream ss(timeStr); ss.imbue(std::locale("C")); ss >> std::get_time(&t, "%a, %d %b %Y %H:%M:%S GMT"); -#ifdef _WIN32 +#ifdef AZ_PLATFORM_WINDOWS time_t tt = _mkgmtime(&t); -#else +#elif defined(AZ_PLATFORM_POSIX) time_t tt = timegm(&t); #endif return std::chrono::system_clock::from_time_t(tt);