xtensa: move byte-order macros out of arch.h

These are macros that are expected to be defined at all times by
the compiler. We need them at the very beginning of kernel.h for
the k_thread definition, before it's possible to include arch.h.

Make a special toolchain header for XCC compiler and place these
defines in there. Otherwise inherit all the other GCC defines.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
Andrew Boie 2017-05-10 13:28:38 -07:00 committed by Anas Nashif
commit a2b324035c
3 changed files with 35 additions and 16 deletions

View file

@ -26,21 +26,6 @@ extern "C" {
#include <arch/xtensa/xtensa_irq.h> #include <arch/xtensa/xtensa_irq.h>
#include <xtensa/config/core.h> #include <xtensa/config/core.h>
/*
* XCC does not define the following macros with the expected names, but the
* file machine/endian.h from XT_LIB defines similar ones. Thus we include it
* and define the missing macros ourselves.
*/
#ifndef __BYTE_ORDER__
#define __BYTE_ORDER__ XCHAL_MEMORY_ORDER
#endif
#ifndef __ORDER_BIG_ENDIAN__
#define __ORDER_BIG_ENDIAN__ XTHAL_BIGENDIAN
#endif
#ifndef __ORDER_LITTLE_ENDIAN__
#define __ORDER_LITTLE_ENDIAN__ XTHAL_LITTLEENDIAN
#endif
#define STACK_ALIGN 16 #define STACK_ALIGN 16
#define OCTET_TO_SIZEOFUNIT(X) (X) #define OCTET_TO_SIZEOFUNIT(X) (X)
#define SIZEOFUNIT_TO_OCTET(X) (X) #define SIZEOFUNIT_TO_OCTET(X) (X)

View file

@ -15,7 +15,9 @@
#ifndef _TOOLCHAIN_H #ifndef _TOOLCHAIN_H
#define _TOOLCHAIN_H #define _TOOLCHAIN_H
#if defined(__GNUC__) || (defined(_LINKER) && defined(__GCC_LINKER_CMD__)) #if defined(__XCC__)
#include <toolchain/xcc.h>
#elif defined(__GNUC__) || (defined(_LINKER) && defined(__GCC_LINKER_CMD__))
#include <toolchain/gcc.h> #include <toolchain/gcc.h>
#else #else
#include <toolchain/other.h> #include <toolchain/other.h>

32
include/toolchain/xcc.h Normal file
View file

@ -0,0 +1,32 @@
/*
* Copyright (c) 2017 Intel Corporation
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef _XCC_TOOLCHAIN_H_
#define _XCC_TOOLCHAIN_H_
#include <toolchain/gcc.h>
#ifndef __GCC_LINKER_CMD__
#include <xtensa/config/core.h>
/*
* XCC does not define the following macros with the expected names, but the
* HAL defines similar ones. Thus we include it and define the missing macros
* ourselves.
*/
#ifndef __BYTE_ORDER__
#define __BYTE_ORDER__ XCHAL_MEMORY_ORDER
#endif
#ifndef __ORDER_BIG_ENDIAN__
#define __ORDER_BIG_ENDIAN__ XTHAL_BIGENDIAN
#endif
#ifndef __ORDER_LITTLE_ENDIAN__
#define __ORDER_LITTLE_ENDIAN__ XTHAL_LITTLEENDIAN
#endif
#endif /* __GCC_LINKER_CMD__ */
#endif