Path: blob/master/libs/tomcrypt/src/headers/tomcrypt_argchk.h
5971 views
/* LibTomCrypt, modular cryptographic library -- Tom St Denis1*2* LibTomCrypt is a library that provides various cryptographic3* algorithms in a highly modular and flexible manner.4*5* The library is free for all purposes without any express6* guarantee it works.7*/89/* Defines the LTC_ARGCHK macro used within the library */10/* ARGTYPE is defined in tomcrypt_cfg.h */11#if ARGTYPE == 01213#include <signal.h>1415/* this is the default LibTomCrypt macro */16#if defined(__clang__) || defined(__GNUC_MINOR__)17#define NORETURN __attribute__ ((noreturn))18#else19#define NORETURN20#endif2122void crypt_argchk(const char *v, const char *s, int d) NORETURN;23#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)24#define LTC_ARGCHKVD(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)2526#elif ARGTYPE == 12728/* fatal type of error */29#define LTC_ARGCHK(x) assert((x))30#define LTC_ARGCHKVD(x) LTC_ARGCHK(x)3132#elif ARGTYPE == 23334#define LTC_ARGCHK(x) if (!(x)) { fprintf(stderr, "\nwarning: ARGCHK failed at %s:%d\n", __FILE__, __LINE__); }35#define LTC_ARGCHKVD(x) LTC_ARGCHK(x)3637#elif ARGTYPE == 33839#define LTC_ARGCHK(x)40#define LTC_ARGCHKVD(x) LTC_ARGCHK(x)4142#elif ARGTYPE == 44344#define LTC_ARGCHK(x) if (!(x)) return CRYPT_INVALID_ARG;45#define LTC_ARGCHKVD(x) if (!(x)) return;4647#endif484950