security/sandbox/chromium/base/format_macros.h

Wed, 31 Dec 2014 07:16:47 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:16:47 +0100
branch
TOR_BUG_9701
changeset 3
141e0f1194b1
permissions
-rw-r--r--

Revert simplistic fix pending revisit of Mozilla integration attempt.

michael@0 1 // Copyright (c) 2009 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_FORMAT_MACROS_H_
michael@0 6 #define BASE_FORMAT_MACROS_H_
michael@0 7
michael@0 8 // This file defines the format macros for some integer types.
michael@0 9
michael@0 10 // To print a 64-bit value in a portable way:
michael@0 11 // int64_t value;
michael@0 12 // printf("xyz:%" PRId64, value);
michael@0 13 // The "d" in the macro corresponds to %d; you can also use PRIu64 etc.
michael@0 14 //
michael@0 15 // For wide strings, prepend "Wide" to the macro:
michael@0 16 // int64_t value;
michael@0 17 // StringPrintf(L"xyz: %" WidePRId64, value);
michael@0 18 //
michael@0 19 // To print a size_t value in a portable way:
michael@0 20 // size_t size;
michael@0 21 // printf("xyz: %" PRIuS, size);
michael@0 22 // The "u" in the macro corresponds to %u, and S is for "size".
michael@0 23
michael@0 24 #include "build/build_config.h"
michael@0 25
michael@0 26 #if defined(OS_POSIX)
michael@0 27
michael@0 28 #if (defined(_INTTYPES_H) || defined(_INTTYPES_H_)) && !defined(PRId64)
michael@0 29 #error "inttypes.h has already been included before this header file, but "
michael@0 30 #error "without __STDC_FORMAT_MACROS defined."
michael@0 31 #endif
michael@0 32
michael@0 33 #if !defined(__STDC_FORMAT_MACROS)
michael@0 34 #define __STDC_FORMAT_MACROS
michael@0 35 #endif
michael@0 36
michael@0 37 #include <inttypes.h>
michael@0 38
michael@0 39 // GCC will concatenate wide and narrow strings correctly, so nothing needs to
michael@0 40 // be done here.
michael@0 41 #define WidePRId64 PRId64
michael@0 42 #define WidePRIu64 PRIu64
michael@0 43 #define WidePRIx64 PRIx64
michael@0 44
michael@0 45 #if !defined(PRIuS)
michael@0 46 #define PRIuS "zu"
michael@0 47 #endif
michael@0 48
michael@0 49 #else // OS_WIN
michael@0 50
michael@0 51 #if !defined(PRId64)
michael@0 52 #define PRId64 "I64d"
michael@0 53 #endif
michael@0 54
michael@0 55 #if !defined(PRIu64)
michael@0 56 #define PRIu64 "I64u"
michael@0 57 #endif
michael@0 58
michael@0 59 #if !defined(PRIx64)
michael@0 60 #define PRIx64 "I64x"
michael@0 61 #endif
michael@0 62
michael@0 63 #define WidePRId64 L"I64d"
michael@0 64 #define WidePRIu64 L"I64u"
michael@0 65 #define WidePRIx64 L"I64x"
michael@0 66
michael@0 67 #if !defined(PRIuS)
michael@0 68 #define PRIuS "Iu"
michael@0 69 #endif
michael@0 70
michael@0 71 #endif
michael@0 72
michael@0 73 #endif // BASE_FORMAT_MACROS_H_

mercurial