diff --git a/kernel/nanokernel/include/genOffset.h b/kernel/nanokernel/include/genOffset.h index f414ef9af4c..869a9b7e642 100644 --- a/kernel/nanokernel/include/genOffset.h +++ b/kernel/nanokernel/include/genOffset.h @@ -95,6 +95,7 @@ $ nm offsets.o /*#include "../../../../../include/absSym.h"*/ #include +#include #ifdef __GNUC__ @@ -118,19 +119,10 @@ $ nm offsets.o #endif /* end of "unsupported toolchain" */ -/* - * Use the OFFSET() in the event the ANSI C offsetof() macro is not - * suppported. - */ - -/* byte offset of member in structure */ - -#define OFFSET(structure, member) ((long)&(((structure *)0)->member)) - /* definition of the GEN_OFFSET_SYM() macros is toolchain independant */ #define GEN_OFFSET_SYM(S, M) \ - GEN_ABSOLUTE_SYM(__##S##_##M##_##OFFSET, OFFSET(S, M)) + GEN_ABSOLUTE_SYM(__##S##_##M##_##OFFSET, offsetof(S, M)) /* * Macro used to generate an absolute symbol utilized by host-side tools. diff --git a/samples/microkernel/test/test_fp_sharing/src/float_context.h b/samples/microkernel/test/test_fp_sharing/src/float_context.h index becaa9e7271..d66d82417ec 100644 --- a/samples/microkernel/test/test_fp_sharing/src/float_context.h +++ b/samples/microkernel/test/test_fp_sharing/src/float_context.h @@ -33,10 +33,6 @@ #ifndef _FLOATCONTEXT_H #define _FLOATCONTEXT_H -/* byte offset of member in structure */ - -#define OFFSET(structure, member) ((long)&(((structure *)0)->member)) - /* * Each architecture must define the FP_REG_SET and FP_NONVOLATILE_REG_SET * structures, and tailor the architecture specific implementations of diff --git a/samples/microkernel/test/test_fp_sharing/src/main.c b/samples/microkernel/test/test_fp_sharing/src/main.c index f06da4c3e1c..41a8c2b5e31 100644 --- a/samples/microkernel/test/test_fp_sharing/src/main.c +++ b/samples/microkernel/test/test_fp_sharing/src/main.c @@ -96,6 +96,7 @@ x87 FPU registers are being saved/restored. #include #include #include "float_context.h" +#include #ifndef MAX_TESTS /* test duration, unless overridden by project builder (0 => run forever) */ @@ -416,7 +417,7 @@ void load_store_high(void) numNonVolatileBytes = 0; - for (bufIx = OFFSET(FP_REG_SET, fpNonVolRegSet); + for (bufIx = offsetof(FP_REG_SET, fpNonVolRegSet); numNonVolatileBytes < SIZEOF_FP_NONVOLATILE_REG_SET; ++bufIx, ++numNonVolatileBytes) floatRegisterSetBytePtr[bufIx] = 0; @@ -450,9 +451,9 @@ void load_store_high(void) numNonVolatileBytes = 0; floatRegInitByte = FIBER_FLOAT_REG_CHECK_BYTE + - OFFSET(FP_REG_SET, fpNonVolRegSet); + offsetof(FP_REG_SET, fpNonVolRegSet); - for (bufIx = OFFSET(FP_REG_SET, fpNonVolRegSet); + for (bufIx = offsetof(FP_REG_SET, fpNonVolRegSet); numNonVolatileBytes < SIZEOF_FP_NONVOLATILE_REG_SET; ++bufIx, ++numNonVolatileBytes) { if (floatRegisterSetBytePtr[bufIx] !=