michael@0: // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. michael@0: // Use of this source code is governed by a BSD-style license that can be michael@0: // found in the LICENSE file. michael@0: michael@0: #ifndef BASE_PORT_H_ michael@0: #define BASE_PORT_H_ michael@0: michael@0: #include michael@0: #include "build/build_config.h" michael@0: michael@0: #ifdef COMPILER_MSVC michael@0: #define GG_LONGLONG(x) x##I64 michael@0: #define GG_ULONGLONG(x) x##UI64 michael@0: #else michael@0: #define GG_LONGLONG(x) x##LL michael@0: #define GG_ULONGLONG(x) x##ULL michael@0: #endif michael@0: michael@0: // Per C99 7.8.14, define __STDC_CONSTANT_MACROS before including michael@0: // to get the INTn_C and UINTn_C macros for integer constants. It's difficult michael@0: // to guarantee any specific ordering of header includes, so it's difficult to michael@0: // guarantee that the INTn_C macros can be defined by including at michael@0: // any specific point. Provide GG_INTn_C macros instead. michael@0: michael@0: #define GG_INT8_C(x) (x) michael@0: #define GG_INT16_C(x) (x) michael@0: #define GG_INT32_C(x) (x) michael@0: #define GG_INT64_C(x) GG_LONGLONG(x) michael@0: michael@0: #define GG_UINT8_C(x) (x ## U) michael@0: #define GG_UINT16_C(x) (x ## U) michael@0: #define GG_UINT32_C(x) (x ## U) michael@0: #define GG_UINT64_C(x) GG_ULONGLONG(x) michael@0: michael@0: namespace base { michael@0: michael@0: // It's possible for functions that use a va_list, such as StringPrintf, to michael@0: // invalidate the data in it upon use. The fix is to make a copy of the michael@0: // structure before using it and use that copy instead. va_copy is provided michael@0: // for this purpose. MSVC does not provide va_copy, so define an michael@0: // implementation here. It is not guaranteed that assignment is a copy, so the michael@0: // StringUtil.VariableArgsFunc unit test tests this capability. michael@0: michael@0: // The C standard says that va_copy is a "macro", not a function. Trying to michael@0: // use va_list as ref args to a function, as above, breaks some machines. michael@0: # if defined(COMPILER_GCC) michael@0: # define base_va_copy(_a, _b) ::va_copy(_a, _b) michael@0: # elif defined(COMPILER_MSVC) michael@0: # define base_va_copy(_a, _b) (_a = _b) michael@0: # else michael@0: # error No va_copy for your compiler michael@0: # endif michael@0: michael@0: } // namespace base michael@0: michael@0: // Define an OS-neutral wrapper for shared library entry points michael@0: #if defined(OS_WIN) michael@0: #define API_CALL __stdcall michael@0: #elif defined(OS_LINUX) || defined(OS_MACOSX) michael@0: #define API_CALL michael@0: #endif michael@0: michael@0: #endif // BASE_PORT_H_