/* * XIOH power sequence * Copyright (C) 2013 Avencall * * compiler.h - compiler dependant defines * Authors: * Guillaume Knispel * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef COMPILER_H #define COMPILER_H /* MY_IAR, MY_TI, and MY_GCC are here to ease further compilation conditionals. * Remember that a lot of non-gcc compilers also define __GNUC__ so * directly testing against that is not a good idea. * * The SV() macro stands for "State Value". * It is used to create enum values latter used in switches with in_range. * in_range expands to __even_in_range when supported, in which case * the values should be even. * GCC seems happier with consecutive values. * * MASK_MISRA and UNMASK_MISRA are used to temporarily disable MISRA rules * checking that is provided by TI MSP430 Optimizing C compiler. */ #if defined(__IAR_SYSTEMS_ICC__) # define MY_IAR # define MASK_MISRA # define UNMASK_MISRA # define SV(v) ((v) * 2) # define in_range __even_in_range # define out_range(v, mx) ((v) > (mx)) #elif defined(__TI_COMPILER_VERSION) || defined(__TI_COMPILER_VERSION__) # define MY_TI # define EMIT_PRAGMA(x) _Pragma(#x) # define MASK_MISRA EMIT_PRAGMA(CHECK_MISRA ("none")) # define UNMASK_MISRA EMIT_PRAGMA(RESET_MISRA ("all")) # define SV(v) ((v) * 2) # define in_range __even_in_range # define out_range(v, mx) (((v) & 1) || ((v) > (mx))) #else /* GCC */ # define MY_GCC # define MASK_MISRA # define UNMASK_MISRA # define in_range(v, mx) (v) # define out_range(v, mx) ((v) > (mx)) # define SV(v) (v) #endif /* IAR / TI / GCC */ #endif /* COMPILER_H */