OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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: Remove these type guards. These are to avoid conflicts with | |
23 // obsolete/protypes.h in the Gecko SDK. | |
24 #ifndef _INT32 | |
25 #define _INT32 | |
26 typedef int int32; | 22 typedef int int32; |
27 #endif | |
28 | 23 |
29 // The NSPR system headers define 64-bit as |long| when possible, except on | 24 // The NSPR system headers define 64-bit as |long| when possible, except on |
30 // Mac OS X. In order to not have typedef mismatches, we do the same on LP64. | 25 // Mac OS X. In order to not have typedef mismatches, we do the same on LP64. |
31 // | 26 // |
32 // On Mac OS X, |long long| is used for 64-bit types for compatibility with | 27 // On Mac OS X, |long long| is used for 64-bit types for compatibility with |
33 // <inttypes.h> format macros even in the LP64 model. | 28 // <inttypes.h> format macros even in the LP64 model. |
34 #if defined(__LP64__) && !defined(OS_MACOSX) && !defined(OS_OPENBSD) | 29 #if defined(__LP64__) && !defined(OS_MACOSX) && !defined(OS_OPENBSD) |
35 typedef long int64; | 30 typedef long int64; |
36 #else | 31 #else |
37 typedef long long int64; | 32 typedef long long int64; |
38 #endif | 33 #endif |
39 | 34 |
40 // NOTE: unsigned types are DANGEROUS in loops and other arithmetical | 35 // NOTE: unsigned types are DANGEROUS in loops and other arithmetical |
41 // places. Use the signed types unless your variable represents a bit | 36 // places. Use the signed types unless your variable represents a bit |
42 // pattern (eg a hash value) or you really need the extra bit. Do NOT | 37 // pattern (eg a hash value) or you really need the extra bit. Do NOT |
43 // use 'unsigned' to express "this value should always be positive"; | 38 // use 'unsigned' to express "this value should always be positive"; |
44 // use assertions for this. | 39 // use assertions for this. |
45 | 40 |
46 typedef unsigned char uint8; | 41 typedef unsigned char uint8; |
47 typedef unsigned short uint16; | 42 typedef unsigned short uint16; |
48 // TODO: Remove these type guards. These are to avoid conflicts with | |
49 // obsolete/protypes.h in the Gecko SDK. | |
50 #ifndef _UINT32 | |
51 #define _UINT32 | |
52 typedef unsigned int uint32; | 43 typedef unsigned int uint32; |
53 #endif | |
54 | 44 |
55 // See the comment above about NSPR and 64-bit. | 45 // See the comment above about NSPR and 64-bit. |
56 #if defined(__LP64__) && !defined(OS_MACOSX) && !defined(OS_OPENBSD) | 46 #if defined(__LP64__) && !defined(OS_MACOSX) && !defined(OS_OPENBSD) |
57 typedef unsigned long uint64; | 47 typedef unsigned long uint64; |
58 #else | 48 #else |
59 typedef unsigned long long uint64; | 49 typedef unsigned long long uint64; |
60 #endif | 50 #endif |
61 | 51 |
62 // A type to represent a Unicode code-point value. As of Unicode 4.0, | 52 // A type to represent a Unicode code-point value. As of Unicode 4.0, |
63 // such values require up to 21 bits. | 53 // such values require up to 21 bits. |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 | 342 |
353 // Use these to declare and define a static local variable (static T;) so that | 343 // Use these to declare and define a static local variable (static T;) so that |
354 // it is leaked so that its destructors are not called at exit. If you need | 344 // it is leaked so that its destructors are not called at exit. If you need |
355 // thread-safe initialization, use base/lazy_instance.h instead. | 345 // thread-safe initialization, use base/lazy_instance.h instead. |
356 #define CR_DEFINE_STATIC_LOCAL(type, name, arguments) \ | 346 #define CR_DEFINE_STATIC_LOCAL(type, name, arguments) \ |
357 static type& name = *new type arguments | 347 static type& name = *new type arguments |
358 | 348 |
359 } // base | 349 } // base |
360 | 350 |
361 #endif // BASE_BASICTYPES_H_ | 351 #endif // BASE_BASICTYPES_H_ |
OLD | NEW |