OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 PPAPI_C_PP_MACROS_H_ | 5 #ifndef PPAPI_C_PP_MACROS_H_ |
6 #define PPAPI_C_PP_MACROS_H_ | 6 #define PPAPI_C_PP_MACROS_H_ |
7 | 7 |
8 /** | 8 /** |
9 * @file | 9 * @file |
10 * Defines the API ... | 10 * Defines the API ... |
(...skipping 35 matching lines...) Loading... |
46 | 46 |
47 NAME is the name of the type without any spaces or the struct or enum | 47 NAME is the name of the type without any spaces or the struct or enum |
48 keywords. | 48 keywords. |
49 | 49 |
50 CTYPENAME is the typename required by C. I.e., for a struct or enum, the | 50 CTYPENAME is the typename required by C. I.e., for a struct or enum, the |
51 appropriate keyword must be included. | 51 appropriate keyword must be included. |
52 | 52 |
53 SIZE is the expected size in bytes. | 53 SIZE is the expected size in bytes. |
54 */ | 54 */ |
55 #define PP_COMPILE_ASSERT_SIZE_IN_BYTES_IMPL(NAME, CTYPENAME, SIZE) \ | 55 #define PP_COMPILE_ASSERT_SIZE_IN_BYTES_IMPL(NAME, CTYPENAME, SIZE) \ |
56 struct _dummy_struct_for_##NAME { \ | 56 struct PP_Dummy_Struct_For_##NAME { \ |
57 char _COMPILE_ASSERT_FAILED_The_type_named_ \ | 57 char _COMPILE_ASSERT_FAILED_The_type_named_ \ |
58 ## NAME ## _is_not_ ## SIZE ## \ | 58 ## NAME ## _is_not_ ## SIZE ## \ |
59 _bytes_wide[(sizeof(CTYPENAME) == SIZE) ? 1 : -1]; } | 59 _bytes_wide[(sizeof(CTYPENAME) == SIZE) ? 1 : -1]; } |
60 | 60 |
61 /* PP_COMPILE_ASSERT_SIZE_IN_BYTES is for typenames that contain no spaces. | 61 /* PP_COMPILE_ASSERT_SIZE_IN_BYTES is for typenames that contain no spaces. |
62 E.g.: | 62 E.g.: |
63 PP_COMPILE_ASSERT_SIZE_IN_BYTES(int, 4); | 63 PP_COMPILE_ASSERT_SIZE_IN_BYTES(int, 4); |
64 typedef struct { int a; } Foo; | 64 typedef struct { int a; } Foo; |
65 PP_COMPILE_ASSERT_SIZE_IN_BYTES(Foo, 4); | 65 PP_COMPILE_ASSERT_SIZE_IN_BYTES(Foo, 4); |
66 */ | 66 */ |
67 #define PP_COMPILE_ASSERT_SIZE_IN_BYTES(NAME, SIZE) \ | 67 #define PP_COMPILE_ASSERT_SIZE_IN_BYTES(NAME, SIZE) \ |
68 PP_COMPILE_ASSERT_SIZE_IN_BYTES_IMPL(NAME, NAME, SIZE) | 68 PP_COMPILE_ASSERT_SIZE_IN_BYTES_IMPL(NAME, NAME, SIZE) |
69 | 69 |
70 /* PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES is for typenames that contain 'struct' | 70 /* PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES is for typenames that contain 'struct' |
71 in C. That is, struct names that are not typedefs. | 71 in C. That is, struct names that are not typedefs. |
72 E.g.: | 72 E.g.: |
73 struct Foo { int a; }; | 73 struct Foo { int a; }; |
74 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(Foo, 4); | 74 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(Foo, 4); |
75 */ | 75 */ |
76 #define PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(NAME, SIZE) \ | 76 #define PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(NAME, SIZE) \ |
77 PP_COMPILE_ASSERT_SIZE_IN_BYTES_IMPL(NAME, struct NAME, SIZE) | 77 PP_COMPILE_ASSERT_SIZE_IN_BYTES_IMPL(NAME, struct NAME, SIZE) |
78 | 78 |
| 79 /* PP_COMPILE_ASSERT_ENUM_SIZE_IN_BYTES is for typenames that contain 'enum' |
| 80 in C. That is, enum names that are not typedefs. |
| 81 E.g.: |
| 82 enum Bar { A = 0, B = 1 }; |
| 83 PP_COMPILE_ASSERT_ENUM_SIZE_IN_BYTES(Foo, 4); |
| 84 */ |
| 85 #define PP_COMPILE_ASSERT_ENUM_SIZE_IN_BYTES(NAME, SIZE) \ |
| 86 PP_COMPILE_ASSERT_SIZE_IN_BYTES_IMPL(NAME, enum NAME, SIZE) |
| 87 |
| 88 /* Processor architecture detection. This was copied from: |
| 89 chromium/src/build/build_config.h |
| 90 For more info on what's defined, see: |
| 91 http://msdn.microsoft.com/en-us/library/b0084kay.aspx |
| 92 http://www.agner.org/optimize/calling_conventions.pdf |
| 93 or with gcc, run: "echo | gcc -E -dM -" |
| 94 */ |
| 95 #if defined(_M_X64) || defined(__x86_64__) |
| 96 #define ARCH_CPU_X86_FAMILY 1 |
| 97 #define ARCH_CPU_X86_64 1 |
| 98 #define ARCH_CPU_64_BITS 1 |
| 99 #elif defined(_M_IX86) || defined(__i386__) |
| 100 #define ARCH_CPU_X86_FAMILY 1 |
| 101 #define ARCH_CPU_X86 1 |
| 102 #define ARCH_CPU_32_BITS 1 |
| 103 #elif defined(__ARMEL__) |
| 104 #define ARCH_CPU_ARM_FAMILY 1 |
| 105 #define ARCH_CPU_ARMEL 1 |
| 106 #define ARCH_CPU_32_BITS 1 |
| 107 #define WCHAR_T_IS_UNSIGNED 1 |
| 108 #else |
| 109 #error Please add support for your architecture in ppapi/c/pp_macros.h |
| 110 #endif |
| 111 |
79 /** | 112 /** |
80 * @} | 113 * @} |
81 * End of addtogroup PP | 114 * End of addtogroup PP |
82 */ | 115 */ |
83 | 116 |
84 #endif // PPAPI_C_PP_MACROS_H_ | 117 #endif // PPAPI_C_PP_MACROS_H_ |
85 | 118 |
OLD | NEW |