00001 /** 00002 * \file 00003 * Default definitions of C compiler quirk work-arounds. 00004 * \author Adam Dunkels <adam@dunkels.com> 00005 * 00006 * This file is used for making use of extra functionality of some C 00007 * compilers used for Contiki, and defining work-arounds for various 00008 * quirks and problems with some other C compilers. 00009 */ 00010 00011 /* 00012 * Copyright (c) 2003, Adam Dunkels. 00013 * All rights reserved. 00014 * 00015 * Redistribution and use in source and binary forms, with or without 00016 * modification, are permitted provided that the following conditions 00017 * are met: 00018 * 1. Redistributions of source code must retain the above copyright 00019 * notice, this list of conditions and the following disclaimer. 00020 * 2. Redistributions in binary form must reproduce the above 00021 * copyright notice, this list of conditions and the following 00022 * disclaimer in the documentation and/or other materials provided 00023 * with the distribution. 00024 * 3. The name of the author may not be used to endorse or promote 00025 * products derived from this software without specific prior 00026 * written permission. 00027 * 00028 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 00029 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 00030 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00031 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 00032 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00033 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 00034 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00035 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 00036 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00037 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00038 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00039 * 00040 * This file is part of the Contiki desktop OS 00041 * 00042 * $Id: cc.h,v 1.6 2008/07/02 08:35:29 adamdunkels Exp $ 00043 * 00044 */ 00045 #ifndef __CC_H__ 00046 #define __CC_H__ 00047 00048 #include "contiki-conf.h" 00049 00050 /** 00051 * Configure if the C compiler supports the "register" keyword for 00052 * function arguments. 00053 */ 00054 #if CC_CONF_REGISTER_ARGS 00055 #define CC_REGISTER_ARG register 00056 #else /* CC_CONF_REGISTER_ARGS */ 00057 #define CC_REGISTER_ARG 00058 #endif /* CC_CONF_REGISTER_ARGS */ 00059 00060 /** 00061 * Configure if the C compiler supports the arguments for function 00062 * pointers. 00063 */ 00064 #if CC_CONF_FUNCTION_POINTER_ARGS 00065 #define CC_FUNCTION_POINTER_ARGS 1 00066 #else /* CC_CONF_FUNCTION_POINTER_ARGS */ 00067 #define CC_FUNCTION_POINTER_ARGS 0 00068 #endif /* CC_CONF_FUNCTION_POINTER_ARGS */ 00069 00070 /** 00071 * Configure if the C compiler supports fastcall function 00072 * declarations. 00073 */ 00074 #ifdef CC_CONF_FASTCALL 00075 #define CC_FASTCALL CC_CONF_FASTCALL 00076 #else /* CC_CONF_FASTCALL */ 00077 #define CC_FASTCALL 00078 #endif /* CC_CONF_FASTCALL */ 00079 00080 /** 00081 * Configure if the C compiler have problems with const function pointers 00082 */ 00083 #ifdef CC_CONF_CONST_FUNCTION_BUG 00084 #define CC_CONST_FUNCTION 00085 #else /* CC_CONF_FASTCALL */ 00086 #define CC_CONST_FUNCTION const 00087 #endif /* CC_CONF_FASTCALL */ 00088 00089 /** 00090 * Configure work-around for unsigned char bugs with sdcc. 00091 */ 00092 #if CC_CONF_UNSIGNED_CHAR_BUGS 00093 #define CC_UNSIGNED_CHAR_BUGS 1 00094 #else /* CC_CONF_UNSIGNED_CHAR_BUGS */ 00095 #define CC_UNSIGNED_CHAR_BUGS 0 00096 #endif /* CC_CONF_UNSIGNED_CHAR_BUGS */ 00097 00098 /** 00099 * Configure if C compiler supports double hash marks in C macros. 00100 */ 00101 #if CC_CONF_DOUBLE_HASH 00102 #define CC_DOUBLE_HASH 1 00103 #else /* CC_CONF_DOUBLE_HASH */ 00104 #define CC_DOUBLE_HASH 0 00105 #endif /* CC_CONF_DOUBLE_HASH */ 00106 00107 #ifdef CC_CONF_INLINE 00108 #define CC_INLINE CC_CONF_INLINE 00109 #else /* CC_CONF_INLINE */ 00110 #define CC_INLINE 00111 #endif /* CC_CONF_INLINE */ 00112 00113 /** 00114 * Configure if the C compiler supports the assignment of struct value. 00115 */ 00116 #ifdef CC_CONF_ASSIGN_AGGREGATE 00117 #define CC_ASSIGN_AGGREGATE(dest, src) CC_CONF_ASSIGN_AGGREGATE(dest, src) 00118 #else /* CC_CONF_ASSIGN_AGGREGATE */ 00119 #define CC_ASSIGN_AGGREGATE(dest, src) *dest = *src 00120 #endif /* CC_CONF_ASSIGN_AGGREGATE */ 00121 00122 #if CC_CONF_NO_VA_ARGS 00123 #define CC_NO_VA_ARGS CC_CONF_VA_ARGS 00124 #endif 00125 00126 #ifndef NULL 00127 #define NULL 0 00128 #endif /* NULL */ 00129 00130 #define CC_CONCAT2(s1, s2) s1##s2 00131 /** 00132 * A C preprocessing macro for concatenating to 00133 * strings. 00134 * 00135 * We need use two macros (CC_CONCAT and CC_CONCAT2) in order to allow 00136 * concatenation of two #defined macros. 00137 */ 00138 #define CC_CONCAT(s1, s2) CC_CONCAT2(s1, s2) 00139 00140 #endif /* __CC_H__ */