1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
3  *
4  * LibTomCrypt is a library that provides various cryptographic
5  * algorithms in a highly modular and flexible manner.
6  *
7  * The library is free for all purposes without any express
8  * guarantee it works.
9  */
10 
11 /* Defines the LTC_ARGCHK macro used within the library */
12 /* ARGTYPE is defined in tomcrypt_cfg.h */
13 
14 /* ARGTYPE is per default defined to 0  */
15 #if ARGTYPE == 0
16 
17 #include <signal.h>
18 
19 LTC_NORETURN void crypt_argchk(const char *v, const char *s, int d);
20 #define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
21 #define LTC_ARGCHKVD(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
22 
23 #elif ARGTYPE == 1
24 
25 /* fatal type of error */
26 #define LTC_ARGCHK(x) assert((x))
27 #define LTC_ARGCHKVD(x) LTC_ARGCHK(x)
28 
29 #elif ARGTYPE == 2
30 
31 #define LTC_ARGCHK(x) if (!(x)) { fprintf(stderr, "\nwarning: ARGCHK failed at %s:%d\n", __FILE__, __LINE__); }
32 #define LTC_ARGCHKVD(x) LTC_ARGCHK(x)
33 
34 #elif ARGTYPE == 3
35 
36 #define LTC_ARGCHK(x) LTC_UNUSED_PARAM(x)
37 #define LTC_ARGCHKVD(x) LTC_ARGCHK(x)
38 
39 #elif ARGTYPE == 4
40 
41 #define LTC_ARGCHK(x)   if (!(x)) return CRYPT_INVALID_ARG;
42 #define LTC_ARGCHKVD(x) if (!(x)) return;
43 
44 #endif
45 
46 
47 /* ref:         $Format:%D$ */
48 /* git commit:  $Format:%H$ */
49 /* commit time: $Format:%ai$ */
50