EVE 1.0
env.h
Go to the documentation of this file.
1 #ifndef EVE_ENV_H_INCLUDED
2 #define EVE_ENV_H_INCLUDED
3 
4 /**********************************************************************/
5 /*
6  * Copyright (c) 2013-2015, Jetro AS
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without modification,
10  * are permitted provided that the following conditions are met:
11  *
12  * 1. Redistributions of source code must retain the above copyright notice,
13  * this list of conditions and the following disclaimer.
14  * 2. Redistributions in binary form must reproduce the above copyright notice,
15  * this list of conditions and the following disclaimer in the documentation
16  * and/or other materials provided with the distribution.
17  * 3. The name of the author may not be used to endorse or promote products
18  * derived from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONRIBUTORS ``AS IS'' AND ANY EXPRESS
21  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
22  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
23  * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
25  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
28  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
29  * OF SUCH DAMAGE.
30  *
31  * This file is part of the EVE platform.
32  */
33 
34 
35  /**
36  * \file
37  * \brief EVE build environment.
38  *
39  * \author DT, Jetro AS
40  */ /******************************************************************/
41 
42 /**
43  * \defgroup eve_env EVE environment
44  * \ingroup util
45  * @{
46  */
47 
48 #include <nordic_common.h>
49 
50 /**********************************************************************/
51 /** \def TRUE
52  * Same as true.
53  */
54 #ifndef TRUE
55 #define TRUE true
56 #endif
57 
58 /**********************************************************************/
59 /** \def FALSE
60  * Same as false.
61  */
62 #ifndef FALSE
63 #define FALSE false
64 #endif
65 
66 #if 0 /* Taken from nordic_common.h */
67 /**********************************************************************/
68 /** \def MIN(a, b)
69  * Canonical macro-based MIN. Use with care for side effectes!
70  */
71 #ifndef MIN
72  #define MIN(a, b) (((a) < (b)) ? (a) : (b))
73 #endif
74 
75 /**********************************************************************/
76 /** \def MAX(a, b)
77  * Canonical macro-based MAX. Use with care for side effectes!
78  */
79 #ifndef MAX
80  #define MAX(a, b) (((a) > (b)) ? (a) : (b))
81 #endif
82 #endif /* if 0 */
83 
84 /**********************************************************************/
85 /** \def ARRAY_SIZE(a)
86  * Canonical macro-based ARRAY_SIZE. Use with care for side effectes!
87  */
88 #ifndef ARRAY_SIZE
89  #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
90 #endif
91 
92 /**********************************************************************/
93 /** \def container_of(ptr, type, mem)
94  * Converts pointer to a member of a structure to the pointer to the structure.
95  *
96  * Usage:
97  * \code
98  struct my_work_t {
99  struct work_t base_work;
100  int my_data;
101  };
102  void my_work_cb(struct work_t *work) {
103  struct my_work_t *my_work = container_of(work, struct my_work_t, base_work);
104  my_work->my_data++;
105  }
106  * \endcode
107  *
108  * \param ptr pointer to the member of the structure
109  * \param type type name of the structure
110  * \param mem name of the memeber of the structure
111  * \return pointer to the structure
112  */
113 #ifndef container_of
114  #define container_of(ptr, type, mem) \
115  ((type*) (((char*)(ptr)) - offsetof(type, mem)))
116 #endif
117 
118 /** @} */ /* eve_env */
119 
120 #endif /* EVE_ENV_H_INCLUDED */