1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/security/sandbox/chromium/base/port.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,54 @@ 1.4 +// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1.5 +// Use of this source code is governed by a BSD-style license that can be 1.6 +// found in the LICENSE file. 1.7 + 1.8 +#ifndef BASE_PORT_H_ 1.9 +#define BASE_PORT_H_ 1.10 + 1.11 +#include <stdarg.h> 1.12 +#include "build/build_config.h" 1.13 + 1.14 +#ifdef COMPILER_MSVC 1.15 +#define GG_LONGLONG(x) x##I64 1.16 +#define GG_ULONGLONG(x) x##UI64 1.17 +#else 1.18 +#define GG_LONGLONG(x) x##LL 1.19 +#define GG_ULONGLONG(x) x##ULL 1.20 +#endif 1.21 + 1.22 +// Per C99 7.8.14, define __STDC_CONSTANT_MACROS before including <stdint.h> 1.23 +// to get the INTn_C and UINTn_C macros for integer constants. It's difficult 1.24 +// to guarantee any specific ordering of header includes, so it's difficult to 1.25 +// guarantee that the INTn_C macros can be defined by including <stdint.h> at 1.26 +// any specific point. Provide GG_INTn_C macros instead. 1.27 + 1.28 +#define GG_INT8_C(x) (x) 1.29 +#define GG_INT16_C(x) (x) 1.30 +#define GG_INT32_C(x) (x) 1.31 +#define GG_INT64_C(x) GG_LONGLONG(x) 1.32 + 1.33 +#define GG_UINT8_C(x) (x ## U) 1.34 +#define GG_UINT16_C(x) (x ## U) 1.35 +#define GG_UINT32_C(x) (x ## U) 1.36 +#define GG_UINT64_C(x) GG_ULONGLONG(x) 1.37 + 1.38 +// It's possible for functions that use a va_list, such as StringPrintf, to 1.39 +// invalidate the data in it upon use. The fix is to make a copy of the 1.40 +// structure before using it and use that copy instead. va_copy is provided 1.41 +// for this purpose. MSVC does not provide va_copy, so define an 1.42 +// implementation here. It is not guaranteed that assignment is a copy, so the 1.43 +// StringUtil.VariableArgsFunc unit test tests this capability. 1.44 +#if defined(COMPILER_GCC) 1.45 +#define GG_VA_COPY(a, b) (va_copy(a, b)) 1.46 +#elif defined(COMPILER_MSVC) 1.47 +#define GG_VA_COPY(a, b) (a = b) 1.48 +#endif 1.49 + 1.50 +// Define an OS-neutral wrapper for shared library entry points 1.51 +#if defined(OS_WIN) 1.52 +#define API_CALL __stdcall 1.53 +#else 1.54 +#define API_CALL 1.55 +#endif 1.56 + 1.57 +#endif // BASE_PORT_H_