2 Copyright (c) 2012, Broadcom Europe Ltd
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are met:
7 * Redistributions of source code must retain the above copyright
8 notice, this list of conditions and the following disclaimer.
9 * Redistributions in binary form must reproduce the above copyright
10 notice, this list of conditions and the following disclaimer in the
11 documentation and/or other materials provided with the distribution.
12 * Neither the name of the copyright holder nor the
13 names of its contributors may be used to endorse or promote products
14 derived from this software without specific prior written permission.
16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
20 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 #ifndef __VC_INCLUDE_COMMON_H__
29 #define __VC_INCLUDE_COMMON_H__
31 #include "interface/vcos/vcos_stdint.h"
32 #include "interface/vctypes/vc_image_types.h"
34 #if defined(__HIGHC__) && defined(_VIDEOCORE) && !defined(_I386)
35 // __HIGHC__ is only available with MW
36 // The scvc plugins are compiled (bizarrely) on an x86 with _VIDEOCORE set!
37 #include <vc/intrinsics.h>
42 #define _Rarely(x) (x)
45 #define _Usually(x) (x)
55 # define INLINE __inline
58 /* Align a pointer/integer by rounding up/down */
59 #define ALIGN_DOWN(p, n) ((uint32_t)(p) - ( (uint32_t)(p) % (uint32_t)(n) ))
60 #define ALIGN_UP(p, n) ALIGN_DOWN((uint32_t)(p) + (uint32_t)(n) - 1, (n))
62 #elif defined (VCMODS_LCC)
66 #elif !defined(__KERNEL__)
74 /* Fixed-point types */
75 typedef unsigned short uint8p8_t;
76 typedef signed short sint8p8_t;
77 typedef unsigned short uint4p12_t;
78 typedef signed short sint4p12_t;
79 typedef signed short sint0p16_t;
80 typedef signed char sint8p0_t;
81 typedef unsigned char uint0p8_t;
82 typedef signed long int24p8_t;
84 /*{{{ Common typedefs */
93 #define bool_t VC_BOOL_T
98 /*{{{ Common macros */
101 /* Align a pointer/integer by rounding up/down */
102 #define ALIGN_DOWN(p, n) ((uintptr_t)(p) - ( (uintptr_t)(p) % (uintptr_t)(n) ))
103 #define ALIGN_UP(p, n) ALIGN_DOWN((uintptr_t)(p) + (uintptr_t)(n) - 1, (n))
105 #define CLIP(lower, n, upper) _min((upper), _max((lower), (n)))
109 /*{{{ Debugging and profiling macros */
112 /* There's already an assert_once in <logging/logging.h> */
114 #define assert_once(x) \
116 static uint8_t ignore = 0; \
124 #define assert_once(x) (void)0
128 #if defined(__HIGHC__) && !defined(NDEBUG)
129 /* HighC lacks a __FUNCTION__ preproc symbol... :( */
130 #define profile_rename(name) _ASM(".global " name "\n" name ":\n")
132 #define profile_rename(name) (void)0
139 #endif /* __VCINCLUDE_COMMON_H__ */