BA / Mbed OS BaBoRo1
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers fnet_comp.h Source File

fnet_comp.h

00001 /**************************************************************************
00002 *
00003 * Copyright 2011-2016 by Andrey Butok. FNET Community.
00004 * Copyright 2008-2010 by Andrey Butok. Freescale Semiconductor, Inc.
00005 *
00006 ***************************************************************************
00007 *
00008 *  Licensed under the Apache License, Version 2.0 (the "License"); you may
00009 *  not use this file except in compliance with the License.
00010 *  You may obtain a copy of the License at
00011 *
00012 *  http://www.apache.org/licenses/LICENSE-2.0
00013 *
00014 *  Unless required by applicable law or agreed to in writing, software
00015 *  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
00016 *  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00017 *  See the License for the specific language governing permissions and
00018 *  limitations under the License.
00019 *
00020 **********************************************************************/
00021 /*!
00022 * @brief C-compiler-specific definitions.
00023 *
00024 ***************************************************************************/
00025 
00026 
00027 #ifndef _FNET_COMP_H_
00028 
00029 #define _FNET_COMP_H_
00030 
00031 #include "fnet_config.h"
00032 
00033 #if FNET_CFG_COMP_CW
00034     /* To use _Pragma(), enable C99 Extensions. */
00035     #pragma c99 on
00036 
00037     /* For CW10.1 ARM compiler. After CW10.2 Release is obsolete. */
00038     #if FNET_MK
00039         #pragma load_store_elimination off   /*  Disable Load Store Optimization, workaround of CW10.x bug. */
00040         #define FNET_COMP_PACKED __attribute__ ((aligned (1)))
00041     #endif
00042 
00043     #if 1 /* Newest CWs pragma */
00044         #define FNET_COMP_PACKED_BEGIN  _Pragma("pack(1)")
00045         #define FNET_COMP_PACKED_END    _Pragma("pack()")
00046     #else /* Old CWs pragma */
00047         #define FNET_COMP_PACKED_BEGIN  _Pragma("options align = packed")
00048         #define FNET_COMP_PACKED_END    _Pragma("options align = reset")
00049     #endif
00050 
00051 #endif
00052 
00053 #if FNET_CFG_COMP_IAR
00054     /* Disable some warnings.*/
00055     #pragma diag_suppress=Pa039
00056 
00057     /* To use _Pragma(), enable C99 Extensions. */
00058     #define FNET_COMP_PACKED_BEGIN  _Pragma("pack(1)")
00059     #define FNET_COMP_PACKED_END    _Pragma("pack()")
00060 #endif
00061 
00062 #if FNET_CFG_COMP_UV
00063 
00064     /* To use anonimous unions.*/
00065     #pragma anon_unions
00066 
00067     /* To use _Pragma(), enable C99 Extensions. */
00068     #define FNET_COMP_PACKED_BEGIN  _Pragma("pack(1)")
00069     #define FNET_COMP_PACKED_END    _Pragma("pack(8)")
00070 
00071     #define FNET_COMP_PACKED_VAR    __packed
00072 #endif
00073 
00074 #if FNET_CFG_COMP_GNUC
00075     #define FNET_COMP_PACKED_BEGIN  _Pragma("pack(1)")
00076     #define FNET_COMP_PACKED_END    _Pragma("pack(8)")
00077     //#define FNET_COMP_PACKED __attribute__((aligned(1),packed))
00078 #endif
00079 
00080 #if FNET_CFG_COMP_GHS
00081     #define FNET_COMP_PACKED_BEGIN  _Pragma("pack(1)")
00082     #define FNET_COMP_PACKED_END    _Pragma("pack()")
00083 
00084     #define FNET_COMP_PACKED_VAR    __packed
00085 #endif
00086 
00087 #if FNET_CFG_COMP_DCC
00088     #pragma option -Xalign-min=1
00089     #define FNET_COMP_PACKED_BEGIN  #pragma pack(2,2)
00090     #define FNET_COMP_PACKED_END    #pragma pack(4,2)
00091 #endif
00092 
00093 /* Changes the current alignment mode for one member in a structure
00094  *  so that member will be packed on a 1-byte boundary */
00095 #ifndef FNET_COMP_PACKED
00096     #define FNET_COMP_PACKED
00097 #endif
00098 
00099 /* Modifies the current alignment mode in the structure,
00100 which causes that member to be packed on a 1-byte boundary
00101 */
00102 #ifndef FNET_COMP_PACKED_BEGIN
00103     #define FNET_COMP_PACKED_BEGIN
00104 #endif
00105 
00106 /* Modifies the current alignment mode of the variable to unaligned.
00107 */
00108 #ifndef FNET_COMP_PACKED_VAR
00109     #define FNET_COMP_PACKED_VAR
00110 #endif
00111 
00112 /* Restore alignment mode.*/
00113 #ifndef FNET_COMP_PACKED_END
00114     #define FNET_COMP_PACKED_END
00115 #endif
00116 
00117 /* Mark unused function argument. To avoid compiler warnings.*/
00118 #ifndef FNET_COMP_UNUSED_ARG
00119     #define FNET_COMP_UNUSED_ARG(x) (void)(x)
00120 #endif
00121 
00122 #endif /* _FNET_COMP_H_ */