-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Necessary changes were made in the aws-sdk-cpp to support AIX OS. #3714
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. im confused here are you trying to implement
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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] = { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 */
}
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
| { 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; */ | ||
sbiscigl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 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; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,6 +12,9 @@ | |
| #include <unistd.h> | ||
| #include <climits> | ||
| #endif | ||
| #ifdef _AIX | ||
| #define NAME_MAX 255 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what is this define used for?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NAME_MAX is used in the same file at line 281. |
||
| #endif | ||
|
|
||
| using namespace Aws; | ||
| using namespace Aws::Utils; | ||
|
|
||
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.