Skip to content

Commit

Permalink
Ensure that context instance id storage is aligned correctly (#365)
Browse files Browse the repository at this point in the history
* Ensure that context instance id storage is aligned correctly

* Make alignment compatible with MSVC

* Namespace alignment macro with RCL_
  • Loading branch information
sgvandijk authored and sloretz committed Jan 3, 2019
1 parent f755c64 commit 22e61b4
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion rcl/include/rcl/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ extern "C"
#include "rcl/types.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;

struct rcl_context_impl_t;
Expand Down Expand Up @@ -132,7 +139,7 @@ typedef struct rcl_context_t
* 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
*/
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;

/// Return a zero initialization context object.
Expand Down

0 comments on commit 22e61b4

Please sign in to comment.