Initial release

Fork of nrf51-sdk by Lancaster University

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers compiler_abstraction.h Source File

compiler_abstraction.h

00001 /*
00002  * Copyright (c) Nordic Semiconductor ASA
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without modification,
00006  * are permitted provided that the following conditions are met:
00007  *
00008  *   1. Redistributions of source code must retain the above copyright notice, this
00009  *   list of conditions and the following disclaimer.
00010  *
00011  *   2. Redistributions in binary form must reproduce the above copyright notice, this
00012  *   list of conditions and the following disclaimer in the documentation and/or
00013  *   other materials provided with the distribution.
00014  *
00015  *   3. Neither the name of Nordic Semiconductor ASA nor the names of other
00016  *   contributors to this software may be used to endorse or promote products
00017  *   derived from this software without specific prior written permission.
00018  *
00019  *
00020  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
00021  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00022  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00023  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
00024  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00025  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00026  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
00027  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00028  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00029  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00030  *
00031  */
00032 #ifndef _COMPILER_ABSTRACTION_H
00033 #define _COMPILER_ABSTRACTION_H
00034 
00035 /*lint ++flb "Enter library region" */
00036 
00037 #if defined ( __CC_ARM )
00038     
00039     #ifndef __ASM
00040         #define __ASM               __asm                       
00041     #endif
00042     
00043     #ifndef __INLINE
00044         #define __INLINE            __inline                    
00045     #endif
00046     
00047     #ifndef __WEAK
00048         #define __WEAK              __weak                      
00049     #endif
00050     
00051     #ifndef __ALIGN
00052         #define __ALIGN(n)          __align(n)                  
00053     #endif
00054     
00055     #define GET_SP()                __current_sp()              
00056   
00057 #elif defined ( __ICCARM__ )
00058     
00059     #ifndef __ASM
00060         #define __ASM               __asm                       
00061     #endif
00062     
00063     #ifndef __INLINE
00064         #define __INLINE            inline                      
00065     #endif
00066     
00067     #ifndef __WEAK
00068         #define __WEAK              __weak                      
00069     #endif
00070 
00071     /* Not defined for IAR since it requires a new line to work, and C preprocessor does not allow that. */
00072     #ifndef __ALIGN
00073         #define __ALIGN(n)          
00074     #endif
00075     
00076     #define GET_SP()                __get_SP()                  
00077     
00078 #elif defined   ( __GNUC__ )
00079     
00080     #ifndef __ASM
00081         #define __ASM               __asm                       
00082     #endif
00083     
00084     #ifndef __INLINE
00085         #define __INLINE            inline                      
00086     #endif
00087     
00088     #ifndef __WEAK
00089         #define __WEAK              __attribute__((weak))       
00090     #endif
00091     
00092     #ifndef __ALIGN
00093         #define __ALIGN(n)          __attribute__((aligned(n))) 
00094     #endif
00095     
00096     #define GET_SP()                gcc_current_sp()            
00097 
00098     static inline unsigned int gcc_current_sp(void)
00099     {
00100         register unsigned sp __ASM("sp");
00101         return sp;
00102     }
00103     
00104 #elif defined   ( __TASKING__ )
00105         
00106     #ifndef __ASM        
00107         #define __ASM               __asm                      
00108     #endif
00109     
00110     #ifndef __INLINE
00111         #define __INLINE            inline                     
00112     #endif
00113     
00114     #ifndef __WEAK
00115         #define __WEAK              __attribute__((weak))      
00116     #endif
00117     
00118     #ifndef __ALIGN
00119         #define __ALIGN(n)          __align(n)                  
00120     #endif
00121     
00122     #define GET_SP()                __get_MSP()                
00123     
00124 #endif
00125 
00126 /*lint --flb "Leave library region" */
00127 
00128 #endif