Merge pull request #9724 from MisterDA/fix-domain-state

Fix #9714 "Compilation failure in domain_state.h"
master
David Allsopp 2020-07-03 13:38:57 +01:00 committed by GitHub
commit bdb471287f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 3 deletions

View File

@ -260,6 +260,12 @@ Working version
(Xavier Leroy, Sadiq Jaffer, Gabriel Scherer,
review by Xavier Leroy and Jacques-Henri Jourdan)
- #9714, #9724: Use the C++ alignas keyword when compiling in C++.
Fixes a bug with MSVC C++ 2015/2017. Add a terminator to the
`caml_domain_state` structure to better ensure that members are
correctly spaced.
(Antonin Décimo, review by David Allsopp and Xavier Leroy)
OCaml 4.11
----------

View File

@ -33,6 +33,7 @@ typedef struct {
#endif
#include "domain_state.tbl"
#undef DOMAIN_STATE
CAMLalign(8) char end_of_domain_state;
} caml_domain_state;
enum {
@ -45,9 +46,8 @@ enum {
/* Check that the structure was laid out without padding,
since the runtime assumes this in computing offsets */
CAML_STATIC_ASSERT(
sizeof(caml_domain_state) ==
(Domain_state_num_fields
) * 8);
offsetof(caml_domain_state, end_of_domain_state) ==
Domain_state_num_fields * 8);
CAMLextern caml_domain_state* Caml_state;
#ifdef CAML_NAME_SPACE

View File

@ -96,6 +96,8 @@ CAMLdeprecated_typedef(addr, char *);
/* we need to be able to compute the exact offset of each member. */
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
#define CAMLalign(n) _Alignas(n)
#elif defined(__cplusplus) && (__cplusplus >= 201103L || _MSC_VER >= 1900)
#define CAMLalign(n) alignas(n)
#elif defined(SUPPORTS_ALIGNED_ATTRIBUTE)
#define CAMLalign(n) __attribute__((aligned(n)))
#elif _MSC_VER >= 1500