Move ossl_assert
[openssl.git] / include / internal / cryptlib.h
similarity index 84%
rename from crypto/include/internal/cryptlib.h
rename to include/internal/cryptlib.h
index d2ab720d34e8edd174a459cfd24df9dcacb07ee1..c73c7542424723d02a31b8b96d85a09b76a16d1b 100644 (file)
 extern "C" {
 #endif
 
 extern "C" {
 #endif
 
+#ifdef NDEBUG
+# define ossl_assert(x) ((x) != 0)
+#else
+__owur static ossl_inline int ossl_assert_int(int expr, const char *exprstr,
+                                              const char *file, int line)
+{
+    if (!expr)
+        OPENSSL_die(exprstr, file, line);
+
+    return expr;
+}
+
+# define ossl_assert(x) ossl_assert_int((x) != 0, "Assertion failed: "#x, \
+                                         __FILE__, __LINE__)
+
+#endif
+
 typedef struct ex_callback_st EX_CALLBACK;
 
 DEFINE_STACK_OF(EX_CALLBACK)
 typedef struct ex_callback_st EX_CALLBACK;
 
 DEFINE_STACK_OF(EX_CALLBACK)