Replace use of OFFSET with stddef's offsetof

Instances of the custom OFFSET() macro are replaced with the standard
offsetof() macro from stddef.h to reduce code duplication.

Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
This commit is contained in:
Peter Mitsis 2015-04-14 10:57:14 -04:00 committed by Anas Nashif
commit 941cab98b0
3 changed files with 6 additions and 17 deletions

View file

@ -95,6 +95,7 @@ $ nm offsets.o
/*#include "../../../../../include/absSym.h"*/
#include <absSym.h>
#include <stddef.h>
#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.

View file

@ -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

View file

@ -96,6 +96,7 @@ x87 FPU registers are being saved/restored.
#include <nanokernel/cpu.h>
#include <tc_util.h>
#include "float_context.h"
#include <stddef.h>
#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] !=