1 // Copied from Chromium: https://src.chromium.org/svn/trunk/src/base/os_compat_android.cc
3 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
4 // Use of this source code is governed by a BSD-style license that can be
5 // found in the LICENSE file.
7 #if defined(__ANDROID__)
9 #include <asm/unistd.h>
13 #include <sys/syscall.h>
15 #if !defined(__LP64__)
19 #if !defined(__LP64__)
20 // 32-bit Android has only timegm64() and not timegm().
21 // We replicate the behaviour of timegm() when the result overflows time_t.
22 time_t timegm(struct tm* const t) {
23 // time_t is signed on Android.
24 static const time_t kTimeMax = ~(1L << (sizeof(time_t) * CHAR_BIT - 1));
25 static const time_t kTimeMin = (1L << (sizeof(time_t) * CHAR_BIT - 1));
26 time64_t result = timegm64(t);
27 if (result < kTimeMin || result > kTimeMax)