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:
parent
3f44105695
commit
941cab98b0
3 changed files with 6 additions and 17 deletions
|
@ -95,6 +95,7 @@ $ nm offsets.o
|
||||||
|
|
||||||
/*#include "../../../../../include/absSym.h"*/
|
/*#include "../../../../../include/absSym.h"*/
|
||||||
#include <absSym.h>
|
#include <absSym.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
|
|
||||||
|
@ -118,19 +119,10 @@ $ nm offsets.o
|
||||||
|
|
||||||
#endif /* end of "unsupported toolchain" */
|
#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 */
|
/* definition of the GEN_OFFSET_SYM() macros is toolchain independant */
|
||||||
|
|
||||||
#define GEN_OFFSET_SYM(S, M) \
|
#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.
|
* Macro used to generate an absolute symbol utilized by host-side tools.
|
||||||
|
|
|
@ -33,10 +33,6 @@
|
||||||
#ifndef _FLOATCONTEXT_H
|
#ifndef _FLOATCONTEXT_H
|
||||||
#define _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
|
* Each architecture must define the FP_REG_SET and FP_NONVOLATILE_REG_SET
|
||||||
* structures, and tailor the architecture specific implementations of
|
* structures, and tailor the architecture specific implementations of
|
||||||
|
|
|
@ -96,6 +96,7 @@ x87 FPU registers are being saved/restored.
|
||||||
#include <nanokernel/cpu.h>
|
#include <nanokernel/cpu.h>
|
||||||
#include <tc_util.h>
|
#include <tc_util.h>
|
||||||
#include "float_context.h"
|
#include "float_context.h"
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
#ifndef MAX_TESTS
|
#ifndef MAX_TESTS
|
||||||
/* test duration, unless overridden by project builder (0 => run forever) */
|
/* test duration, unless overridden by project builder (0 => run forever) */
|
||||||
|
@ -416,7 +417,7 @@ void load_store_high(void)
|
||||||
|
|
||||||
numNonVolatileBytes = 0;
|
numNonVolatileBytes = 0;
|
||||||
|
|
||||||
for (bufIx = OFFSET(FP_REG_SET, fpNonVolRegSet);
|
for (bufIx = offsetof(FP_REG_SET, fpNonVolRegSet);
|
||||||
numNonVolatileBytes < SIZEOF_FP_NONVOLATILE_REG_SET;
|
numNonVolatileBytes < SIZEOF_FP_NONVOLATILE_REG_SET;
|
||||||
++bufIx, ++numNonVolatileBytes)
|
++bufIx, ++numNonVolatileBytes)
|
||||||
floatRegisterSetBytePtr[bufIx] = 0;
|
floatRegisterSetBytePtr[bufIx] = 0;
|
||||||
|
@ -450,9 +451,9 @@ void load_store_high(void)
|
||||||
|
|
||||||
numNonVolatileBytes = 0;
|
numNonVolatileBytes = 0;
|
||||||
floatRegInitByte = FIBER_FLOAT_REG_CHECK_BYTE +
|
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;
|
numNonVolatileBytes < SIZEOF_FP_NONVOLATILE_REG_SET;
|
||||||
++bufIx, ++numNonVolatileBytes) {
|
++bufIx, ++numNonVolatileBytes) {
|
||||||
if (floatRegisterSetBytePtr[bufIx] !=
|
if (floatRegisterSetBytePtr[bufIx] !=
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue