Compiler specific configuration

If a source code file depends on a configuration option,
that, in turn, depends on a compiler, this file has to
include toolchain.h.

toolchain.h includes a compiler specific header file that
sets the proper configuration option.

Change-Id: I7c9002522a8c6d6fd945e27a450ebe46ba9d4892
Signed-off-by: Dmitriy Korovkin <dmitriy.korovkin@windriver.com>
This commit is contained in:
Dmitriy Korovkin 2015-04-27 18:03:01 -04:00 committed by Anas Nashif
commit e82a2a36c7
6 changed files with 4 additions and 99 deletions

View file

@ -36,12 +36,6 @@ This module provides the _NanoFatalErrorHandler() routine.
*/ */
/* includes */ /* includes */
/* Stack canaries not supported on Diab */
#ifdef __DCC__
#undef CONFIG_STACK_CANARIES
#endif
#include <toolchain.h> #include <toolchain.h>
#include <sections.h> #include <sections.h>

View file

@ -34,9 +34,7 @@
#define __NANOKERNEL_H__ #define __NANOKERNEL_H__
#include <stdint.h> #include <stdint.h>
#ifdef __DCC__ #include <toolchain.h> /* compiler specific configuration options */
#undef CONFIG_STACK_CANARIES
#endif
#include <nanokernel/private.h> #include <nanokernel/private.h>
#include <kernel_version.h> #include <kernel_version.h>

View file

@ -41,12 +41,10 @@ utilize toolchain specific attributes and/or pragmas.
#ifndef _TOOLCHAIN_H #ifndef _TOOLCHAIN_H
#define _TOOLCHAIN_H #define _TOOLCHAIN_H
#if defined(__GNUC__) #if defined(__GNUC__) || (defined(_LINKER) && defined(__GCC_LINKER_CMD__))
#include <toolchain/gcc.h> #include <toolchain/gcc.h>
#elif defined(__DCC__)
#include <toolchain/diab.h>
#else #else
#include <toolchain/unsupported.h> #include <toolchain/other.h>
#endif #endif
#endif /* _TOOLCHAIN_H */ #endif /* _TOOLCHAIN_H */

View file

@ -46,18 +46,6 @@
#define FUNC_CONSTRUCT(lvl) __attribute__((constructor(lvl))) #define FUNC_CONSTRUCT(lvl) __attribute__((constructor(lvl)))
/*
* The Intel C Compiler defines both __INTEL_COMPILER and __GNUC__; the
* GNU C Compiler defines only __GNUC__. Consequently, to differentiate
* between those two compilers, checks for __INTEL_COMPILER must be done
* before __GNUC__.
*/
#if defined (__INTEL_COMPILER)
#define CODE_UNREACHABLE
#define FUNC_NORETURN
#define _NODATA_SECTION(segment) __attribute__((section(#segment)))
#else
#define CODE_UNREACHABLE __builtin_unreachable () #define CODE_UNREACHABLE __builtin_unreachable ()
#define FUNC_NORETURN __attribute__((__noreturn__)) #define FUNC_NORETURN __attribute__((__noreturn__))
@ -70,7 +58,6 @@
#define _NODATA_SECTION(segment) \ #define _NODATA_SECTION(segment) \
__attribute__((section(#segment ",\"wa\",@nobits#"))) __attribute__((section(#segment ",\"wa\",@nobits#")))
#endif #endif
#endif
/* /*
* Unaligned reads and writes * Unaligned reads and writes

View file

@ -1,68 +0,0 @@
/* toolchain/unsupported.h - unsupported toolchain abstraction */
/*
* Copyright (c) 2010-2014 Wind River Systems, Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1) Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2) Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3) Neither the name of Wind River Systems nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
DESCRIPTION
Macros to abstract compiler capabilities for unsupported toolchains
\NOMANUAL
*/
#define FUNC_ALIAS(func, aliasToFunc, retType) \
#error FUNC_ALIAS(): unsupported toolchain
#define FUNC_CONSTRUCT(lvl) #error FUNC_CONSTRUCT() : unsupported toolchain
/*
* Do nothing if not using a supported compiler. The end result will
* simply not be as memory efficient as it could be.
*/
#define CODE_UNREACHABLE
#define FUNC_NORETURN #warning FUNC_NORETURN : unsupported toolchain
#define _NODATA_SECTION(segment) __attribute__((section(#segment)))
#define _GENERIC_SECTION(segment) __attribute__((section(#segment)))
#define PACK_STRUCT #error PACK_STRUCT : unsupported toolchain
#define ALIGN_STRUCT(x) #error ALIGN_STRUCT() : unsupported toolchain
/*
* Do nothing if not using a supported compiler.
*/
#define ARG_UNUSED(x)
#define likely(x) (x)
#define unlikely(x) (x)
#define REQUIRES(sym) #error REQUIRES() : unsupported toolchain

View file

@ -41,11 +41,7 @@ function __stack_chk_fail and global variable __stack_chk_guard.
*/ */
/* includes */ /* includes */
#include <toolchain.h> /* compiler specific configurations */
/* Stack canaries not supported on Diab */
#ifdef __DCC__
#undef CONFIG_STACK_CANARIES
#endif
#if defined(CONFIG_STACK_CANARIES) #if defined(CONFIG_STACK_CANARIES)