1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Support for Intel Camera Imaging ISP subsystem.
4 * Copyright (c) 2015, Intel Corporation.
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.
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
16 #ifndef __ASSERT_SUPPORT_H_INCLUDED__
17 #define __ASSERT_SUPPORT_H_INCLUDED__
20 * The following macro can help to test the size of a struct at compile
21 * time rather than at run-time. It does not work for all compilers; see
24 * Depending on the value of 'condition', the following macro is expanded to:
26 * an expression containing an array declaration with negative size,
27 * usually resulting in a compilation error
29 * (void) 1; // C statement with no effect
32 * COMPILATION_ERROR_IF( sizeof(struct host_sp_queues) != SIZE_OF_HOST_SP_QUEUES_STRUCT);
34 * verify that the macro indeed triggers a compilation error with your compiler:
35 * COMPILATION_ERROR_IF( sizeof(struct host_sp_queues) != (sizeof(struct host_sp_queues)+1) );
37 * Not all compilers will trigger an error with this macro; use a search engine to search for
38 * BUILD_BUG_ON to find other methods.
40 #define COMPILATION_ERROR_IF(condition) ((void)sizeof(char[1 - 2 * !!(condition)]))
42 /* Compile time assertion */
44 #define CT_ASSERT(cnd) ((void)sizeof(char[(cnd) ? 1 : -1]))
45 #endif /* CT_ASSERT */
47 #include <linux/bug.h>
49 /* TODO: it would be cleaner to use this:
50 * #define assert(cnd) BUG_ON(cnd)
51 * but that causes many compiler warnings (==errors) under Android
52 * because it seems that the BUG_ON() macro is not seen as a check by
53 * gcc like the BUG() macro is. */
60 #ifndef PIPE_GENERATION
61 /* Deprecated OP___assert, this is still used in ~1000 places
62 * in the code. This will be removed over time.
63 * The implementation for the pipe generation tool is in see support.isp.h */
64 #define OP___assert(cnd) assert(cnd)
66 static inline void compile_time_assert(unsigned int cond)
68 /* Call undefined function if cond is false */
69 void _compile_time_assert(void);
70 if (!cond) _compile_time_assert();
72 #endif /* PIPE_GENERATION */
74 #endif /* __ASSERT_SUPPORT_H_INCLUDED__ */