summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ppapi/c/pp_input_event.h9
-rw-r--r--ppapi/c/pp_macros.h33
-rw-r--r--ppapi/c/ppp_instance.h2
3 files changed, 40 insertions, 4 deletions
diff --git a/ppapi/c/pp_input_event.h b/ppapi/c/pp_input_event.h
index 715c016..7f95e09 100644
--- a/ppapi/c/pp_input_event.h
+++ b/ppapi/c/pp_input_event.h
@@ -14,6 +14,7 @@
*/
#include "ppapi/c/pp_bool.h"
+#include "ppapi/c/pp_macros.h"
#include "ppapi/c/pp_stdint.h"
#include "ppapi/c/pp_time.h"
@@ -149,6 +150,10 @@ struct PP_InputEvent_Wheel {
PP_Bool scroll_by_page;
};
+/* Ensure the elements of the struct (especially the time_stamp) are aligned on
+ 8-byte boundaries, since some compilers align doubles on 8-byte boundaries
+ for 32-bit x86, and some align on 4-byte boundaries. */
+#pragma pack(push, 8)
struct PP_InputEvent {
/** Identifies the type of the event. */
PP_InputEvent_Type type;
@@ -173,6 +178,10 @@ struct PP_InputEvent {
char padding[64];
} u;
};
+#pragma pack(pop)
+/* TODO(dmichael): Figure out why the input event is not 80 bytes wide on Mac.
+PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_InputEvent, 80);
+ */
/**
* @}
diff --git a/ppapi/c/pp_macros.h b/ppapi/c/pp_macros.h
index ffc48b0..a46ea2e 100644
--- a/ppapi/c/pp_macros.h
+++ b/ppapi/c/pp_macros.h
@@ -42,12 +42,39 @@
(which should always be valid) if the enum's size is SIZE, and otherwise the
size of the array will be -1 (which all/most compilers should flag as an
error). This is wrapped inside a struct, because if it is a simple global
- we get multiple definition errors at link time. */
-#define PP_COMPILE_ASSERT_SIZE_IN_BYTES(NAME, SIZE) \
+ we get multiple definition errors at link time.
+
+ NAME is the name of the type without any spaces or the struct or enum
+ keywords.
+
+ CTYPENAME is the typename required by C. I.e., for a struct or enum, the
+ appropriate keyword must be included.
+
+ SIZE is the expected size in bytes.
+ */
+#define PP_COMPILE_ASSERT_SIZE_IN_BYTES_IMPL(NAME, CTYPENAME, SIZE) \
struct _dummy_struct_for_##NAME { \
char _COMPILE_ASSERT_FAILED_The_type_named_ \
## NAME ## _is_not_ ## SIZE ## \
-_bytes_wide[(sizeof(NAME) == SIZE) ? 1 : -1]; }
+_bytes_wide[(sizeof(CTYPENAME) == SIZE) ? 1 : -1]; }
+
+/* PP_COMPILE_ASSERT_SIZE_IN_BYTES is for typenames that contain no spaces.
+ E.g.:
+ PP_COMPILE_ASSERT_SIZE_IN_BYTES(int, 4);
+ typedef struct { int a; } Foo;
+ PP_COMPILE_ASSERT_SIZE_IN_BYTES(Foo, 4);
+ */
+#define PP_COMPILE_ASSERT_SIZE_IN_BYTES(NAME, SIZE) \
+PP_COMPILE_ASSERT_SIZE_IN_BYTES_IMPL(NAME, NAME, SIZE)
+
+/* PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES is for typenames that contain 'struct'
+ in C. That is, struct names that are not typedefs.
+ E.g.:
+ struct Foo { int a; };
+ PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(Foo, 4);
+ */
+#define PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(NAME, SIZE) \
+PP_COMPILE_ASSERT_SIZE_IN_BYTES_IMPL(NAME, struct NAME, SIZE)
/**
* @}
diff --git a/ppapi/c/ppp_instance.h b/ppapi/c/ppp_instance.h
index cb7988d..19907ca 100644
--- a/ppapi/c/ppp_instance.h
+++ b/ppapi/c/ppp_instance.h
@@ -13,7 +13,7 @@
struct PP_InputEvent;
struct PP_Var;
-#define PPP_INSTANCE_INTERFACE "PPP_Instance;0.2"
+#define PPP_INSTANCE_INTERFACE "PPP_Instance;0.3"
/**
* @file