| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 #ifndef BASE_BASICTYPES_H_ |
| 6 #define BASE_BASICTYPES_H_ | 6 #define BASE_BASICTYPES_H_ |
| 7 | 7 |
| 8 #include <limits.h> // So we can set the bounds of our types | 8 #include <limits.h> // So we can set the bounds of our types |
| 9 #include <stddef.h> // For size_t | 9 #include <stddef.h> // For size_t |
| 10 #include <string.h> // for memcpy | 10 #include <string.h> // for memcpy |
| 11 | 11 |
| 12 #include "base/port.h" // Types that only need exist on certain systems | 12 #include "base/port.h" // Types that only need exist on certain systems |
| 13 | 13 |
| 14 #ifndef COMPILER_MSVC | 14 #ifndef COMPILER_MSVC |
| 15 // stdint.h is part of C99 but MSVC doesn't have it. | 15 // stdint.h is part of C99 but MSVC doesn't have it. |
| 16 #include <stdint.h> // For intptr_t. | 16 #include <stdint.h> // For intptr_t. |
| 17 #endif | 17 #endif |
| 18 | 18 |
| 19 typedef signed char schar; | 19 typedef signed char schar; |
| 20 typedef signed char int8; | 20 typedef signed char int8; |
| 21 typedef short int16; | 21 typedef short int16; |
| 22 // TODO(mbelshe) Remove these type guards. These are | 22 // TODO(mbelshe) Remove these type guards. These are |
| 23 // temporary to avoid conflicts with npapi.h. | 23 // temporary to avoid conflicts with npapi.h. |
| 24 #ifndef _INT32 | 24 #ifndef _INT32 |
| 25 #define _INT32 | 25 #define _INT32 |
| 26 typedef int int32; | 26 typedef int int32; |
| 27 #endif | 27 #endif |
| 28 |
| 29 // The NSPR system headers define 64-bit as long when possible. In order to |
| 30 // not have typedef mismatches, we do the same on LP64. |
| 31 #if __LP64__ |
| 32 typedef long int64; |
| 33 #else |
| 28 typedef long long int64; | 34 typedef long long int64; |
| 35 #endif |
| 29 | 36 |
| 30 // NOTE: unsigned types are DANGEROUS in loops and other arithmetical | 37 // NOTE: unsigned types are DANGEROUS in loops and other arithmetical |
| 31 // places. Use the signed types unless your variable represents a bit | 38 // places. Use the signed types unless your variable represents a bit |
| 32 // pattern (eg a hash value) or you really need the extra bit. Do NOT | 39 // pattern (eg a hash value) or you really need the extra bit. Do NOT |
| 33 // use 'unsigned' to express "this value should always be positive"; | 40 // use 'unsigned' to express "this value should always be positive"; |
| 34 // use assertions for this. | 41 // use assertions for this. |
| 35 | 42 |
| 36 typedef unsigned char uint8; | 43 typedef unsigned char uint8; |
| 37 typedef unsigned short uint16; | 44 typedef unsigned short uint16; |
| 38 // TODO(mbelshe) Remove these type guards. These are | 45 // TODO(mbelshe) Remove these type guards. These are |
| 39 // temporary to avoid conflicts with npapi.h. | 46 // temporary to avoid conflicts with npapi.h. |
| 40 #ifndef _UINT32 | 47 #ifndef _UINT32 |
| 41 #define _UINT32 | 48 #define _UINT32 |
| 42 typedef unsigned int uint32; | 49 typedef unsigned int uint32; |
| 43 #endif | 50 #endif |
| 51 |
| 52 // See the comment above about NSPR and 64-bit. |
| 53 #if __LP64__ |
| 54 typedef unsigned long uint64; |
| 55 #else |
| 44 typedef unsigned long long uint64; | 56 typedef unsigned long long uint64; |
| 57 #endif |
| 45 | 58 |
| 46 // A type to represent a Unicode code-point value. As of Unicode 4.0, | 59 // A type to represent a Unicode code-point value. As of Unicode 4.0, |
| 47 // such values require up to 21 bits. | 60 // such values require up to 21 bits. |
| 48 // (For type-checking on pointers, make this explicitly signed, | 61 // (For type-checking on pointers, make this explicitly signed, |
| 49 // and it should always be the signed version of whatever int32 is.) | 62 // and it should always be the signed version of whatever int32 is.) |
| 50 typedef signed int char32; | 63 typedef signed int char32; |
| 51 | 64 |
| 52 const uint8 kuint8max = (( uint8) 0xFF); | 65 const uint8 kuint8max = (( uint8) 0xFF); |
| 53 const uint16 kuint16max = ((uint16) 0xFFFF); | 66 const uint16 kuint16max = ((uint16) 0xFFFF); |
| 54 const uint32 kuint32max = ((uint32) 0xFFFFFFFF); | 67 const uint32 kuint32max = ((uint32) 0xFFFFFFFF); |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 // constructor declared as | 339 // constructor declared as |
| 327 // explicit MyClass(base::LinkerInitialized x) {} | 340 // explicit MyClass(base::LinkerInitialized x) {} |
| 328 // and invoked as | 341 // and invoked as |
| 329 // static MyClass my_variable_name(base::LINKER_INITIALIZED); | 342 // static MyClass my_variable_name(base::LINKER_INITIALIZED); |
| 330 namespace base { | 343 namespace base { |
| 331 enum LinkerInitialized { LINKER_INITIALIZED }; | 344 enum LinkerInitialized { LINKER_INITIALIZED }; |
| 332 } // base | 345 } // base |
| 333 | 346 |
| 334 | 347 |
| 335 #endif // BASE_BASICTYPES_H_ | 348 #endif // BASE_BASICTYPES_H_ |
| OLD | NEW |