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 | |
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')
33 files changed, 189 insertions, 30 deletions
diff --git a/ppapi/c/dev/pp_cursor_type_dev.h b/ppapi/c/dev/pp_cursor_type_dev.h index b7a113a..a799468 100644 --- a/ppapi/c/dev/pp_cursor_type_dev.h +++ b/ppapi/c/dev/pp_cursor_type_dev.h @@ -5,6 +5,8 @@ #ifndef PPAPI_C_DEV_PP_CURSORTYPE_DEV_H_ #define PPAPI_C_DEV_PP_CURSORTYPE_DEV_H_ +#include "ppapi/c/pp_macros.h" + enum PP_CursorType_Dev { PP_CURSORTYPE_POINTER = 0, PP_CURSORTYPE_CROSS = 1, @@ -49,5 +51,6 @@ enum PP_CursorType_Dev { PP_CURSORTYPE_ZOOMOUT = 40, PP_CURSORTYPE_CUSTOM = 41 }; +PP_COMPILE_ASSERT_ENUM_SIZE_IN_BYTES(PP_CursorType_Dev, 4); #endif // PPAPI_C_DEV_PP_CURSORTYPE_DEV_H_ diff --git a/ppapi/c/dev/pp_file_info_dev.h b/ppapi/c/dev/pp_file_info_dev.h index c1e1a07..d381193 100644 --- a/ppapi/c/dev/pp_file_info_dev.h +++ b/ppapi/c/dev/pp_file_info_dev.h @@ -5,6 +5,7 @@ #ifndef PPAPI_C_DEV_PP_FILE_INFO_DEV_H_ #define PPAPI_C_DEV_PP_FILE_INFO_DEV_H_ +#include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_time.h" @@ -13,12 +14,14 @@ typedef enum { PP_FILETYPE_DIRECTORY, PP_FILETYPE_OTHER // A catch-all for unidentified types. } PP_FileType_Dev; +PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_FileType_Dev, 4); typedef enum { PP_FILESYSTEMTYPE_EXTERNAL, PP_FILESYSTEMTYPE_LOCALPERSISTENT, PP_FILESYSTEMTYPE_LOCALTEMPORARY } PP_FileSystemType_Dev; +PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_FileSystemType_Dev, 4); struct PP_FileInfo_Dev { int64_t size; // Measured in bytes @@ -28,5 +31,6 @@ struct PP_FileInfo_Dev { PP_Time last_access_time; PP_Time last_modified_time; }; +PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_FileInfo_Dev, 40); #endif // PPAPI_C_DEV_PP_FILE_INFO_DEV_H_ diff --git a/ppapi/c/dev/pp_video_dev.h b/ppapi/c/dev/pp_video_dev.h index c141a85..adef7be 100644 --- a/ppapi/c/dev/pp_video_dev.h +++ b/ppapi/c/dev/pp_video_dev.h @@ -7,6 +7,7 @@ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_instance.h" +#include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" @@ -39,6 +40,7 @@ enum PP_VideoKey_Dev { PP_VIDEOKEY_H264FEATURE_CABAC, PP_VIDEOKEY_H264FEATURE_WEIGHTEDPREDICTION }; +PP_COMPILE_ASSERT_ENUM_SIZE_IN_BYTES(PP_VideoKey_Dev, 4); enum PP_VideoDecoderEvent_Dev { PP_VIDEODECODEREVENT_NONE = 0, @@ -49,6 +51,7 @@ enum PP_VideoDecoderEvent_Dev { // Signaling new cropping rectangle PP_VIDEODECODEREVENT_NEWCROP }; +PP_COMPILE_ASSERT_ENUM_SIZE_IN_BYTES(PP_VideoDecoderEvent_Dev, 4); enum PP_VideoDecodeError_Dev { PP_VIDEODECODEERROR_NONE = 0, @@ -58,6 +61,7 @@ enum PP_VideoDecodeError_Dev { PP_VIDEODECODEERROR_BADINPUT, PP_VIDEODECODEERROR_HARDWARE }; +PP_COMPILE_ASSERT_ENUM_SIZE_IN_BYTES(PP_VideoDecodeError_Dev, 4); enum PP_VideoCodecId_Dev { PP_VIDEODECODECID_NONE = 0, @@ -66,12 +70,14 @@ enum PP_VideoCodecId_Dev { PP_VIDEODECODECID_MPEG2, PP_VIDEODECODECID_VP8 }; +PP_COMPILE_ASSERT_ENUM_SIZE_IN_BYTES(PP_VideoCodecId_Dev, 4); enum PP_VideoOperation_Dev { PP_VIDEOOPERATION_NONE = 0, PP_VIDEOOPERATION_DECODE, PP_VIDEOOPERATION_ENCODE }; +PP_COMPILE_ASSERT_ENUM_SIZE_IN_BYTES(PP_VideoOperation_Dev, 4); enum PP_VideoCodecProfile_Dev { PP_VIDEOCODECPROFILE_NONE = 0, @@ -94,6 +100,7 @@ enum PP_VideoCodecProfile_Dev { PP_VIDEOCODECPROFILE_MPEG2_SPATIAL, PP_VIDEOCODECPROFILE_MPEG2_HIGH }; +PP_COMPILE_ASSERT_ENUM_SIZE_IN_BYTES(PP_VideoCodecProfile_Dev, 4); enum PP_VideoCodecLevel_Dev { PP_VIDEOCODECLEVEL_NONE = 0, @@ -128,12 +135,14 @@ enum PP_VideoCodecLevel_Dev { PP_VIDEOCODECLEVEL_MPEG2_HIGH1440, PP_VIDEOCODECLEVEL_MPEG2_HIGH }; +PP_COMPILE_ASSERT_ENUM_SIZE_IN_BYTES(PP_VideoCodecLevel_Dev, 4); enum PP_VideoPayloadFormat_Dev { PP_VIDEOPAYLOADFORMAT_NONE = 0, PP_VIDEOPAYLOADFORMAT_BYTESTREAM, PP_VIDEOPAYLOADFORMAT_RTPPAYLOAD }; +PP_COMPILE_ASSERT_ENUM_SIZE_IN_BYTES(PP_VideoPayloadFormat_Dev, 4); enum PP_VideoFrameColorType_Dev { PP_VIDEOFRAMECOLORTYPE_NONE = 0, @@ -145,6 +154,7 @@ enum PP_VideoFrameColorType_Dev { PP_VIDEOFRAMECOLORTYPE_YUV422PLANAR, PP_VIDEOFRAMECOLORTYPE_YUV444PLANAR }; +PP_COMPILE_ASSERT_ENUM_SIZE_IN_BYTES(PP_VideoFrameColorType_Dev, 4); enum PP_VideoFrameSurfaceType_Dev { PP_VIDEOFRAMESURFACETYPE_NONE = 0, @@ -152,6 +162,7 @@ enum PP_VideoFrameSurfaceType_Dev { PP_VIDEOFRAMESURFACETYPE_GLTEXTURE, PP_VIDEOFRAMESURFACETYPE_PIXMAP }; +PP_COMPILE_ASSERT_ENUM_SIZE_IN_BYTES(PP_VideoFrameSurfaceType_Dev, 4); enum PP_VideoFrameInfoFlag_Dev { PP_VIDEOFRAMEINFOFLAG_NONE = 0, @@ -164,6 +175,7 @@ enum PP_VideoFrameInfoFlag_Dev { // Indicate the decoded frame has data corruption. Used by browser. PP_VIDEOFRAMEINFOFLAG_DATACORRUPT = 1 << 3 }; +PP_COMPILE_ASSERT_ENUM_SIZE_IN_BYTES(PP_VideoFrameInfoFlag_Dev, 4); enum PP_VideoFrameBufferConst_Dev { // YUV formats @@ -178,8 +190,10 @@ enum PP_VideoFrameBufferConst_Dev { PP_VIDEOFRAMEBUFFER_MAXNUMBERPLANES = 4 }; +PP_COMPILE_ASSERT_ENUM_SIZE_IN_BYTES(PP_VideoFrameBufferConst_Dev, 4); typedef int64_t PP_VideoDecodeData_Dev; +PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_VideoDecodeData_Dev, 8); // Array of key/value pairs describing video configuration. // It could include any keys from PP_VideoKey. Its last element shall be @@ -195,34 +209,48 @@ typedef int64_t PP_VideoDecodeData_Dev; // }; typedef int32_t* PP_VideoConfig_Dev; typedef int32_t PP_VideoConfigElement_Dev; +PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_VideoConfigElement_Dev, 4); // The data structure for compressed data buffer. struct PP_VideoCompressedDataBuffer_Dev { // The buffer is created through PPB_Buffer API. // TODO(wjia): would uint8_t* be good, too? PP_Resource buffer; + // number of bytes with real data in the buffer. int32_t filled_size; - // Time stamp of the frame in microsecond. - uint64_t time_stamp_us; - // Bit mask of PP_VideoFrameInfoFlag. uint32_t flags; + + // Time stamp of the frame in microsecond. + uint64_t time_stamp_us; }; +PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_VideoCompressedDataBuffer_Dev, 24); struct PP_VideoFrameBuffer_Dev { union { struct { - int32_t planes; struct { int32_t width; int32_t height; int32_t stride; + // Padding to ensure the PP_Resource is 8-byte aligned relative to the + // start of the struct. This helps ensure PP_VideoFrameBuffer_Dev has + // consistent size and alignment across compilers. + int32_t padding; + // TODO(wjia): uint8* would be better for some cases. PP_Resource buffer; } data_plane[PP_VIDEOFRAMEBUFFER_MAXNUMBERPLANES]; + + int32_t planes; + + // This padding makes sure the sys_mem struct's size is a multiple of 8 + // bytes, ensuring that handle is always 8-byte aligned relative to the + // start of the PP_VideoFrameBuffer_Dev struct. + int32_t padding; } sys_mem; // Handle for pixmap, gl texture, etc. @@ -232,23 +260,40 @@ struct PP_VideoFrameBuffer_Dev { // Storage for decoder to save some private data. It could be useful when // plugin returns frame buffer to decoder. void* private_handle; + + // In some 32-bit platforms (NaCl and Win32), this struct is 8-byte aligned + // due to the PP_Resource above. That causes the compiler to pad it an extra + // 4 bytes on the end. In other 32-bit platforms, there is no such pad. This + // padding ensures that the size is consistent on 32-bit platforms (and it + // is still consistent on 64-bit platforms, just bigger than it would be + // without the padding). + int32_t padding; }; struct PP_VideoUncompressedDataBuffer_Dev { PP_VideoConfig_Dev format; - struct PP_VideoFrameBuffer_Dev buffer; + + // Bit mask of PP_VideoFrameInfoFlag. + uint32_t flags; // Time stamp of the frame in microsecond. uint64_t time_stamp_us; - // Bit mask of PP_VideoFrameInfoFlag. - uint32_t flags; + struct PP_VideoFrameBuffer_Dev buffer; // Output from decoder, indicating the decoded frame has error pixels. This // could be resulted from corrupted input bit stream and error concealment // in decoding. PP_TRUE indicates error. // TODO(wjia): add more info about error pixels, such as error MB map, etc. PP_Bool error; + + // In some 32-bit platforms (NaCl and Win32), this struct is 8-byte aligned + // due to the uint64_t and buffer above. That causes the compiler to pad it + // an extra 4 bytes on the end. In other 32-bit platforms, there is no such + // pad. This padding ensures that the size is consistent on 32-bit platforms + // (and it is still consistent on 64-bit platforms, just bigger than it would + // be without the padding). + int32_t padding; }; // Plugin callback for decoder to deliver decoded frame buffers. diff --git a/ppapi/c/dev/ppb_audio_config_dev.h b/ppapi/c/dev/ppb_audio_config_dev.h index 780d768..07c7824 100644 --- a/ppapi/c/dev/ppb_audio_config_dev.h +++ b/ppapi/c/dev/ppb_audio_config_dev.h @@ -6,6 +6,7 @@ #define PPAPI_C_DEV_PPB_AUDIO_CONFIG_DEV_H_ #include "ppapi/c/pp_bool.h" +#include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_module.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" @@ -22,6 +23,7 @@ typedef enum { PP_AUDIOSAMPLERATE_44100 = 44100, PP_AUDIOSAMPLERATE_48000 = 48000 } PP_AudioSampleRate_Dev; +PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_AudioSampleRate_Dev, 4); /** * Audio configuration. This base configuration interface supports only stereo diff --git a/ppapi/c/dev/ppb_char_set_dev.h b/ppapi/c/dev/ppb_char_set_dev.h index a433c62..ac1ad96 100644 --- a/ppapi/c/dev/ppb_char_set_dev.h +++ b/ppapi/c/dev/ppb_char_set_dev.h @@ -5,11 +5,12 @@ #ifndef PPAPI_C_DEV_PPB_CHAR_SET_DEV_H_ #define PPAPI_C_DEV_PPB_CHAR_SET_DEV_H_ +#include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_module.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_var.h" -#define PPB_CHAR_SET_DEV_INTERFACE "PPB_CharSet(Dev);0.2" +#define PPB_CHAR_SET_DEV_INTERFACE "PPB_CharSet(Dev);0.3" // Specifies the error behavior for the character set conversion functions. // This will affect two cases: where the input is not encoded correctly, and @@ -31,6 +32,7 @@ enum PP_CharSet_ConversionError { // many languages this will be the representation of the '?' character. PP_CHARSET_CONVERSIONERROR_SUBSTITUTE }; +PP_COMPILE_ASSERT_ENUM_SIZE_IN_BYTES(PP_CharSet_ConversionError, 4); struct PPB_CharSet_Dev { // Converts the UTF-16 string pointed to in |*utf16| to an 8-bit string in the diff --git a/ppapi/c/dev/ppb_directory_reader_dev.h b/ppapi/c/dev/ppb_directory_reader_dev.h index a4b6558..8dc0f6a 100644 --- a/ppapi/c/dev/ppb_directory_reader_dev.h +++ b/ppapi/c/dev/ppb_directory_reader_dev.h @@ -5,8 +5,9 @@ #ifndef PPAPI_C_DEV_PPB_DIRECTORY_READER_DEV_H_ #define PPAPI_C_DEV_PPB_DIRECTORY_READER_DEV_H_ -#include "ppapi/c/pp_bool.h" #include "ppapi/c/dev/pp_file_info_dev.h" +#include "ppapi/c/pp_bool.h" +#include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_module.h" #include "ppapi/c/pp_resource.h" @@ -15,9 +16,17 @@ struct PP_CompletionCallback; struct PP_DirectoryEntry_Dev { PP_Resource file_ref; PP_FileType_Dev file_type; + + /** Ensure that this struct is 16-bytes wide by padding the end. Because + * PP_Resource is an 8-byte type, some compilers align this struct on 8-byte + * boundaries and pad it to 16 bytes even without @a padding. This makes its + * size consistent across compilers. + */ + int32_t padding; }; +PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_DirectoryEntry_Dev, 16); -#define PPB_DIRECTORYREADER_DEV_INTERFACE "PPB_DirectoryReader(Dev);0.2" +#define PPB_DIRECTORYREADER_DEV_INTERFACE "PPB_DirectoryReader(Dev);0.3" struct PPB_DirectoryReader_Dev { // Creates a DirectoryReader for the given directory. Upon success, the diff --git a/ppapi/c/dev/ppb_file_chooser_dev.h b/ppapi/c/dev/ppb_file_chooser_dev.h index cc2bafe..b63a930 100644 --- a/ppapi/c/dev/ppb_file_chooser_dev.h +++ b/ppapi/c/dev/ppb_file_chooser_dev.h @@ -7,6 +7,7 @@ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_instance.h" +#include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" struct PP_CompletionCallback; @@ -16,6 +17,7 @@ typedef enum { PP_FILECHOOSERMODE_OPENMULTIPLE // TODO(darin): Should there be a way to choose a directory? } PP_FileChooserMode_Dev; +PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_FileChooserMode_Dev, 4); struct PP_FileChooserOptions_Dev { PP_FileChooserMode_Dev mode; diff --git a/ppapi/c/dev/ppb_file_io_dev.h b/ppapi/c/dev/ppb_file_io_dev.h index b69e005..1264599 100644 --- a/ppapi/c/dev/ppb_file_io_dev.h +++ b/ppapi/c/dev/ppb_file_io_dev.h @@ -6,6 +6,7 @@ #define PPAPI_C_DEV_PPB_FILE_IO_DEV_H_ #include "ppapi/c/pp_bool.h" +#include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_module.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" @@ -36,6 +37,7 @@ typedef enum { // exists, then the FileIO::Open call will fail. PP_FILEOPENFLAG_EXCLUSIVE = 1 << 4 } PP_FileOpenFlags_Dev; +PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_FileOpenFlags_Dev, 4); #define PPB_FILEIO_DEV_INTERFACE "PPB_FileIO(Dev);0.2" diff --git a/ppapi/c/dev/ppb_file_ref_dev.h b/ppapi/c/dev/ppb_file_ref_dev.h index 1ca6d52..210ddbd 100644 --- a/ppapi/c/dev/ppb_file_ref_dev.h +++ b/ppapi/c/dev/ppb_file_ref_dev.h @@ -11,7 +11,7 @@ #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_var.h" -#define PPB_FILEREF_DEV_INTERFACE "PPB_FileRef(Dev);0.3" +#define PPB_FILEREF_DEV_INTERFACE "PPB_FileRef(Dev);0.4" // A FileRef is a "weak pointer" to a file in a file system. It contains a // PP_FileSystemType identifier and a file path string. diff --git a/ppapi/c/dev/ppb_font_dev.h b/ppapi/c/dev/ppb_font_dev.h index 9b5902f..8056d95 100644 --- a/ppapi/c/dev/ppb_font_dev.h +++ b/ppapi/c/dev/ppb_font_dev.h @@ -6,12 +6,13 @@ #define PPAPI_C_DEV_PPB_FONT_DEV_H_ #include "ppapi/c/pp_bool.h" +#include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_module.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_var.h" -#define PPB_FONT_DEV_INTERFACE "PPB_Font(Dev);0.2" +#define PPB_FONT_DEV_INTERFACE "PPB_Font(Dev);0.4" struct PP_Point; struct PP_Rect; @@ -27,6 +28,7 @@ typedef enum { PP_FONTFAMILY_SANSSERIF = 2, PP_FONTFAMILY_MONOSPACE = 3 } PP_FontFamily_Dev; +PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_FontFamily_Dev, 4); typedef enum { PP_FONTWEIGHT_100 = 0, @@ -41,6 +43,7 @@ typedef enum { PP_FONTWEIGHT_NORMAL = PP_FONTWEIGHT_400, PP_FONTWEIGHT_BOLD = PP_FONTWEIGHT_700 } PP_FontWeight_Dev; +PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_FontWeight_Dev, 4); struct PP_FontDescription_Dev { // Font face name as a string. This can also be a Null var, in which case the @@ -62,9 +65,17 @@ struct PP_FontDescription_Dev { // Adjustment to apply to letter and word spacing, respectively. Initialize // to 0 to get normal spacing. Negative values bring letters/words closer // together, positive values separate them. - int letter_spacing; - int word_spacing; + int32_t letter_spacing; + int32_t word_spacing; + + // Ensure that this struct is 48-bytes wide by padding the end. In some + // compilers, PP_Var is 8-byte aligned, so those compilers align this struct + // on 8-byte boundaries as well and pad it to 16 bytes even without this + // padding attribute. This padding makes its size consistent across + // compilers. + int32_t padding; }; +PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_FontDescription_Dev, 48); struct PP_FontMetrics_Dev { int32_t height; @@ -73,6 +84,7 @@ struct PP_FontMetrics_Dev { int32_t line_spacing; int32_t x_height; }; +PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_FontMetrics_Dev, 20); struct PP_TextRun_Dev { // This var must either be a string or a null var (which will be treated as @@ -86,6 +98,7 @@ struct PP_TextRun_Dev { // content PP_Bool override_direction; }; +PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_TextRun_Dev, 24); struct PPB_Font_Dev { // Returns a font which best matches the given description. The return value diff --git a/ppapi/c/dev/ppb_opengles_dev.h b/ppapi/c/dev/ppb_opengles_dev.h index 30206a2..8e39af5 100644 --- a/ppapi/c/dev/ppb_opengles_dev.h +++ b/ppapi/c/dev/ppb_opengles_dev.h @@ -9,27 +9,42 @@ #ifndef PPAPI_C_DEV_PPB_OPENGLES_DEV_H_ #define PPAPI_C_DEV_PPB_OPENGLES_DEV_H_ +#include "ppapi/c/pp_macros.h" #include "ppapi/GLES2/khrplatform.h" #define PPB_OPENGLES_DEV_INTERFACE "PPB_OpenGLES(Dev);2.0" typedef unsigned int GLenum; +PP_COMPILE_ASSERT_SIZE_IN_BYTES(GLenum, 4); typedef void GLvoid; typedef khronos_intptr_t GLintptr; typedef int GLsizei; +PP_COMPILE_ASSERT_SIZE_IN_BYTES(GLsizei, 4); typedef khronos_ssize_t GLsizeiptr; typedef int GLint; +PP_COMPILE_ASSERT_SIZE_IN_BYTES(GLint, 4); typedef unsigned char GLboolean; +PP_COMPILE_ASSERT_SIZE_IN_BYTES(GLboolean, 1); typedef unsigned int GLuint; +PP_COMPILE_ASSERT_SIZE_IN_BYTES(GLuint, 4); typedef unsigned int GLbitfield; +PP_COMPILE_ASSERT_SIZE_IN_BYTES(GLbitfield, 4); typedef short GLshort; +PP_COMPILE_ASSERT_SIZE_IN_BYTES(GLshort, 2); typedef float GLfloat; +PP_COMPILE_ASSERT_SIZE_IN_BYTES(GLfloat, 4); typedef float GLclampf; +PP_COMPILE_ASSERT_SIZE_IN_BYTES(GLclampf, 4); typedef signed char GLbyte; +PP_COMPILE_ASSERT_SIZE_IN_BYTES(GLbyte, 1); typedef unsigned char GLubyte; +PP_COMPILE_ASSERT_SIZE_IN_BYTES(GLubyte, 1); typedef int GLfixed; +PP_COMPILE_ASSERT_SIZE_IN_BYTES(GLfixed, 4); typedef unsigned short GLushort; +PP_COMPILE_ASSERT_SIZE_IN_BYTES(GLushort, 2); typedef int GLclampx; +PP_COMPILE_ASSERT_SIZE_IN_BYTES(GLclampx, 4); struct PPB_OpenGLES_Dev { void (*ActiveTexture)(GLenum texture); diff --git a/ppapi/c/dev/ppb_scrollbar_dev.h b/ppapi/c/dev/ppb_scrollbar_dev.h index 1252673..25cf0e7 100644 --- a/ppapi/c/dev/ppb_scrollbar_dev.h +++ b/ppapi/c/dev/ppb_scrollbar_dev.h @@ -7,6 +7,7 @@ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_instance.h" +#include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" @@ -18,6 +19,7 @@ typedef enum { PP_SCROLLBY_PAGE = 2, PP_SCROLLBY_DOCUMENT = 3 } PP_ScrollBy_Dev; +PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_ScrollBy_Dev, 4); #define PPB_SCROLLBAR_DEV_INTERFACE "PPB_Scrollbar(Dev);0.2" diff --git a/ppapi/c/dev/ppb_transport_dev.h b/ppapi/c/dev/ppb_transport_dev.h index fd96a22..33dbf57 100644 --- a/ppapi/c/dev/ppb_transport_dev.h +++ b/ppapi/c/dev/ppb_transport_dev.h @@ -13,7 +13,7 @@ #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_var.h" -#define PPB_TRANSPORT_DEV_INTERFACE "PPB_Transport;0.2" +#define PPB_TRANSPORT_DEV_INTERFACE "PPB_Transport;0.3" struct PPB_Transport_Dev { // Creates a new transport object with the specified name diff --git a/ppapi/c/dev/ppb_url_util_dev.h b/ppapi/c/dev/ppb_url_util_dev.h index d557b88..49bcc18 100644 --- a/ppapi/c/dev/ppb_url_util_dev.h +++ b/ppapi/c/dev/ppb_url_util_dev.h @@ -7,10 +7,11 @@ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_instance.h" +#include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_var.h" -#define PPB_URLUTIL_DEV_INTERFACE "PPB_UrlUtil(Dev);0.2" +#define PPB_URLUTIL_DEV_INTERFACE "PPB_UrlUtil(Dev);0.3" // A component specifies the range of the part of the URL. The begin specifies // the index into the string of the first character of that component. The len @@ -32,6 +33,7 @@ struct PP_UrlComponent_Dev { int32_t begin; int32_t len; }; +PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_UrlComponent_Dev, 8); struct PP_UrlComponents_Dev { struct PP_UrlComponent_Dev scheme; @@ -43,6 +45,7 @@ struct PP_UrlComponents_Dev { struct PP_UrlComponent_Dev query; struct PP_UrlComponent_Dev ref; }; +PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_UrlComponents_Dev, 64); // URL encoding: URLs are supplied to this interface as NULL-terminated 8-bit // strings. You can pass non-ASCII characters which will be interpreted as diff --git a/ppapi/c/dev/ppb_video_decoder_dev.h b/ppapi/c/dev/ppb_video_decoder_dev.h index 842d7ff..975e68b 100644 --- a/ppapi/c/dev/ppb_video_decoder_dev.h +++ b/ppapi/c/dev/ppb_video_decoder_dev.h @@ -12,7 +12,7 @@ #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_completion_callback.h" -#define PPB_VIDEODECODER_DEV_INTERFACE "PPB_VideoDecoder(Dev);0.2" +#define PPB_VIDEODECODER_DEV_INTERFACE "PPB_VideoDecoder(Dev);0.3" struct PPB_VideoDecoder_Dev { // Queries capability of the decoder for |codec|. diff --git a/ppapi/c/dev/ppp_printing_dev.h b/ppapi/c/dev/ppp_printing_dev.h index affecc8..00b5e6b 100644 --- a/ppapi/c/dev/ppp_printing_dev.h +++ b/ppapi/c/dev/ppp_printing_dev.h @@ -7,6 +7,7 @@ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_instance.h" +#include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_rect.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" @@ -17,12 +18,14 @@ typedef enum { PP_PRINTORIENTATION_ROTATED_180 = 2, PP_PRINTORIENTATION_ROTATED_90_CCW = 3 } PP_PrintOrientation_Dev; +PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_PrintOrientation_Dev, 4); typedef enum { PP_PRINTOUTPUTFORMAT_RASTER = 0, PP_PRINTOUTPUTFORMAT_PDF = 1, PP_PRINTOUTPUTFORMAT_POSTSCRIPT = 2 } PP_PrintOutputFormat_Dev; +PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_PrintOutputFormat_Dev, 4); struct PP_PrintSettings_Dev { // This is the size of the printable area in points (1/72 of an inch) @@ -32,6 +35,7 @@ struct PP_PrintSettings_Dev { PP_Bool grayscale; PP_PrintOutputFormat_Dev format; }; +PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_PrintSettings_Dev, 32); // Specifies a contiguous range of page numbers to be printed. // The page numbers use a zero-based index. @@ -39,6 +43,7 @@ struct PP_PrintPageNumberRange_Dev { uint32_t first_page_number; uint32_t last_page_number; }; +PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_PrintPageNumberRange_Dev, 8); // Interface for the plugin to implement printing. #define PPP_PRINTING_DEV_INTERFACE "PPP_Printing(Dev);0.2" diff --git a/ppapi/c/pp_bool.h b/ppapi/c/pp_bool.h index bbb5e0ea..929c51c 100644 --- a/ppapi/c/pp_bool.h +++ b/ppapi/c/pp_bool.h @@ -25,7 +25,6 @@ typedef enum { PP_FALSE = 0, PP_TRUE = 1 } PP_Bool; - PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_Bool, 4); /** diff --git a/ppapi/c/pp_input_event.h b/ppapi/c/pp_input_event.h index 2a260af..5ac9e5e 100644 --- a/ppapi/c/pp_input_event.h +++ b/ppapi/c/pp_input_event.h @@ -24,6 +24,7 @@ typedef enum { PP_INPUTEVENT_MOUSEBUTTON_MIDDLE = 1, PP_INPUTEVENT_MOUSEBUTTON_RIGHT = 2 } PP_InputEvent_MouseButton; +PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_InputEvent_MouseButton, 4); typedef enum { PP_INPUTEVENT_TYPE_UNDEFINED = -1, @@ -38,6 +39,7 @@ typedef enum { PP_INPUTEVENT_TYPE_KEYUP = 8, PP_INPUTEVENT_TYPE_CHAR = 9 } PP_InputEvent_Type; +PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_InputEvent_Type, 4); typedef enum { PP_INPUTEVENT_MODIFIER_SHIFTKEY = 1 << 0, @@ -52,6 +54,7 @@ typedef enum { PP_INPUTEVENT_MODIFIER_CAPSLOCKKEY = 1 << 9, PP_INPUTEVENT_MODIFIER_NUMLOCKKEY = 1 << 10 } PP_InputEvent_Modifier; +PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_InputEvent_Modifier, 4); /** * An event representing a key up or down event. @@ -78,6 +81,7 @@ struct PP_InputEvent_Key { */ uint32_t key_code; }; +PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_InputEvent_Key, 8); /** * An event representing a typed character. @@ -111,6 +115,7 @@ struct PP_InputEvent_Character { */ char text[5]; }; +PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_InputEvent_Character, 12); /** Represents a mouse event for everything other than the mouse wheel. */ struct PP_InputEvent_Mouse { @@ -137,6 +142,7 @@ struct PP_InputEvent_Mouse { /** TODO(brettw) figure out exactly what this means. */ int32_t click_count; }; +PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_InputEvent_Mouse, 20); struct PP_InputEvent_Wheel { /** A combination of the EVENT_MODIFIER flags. */ @@ -149,6 +155,7 @@ struct PP_InputEvent_Wheel { PP_Bool scroll_by_page; }; +PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_InputEvent_Wheel, 24); struct PP_InputEvent { /** Identifies the type of the event. */ diff --git a/ppapi/c/pp_instance.h b/ppapi/c/pp_instance.h index 6f78f11..f061ceb 100644 --- a/ppapi/c/pp_instance.h +++ b/ppapi/c/pp_instance.h @@ -13,6 +13,7 @@ * @{ */ +#include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_stdint.h" /** A PP_Instance uniquely identifies one plugin instance, which is one time @@ -24,6 +25,7 @@ * indicate a "NULL handle." */ typedef int64_t PP_Instance; +PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_Instance, 8); /** * @} 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 diff --git a/ppapi/c/pp_module.h b/ppapi/c/pp_module.h index 5376207..f62337b 100644 --- a/ppapi/c/pp_module.h +++ b/ppapi/c/pp_module.h @@ -13,6 +13,7 @@ * @{ */ +#include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_stdint.h" /** @@ -21,6 +22,7 @@ * 0, so a plugin can initialize it to 0 to indicate a "NULL handle." */ typedef int64_t PP_Module; +PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_Module, 8); /** * @} diff --git a/ppapi/c/pp_point.h b/ppapi/c/pp_point.h index 0ff8562..675a552 100644 --- a/ppapi/c/pp_point.h +++ b/ppapi/c/pp_point.h @@ -20,6 +20,7 @@ struct PP_Point { int32_t x; int32_t y; }; +PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_Point, 8); PP_INLINE struct PP_Point PP_MakePoint(int32_t x, int32_t y) { struct PP_Point ret; diff --git a/ppapi/c/pp_rect.h b/ppapi/c/pp_rect.h index 39808e2..561a7cc 100644 --- a/ppapi/c/pp_rect.h +++ b/ppapi/c/pp_rect.h @@ -22,6 +22,7 @@ struct PP_Rect { struct PP_Point point; struct PP_Size size; }; +PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_Rect, 16); PP_INLINE struct PP_Rect PP_MakeRectFromXYWH(int32_t x, int32_t y, int32_t w, int32_t h) { diff --git a/ppapi/c/pp_resource.h b/ppapi/c/pp_resource.h index 755995a..c3d1aca 100644 --- a/ppapi/c/pp_resource.h +++ b/ppapi/c/pp_resource.h @@ -5,6 +5,7 @@ #ifndef PPAPI_C_PP_RESOURCE_H_ #define PPAPI_C_PP_RESOURCE_H_ +#include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_stdint.h" /** @@ -30,6 +31,7 @@ * resource to indicate failure. */ typedef int64_t PP_Resource; +PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_Resource, 8); /** * @} diff --git a/ppapi/c/pp_size.h b/ppapi/c/pp_size.h index 1f77f7f..722af51 100644 --- a/ppapi/c/pp_size.h +++ b/ppapi/c/pp_size.h @@ -20,6 +20,7 @@ struct PP_Size { int32_t width; int32_t height; }; +PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_Size, 8); PP_INLINE struct PP_Size PP_MakeSize(int32_t w, int32_t h) { struct PP_Size ret; diff --git a/ppapi/c/pp_time.h b/ppapi/c/pp_time.h index 7dec91a..330a16c 100644 --- a/ppapi/c/pp_time.h +++ b/ppapi/c/pp_time.h @@ -13,12 +13,15 @@ * @{ */ +#include "ppapi/c/pp_macros.h" + /** * PP_Time represents the "wall clock time" according to the browser and is * defined as the number of seconds since the Epoch (00:00:00 UTC, January 1, * 1970). */ typedef double PP_Time; +PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_Time, 8); /** * Represents time ticks which is measured in seconds and is used for indicating @@ -30,6 +33,7 @@ typedef double PP_Time; * epoch, so the most you can do is compare two values. */ typedef double PP_TimeTicks; +PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_TimeTicks, 8); /** * @} diff --git a/ppapi/c/pp_var.h b/ppapi/c/pp_var.h index fad5db4..1695293 100644 --- a/ppapi/c/pp_var.h +++ b/ppapi/c/pp_var.h @@ -26,7 +26,6 @@ typedef enum { PP_VARTYPE_STRING, PP_VARTYPE_OBJECT } PP_VarType; - PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_VarType, 4); /** @@ -43,6 +42,13 @@ PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_VarType, 4); */ struct PP_Var { PP_VarType type; + + /** Ensures @a value is aligned on an 8-byte boundary relative to the + * start of the struct. Some compilers align doubles on 8-byte boundaries + * for 32-bit x86, and some align on 4-byte boundaries. + */ + int32_t padding; + union { PP_Bool as_bool; int32_t as_int; @@ -56,31 +62,32 @@ struct PP_Var { int64_t as_id; } value; }; +PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_Var, 16); PP_INLINE struct PP_Var PP_MakeUndefined() { - struct PP_Var result = { PP_VARTYPE_UNDEFINED, {PP_FALSE} }; + struct PP_Var result = { PP_VARTYPE_UNDEFINED, 0, {PP_FALSE} }; return result; } PP_INLINE struct PP_Var PP_MakeNull() { - struct PP_Var result = { PP_VARTYPE_NULL, {PP_FALSE} }; + struct PP_Var result = { PP_VARTYPE_NULL, 0, {PP_FALSE} }; return result; } PP_INLINE struct PP_Var PP_MakeBool(PP_Bool value) { - struct PP_Var result = { PP_VARTYPE_BOOL, {PP_FALSE} }; + struct PP_Var result = { PP_VARTYPE_BOOL, 0, {PP_FALSE} }; result.value.as_bool = value; return result; } PP_INLINE struct PP_Var PP_MakeInt32(int32_t value) { - struct PP_Var result = { PP_VARTYPE_INT32, {PP_FALSE} }; + struct PP_Var result = { PP_VARTYPE_INT32, 0, {PP_FALSE} }; result.value.as_int = value; return result; } PP_INLINE struct PP_Var PP_MakeDouble(double value) { - struct PP_Var result = { PP_VARTYPE_DOUBLE, {PP_FALSE} }; + struct PP_Var result = { PP_VARTYPE_DOUBLE, 0, {PP_FALSE} }; result.value.as_double = value; return result; } diff --git a/ppapi/c/ppb_class.h b/ppapi/c/ppb_class.h index 5b027f9..0cb249c 100644 --- a/ppapi/c/ppb_class.h +++ b/ppapi/c/ppb_class.h @@ -11,7 +11,7 @@ #include "ppapi/c/pp_var.h" #include "ppapi/c/ppb_var.h" -#define PPB_CLASS_INTERFACE "PPB_Class;0.2" +#define PPB_CLASS_INTERFACE "PPB_Class;0.3" /** * @file diff --git a/ppapi/c/ppb_image_data.h b/ppapi/c/ppb_image_data.h index 6387941..ce9356f 100644 --- a/ppapi/c/ppb_image_data.h +++ b/ppapi/c/ppb_image_data.h @@ -6,6 +6,7 @@ #define PPAPI_C_PPB_IMAGE_DATA_H_ #include "ppapi/c/pp_bool.h" +#include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_module.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_size.h" @@ -15,6 +16,7 @@ typedef enum { PP_IMAGEDATAFORMAT_BGRA_PREMUL, PP_IMAGEDATAFORMAT_RGBA_PREMUL } PP_ImageDataFormat; +PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_ImageDataFormat, 4); struct PP_ImageDataDesc { PP_ImageDataFormat format; @@ -26,6 +28,7 @@ struct PP_ImageDataDesc { // may be padding at the end of the lines. int32_t stride; }; +PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_ImageDataDesc, 16); #define PPB_IMAGEDATA_INTERFACE "PPB_ImageData;0.2" diff --git a/ppapi/c/ppb_instance.h b/ppapi/c/ppb_instance.h index 2cb9d78..f7f137f 100644 --- a/ppapi/c/ppb_instance.h +++ b/ppapi/c/ppb_instance.h @@ -10,7 +10,7 @@ #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_var.h" -#define PPB_INSTANCE_INTERFACE "PPB_Instance;0.2" +#define PPB_INSTANCE_INTERFACE "PPB_Instance;0.3" /** * @file diff --git a/ppapi/c/ppb_url_request_info.h b/ppapi/c/ppb_url_request_info.h index 1c697fc1..5a8c1f2 100644 --- a/ppapi/c/ppb_url_request_info.h +++ b/ppapi/c/ppb_url_request_info.h @@ -6,6 +6,7 @@ #define PPAPI_C_PPB_URL_REQUEST_INFO_H_ #include "ppapi/c/pp_bool.h" +#include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_module.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" @@ -32,8 +33,9 @@ typedef enum { // Boolean (default = PP_FALSE). PP_URLREQUESTPROPERTY_RECORDUPLOADPROGRESS } PP_URLRequestProperty; +PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_URLRequestProperty, 4); -#define PPB_URLREQUESTINFO_INTERFACE "PPB_URLRequestInfo;1" +#define PPB_URLREQUESTINFO_INTERFACE "PPB_URLRequestInfo;1.1" struct PPB_URLRequestInfo { // Create a new URLRequestInfo object. Returns 0 if the module is invalid. diff --git a/ppapi/c/ppb_url_response_info.h b/ppapi/c/ppb_url_response_info.h index 97627ab..e9cec29 100644 --- a/ppapi/c/ppb_url_response_info.h +++ b/ppapi/c/ppb_url_response_info.h @@ -6,6 +6,7 @@ #define PPAPI_C_PPB_URL_RESPONSE_INFO_H_ #include "ppapi/c/pp_bool.h" +#include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_var.h" @@ -17,8 +18,9 @@ typedef enum { PP_URLRESPONSEPROPERTY_STATUSLINE, // string PP_URLRESPONSEPROPERTY_HEADERS // string, \n-delim } PP_URLResponseProperty; +PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_URLResponseProperty, 4); -#define PPB_URLRESPONSEINFO_INTERFACE "PPB_URLResponseInfo;1" +#define PPB_URLRESPONSEINFO_INTERFACE "PPB_URLResponseInfo;1.1" struct PPB_URLResponseInfo { // Returns PP_TRUE if the given resource is an URLResponseInfo. Returns diff --git a/ppapi/c/ppb_var.h b/ppapi/c/ppb_var.h index fe4c1ef..a4a1f25 100644 --- a/ppapi/c/ppb_var.h +++ b/ppapi/c/ppb_var.h @@ -13,7 +13,7 @@ #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_var.h" -#define PPB_VAR_INTERFACE "PPB_Var;0.2" +#define PPB_VAR_INTERFACE "PPB_Var;0.3" /** * @file @@ -33,6 +33,7 @@ enum PP_ObjectProperty_Modifier { PP_OBJECTPROPERTY_MODIFIER_DONTDELETE = 1 << 2, PP_OBJECTPROPERTY_MODIFIER_HASVALUE = 1 << 3 }; +PP_COMPILE_ASSERT_ENUM_SIZE_IN_BYTES(PP_ObjectProperty_Modifier, 4); struct PP_ObjectProperty { struct PP_Var name; @@ -40,7 +41,16 @@ struct PP_ObjectProperty { struct PP_Var getter; struct PP_Var setter; uint32_t modifiers; + + /** Ensure that this struct is 72 bytes wide by padding the end. In some + * compilers, PP_Var is 8-byte aligned, so those compilers align this struct + * on 8-byte boundaries as well and pad it to 72 bytes even without this + * padding attribute. This padding makes its size consistent across + * compilers. + */ + int32_t padding; }; +PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_ObjectProperty, 72); /** * PPB_Var API |