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