ipc/chromium/src/base/port.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
michael@0 2 // Use of this source code is governed by a BSD-style license that can be
michael@0 3 // found in the LICENSE file.
michael@0 4
michael@0 5 #ifndef BASE_PORT_H_
michael@0 6 #define BASE_PORT_H_
michael@0 7
michael@0 8 #include <stdarg.h>
michael@0 9 #include "build/build_config.h"
michael@0 10
michael@0 11 #ifdef COMPILER_MSVC
michael@0 12 #define GG_LONGLONG(x) x##I64
michael@0 13 #define GG_ULONGLONG(x) x##UI64
michael@0 14 #else
michael@0 15 #define GG_LONGLONG(x) x##LL
michael@0 16 #define GG_ULONGLONG(x) x##ULL
michael@0 17 #endif
michael@0 18
michael@0 19 // Per C99 7.8.14, define __STDC_CONSTANT_MACROS before including <stdint.h>
michael@0 20 // to get the INTn_C and UINTn_C macros for integer constants. It's difficult
michael@0 21 // to guarantee any specific ordering of header includes, so it's difficult to
michael@0 22 // guarantee that the INTn_C macros can be defined by including <stdint.h> at
michael@0 23 // any specific point. Provide GG_INTn_C macros instead.
michael@0 24
michael@0 25 #define GG_INT8_C(x) (x)
michael@0 26 #define GG_INT16_C(x) (x)
michael@0 27 #define GG_INT32_C(x) (x)
michael@0 28 #define GG_INT64_C(x) GG_LONGLONG(x)
michael@0 29
michael@0 30 #define GG_UINT8_C(x) (x ## U)
michael@0 31 #define GG_UINT16_C(x) (x ## U)
michael@0 32 #define GG_UINT32_C(x) (x ## U)
michael@0 33 #define GG_UINT64_C(x) GG_ULONGLONG(x)
michael@0 34
michael@0 35 namespace base {
michael@0 36
michael@0 37 // It's possible for functions that use a va_list, such as StringPrintf, to
michael@0 38 // invalidate the data in it upon use. The fix is to make a copy of the
michael@0 39 // structure before using it and use that copy instead. va_copy is provided
michael@0 40 // for this purpose. MSVC does not provide va_copy, so define an
michael@0 41 // implementation here. It is not guaranteed that assignment is a copy, so the
michael@0 42 // StringUtil.VariableArgsFunc unit test tests this capability.
michael@0 43
michael@0 44 // The C standard says that va_copy is a "macro", not a function. Trying to
michael@0 45 // use va_list as ref args to a function, as above, breaks some machines.
michael@0 46 # if defined(COMPILER_GCC)
michael@0 47 # define base_va_copy(_a, _b) ::va_copy(_a, _b)
michael@0 48 # elif defined(COMPILER_MSVC)
michael@0 49 # define base_va_copy(_a, _b) (_a = _b)
michael@0 50 # else
michael@0 51 # error No va_copy for your compiler
michael@0 52 # endif
michael@0 53
michael@0 54 } // namespace base
michael@0 55
michael@0 56 // Define an OS-neutral wrapper for shared library entry points
michael@0 57 #if defined(OS_WIN)
michael@0 58 #define API_CALL __stdcall
michael@0 59 #elif defined(OS_LINUX) || defined(OS_MACOSX)
michael@0 60 #define API_CALL
michael@0 61 #endif
michael@0 62
michael@0 63 #endif // BASE_PORT_H_

mercurial