Necessary changes were made in the aws-sdk-cpp to support AIX OS.#3714
Necessary changes were made in the aws-sdk-cpp to support AIX OS.#3714patel-parth7 wants to merge 3 commits intoaws:mainfrom
Conversation
| { | ||
| time_t timegm (struct tm *tm) | ||
| { | ||
| static const int msum [2][12] = { |
There was a problem hiding this comment.
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 */
}There was a problem hiding this comment.
As mentioned in the previous comment, I will not use any C++ constructs.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
I will implement timegm() as a standalone C-style API, so I will not use any C++ constructs.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 AwsThis 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") |
There was a problem hiding this comment.
why does this need to be moved?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
what is this define used for?
There was a problem hiding this comment.
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.
*Issue #3440 *
Description of changes:
Check all that applies:
Require to add support for AIX platform.
Check which platforms you have built SDK on to verify the correctness of this PR.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.