2 * @brief Special compiler's definitions
\r
5 * Copyright(C) NXP Semiconductors, 2012
\r
6 * Copyright(C) Dean Camera, 2011, 2012
\r
7 * All rights reserved.
\r
10 * Software that is described herein is for illustrative purposes only
\r
11 * which provides customers with programming information regarding the
\r
12 * LPC products. This software is supplied "AS IS" without any warranties of
\r
13 * any kind, and NXP Semiconductors and its licensor disclaim any and
\r
14 * all warranties, express or implied, including all implied warranties of
\r
15 * merchantability, fitness for a particular purpose and non-infringement of
\r
16 * intellectual property rights. NXP Semiconductors assumes no responsibility
\r
17 * or liability for the use of the software, conveys no license or rights under any
\r
18 * patent, copyright, mask work right, or any other intellectual property rights in
\r
19 * or to any products. NXP Semiconductors reserves the right to make changes
\r
20 * in the software without notification. NXP Semiconductors also makes no
\r
21 * representation or warranty that such application will be suitable for the
\r
22 * specified use without further testing or modification.
\r
25 * Permission to use, copy, modify, and distribute this software and its
\r
26 * documentation is hereby granted, under NXP Semiconductors' and its
\r
27 * licensor's relevant copyrights in the software, without fee, provided that it
\r
28 * is used in conjunction with NXP Semiconductors microcontrollers. This
\r
29 * copyright, permission, and disclaimer notice must appear in all copies of
\r
35 /** @ingroup Group_Common
\r
36 * @defgroup Group_CompilerSpecific Compiler Specific Definitions
\r
37 * @brief Compiler specific definitions for code optimization and correctness.
\r
39 * Compiler specific definitions to expose certain compiler features which may increase the level of code optimization
\r
40 * for a specific compiler, or correct certain issues that may be present such as memory barriers for use in conjunction
\r
41 * with atomic variable access.
\r
43 * Where possible, on alternative compilers, these macros will either have no effect, or default to returning a sane value
\r
44 * so that they can be used in existing code without the need for extra compiler checks in the user application code.
\r
49 #ifndef __LPCUSBlib_COMPILERSPEC_H__
\r
50 #define __LPCUSBlib_COMPILERSPEC_H__
\r
52 /* Preprocessor Checks: */
\r
53 #if !defined(__INCLUDE_FROM_COMMON_H)
\r
54 #error Do not include this file directly. Include LPCUSBlib/Common/Common.h instead to gain this functionality.
\r
57 /* Public Interface - May be used in end-application: */
\r
59 #if defined(__GNUC__) || defined(__DOXYGEN__)
\r
60 /** Forces GCC to use pointer indirection (via the device's pointer register pairs) when accessing the given
\r
61 * struct pointer. In some cases GCC will emit non-optimal assembly code when accessing a structure through
\r
62 * a pointer, resulting in a larger binary. When this macro is used on a (non \c const) structure pointer before
\r
63 * use, it will force GCC to use pointer indirection on the elements rather than direct store and load
\r
66 * @param StructPtr Pointer to a structure which is to be forced into indirect access mode.
\r
68 #define GCC_FORCE_POINTER_ACCESS(StructPtr) __asm__ __volatile__("" : "=b" (StructPtr) : "0" (StructPtr))
\r
70 /** Forces GCC to create a memory barrier, ensuring that memory accesses are not reordered past the barrier point.
\r
71 * This can be used before ordering-critical operations, to ensure that the compiler does not re-order the resulting
\r
72 * assembly output in an unexpected manner on sections of code that are ordering-specific.
\r
74 #define GCC_MEMORY_BARRIER() // FIXME __asm__ __volatile__("" ::: "memory");
\r
76 /** Evaluates to boolean true if the specified value can be determined at compile time to be a constant value
\r
77 * when compiling under GCC.
\r
79 * @param x Value to check compile time constantness of.
\r
81 * @return Boolean true if the given value is known to be a compile time constant, false otherwise.
\r
83 #define GCC_IS_COMPILE_CONST(x) __builtin_constant_p(x)
\r
85 #define GCC_FORCE_POINTER_ACCESS(StructPtr)
\r
86 #define GCC_MEMORY_BARRIER()
\r
87 #define GCC_IS_COMPILE_CONST(x) 0
\r