diff options
author | dmichael@google.com <dmichael@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-13 20:04:31 +0000 |
---|---|---|
committer | dmichael@google.com <dmichael@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-13 20:04:31 +0000 |
commit | 1ad2a1dbcde42412bb92c83fe5e0d6999ed00311 (patch) | |
tree | bec94376d42b1943e2830e695956252232283b4d /ppapi/c/pp_macros.h | |
parent | f68fbd1b300401c79df8df9773bbe7aa36ff6062 (diff) | |
download | chromium_src-1ad2a1dbcde42412bb92c83fe5e0d6999ed00311.zip chromium_src-1ad2a1dbcde42412bb92c83fe5e0d6999ed00311.tar.gz chromium_src-1ad2a1dbcde42412bb92c83fe5e0d6999ed00311.tar.bz2 |
Add compile assertions to enforce the sizes of all structs and enums in the C API. Adjust some structs to make their sizes consistent across architectures. Note that some structs contain pointers, so are difficult to make consistent between 32-bit and 64-bit. Those types are in test_struct_sizes.c. Other types have a compile assertion immediately after their definition.
This was broken off from a bigger CL:
http://codereview.chromium.org/5340003/
BUG=61004,92983
TEST=test_struct_sizes.c, compile assertions throughout
See this CL for the code that helped generate the static assertions and find affected interfaces:
http://codereview.chromium.org/5730003
Review URL: http://codereview.chromium.org/5674004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@69038 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/c/pp_macros.h')
-rw-r--r-- | ppapi/c/pp_macros.h | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/ppapi/c/pp_macros.h b/ppapi/c/pp_macros.h index a46ea2e..c56bc85 100644 --- a/ppapi/c/pp_macros.h +++ b/ppapi/c/pp_macros.h @@ -53,7 +53,7 @@ SIZE is the expected size in bytes. */ #define PP_COMPILE_ASSERT_SIZE_IN_BYTES_IMPL(NAME, CTYPENAME, SIZE) \ -struct _dummy_struct_for_##NAME { \ +struct PP_Dummy_Struct_For_##NAME { \ char _COMPILE_ASSERT_FAILED_The_type_named_ \ ## NAME ## _is_not_ ## SIZE ## \ _bytes_wide[(sizeof(CTYPENAME) == SIZE) ? 1 : -1]; } @@ -76,6 +76,15 @@ PP_COMPILE_ASSERT_SIZE_IN_BYTES_IMPL(NAME, NAME, SIZE) #define PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(NAME, SIZE) \ PP_COMPILE_ASSERT_SIZE_IN_BYTES_IMPL(NAME, struct NAME, SIZE) +/* PP_COMPILE_ASSERT_ENUM_SIZE_IN_BYTES is for typenames that contain 'enum' + in C. That is, enum names that are not typedefs. + E.g.: + enum Bar { A = 0, B = 1 }; + PP_COMPILE_ASSERT_ENUM_SIZE_IN_BYTES(Foo, 4); + */ +#define PP_COMPILE_ASSERT_ENUM_SIZE_IN_BYTES(NAME, SIZE) \ +PP_COMPILE_ASSERT_SIZE_IN_BYTES_IMPL(NAME, enum NAME, SIZE) + /** * @} * End of addtogroup PP |