Skip to content

Necessary changes were made in the aws-sdk-cpp to support AIX OS.#3714

Open
patel-parth7 wants to merge 3 commits intoaws:mainfrom
patel-parth7:issue_3440
Open

Necessary changes were made in the aws-sdk-cpp to support AIX OS.#3714
patel-parth7 wants to merge 3 commits intoaws:mainfrom
patel-parth7:issue_3440

Conversation

@patel-parth7
Copy link

*Issue #3440 *

Description of changes:

Check all that applies:

  • [ Yes] Did a review by yourself.
  • Added proper tests to cover this PR. (If tests are not applicable, explain.)
  • [ NA] Checked if this PR is a breaking (APIs have been changed) change.
  • Checked if this PR will not introduce cross-platform inconsistent behavior.
  • [Yes] Checked if this PR would require a ReadMe/Wiki update.
    Require to add support for AIX platform.

Check which platforms you have built SDK on to verify the correctness of this PR.

  • Linux
  • Windows
  • Android
  • MacOS
  • IOS
  • [AIX ] Other Platforms

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

{
time_t timegm (struct tm *tm)
{
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.

{
namespace Time
{
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

Copy link
Contributor

Choose a reason for hiding this comment

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

so i don't really like this, this is sort of tricking the runtime into thinking timegm exists. what you should do is create a implementation specific to AIX for the sdk interface. i.e. in the platform specific directory. create a aix directory. and then implement Time.cpp using AIX interfaces i.e.

/**
 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
 * SPDX-License-Identifier: Apache-2.0.
 */

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

#include <time.h>

namespace Aws
{
namespace Time
{

time_t TimeGM(struct tm* const t)
{
  //TODO: your AIX code
}

void LocalTime(tm* t, std::time_t time)
{
  //TODO: your AIX code
}

void GMTime(tm* t, std::time_t time)
{
  //TODO: your AIX code
}

} // namespace Time
} // namespace Aws

This way you aren't messing with the runtime or trying to piggy back back off of the linux implementation. the platform support is cleaner and compartmentalized.

# 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.

#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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants