From a81ae51cf8b57ba03a9419bf41f4d5335f3c467d Mon Sep 17 00:00:00 2001 From: Parth Patel Date: Mon, 9 Feb 2026 03:30:10 -0600 Subject: [PATCH 1/2] Necessary changes were made in the aws-sdk-cpp to support AIX OS. --- CMakeLists.txt | 12 +-- src/aws-cpp-sdk-core/CMakeLists.txt | 3 + .../source/platform/aix/TimeHelper.cpp | 80 +++++++++++++++++++ .../utils/FileSystemUtilsTest.cpp | 3 + 4 files changed, 93 insertions(+), 5 deletions(-) create mode 100644 src/aws-cpp-sdk-core/source/platform/aix/TimeHelper.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 39d9106d8bfc..d0d31977e82f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -153,11 +153,6 @@ if (LEGACY_BUILD) endif () endif () - # use response files to prevent command-line-too-big errors for large libraries like iam - set(CMAKE_CXX_USE_RESPONSE_FILE_FOR_OBJECTS 1) - set(CMAKE_CXX_USE_RESPONSE_FILE_FOR_INCLUDES 1) - set(CMAKE_CXX_RESPONSE_FILE_LINK_FLAG "@") - if (COMMAND apply_pre_project_platform_settings) apply_pre_project_platform_settings() endif () @@ -173,6 +168,13 @@ if (LEGACY_BUILD) # build the sdk targets project("aws-cpp-sdk-all" VERSION "${PROJECT_VERSION}" LANGUAGES CXX) + if(NOT CMAKE_SYSTEM_NAME STREQUAL "AIX") + # use response files to prevent command-line-too-big errors for large libraries like iam + set(CMAKE_CXX_USE_RESPONSE_FILE_FOR_OBJECTS 1) + set(CMAKE_CXX_USE_RESPONSE_FILE_FOR_INCLUDES 1) + set(CMAKE_CXX_RESPONSE_FILE_LINK_FLAG "@") + endif() + find_package(Python3 COMPONENTS Interpreter Development) set(PYTHON3_CMD ${PYTHON_EXECUTABLE}) diff --git a/src/aws-cpp-sdk-core/CMakeLists.txt b/src/aws-cpp-sdk-core/CMakeLists.txt index c6a0f1c262ed..e2cf70269fed 100644 --- a/src/aws-cpp-sdk-core/CMakeLists.txt +++ b/src/aws-cpp-sdk-core/CMakeLists.txt @@ -321,6 +321,9 @@ elseif(PLATFORM_LINUX OR PLATFORM_APPLE) #add unix specific impl stuff here. file(GLOB PLATFORM_LINUX_SHARED_SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/source/platform/linux-shared/*.cpp") + if(CMAKE_SYSTEM_NAME STREQUAL "AIX") + list(APPEND PLATFORM_LINUX_SHARED_SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/source/platform/aix/*.cpp") + endif() file(GLOB AWS_NATIVE_SDK_LINUX_SHARED_SRC ${PLATFORM_LINUX_SHARED_SOURCE} diff --git a/src/aws-cpp-sdk-core/source/platform/aix/TimeHelper.cpp b/src/aws-cpp-sdk-core/source/platform/aix/TimeHelper.cpp new file mode 100644 index 000000000000..9bebab39ba2f --- /dev/null +++ b/src/aws-cpp-sdk-core/source/platform/aix/TimeHelper.cpp @@ -0,0 +1,80 @@ +/* TimeHelper.cpp + timegm() implementation for AIX platform. +*/ + +#include + +#include + +namespace Aws +{ +namespace Time +{ +time_t timegm (struct tm *tm) +{ + static const int msum [2][12] = { + { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334}, /* normal years */ + { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335} /* leap years */ + }; + static const int mlen [2][12] = { + { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}, + { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31} + }; + static const int tmstr_year= 1900; /* base of 'tm_year' in 'struct tm' */ + static const int epoch_year= 1970; /* unix timestamp epoch */ + static const int base_year= -9999; /* start of a 400-year period: used to be 1601, + but this allows larger range (in 64 bit) + mind you, this is proleptic Gregorian */ + int year, ytmp, dtmp, ytmpe, dtmpe; + int isleapyear; + long long t; + + if (!tm) return -1; + + year = tm->tm_year + tmstr_year; + isleapyear= (year%4==0) - (year%100==0) + (year%400==0); + + if (year<-9999 || year>9999 || + tm->tm_mon<0 || tm->tm_mon>11 || + tm->tm_mday<1 || tm->tm_mday>mlen[isleapyear][tm->tm_mon] || + tm->tm_hour<0 || tm->tm_hour>23 || + tm->tm_min<0 || tm->tm_min>59 || + tm->tm_min<0 || tm->tm_sec>59) return -1; + +/* days between 'current year' and 'epoch_year' has to be calculated + in three steps: */ + +/* 1. days between current year and 'base_year' */ + ytmp = year - base_year; + dtmp = ytmp*365 + ytmp/4 - ytmp/100 + ytmp/400; + +/* 2. days between 'epoch year' and 'base_year' */ + ytmpe = epoch_year - base_year; + dtmpe = ytmpe*365 + ytmpe/4 - ytmpe/100 + ytmpe/400; + +/* 3. days between 'current year' and 'epoch_year' */ + t = dtmp - dtmpe; + + t += msum[isleapyear][tm->tm_mon]; + t += tm->tm_mday-1; + + tm->tm_wday = (t+4)%7;/* 0..6=Sun..Sat; adding 4 to adjust 1970.01.01.=Thursday; */ + if (tm->tm_wday<0) tm->tm_wday += 7; + tm->tm_yday = msum[isleapyear][tm->tm_mon] + tm->tm_mday-1; + tm->tm_isdst= 0; + + t = t*24 + tm->tm_hour; + t = t*60 + tm->tm_min; + t = t*60 + tm->tm_sec; + +#if LONG_MAX == 2147483647L + if (tLONG_MAX) { + t= -1; + } +#endif + + return t; +} + +} // namespace Time +} // namespace Aws diff --git a/tests/aws-cpp-sdk-core-tests/utils/FileSystemUtilsTest.cpp b/tests/aws-cpp-sdk-core-tests/utils/FileSystemUtilsTest.cpp index d54c8afb4741..feadde87dfe9 100644 --- a/tests/aws-cpp-sdk-core-tests/utils/FileSystemUtilsTest.cpp +++ b/tests/aws-cpp-sdk-core-tests/utils/FileSystemUtilsTest.cpp @@ -12,6 +12,9 @@ #include #include #endif +#ifdef _AIX +#define NAME_MAX 255 +#endif using namespace Aws; using namespace Aws::Utils; From 5d243325499c12ef5910436cafc4e31126ad0eac Mon Sep 17 00:00:00 2001 From: Parth Patel Date: Wed, 11 Feb 2026 06:50:02 -0600 Subject: [PATCH 2/2] Addressed the review comments (#3714) --- .../source/platform/aix/TimeHelper.cpp | 53 ++++++++++++++----- 1 file changed, 39 insertions(+), 14 deletions(-) diff --git a/src/aws-cpp-sdk-core/source/platform/aix/TimeHelper.cpp b/src/aws-cpp-sdk-core/source/platform/aix/TimeHelper.cpp index 9bebab39ba2f..8ab073c02238 100644 --- a/src/aws-cpp-sdk-core/source/platform/aix/TimeHelper.cpp +++ b/src/aws-cpp-sdk-core/source/platform/aix/TimeHelper.cpp @@ -1,15 +1,36 @@ -/* TimeHelper.cpp - timegm() implementation for AIX platform. +/* + This is free and unencumbered software released into the public domain. + + Anyone is free to copy, modify, publish, use, compile, sell, or + distribute this software, either in source code form or as a compiled + binary, for any purpose, commercial or non-commercial, and by any + means. + + In jurisdictions that recognize copyright laws, the author or authors + of this software dedicate any and all copyright interest in the + software to the public domain. We make this dedication for the benefit + of the public at large and to the detriment of our heirs and + successors. We intend this dedication to be an overt act of + relinquishment in perpetuity of all present and future rights to this + software under copyright law. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR + OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + OTHER DEALINGS IN THE SOFTWARE. + + For more information, please refer to + */ -#include +/* timegm() implementation for AIX platform. */ #include -namespace Aws -{ -namespace Time -{ +time_t timegm (struct tm *); time_t timegm (struct tm *tm) { static const int msum [2][12] = { @@ -29,7 +50,10 @@ time_t timegm (struct tm *tm) int isleapyear; long long t; - if (!tm) return -1; + if (!tm){ + errno = EINVAL; + return (time_t)-1; + } year = tm->tm_year + tmstr_year; isleapyear= (year%4==0) - (year%100==0) + (year%400==0); @@ -39,8 +63,11 @@ time_t timegm (struct tm *tm) tm->tm_mday<1 || tm->tm_mday>mlen[isleapyear][tm->tm_mon] || tm->tm_hour<0 || tm->tm_hour>23 || tm->tm_min<0 || tm->tm_min>59 || - tm->tm_min<0 || tm->tm_sec>59) return -1; + tm->tm_sec<0 || tm->tm_sec>59) { + errno = EINVAL; + return (time_t)-1; + } /* days between 'current year' and 'epoch_year' has to be calculated in three steps: */ @@ -69,12 +96,10 @@ time_t timegm (struct tm *tm) #if LONG_MAX == 2147483647L if (tLONG_MAX) { - t= -1; + errno = EOVERFLOW; + return (time_t)-1; } #endif - return t; + return (time_t)t; } - -} // namespace Time -} // namespace Aws