Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 ()
Expand All @@ -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")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why does this need to be moved?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CMake response file support is not enabled on AIX, so it must be blocked.
To block it on AIX, we need to use CMAKE_SYSTEM_NAME, which is evaluated after the project() call.

# 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})

Expand Down
3 changes: 3 additions & 0 deletions src/aws-cpp-sdk-core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
105 changes: 105 additions & 0 deletions src/aws-cpp-sdk-core/source/platform/aix/TimeHelper.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
/*
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 <https://unlicense.org>
<https://github.com/lzsiga/timegm/blob/main/aix-timegm.c>
*/

/* timegm() implementation for AIX platform. */

#include <time.h>

time_t timegm (struct tm *);
time_t timegm (struct tm *tm)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

im confused here are you trying to implement timegm for SDK interface or are you trying to implement the interface for linux, and then subsequently use the linux implementation?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will implement timegm() as a standalone C-style API, so I will not use any C++ constructs.

Copy link
Contributor

@sbiscigl sbiscigl Feb 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this doesnt really answer my question -- what is it that you are trying to accomplish here. are you trying to make a SDK implementation for AIX or are you trying to implement the C API so that you can use the linux implementation. what im really getting is how does this actually work for you. are you using the linux implementation which requires timegm but using your implementation of timegm?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My plan is to use the Linux implementation, and since timegm is not available on AIX, I am providing a timegm implementation in the newly introduced TimeHelper.cpp

{
static const int msum [2][12] = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

while this pattern may be common for C. lets use C++ patterns. lets use anonymous name spacing for static. additionally lets use C++ arrays not C arrays.

namespace {
const Aws::Array<Aws::Array<int, 12>, 2> msum{{
    {{ 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 */
}};
const Aws::Array<Aws::Array<int, 12>, 2> msummlen{{
  {{ 31, 28, 31, 30,  31,  30,  31,  31,  30,  31,  30, 31}},
  {{ 31, 29, 31, 30,  31,  30,  31,  31,  30,  31,  30, 31}}
}};
const int tmstr_year= 1900; /* base of 'tm_year' in 'struct tm' */
const int epoch_year= 1970; /* unix timestamp epoch */
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 */
}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned in the previous comment, I will not use any C++ constructs.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the file is called "TimeHelper.cpp", this is a C++ source file, compiled with a C++ compiler. we wont be accepting this as-is. This is a C++ project. We use C++ constructs.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the first commit, I created a C++ source file because I was using a namespace. Since we are now keeping this as a C API, we can rename the file to .c.
Please let me know if you are okay with renaming the file and keeping the timegm implementation as C source code.

{ 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){
errno = EINVAL;
return (time_t)-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_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: */

/* 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 (t<LONG_MIN || t>LONG_MAX) {
errno = EOVERFLOW;
return (time_t)-1;
}
#endif

return (time_t)t;
}
3 changes: 3 additions & 0 deletions tests/aws-cpp-sdk-core-tests/utils/FileSystemUtilsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
#include <unistd.h>
#include <climits>
#endif
#ifdef _AIX
#define NAME_MAX 255
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this define used for?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NAME_MAX is used in the same file at line 281.
On AIX, this macro is undefined. So need to define it with respect to AIX.

#endif

using namespace Aws;
using namespace Aws::Utils;
Expand Down