refactor: Move default callbacks to util.h
This commit is contained in:
parent
4c94c55bce
commit
a4875e30a6
@ -23,17 +23,6 @@
|
|||||||
#include "ecmult_gen.h"
|
#include "ecmult_gen.h"
|
||||||
#include "ecmult_gen_prec_impl.h"
|
#include "ecmult_gen_prec_impl.h"
|
||||||
|
|
||||||
static void default_error_callback_fn(const char* str, void* data) {
|
|
||||||
(void)data;
|
|
||||||
fprintf(stderr, "[libsecp256k1] internal consistency check failed: %s\n", str);
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
|
|
||||||
static const secp256k1_callback default_error_callback = {
|
|
||||||
default_error_callback_fn,
|
|
||||||
NULL
|
|
||||||
};
|
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
secp256k1_ge_storage* table;
|
secp256k1_ge_storage* table;
|
||||||
int inner;
|
int inner;
|
||||||
|
@ -44,34 +44,6 @@
|
|||||||
} \
|
} \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
#ifndef USE_EXTERNAL_DEFAULT_CALLBACKS
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
static void secp256k1_default_illegal_callback_fn(const char* str, void* data) {
|
|
||||||
(void)data;
|
|
||||||
fprintf(stderr, "[libsecp256k1] illegal argument: %s\n", str);
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
static void secp256k1_default_error_callback_fn(const char* str, void* data) {
|
|
||||||
(void)data;
|
|
||||||
fprintf(stderr, "[libsecp256k1] internal consistency check failed: %s\n", str);
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
void secp256k1_default_illegal_callback_fn(const char* str, void* data);
|
|
||||||
void secp256k1_default_error_callback_fn(const char* str, void* data);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static const secp256k1_callback default_illegal_callback = {
|
|
||||||
secp256k1_default_illegal_callback_fn,
|
|
||||||
NULL
|
|
||||||
};
|
|
||||||
|
|
||||||
static const secp256k1_callback default_error_callback = {
|
|
||||||
secp256k1_default_error_callback_fn,
|
|
||||||
NULL
|
|
||||||
};
|
|
||||||
|
|
||||||
struct secp256k1_context_struct {
|
struct secp256k1_context_struct {
|
||||||
secp256k1_ecmult_gen_context ecmult_gen_ctx;
|
secp256k1_ecmult_gen_context ecmult_gen_ctx;
|
||||||
secp256k1_callback illegal_callback;
|
secp256k1_callback illegal_callback;
|
||||||
|
27
src/util.h
27
src/util.h
@ -25,6 +25,33 @@ static SECP256K1_INLINE void secp256k1_callback_call(const secp256k1_callback *
|
|||||||
cb->fn(text, (void*)cb->data);
|
cb->fn(text, (void*)cb->data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef USE_EXTERNAL_DEFAULT_CALLBACKS
|
||||||
|
static void secp256k1_default_illegal_callback_fn(const char* str, void* data) {
|
||||||
|
(void)data;
|
||||||
|
fprintf(stderr, "[libsecp256k1] illegal argument: %s\n", str);
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
static void secp256k1_default_error_callback_fn(const char* str, void* data) {
|
||||||
|
(void)data;
|
||||||
|
fprintf(stderr, "[libsecp256k1] internal consistency check failed: %s\n", str);
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
void secp256k1_default_illegal_callback_fn(const char* str, void* data);
|
||||||
|
void secp256k1_default_error_callback_fn(const char* str, void* data);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static const secp256k1_callback default_illegal_callback = {
|
||||||
|
secp256k1_default_illegal_callback_fn,
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
static const secp256k1_callback default_error_callback = {
|
||||||
|
secp256k1_default_error_callback_fn,
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
#ifdef DETERMINISTIC
|
#ifdef DETERMINISTIC
|
||||||
#define TEST_FAILURE(msg) do { \
|
#define TEST_FAILURE(msg) do { \
|
||||||
fprintf(stderr, "%s\n", msg); \
|
fprintf(stderr, "%s\n", msg); \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user