From 99f6f9e14d4cdcdd53b3df3cf107d041e662ea06 Mon Sep 17 00:00:00 2001 From: William Findlay Date: Wed, 27 Oct 2021 12:27:54 -0400 Subject: [PATCH] aya: fix include_bytes_aligned! macro to work in some corner cases I found a corner case in my own development workflow that caused the existing macro to not work properly. The following changes appear to fix things. Ideally, we could add some test cases to CI to prevent regressions. This would require creating a dedicated directory to hold test cases so that we can "include" them at compile time. --- aya/src/util.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/aya/src/util.rs b/aya/src/util.rs index 0586531b..796fb8d4 100644 --- a/aya/src/util.rs +++ b/aya/src/util.rs @@ -125,9 +125,12 @@ pub(crate) fn tc_handler_make(major: u32, minor: u32) -> u32 { #[macro_export] macro_rules! include_bytes_aligned { ($path:literal) => {{ + #[repr(align(32))] + pub struct Aligned32; + #[repr(C)] pub struct Aligned { - pub _align: [u32; 0], + pub _align: [Aligned32; 0], pub bytes: Bytes, }