1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * Support for Intel Camera Imaging ISP subsystem. 4 * Copyright (c) 2015, Intel Corporation. 5 */ 6 7 #ifndef __ASSERT_SUPPORT_H_INCLUDED__ 8 #define __ASSERT_SUPPORT_H_INCLUDED__ 9 10 /* Compile time assertion */ 11 #ifndef CT_ASSERT 12 #define CT_ASSERT(cnd) ((void)sizeof(char[(cnd) ? 1 : -1])) 13 #endif /* CT_ASSERT */ 14 15 #include <linux/bug.h> 16 17 /* TODO: it would be cleaner to use this: 18 * #define assert(cnd) BUG_ON(cnd) 19 * but that causes many compiler warnings (==errors) under Android 20 * because it seems that the BUG_ON() macro is not seen as a check by 21 * gcc like the BUG() macro is. 22 */ 23 #define assert(cnd) \ 24 do { \ 25 if (!(cnd)) \ 26 BUG(); \ 27 } while (0) 28 29 #ifndef PIPE_GENERATION 30 /* Deprecated OP___assert, this is still used in ~1000 places 31 * in the code. This will be removed over time. 32 * The implementation for the pipe generation tool is in see support.isp.h 33 */ 34 #define OP___assert(cnd) assert(cnd) 35 compile_time_assert(unsigned int cond)36static inline void compile_time_assert(unsigned int cond) 37 { 38 /* Call undefined function if cond is false */ 39 void _compile_time_assert(void); 40 if (!cond) _compile_time_assert(); 41 } 42 #endif /* PIPE_GENERATION */ 43 44 #endif /* __ASSERT_SUPPORT_H_INCLUDED__ */ 45