From 47b58f5ccb9c1b1fe3c42f4d9b8727978c45b82a Mon Sep 17 00:00:00 2001 From: Yuval Tassa Date: Thu, 16 Mar 2023 16:26:46 -0700 Subject: [PATCH] Move memory-alignment static utility from engine_macro.h to engine_io.c PiperOrigin-RevId: 517259347 Change-Id: Ic3f67e9018fe8903e709128674c0da10032e2162 --- src/engine/engine_io.c | 9 +++++++++ src/engine/engine_macro.h | 7 ------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/engine/engine_io.c b/src/engine/engine_io.c index 6c348b25..f4f8c79d 100644 --- a/src/engine/engine_io.c +++ b/src/engine/engine_io.c @@ -308,6 +308,15 @@ static void bufread(void* dest, int num, int szbuf, const void* buf, int* ptrbuf +// number of bytes to be skipped to achieve 64-byte alignment +static inline unsigned int SKIP(intptr_t offset) { + const unsigned int align = 64; + // compute skipped bytes + return (align - (offset % align)) % align; +} + + + //----------------------------------- mjModel construction ----------------------------------------- // set pointers in mjModel buffer diff --git a/src/engine/engine_macro.h b/src/engine/engine_macro.h index 3ad6dca6..d9086197 100644 --- a/src/engine/engine_macro.h +++ b/src/engine/engine_macro.h @@ -73,11 +73,4 @@ #define PTRDIFF(x, y) ((char*)(x) - (char*)(y)) -// number of bytes to be skipped to achieve 64-byte alignment -static inline unsigned int SKIP(intptr_t offset) { - const unsigned int align = 64; - // compute skipped bytes - return (align - (offset % align)) % align; -} - #endif // MUJOCO_SRC_ENGINE_ENGINE_MACRO_H_