Skip to content
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")
Comment thread
sbiscigl marked this conversation as resolved.
# use response files to prevent command-line-too-big errors for large libraries like iam
set(CMAKE_CXX_USE_RESPONSE_FILE_FOR_OBJECTS 1)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

why do these cmake flags need to be turned off for AIX?

Copy link
Copy Markdown
Contributor 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; therefore, it must be blocked.

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
80 changes: 80 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,80 @@
/* TimeHelper.cpp
Comment thread
sbiscigl marked this conversation as resolved.
Outdated
timegm() implementation for AIX platform.
*/

#include <aws/core/platform/Time.h>

#include <time.h>

namespace Aws
{
namespace Time
{
time_t timegm (struct tm *tm)
Comment thread
sbiscigl marked this conversation as resolved.
Outdated
{
static const int msum [2][12] = {
Comment thread
sbiscigl marked this conversation as resolved.
Outdated
{ 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;
Comment thread
sbiscigl marked this conversation as resolved.
Outdated

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;
Comment thread
sbiscigl marked this conversation as resolved.
Outdated

/* 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; */
Comment thread
sbiscigl marked this conversation as resolved.
Outdated
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) {
t= -1;
}
#endif

return t;
}

} // namespace Time
} // namespace Aws
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
Copy Markdown
Collaborator

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
Copy Markdown
Contributor 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.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

on line 281 NAME_MAX is used as

#if defined(HAS_PATHCONF)
    errno = 0;
    long longNameLength = pathconf(".", _PC_NAME_MAX);
    ASSERT_TRUE(longNameLength >= 0 || errno == 0);
    if (longNameLength <= 0)
    {
        longNameLength = NAME_MAX;
    }
#else
    // Path compoments on Windows can't exceed 255(_MAX_FNAME) chars.
    // To cover the Windows case where the path with length over 260(MAX_PATH) chars,
    // set one path part to be 255 characters, so dir1/dir2/dir3/[longDirName] is over 260 chars.
    long longNameLength = 255;
#endif

so which one does AIX fall into? does it have HAS_PATHCONF in which case why can you not use it? if it does not why does the default value of 255 not work for you?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

AIX defines HAS_PATHCONF, so the code enters the corresponding conditional block. However, the NAME_MAX macro is not defined in the AIX system header (sys/limits.h). Therefore, this macro must be explicitly defined for AIX.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Please let me know if any action is required from my side regarding these changes.

#endif

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