1/*
2Copyright (c) 2012, Broadcom Europe Ltd
3All rights reserved.
4
5Redistribution and use in source and binary forms, with or without
6modification, 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.
15
16THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
20DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23ON 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
25SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*/
27#ifndef VC_CONTAINERS_COMMON_H
28#define VC_CONTAINERS_COMMON_H
29
30/** \file containers_common.h
31 * Common definitions for containers infrastructure
32 */
33
34#ifndef ENABLE_CONTAINERS_STANDALONE
35# include "vcos.h"
36# define vc_container_assert(a) vcos_assert(a)
37#else
38# include "assert.h"
39# define vc_container_assert(a) assert(a)
40#endif /* ENABLE_CONTAINERS_STANDALONE */
41
42#ifndef countof
43# define countof(a) (sizeof(a) / sizeof(a[0]))
44#endif
45
46#ifndef MIN
47# define MIN(a, b) ((a) < (b) ? (a) : (b))
48#endif
49#ifndef MAX
50# define MAX(a, b) ((a) > (b) ? (a) : (b))
51#endif
52
53#ifdef _MSC_VER
54# define strcasecmp stricmp
55# define strncasecmp strnicmp
56#endif
57
58#define STATIC_INLINE static __inline
59#define VC_CONTAINER_PARAM_UNUSED(a) (void)(a)
60
61#if defined(__HIGHC__) && !defined(strcasecmp)
62# define strcasecmp(a,b) _stricmp(a,b)
63#endif
64
65#if defined(__GNUC__) && (__GNUC__ > 2)
66# define VC_CONTAINER_CONSTRUCTOR(func) void __attribute__((constructor,used)) func(void)
67# define VC_CONTAINER_DESTRUCTOR(func) void __attribute__((destructor,used)) func(void)
68#else
69# define VC_CONTAINER_CONSTRUCTOR(func) void func(void)
70# define VC_CONTAINER_DESTRUCTOR(func) void func(void)
71#endif
72
73#endif /* VC_CONTAINERS_COMMON_H */
74