Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2851)

Unified Diff: base/time/time_posix.cc

Issue 2807463004: GN: aix port along with linux_s390x, linux_ppc64 and linux_ppc64le support. (Closed)
Patch Set: removed the changes from //base/BUILD.gn Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/threading/platform_thread_posix.cc ('k') | base/trace_event/process_memory_dump.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/time/time_posix.cc
diff --git a/base/time/time_posix.cc b/base/time/time_posix.cc
index 2cceb0c610c27cd65f5797aec1e0547dd4888d41..c4138c3b487539a02d19880b72709fd4237f4cba 100644
--- a/base/time/time_posix.cc
+++ b/base/time/time_posix.cc
@@ -61,6 +61,48 @@ void SysTimeToTimeStruct(SysTime t, struct tm* timestruct, bool is_local) {
gmtime64_r(&t, timestruct);
}
+#elif defined(OS_AIX)
+
+// The function timegm is not available on AIX.
+time_t aix_timegm(struct tm* tm) {
+ time_t ret;
+ char* tz;
+
+ tz = getenv("TZ");
+ if (tz) {
+ tz = strdup(tz);
+ }
+ setenv("TZ", "GMT0", 1);
+ tzset();
+ ret = mktime(tm);
+ if (tz) {
+ setenv("TZ", tz, 1);
+ free(tz);
+ } else {
+ unsetenv("TZ");
+ }
+ tzset();
+ return ret;
+}
+
+typedef time_t SysTime;
+
+SysTime SysTimeFromTimeStruct(struct tm* timestruct, bool is_local) {
+ base::AutoLock locked(*GetSysTimeToTimeStructLock());
+ if (is_local)
+ return mktime(timestruct);
+ else
+ return aix_timegm(timestruct);
+}
+
+void SysTimeToTimeStruct(SysTime t, struct tm* timestruct, bool is_local) {
+ base::AutoLock locked(*GetSysTimeToTimeStructLock());
+ if (is_local)
+ localtime_r(&t, timestruct);
+ else
+ gmtime_r(&t, timestruct);
+}
+
#else // OS_ANDROID && !__LP64__
typedef time_t SysTime;
@@ -248,7 +290,7 @@ bool Time::FromExploded(bool is_local, const Exploded& exploded, Time* time) {
timestruct.tm_wday = exploded.day_of_week; // mktime/timegm ignore this
timestruct.tm_yday = 0; // mktime/timegm ignore this
timestruct.tm_isdst = -1; // attempt to figure it out
-#if !defined(OS_NACL) && !defined(OS_SOLARIS)
+#if !defined(OS_NACL) && !defined(OS_SOLARIS) && !defined(OS_AIX)
timestruct.tm_gmtoff = 0; // not a POSIX field, so mktime/timegm ignore
timestruct.tm_zone = NULL; // not a POSIX field, so mktime/timegm ignore
#endif
« no previous file with comments | « base/threading/platform_thread_posix.cc ('k') | base/trace_event/process_memory_dump.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698