diff options
author | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-15 06:15:04 +0000 |
---|---|---|
committer | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-15 06:15:04 +0000 |
commit | 0c6f3b0c5f6409496fcecab0819b062f36d9b113 (patch) | |
tree | aa589efa568cd3792d1890ba37a8644491ec51f0 /base | |
parent | 71cb4cd0c41e892aac8e29fd52cd0f935573aa36 (diff) | |
download | chromium_src-0c6f3b0c5f6409496fcecab0819b062f36d9b113.zip chromium_src-0c6f3b0c5f6409496fcecab0819b062f36d9b113.tar.gz chromium_src-0c6f3b0c5f6409496fcecab0819b062f36d9b113.tar.bz2 |
OpenBSD: make it possible to build libbase.a.
This still needs a little hack. I had to run gyp_chromium this way:
CHROMIUM_GYP_FILE="base/base.gyp" build/gyp_chromium -DOS=openbsd \
-Duse_gnome_keyring=0 -Duse_system_libevent=1
And then run "gmake base".
BUG=none
Review URL: http://codereview.chromium.org/6840023
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@81709 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r-- | base/atomicops.h | 6 | ||||
-rw-r--r-- | base/atomicops_internals_atomicword_compat.h | 101 | ||||
-rw-r--r-- | base/atomicops_internals_x86_macosx.h | 85 | ||||
-rw-r--r-- | base/debug/debugger_posix.cc | 1 | ||||
-rw-r--r-- | base/debug/stack_trace_posix.cc | 1 | ||||
-rw-r--r-- | base/string_util_posix.h | 9 |
6 files changed, 118 insertions, 85 deletions
diff --git a/base/atomicops.h b/base/atomicops.h index 1f656e7..5b2b9dd 100644 --- a/base/atomicops.h +++ b/base/atomicops.h @@ -145,4 +145,10 @@ Atomic64 Release_Load(volatile const Atomic64* ptr); #error "Atomic operations are not supported on your platform" #endif +// On some platforms we need additional declarations to make +// AtomicWord compatible with our other Atomic* types. +#if defined(OS_MACOSX) || defined(OS_OPENBSD) +#include "base/atomicops_internals_atomicword_compat.h" +#endif + #endif // BASE_ATOMICOPS_H_ diff --git a/base/atomicops_internals_atomicword_compat.h b/base/atomicops_internals_atomicword_compat.h new file mode 100644 index 0000000..8382fe1 --- /dev/null +++ b/base/atomicops_internals_atomicword_compat.h @@ -0,0 +1,101 @@ +// Copyright (c) 2011 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. + +// This file is an internal atomic implementation, use base/atomicops.h instead. + +#ifndef BASE_ATOMICOPS_INTERNALS_ATOMICWORD_COMPAT_H_ +#define BASE_ATOMICOPS_INTERNALS_ATOMICWORD_COMPAT_H_ +#pragma once + +// AtomicWord is a synonym for intptr_t, and Atomic32 is a synonym for int32, +// which in turn means int. On some LP32 platforms, intptr_t is an int, but +// on others, it's a long. When AtomicWord and Atomic32 are based on different +// fundamental types, their pointers are incompatible. +// +// This file defines function overloads to allow both AtomicWord and Atomic32 +// data to be used with this interface. +// +// On LP64 platforms, AtomicWord and Atomic64 are both always long, +// so this problem doesn't occur. + +#if !defined(ARCH_CPU_64_BITS) + +namespace base { +namespace subtle { + +inline AtomicWord NoBarrier_CompareAndSwap(volatile AtomicWord* ptr, + AtomicWord old_value, + AtomicWord new_value) { + return NoBarrier_CompareAndSwap( + reinterpret_cast<volatile Atomic32*>(ptr), old_value, new_value); +} + +inline AtomicWord NoBarrier_AtomicExchange(volatile AtomicWord* ptr, + AtomicWord new_value) { + return NoBarrier_AtomicExchange( + reinterpret_cast<volatile Atomic32*>(ptr), new_value); +} + +inline AtomicWord NoBarrier_AtomicIncrement(volatile AtomicWord* ptr, + AtomicWord increment) { + return NoBarrier_AtomicIncrement( + reinterpret_cast<volatile Atomic32*>(ptr), increment); +} + +inline AtomicWord Barrier_AtomicIncrement(volatile AtomicWord* ptr, + AtomicWord increment) { + return Barrier_AtomicIncrement( + reinterpret_cast<volatile Atomic32*>(ptr), increment); +} + +inline AtomicWord Acquire_CompareAndSwap(volatile AtomicWord* ptr, + AtomicWord old_value, + AtomicWord new_value) { + return base::subtle::Acquire_CompareAndSwap( + reinterpret_cast<volatile Atomic32*>(ptr), old_value, new_value); +} + +inline AtomicWord Release_CompareAndSwap(volatile AtomicWord* ptr, + AtomicWord old_value, + AtomicWord new_value) { + return base::subtle::Release_CompareAndSwap( + reinterpret_cast<volatile Atomic32*>(ptr), old_value, new_value); +} + +inline void NoBarrier_Store(volatile AtomicWord *ptr, AtomicWord value) { + NoBarrier_Store( + reinterpret_cast<volatile Atomic32*>(ptr), value); +} + +inline void Acquire_Store(volatile AtomicWord* ptr, AtomicWord value) { + return base::subtle::Acquire_Store( + reinterpret_cast<volatile Atomic32*>(ptr), value); +} + +inline void Release_Store(volatile AtomicWord* ptr, AtomicWord value) { + return base::subtle::Release_Store( + reinterpret_cast<volatile Atomic32*>(ptr), value); +} + +inline AtomicWord NoBarrier_Load(volatile const AtomicWord *ptr) { + return NoBarrier_Load( + reinterpret_cast<volatile const Atomic32*>(ptr)); +} + +inline AtomicWord Acquire_Load(volatile const AtomicWord* ptr) { + return base::subtle::Acquire_Load( + reinterpret_cast<volatile const Atomic32*>(ptr)); +} + +inline AtomicWord Release_Load(volatile const AtomicWord* ptr) { + return base::subtle::Release_Load( + reinterpret_cast<volatile const Atomic32*>(ptr)); +} + +} // namespace base::subtle +} // namespace base + +#endif // !defined(ARCH_CPU_64_BITS) + +#endif // BASE_ATOMICOPS_INTERNALS_ATOMICWORD_COMPAT_H_ diff --git a/base/atomicops_internals_x86_macosx.h b/base/atomicops_internals_x86_macosx.h index 29e58e3..4b7cec8 100644 --- a/base/atomicops_internals_x86_macosx.h +++ b/base/atomicops_internals_x86_macosx.h @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -192,89 +192,6 @@ inline Atomic64 Release_Load(volatile const Atomic64 *ptr) { #endif // defined(__LP64__) -// MacOS uses long for intptr_t, AtomicWord and Atomic32 are always different -// on the Mac, even when they are the same size. We need to explicitly cast -// from AtomicWord to Atomic32 to implement the AtomicWord interface. -// When in 64-bit mode, AtomicWord is the same as Atomic64, so we need not -// add duplicate definitions. -#ifndef __LP64__ -#define AtomicWordCastType Atomic32 - -inline AtomicWord NoBarrier_CompareAndSwap(volatile AtomicWord* ptr, - AtomicWord old_value, - AtomicWord new_value) { - return NoBarrier_CompareAndSwap( - reinterpret_cast<volatile AtomicWordCastType*>(ptr), - old_value, new_value); -} - -inline AtomicWord NoBarrier_AtomicExchange(volatile AtomicWord* ptr, - AtomicWord new_value) { - return NoBarrier_AtomicExchange( - reinterpret_cast<volatile AtomicWordCastType*>(ptr), new_value); -} - -inline AtomicWord NoBarrier_AtomicIncrement(volatile AtomicWord* ptr, - AtomicWord increment) { - return NoBarrier_AtomicIncrement( - reinterpret_cast<volatile AtomicWordCastType*>(ptr), increment); -} - -inline AtomicWord Barrier_AtomicIncrement(volatile AtomicWord* ptr, - AtomicWord increment) { - return Barrier_AtomicIncrement( - reinterpret_cast<volatile AtomicWordCastType*>(ptr), increment); -} - -inline AtomicWord Acquire_CompareAndSwap(volatile AtomicWord* ptr, - AtomicWord old_value, - AtomicWord new_value) { - return base::subtle::Acquire_CompareAndSwap( - reinterpret_cast<volatile AtomicWordCastType*>(ptr), - old_value, new_value); -} - -inline AtomicWord Release_CompareAndSwap(volatile AtomicWord* ptr, - AtomicWord old_value, - AtomicWord new_value) { - return base::subtle::Release_CompareAndSwap( - reinterpret_cast<volatile AtomicWordCastType*>(ptr), - old_value, new_value); -} - -inline void NoBarrier_Store(volatile AtomicWord *ptr, AtomicWord value) { - NoBarrier_Store( - reinterpret_cast<volatile AtomicWordCastType*>(ptr), value); -} - -inline void Acquire_Store(volatile AtomicWord* ptr, AtomicWord value) { - return base::subtle::Acquire_Store( - reinterpret_cast<volatile AtomicWordCastType*>(ptr), value); -} - -inline void Release_Store(volatile AtomicWord* ptr, AtomicWord value) { - return base::subtle::Release_Store( - reinterpret_cast<volatile AtomicWordCastType*>(ptr), value); -} - -inline AtomicWord NoBarrier_Load(volatile const AtomicWord *ptr) { - return NoBarrier_Load( - reinterpret_cast<volatile const AtomicWordCastType*>(ptr)); -} - -inline AtomicWord Acquire_Load(volatile const AtomicWord* ptr) { - return base::subtle::Acquire_Load( - reinterpret_cast<volatile const AtomicWordCastType*>(ptr)); -} - -inline AtomicWord Release_Load(volatile const AtomicWord* ptr) { - return base::subtle::Release_Load( - reinterpret_cast<volatile const AtomicWordCastType*>(ptr)); -} - -#undef AtomicWordCastType -#endif - } // namespace base::subtle } // namespace base diff --git a/base/debug/debugger_posix.cc b/base/debug/debugger_posix.cc index dfc3d0a..bf90a0f 100644 --- a/base/debug/debugger_posix.cc +++ b/base/debug/debugger_posix.cc @@ -10,6 +10,7 @@ #include <fcntl.h> #include <stdio.h> #include <stdlib.h> +#include <sys/param.h> #include <sys/stat.h> #if !defined(OS_NACL) #include <sys/sysctl.h> diff --git a/base/debug/stack_trace_posix.cc b/base/debug/stack_trace_posix.cc index 50ff113..c405aa2 100644 --- a/base/debug/stack_trace_posix.cc +++ b/base/debug/stack_trace_posix.cc @@ -9,6 +9,7 @@ #include <fcntl.h> #include <stdio.h> #include <stdlib.h> +#include <sys/param.h> #include <sys/stat.h> #include <sys/sysctl.h> #include <sys/types.h> diff --git a/base/string_util_posix.h b/base/string_util_posix.h index 6053ada..d238f7f 100644 --- a/base/string_util_posix.h +++ b/base/string_util_posix.h @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -44,8 +44,15 @@ inline int strncmp16(const char16* s1, const char16* s2, size_t count) { inline int vswprintf(wchar_t* buffer, size_t size, const wchar_t* format, va_list arguments) { +#if defined(OS_OPENBSD) + // TODO(phajdan.jr): There is a patch to add vswprintf to OpenBSD, + // http://marc.info/?l=openbsd-tech&m=130003157729839&w=2 + NOTIMPLEMENTED(); + return -1; +#else DCHECK(IsWprintfFormatPortable(format)); return ::vswprintf(buffer, size, format, arguments); +#endif } } // namespace base |