Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers fnet_comp.h Source File

fnet_comp.h

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