aboutsummaryrefslogtreecommitdiffstats
path: root/lib/crypto/c_src
diff options
context:
space:
mode:
authorHans Nilsson <[email protected]>2019-03-21 12:49:11 +0100
committerHans Nilsson <[email protected]>2019-03-22 10:30:48 +0100
commit3cad91bf826f888ecb0a7aba5618a0ff815228de (patch)
tree54ddb9aa703a217dac8ae54aaa8b21c51571722c /lib/crypto/c_src
parent0facf888f853fd130033b8924a0b1520e4262a57 (diff)
downloadotp-3cad91bf826f888ecb0a7aba5618a0ff815228de.tar.gz
otp-3cad91bf826f888ecb0a7aba5618a0ff815228de.tar.bz2
otp-3cad91bf826f888ecb0a7aba5618a0ff815228de.zip
crypto: Move new error macros to common.h
Diffstat (limited to 'lib/crypto/c_src')
-rw-r--r--lib/crypto/c_src/api_ng.c12
-rw-r--r--lib/crypto/c_src/common.h11
2 files changed, 11 insertions, 12 deletions
diff --git a/lib/crypto/c_src/api_ng.c b/lib/crypto/c_src/api_ng.c
index f4312114ed..5d063c3ae4 100644
--- a/lib/crypto/c_src/api_ng.c
+++ b/lib/crypto/c_src/api_ng.c
@@ -29,18 +29,6 @@
ERL_NIF_TERM ng_crypto_update(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]);
ERL_NIF_TERM ng_crypto_one_shot(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]);
-
-
-/* All nif functions return a valid value or throws an exception */
-#define EXCP(Env, Class, Str) enif_raise_exception((Env), \
- enif_make_tuple2((Env), (Class), \
- enif_make_string((Env),(Str),(ERL_NIF_LATIN1)) ))
-
-#define EXCP_NOTSUP(Env, Str) EXCP((Env), atom_notsup, (Str))
-#define EXCP_BADARG(Env, Str) EXCP((Env), atom_badarg, (Str))
-#define EXCP_ERROR(Env, Str) EXCP((Env), atom_error, (Str))
-
-
#ifdef HAVE_ECB_IVEC_BUG
/* <= 0.9.8l returns faulty ivec length */
# define GET_IV_LEN(Ciph) ((Ciph)->flags & ECB_BUG_0_9_8L) ? 0 : EVP_CIPHER_iv_length((Ciph)->cipher.p)
diff --git a/lib/crypto/c_src/common.h b/lib/crypto/c_src/common.h
index 2bc8bdd73c..0bf7f09f4f 100644
--- a/lib/crypto/c_src/common.h
+++ b/lib/crypto/c_src/common.h
@@ -35,4 +35,15 @@
#include "openssl_config.h"
#include "atoms.h"
+
+/* All nif functions return a valid value or throws an exception */
+#define EXCP(Env, Id, Str) enif_raise_exception((Env), \
+ enif_make_tuple2((Env), \
+ (Id), \
+ enif_make_string((Env),(Str),(ERL_NIF_LATIN1)) ))
+
+#define EXCP_NOTSUP(Env, Str) EXCP((Env), atom_notsup, (Str))
+#define EXCP_BADARG(Env, Str) EXCP((Env), atom_badarg, (Str))
+#define EXCP_ERROR(Env, Str) EXCP((Env), atom_error, (Str))
+
#endif /* E_COMMON_H__ */