1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3 * Support for Intel Camera Imaging ISP subsystem.
4 * Copyright (c) 2015, Intel Corporation.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 */
15
16 #ifndef __ASSERT_SUPPORT_H_INCLUDED__
17 #define __ASSERT_SUPPORT_H_INCLUDED__
18
19 /* Compile time assertion */
20 #ifndef CT_ASSERT
21 #define CT_ASSERT(cnd) ((void)sizeof(char[(cnd) ? 1 : -1]))
22 #endif /* CT_ASSERT */
23
24 #include <linux/bug.h>
25
26 /* TODO: it would be cleaner to use this:
27 * #define assert(cnd) BUG_ON(cnd)
28 * but that causes many compiler warnings (==errors) under Android
29 * because it seems that the BUG_ON() macro is not seen as a check by
30 * gcc like the BUG() macro is.
31 */
32 #define assert(cnd) \
33 do { \
34 if (!(cnd)) \
35 BUG(); \
36 } while (0)
37
38 #ifndef PIPE_GENERATION
39 /* Deprecated OP___assert, this is still used in ~1000 places
40 * in the code. This will be removed over time.
41 * The implementation for the pipe generation tool is in see support.isp.h
42 */
43 #define OP___assert(cnd) assert(cnd)
44
compile_time_assert(unsigned int cond)45 static inline void compile_time_assert(unsigned int cond)
46 {
47 /* Call undefined function if cond is false */
48 void _compile_time_assert(void);
49 if (!cond) _compile_time_assert();
50 }
51 #endif /* PIPE_GENERATION */
52
53 #endif /* __ASSERT_SUPPORT_H_INCLUDED__ */
54