diff options
-rw-r--r-- | base/os_compat_nacl.cc | 27 | ||||
-rw-r--r-- | base/os_compat_nacl.h | 15 | ||||
-rw-r--r-- | base/shared_memory.h | 3 | ||||
-rw-r--r-- | base/third_party/nspr/prtime.cc | 2 | ||||
-rw-r--r-- | base/threading/platform_thread_posix.cc | 5 | ||||
-rw-r--r-- | base/time_posix.cc | 2 |
6 files changed, 53 insertions, 1 deletions
diff --git a/base/os_compat_nacl.cc b/base/os_compat_nacl.cc new file mode 100644 index 0000000..d38f9e0 --- /dev/null +++ b/base/os_compat_nacl.cc @@ -0,0 +1,27 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "base/os_compat_nacl.h" + +#include <stdlib.h> +#include <time.h> + +extern "C" { +// Native Client has no timegm(). +time_t timegm(struct tm* tm) { + time_t ret; + char* tz; + tz = getenv("TZ"); + setenv("TZ", "", 1); + tzset(); + ret = mktime(tm); + if (tz) + setenv("TZ", tz, 1); + else + unsetenv("TZ"); + tzset(); + return ret; +} +} // extern "C" + diff --git a/base/os_compat_nacl.h b/base/os_compat_nacl.h new file mode 100644 index 0000000..3913fcb --- /dev/null +++ b/base/os_compat_nacl.h @@ -0,0 +1,15 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef BASE_OS_COMPAT_NACL_H_ +#define BASE_OS_COMPAT_NACL_H_ +#pragma once + +#include <sys/types.h> + +// NaCl has no timegm(). +extern "C" time_t timegm(struct tm* const t); + +#endif // BASE_OS_COMPAT_NACL_H_ + diff --git a/base/shared_memory.h b/base/shared_memory.h index 8cb27ec..298baa6 100644 --- a/base/shared_memory.h +++ b/base/shared_memory.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -9,6 +9,7 @@ #include "build/build_config.h" #if defined(OS_POSIX) +#include <stdio.h> #include <sys/types.h> #include <semaphore.h> #include "base/file_descriptor_posix.h" diff --git a/base/third_party/nspr/prtime.cc b/base/third_party/nspr/prtime.cc index 61b7303..8075795 100644 --- a/base/third_party/nspr/prtime.cc +++ b/base/third_party/nspr/prtime.cc @@ -74,6 +74,8 @@ #elif defined(OS_ANDROID) #include <ctype.h> #include "base/os_compat_android.h" // For timegm() +#elif defined(OS_NACL) +#include "base/os_compat_nacl.h" // For timegm() #endif #include <errno.h> /* for EINVAL */ #include <time.h> diff --git a/base/threading/platform_thread_posix.cc b/base/threading/platform_thread_posix.cc index 978b21b..cfcabe5 100644 --- a/base/threading/platform_thread_posix.cc +++ b/base/threading/platform_thread_posix.cc @@ -30,6 +30,11 @@ #include "base/android/jni_android.h" #endif +// TODO(bbudge) Use time.h when NaCl toolchain supports _POSIX_TIMERS +#if defined(OS_NACL) +#include <sys/nacl_syscalls.h> +#endif + namespace base { #if defined(OS_MACOSX) diff --git a/base/time_posix.cc b/base/time_posix.cc index be99971..829c000 100644 --- a/base/time_posix.cc +++ b/base/time_posix.cc @@ -15,6 +15,8 @@ #if defined(OS_ANDROID) #include "base/os_compat_android.h" +#elif defined(OS_NACL) +#include "base/os_compat_nacl.h" #endif namespace base { |