| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef BASE_BASICTYPES_H_ | 5 // This file contains macros and macro-like constructs (e.g., templates) that |
| 6 #define BASE_BASICTYPES_H_ | 6 // are commonly used throughout Chromium source. (It may also contain things |
| 7 // that are closely related to things that are commonly used that belong in this |
| 8 // file.) |
| 7 | 9 |
| 8 #include <limits.h> // So we can set the bounds of our types. | 10 #ifndef BASE_MACROS_H_ |
| 11 #define BASE_MACROS_H_ |
| 12 |
| 9 #include <stddef.h> // For size_t. | 13 #include <stddef.h> // For size_t. |
| 10 #include <stdint.h> // For intptr_t. | |
| 11 #include <string.h> // For memcpy. | 14 #include <string.h> // For memcpy. |
| 12 | 15 |
| 13 #include "base/compiler_specific.h" | 16 #include "base/compiler_specific.h" // For ALLOW_UNUSED. |
| 14 #include "base/port.h" // Types that only need exist on certain systems. | |
| 15 | |
| 16 typedef int8_t int8; | |
| 17 typedef uint8_t uint8; | |
| 18 typedef int16_t int16; | |
| 19 typedef int32_t int32; | |
| 20 typedef uint16_t uint16; | |
| 21 typedef uint32_t uint32; | |
| 22 | |
| 23 // TODO(vtl): Figure what's up with the 64-bit types. Can we just define them as | |
| 24 // |int64_t|/|uint64_t|? | |
| 25 // The NSPR system headers define 64-bit as |long| when possible, except on | |
| 26 // Mac OS X. In order to not have typedef mismatches, we do the same on LP64. | |
| 27 // | |
| 28 // On Mac OS X, |long long| is used for 64-bit types for compatibility with | |
| 29 // <inttypes.h> format macros even in the LP64 model. | |
| 30 #if defined(__LP64__) && !defined(OS_MACOSX) && !defined(OS_OPENBSD) | |
| 31 typedef long int64; | |
| 32 typedef unsigned long uint64; | |
| 33 #else | |
| 34 typedef long long int64; | |
| 35 typedef unsigned long long uint64; | |
| 36 #endif | |
| 37 | |
| 38 const uint8 kuint8max = (( uint8) 0xFF); | |
| 39 const uint16 kuint16max = ((uint16) 0xFFFF); | |
| 40 const uint32 kuint32max = ((uint32) 0xFFFFFFFF); | |
| 41 const uint64 kuint64max = ((uint64) GG_LONGLONG(0xFFFFFFFFFFFFFFFF)); | |
| 42 const int8 kint8min = (( int8) 0x80); | |
| 43 const int8 kint8max = (( int8) 0x7F); | |
| 44 const int16 kint16min = (( int16) 0x8000); | |
| 45 const int16 kint16max = (( int16) 0x7FFF); | |
| 46 const int32 kint32min = (( int32) 0x80000000); | |
| 47 const int32 kint32max = (( int32) 0x7FFFFFFF); | |
| 48 const int64 kint64min = (( int64) GG_LONGLONG(0x8000000000000000)); | |
| 49 const int64 kint64max = (( int64) GG_LONGLONG(0x7FFFFFFFFFFFFFFF)); | |
| 50 | 17 |
| 51 // Put this in the private: declarations for a class to be uncopyable. | 18 // Put this in the private: declarations for a class to be uncopyable. |
| 52 #define DISALLOW_COPY(TypeName) \ | 19 #define DISALLOW_COPY(TypeName) \ |
| 53 TypeName(const TypeName&) | 20 TypeName(const TypeName&) |
| 54 | 21 |
| 55 // Put this in the private: declarations for a class to be unassignable. | 22 // Put this in the private: declarations for a class to be unassignable. |
| 56 #define DISALLOW_ASSIGN(TypeName) \ | 23 #define DISALLOW_ASSIGN(TypeName) \ |
| 57 void operator=(const TypeName&) | 24 void operator=(const TypeName&) |
| 58 | 25 |
| 59 // A macro to disallow the copy constructor and operator= functions | 26 // A macro to disallow the copy constructor and operator= functions |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 enum LinkerInitialized { LINKER_INITIALIZED }; | 303 enum LinkerInitialized { LINKER_INITIALIZED }; |
| 337 | 304 |
| 338 // Use these to declare and define a static local variable (static T;) so that | 305 // Use these to declare and define a static local variable (static T;) so that |
| 339 // it is leaked so that its destructors are not called at exit. If you need | 306 // it is leaked so that its destructors are not called at exit. If you need |
| 340 // thread-safe initialization, use base/lazy_instance.h instead. | 307 // thread-safe initialization, use base/lazy_instance.h instead. |
| 341 #define CR_DEFINE_STATIC_LOCAL(type, name, arguments) \ | 308 #define CR_DEFINE_STATIC_LOCAL(type, name, arguments) \ |
| 342 static type& name = *new type arguments | 309 static type& name = *new type arguments |
| 343 | 310 |
| 344 } // base | 311 } // base |
| 345 | 312 |
| 346 #endif // BASE_BASICTYPES_H_ | 313 #endif // BASE_MACROS_H_ |
| OLD | NEW |