Ensure that context instance id storage is aligned correctly (#365)

* Ensure that context instance id storage is aligned correctly

* Make alignment compatible with MSVC

* Namespace alignment macro with RCL_
This commit is contained in:
sgvandijk 2019-01-03 19:54:08 +00:00 committed by Shane Loretz
parent f755c64de8
commit 22e61b4107

View file

@ -29,6 +29,13 @@ extern "C"
#include "rcl/types.h" #include "rcl/types.h"
#include "rcl/visibility_control.h" #include "rcl/visibility_control.h"
#ifdef _MSC_VER
#define RCL_ALIGNAS(N) __declspec(align(N))
#else
#include <stdalign.h>
#define RCL_ALIGNAS(N) alignas(N)
#endif
typedef uint64_t rcl_context_instance_id_t; typedef uint64_t rcl_context_instance_id_t;
struct rcl_context_impl_t; struct rcl_context_impl_t;
@ -132,7 +139,7 @@ typedef struct rcl_context_t
* See this paper for an effort to make this possible in the future: * See this paper for an effort to make this possible in the future:
* http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0943r1.html * http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0943r1.html
*/ */
uint8_t instance_id_storage[RCL_CONTEXT_ATOMIC_INSTANCE_ID_STORAGE_SIZE]; RCL_ALIGNAS(8) uint8_t instance_id_storage[RCL_CONTEXT_ATOMIC_INSTANCE_ID_STORAGE_SIZE];
} rcl_context_t; } rcl_context_t;
/// Return a zero initialization context object. /// Return a zero initialization context object.