1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*
3  * Copyright (c) 2020, Linaro Limited
4  */
5 
6 #ifndef LIBCKTEEC_CK_HELPERS_H
7 #define LIBCKTEEC_CK_HELPERS_H
8 
9 #include <pkcs11.h>
10 #include <tee_client_api.h>
11 
12 #include "local_utils.h"
13 
14 #ifdef DEBUG
15 #define ASSERT_CK_RV(_rv, ...)						\
16 	do {								\
17 		const CK_RV ref[] = { __VA_ARGS__ };			\
18 		size_t count = ARRAY_SIZE(ref);				\
19 									\
20 		ckteec_assert_expected_rv(__func__, (_rv), ref, count);	\
21 	} while (0)
22 
23 void ckteec_assert_expected_rv(const char *function, CK_RV rv,
24 			       const CK_RV *expected_rv, size_t expected_count);
25 #else
26 #define ASSERT_CK_RV(_rv, ...)		(void)0
27 #endif /*DEBUG*/
28 
29 #endif /*LIBCKTEEC_CK_HELPERS_H*/
30