ipc/chromium/src/base/port.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/ipc/chromium/src/base/port.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,63 @@
     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 +namespace base {
    1.39 +
    1.40 +// It's possible for functions that use a va_list, such as StringPrintf, to
    1.41 +// invalidate the data in it upon use.  The fix is to make a copy of the
    1.42 +// structure before using it and use that copy instead.  va_copy is provided
    1.43 +// for this purpose.  MSVC does not provide va_copy, so define an
    1.44 +// implementation here.  It is not guaranteed that assignment is a copy, so the
    1.45 +// StringUtil.VariableArgsFunc unit test tests this capability.
    1.46 +
    1.47 +// The C standard says that va_copy is a "macro", not a function.  Trying to 
    1.48 +// use va_list as ref args to a function, as above, breaks some machines.
    1.49 +#  if defined(COMPILER_GCC)
    1.50 +#    define base_va_copy(_a, _b) ::va_copy(_a, _b)
    1.51 +#  elif defined(COMPILER_MSVC)
    1.52 +#    define base_va_copy(_a, _b) (_a = _b)
    1.53 +#  else
    1.54 +#    error No va_copy for your compiler
    1.55 +#  endif
    1.56 +
    1.57 +}  // namespace base
    1.58 +
    1.59 +// Define an OS-neutral wrapper for shared library entry points
    1.60 +#if defined(OS_WIN)
    1.61 +#define API_CALL __stdcall
    1.62 +#elif defined(OS_LINUX) || defined(OS_MACOSX)
    1.63 +#define API_CALL
    1.64 +#endif
    1.65 +
    1.66 +#endif  // BASE_PORT_H_

mercurial