aboutsummaryrefslogtreecommitdiff
path: root/src/secp256k1/src/util.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/secp256k1/src/util.h')
-rw-r--r--src/secp256k1/src/util.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/secp256k1/src/util.h b/src/secp256k1/src/util.h
index 96b47057c0..c3a8f3a42b 100644
--- a/src/secp256k1/src/util.h
+++ b/src/secp256k1/src/util.h
@@ -61,4 +61,27 @@
#define VERIFY_CHECK(cond) do { (void)(cond); } while(0)
#endif
+static inline void *checked_malloc(size_t size) {
+ void *ret = malloc(size);
+ CHECK(ret != NULL);
+ return ret;
+}
+
+/* Macro for restrict, when available and not in a VERIFY build. */
+#if defined(SECP256K1_BUILD) && defined(VERIFY)
+# define SECP256K1_RESTRICT
+#else
+# if (!defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L) )
+# if SECP256K1_GNUC_PREREQ(3,0)
+# define SECP256K1_RESTRICT __restrict__
+# elif (defined(_MSC_VER) && _MSC_VER >= 1400)
+# define SECP256K1_RESTRICT __restrict
+# else
+# define SECP256K1_RESTRICT
+# endif
+# else
+# define SECP256K1_RESTRICT restrict
+# endif
+#endif
+
#endif