diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-12 14:27:29 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-13 09:35:20 +0000 |
commit | c30a6232df03e1efbd9f3b226777b07e087a1122 (patch) | |
tree | e992f45784689f373bcc38d1b79a239ebe17ee23 /chromium/mojo/public/c/system/macros.h | |
parent | 7b5b123ac58f58ffde0f4f6e488bcd09aa4decd3 (diff) | |
download | qtwebengine-chromium-85-based.tar.gz |
BASELINE: Update Chromium to 85.0.4183.14085-based
Change-Id: Iaa42f4680837c57725b1344f108c0196741f6057
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/mojo/public/c/system/macros.h')
-rw-r--r-- | chromium/mojo/public/c/system/macros.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/chromium/mojo/public/c/system/macros.h b/chromium/mojo/public/c/system/macros.h index 1023e1c111a..ebacb7482ac 100644 --- a/chromium/mojo/public/c/system/macros.h +++ b/chromium/mojo/public/c/system/macros.h @@ -6,6 +6,7 @@ #define MOJO_PUBLIC_C_SYSTEM_MACROS_H_ #include <stddef.h> +#include <stdint.h> #if !defined(__cplusplus) #include <assert.h> // Defines static_assert() in C11. @@ -29,6 +30,18 @@ // Like the C++11 |alignof| operator. #define MOJO_ALIGNOF(type) alignof(type) +// Provides a convenient test for the presence of a field in a user-provided +// structure from a potentially older version of the ABI. Presence is determined +// by comparing the struct's provided |struct_size| value against the known +// offset and size of the field in this version of the ABI. Because fields are +// never reordered or removed, this is a sufficient test for the field's +// presence within whatever version of the ABI the client is programmed against. +#define MOJO_IS_STRUCT_FIELD_PRESENT(struct_pointer, field) \ + ((size_t)(uintptr_t)((const char*)&(struct_pointer)->field - \ + (const char*)(struct_pointer)) + \ + sizeof((struct_pointer)->field) <= \ + (struct_pointer)->struct_size) + // Specify the alignment of a |struct|, etc. // Use like: // struct MOJO_ALIGNAS(8) Foo { ... }; |