Contiki-Inga 3.x
cc.h
Go to the documentation of this file.
1 /**
2  * \file
3  * Default definitions of C compiler quirk work-arounds.
4  * \author Adam Dunkels <adam@dunkels.com>
5  *
6  * This file is used for making use of extra functionality of some C
7  * compilers used for Contiki, and defining work-arounds for various
8  * quirks and problems with some other C compilers.
9  */
10 
11 /*
12  * Copyright (c) 2003, Adam Dunkels.
13  * All rights reserved.
14  *
15  * Redistribution and use in source and binary forms, with or without
16  * modification, are permitted provided that the following conditions
17  * are met:
18  * 1. Redistributions of source code must retain the above copyright
19  * notice, this list of conditions and the following disclaimer.
20  * 2. Redistributions in binary form must reproduce the above
21  * copyright notice, this list of conditions and the following
22  * disclaimer in the documentation and/or other materials provided
23  * with the distribution.
24  * 3. The name of the author may not be used to endorse or promote
25  * products derived from this software without specific prior
26  * written permission.
27  *
28  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
29  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
30  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
31  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
32  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
33  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
34  * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
35  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
36  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
37  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
38  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39  *
40  * This file is part of the Contiki desktop OS
41  *
42  *
43  */
44 #ifndef CC_H_
45 #define CC_H_
46 
47 #include "contiki-conf.h"
48 
49 /**
50  * Configure if the C compiler supports the "register" keyword for
51  * function arguments.
52  */
53 #if CC_CONF_REGISTER_ARGS
54 #define CC_REGISTER_ARG register
55 #else /* CC_CONF_REGISTER_ARGS */
56 #define CC_REGISTER_ARG
57 #endif /* CC_CONF_REGISTER_ARGS */
58 
59 /**
60  * Configure if the C compiler supports the arguments for function
61  * pointers.
62  */
63 #if CC_CONF_FUNCTION_POINTER_ARGS
64 #define CC_FUNCTION_POINTER_ARGS 1
65 #else /* CC_CONF_FUNCTION_POINTER_ARGS */
66 #define CC_FUNCTION_POINTER_ARGS 0
67 #endif /* CC_CONF_FUNCTION_POINTER_ARGS */
68 
69 /**
70  * Configure if the C compiler supports fastcall function
71  * declarations.
72  */
73 #ifdef CC_CONF_FASTCALL
74 #define CC_FASTCALL CC_CONF_FASTCALL
75 #else /* CC_CONF_FASTCALL */
76 #define CC_FASTCALL
77 #endif /* CC_CONF_FASTCALL */
78 
79 /**
80  * Configure if the C compiler have problems with const function pointers
81  */
82 #ifdef CC_CONF_CONST_FUNCTION_BUG
83 #define CC_CONST_FUNCTION
84 #else /* CC_CONF_FASTCALL */
85 #define CC_CONST_FUNCTION const
86 #endif /* CC_CONF_FASTCALL */
87 
88 /**
89  * Configure work-around for unsigned char bugs with sdcc.
90  */
91 #if CC_CONF_UNSIGNED_CHAR_BUGS
92 #define CC_UNSIGNED_CHAR_BUGS 1
93 #else /* CC_CONF_UNSIGNED_CHAR_BUGS */
94 #define CC_UNSIGNED_CHAR_BUGS 0
95 #endif /* CC_CONF_UNSIGNED_CHAR_BUGS */
96 
97 /**
98  * Configure if C compiler supports double hash marks in C macros.
99  */
100 #if CC_CONF_DOUBLE_HASH
101 #define CC_DOUBLE_HASH 1
102 #else /* CC_CONF_DOUBLE_HASH */
103 #define CC_DOUBLE_HASH 0
104 #endif /* CC_CONF_DOUBLE_HASH */
105 
106 #ifdef CC_CONF_INLINE
107 #define CC_INLINE CC_CONF_INLINE
108 #else /* CC_CONF_INLINE */
109 #define CC_INLINE
110 #endif /* CC_CONF_INLINE */
111 
112 /**
113  * Configure if the C compiler supports the assignment of struct value.
114  */
115 #ifdef CC_CONF_ASSIGN_AGGREGATE
116 #define CC_ASSIGN_AGGREGATE(dest, src) CC_CONF_ASSIGN_AGGREGATE(dest, src)
117 #else /* CC_CONF_ASSIGN_AGGREGATE */
118 #define CC_ASSIGN_AGGREGATE(dest, src) *dest = *src
119 #endif /* CC_CONF_ASSIGN_AGGREGATE */
120 
121 #if CC_CONF_NO_VA_ARGS
122 #define CC_NO_VA_ARGS CC_CONF_VA_ARGS
123 #endif
124 
125 #ifndef NULL
126 #define NULL 0
127 #endif /* NULL */
128 
129 #define CC_CONCAT2(s1, s2) s1##s2
130 /**
131  * A C preprocessing macro for concatenating to
132  * strings.
133  *
134  * We need use two macros (CC_CONCAT and CC_CONCAT2) in order to allow
135  * concatenation of two #defined macros.
136  */
137 #define CC_CONCAT(s1, s2) CC_CONCAT2(s1, s2)
138 
139 #endif /* CC_H_ */