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 d2ab720..c73c754 100644 (file)
 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)