#define BC_VEC_INVALID_IDX ((size_t) -1)
#define BC_VEC_START_CAP (1 << 5)
-typedef void (*BcVecFree)(void *);
+typedef void (*BcVecFree)(void *) FAST_FUNC;
typedef struct BcVec {
char *v;
#define BC_NUM_KARATSUBA_LEN (32)
-typedef void (*BcNumDigitOp)(size_t, size_t, bool);
+typedef void (*BcNumDigitOp)(size_t, size_t, bool) FAST_FUNC;
-typedef BcStatus (*BcNumBinaryOp)(BcNum *, BcNum *, BcNum *, size_t);
+typedef BcStatus (*BcNumBinaryOp)(BcNum *, BcNum *, BcNum *, size_t) FAST_FUNC;
-static BcStatus bc_num_add(BcNum *a, BcNum *b, BcNum *c, size_t scale);
-static BcStatus bc_num_sub(BcNum *a, BcNum *b, BcNum *c, size_t scale);
-static BcStatus bc_num_mul(BcNum *a, BcNum *b, BcNum *c, size_t scale);
-static BcStatus bc_num_div(BcNum *a, BcNum *b, BcNum *c, size_t scale);
-static BcStatus bc_num_mod(BcNum *a, BcNum *b, BcNum *c, size_t scale);
-static BcStatus bc_num_pow(BcNum *a, BcNum *b, BcNum *c, size_t scale);
+static BcStatus bc_num_add(BcNum *a, BcNum *b, BcNum *c, size_t scale) FAST_FUNC;
+static BcStatus bc_num_sub(BcNum *a, BcNum *b, BcNum *c, size_t scale) FAST_FUNC;
+static BcStatus bc_num_mul(BcNum *a, BcNum *b, BcNum *c, size_t scale) FAST_FUNC;
+static BcStatus bc_num_div(BcNum *a, BcNum *b, BcNum *c, size_t scale) FAST_FUNC;
+static BcStatus bc_num_mod(BcNum *a, BcNum *b, BcNum *c, size_t scale) FAST_FUNC;
+static BcStatus bc_num_pow(BcNum *a, BcNum *b, BcNum *c, size_t scale) FAST_FUNC;
static BcStatus bc_num_sqrt(BcNum *a, BcNum *b, size_t scale);
static BcStatus bc_num_divmod(BcNum *a, BcNum *b, BcNum *c, BcNum *d,
size_t scale);
#endif
struct BcLex;
-typedef BcStatus (*BcLexNext)(struct BcLex *);
+typedef BcStatus (*BcLexNext)(struct BcLex *) FAST_FUNC;
typedef struct BcLex {
struct BcProgram;
-typedef BcStatus (*BcParseParse)(struct BcParse *);
+typedef BcStatus (*BcParseParse)(struct BcParse *) FAST_FUNC;
typedef struct BcParse {
#define BC_PROG_NUM(r, n) \
((r)->t != BC_RESULT_ARRAY && (r)->t != BC_RESULT_STR && !BC_PROG_STR(n))
-typedef unsigned long (*BcProgramBuiltIn)(BcNum *);
-
#define BC_FLAG_W (1 << 0)
#define BC_FLAG_V (1 << 1)
#define BC_FLAG_S (1 << 2)
return v->v + v->size * (v->len - 1);
}
-static void bc_vec_free(void *vec)
+static FAST_FUNC void bc_vec_free(void *vec)
{
BcVec *v = (BcVec *) vec;
bc_vec_pop_all(v);
return strcmp(((const BcId *) e1)->name, ((const BcId *) e2)->name);
}
-static void bc_id_free(void *id)
+static FAST_FUNC void bc_id_free(void *id)
{
free(((BcId *) id)->name);
}
}
}
-static void bc_num_free(void *num)
+static FAST_FUNC void bc_num_free(void *num)
{
free(((BcNum *) num)->num);
}
return bc_num_div(&one, a, b, scale);
}
-static BcStatus bc_num_a(BcNum *a, BcNum *b, BcNum *restrict c, size_t sub)
+static FAST_FUNC BcStatus bc_num_a(BcNum *a, BcNum *b, BcNum *restrict c, size_t sub)
{
BcDig *ptr, *ptr_a, *ptr_b, *ptr_c;
size_t i, max, min_rdx, min_int, diff, a_int, b_int;
return BC_STATUS_SUCCESS; // can't make void, see bc_num_binary()
}
-static BcStatus bc_num_s(BcNum *a, BcNum *b, BcNum *restrict c, size_t sub)
+static FAST_FUNC BcStatus bc_num_s(BcNum *a, BcNum *b, BcNum *restrict c, size_t sub)
{
ssize_t cmp;
BcNum *minuend, *subtrahend;
return BC_STATUS_SUCCESS; // can't make void, see bc_num_binary()
}
-static BcStatus bc_num_k(BcNum *restrict a, BcNum *restrict b,
+static FAST_FUNC BcStatus bc_num_k(BcNum *restrict a, BcNum *restrict b,
BcNum *restrict c)
{
BcStatus s;
return s;
}
-static BcStatus bc_num_m(BcNum *a, BcNum *b, BcNum *restrict c, size_t scale)
+static FAST_FUNC BcStatus bc_num_m(BcNum *a, BcNum *b, BcNum *restrict c, size_t scale)
{
BcStatus s;
BcNum cpa, cpb;
return s;
}
-static BcStatus bc_num_d(BcNum *a, BcNum *b, BcNum *restrict c, size_t scale)
+static FAST_FUNC BcStatus bc_num_d(BcNum *a, BcNum *b, BcNum *restrict c, size_t scale)
{
BcStatus s = BC_STATUS_SUCCESS;
BcDig *n, *p, q;
return s;
}
-static BcStatus bc_num_r(BcNum *a, BcNum *b, BcNum *restrict c,
+static FAST_FUNC BcStatus bc_num_r(BcNum *a, BcNum *b, BcNum *restrict c,
BcNum *restrict d, size_t scale, size_t ts)
{
BcStatus s;
return s;
}
-static BcStatus bc_num_rem(BcNum *a, BcNum *b, BcNum *restrict c, size_t scale)
+static FAST_FUNC BcStatus bc_num_rem(BcNum *a, BcNum *b, BcNum *restrict c, size_t scale)
{
BcStatus s;
BcNum c1;
return s;
}
-static BcStatus bc_num_p(BcNum *a, BcNum *b, BcNum *restrict c, size_t scale)
+static FAST_FUNC BcStatus bc_num_p(BcNum *a, BcNum *b, BcNum *restrict c, size_t scale)
{
BcStatus s = BC_STATUS_SUCCESS;
BcNum copy;
}
#if ENABLE_DC
-static void bc_num_printChar(size_t num, size_t width, bool radix)
+static FAST_FUNC void bc_num_printChar(size_t num, size_t width, bool radix)
{
(void) radix;
bb_putchar((char) num);
}
#endif
-static void bc_num_printDigits(size_t num, size_t width, bool radix)
+static FAST_FUNC void bc_num_printDigits(size_t num, size_t width, bool radix)
{
size_t exp, pow;
}
}
-static void bc_num_printHex(size_t num, size_t width, bool radix)
+static FAST_FUNC void bc_num_printHex(size_t num, size_t width, bool radix)
{
if (radix) {
bc_num_printNewline();
return s;
}
-static BcStatus bc_num_add(BcNum *a, BcNum *b, BcNum *c, size_t scale)
+static FAST_FUNC BcStatus bc_num_add(BcNum *a, BcNum *b, BcNum *c, size_t scale)
{
BcNumBinaryOp op = (!a->neg == !b->neg) ? bc_num_a : bc_num_s;
(void) scale;
return bc_num_binary(a, b, c, false, op, BC_NUM_AREQ(a, b));
}
-static BcStatus bc_num_sub(BcNum *a, BcNum *b, BcNum *c, size_t scale)
+static FAST_FUNC BcStatus bc_num_sub(BcNum *a, BcNum *b, BcNum *c, size_t scale)
{
BcNumBinaryOp op = (!a->neg == !b->neg) ? bc_num_s : bc_num_a;
(void) scale;
return bc_num_binary(a, b, c, true, op, BC_NUM_AREQ(a, b));
}
-static BcStatus bc_num_mul(BcNum *a, BcNum *b, BcNum *c, size_t scale)
+static FAST_FUNC BcStatus bc_num_mul(BcNum *a, BcNum *b, BcNum *c, size_t scale)
{
size_t req = BC_NUM_MREQ(a, b, scale);
return bc_num_binary(a, b, c, scale, bc_num_m, req);
}
-static BcStatus bc_num_div(BcNum *a, BcNum *b, BcNum *c, size_t scale)
+static FAST_FUNC BcStatus bc_num_div(BcNum *a, BcNum *b, BcNum *c, size_t scale)
{
size_t req = BC_NUM_MREQ(a, b, scale);
return bc_num_binary(a, b, c, scale, bc_num_d, req);
}
-static BcStatus bc_num_mod(BcNum *a, BcNum *b, BcNum *c, size_t scale)
+static FAST_FUNC BcStatus bc_num_mod(BcNum *a, BcNum *b, BcNum *c, size_t scale)
{
size_t req = BC_NUM_MREQ(a, b, scale);
return bc_num_binary(a, b, c, scale, bc_num_rem, req);
}
-static BcStatus bc_num_pow(BcNum *a, BcNum *b, BcNum *c, size_t scale)
+static FAST_FUNC BcStatus bc_num_pow(BcNum *a, BcNum *b, BcNum *c, size_t scale)
{
return bc_num_binary(a, b, c, scale, bc_num_p, a->len * b->len + 1);
}
f->nparams = 0;
}
-static void bc_func_free(void *func)
+static FAST_FUNC void bc_func_free(void *func)
{
BcFunc *f = (BcFunc *) func;
bc_vec_free(&f->code);
}
}
-static void bc_string_free(void *string)
+static FAST_FUNC void bc_string_free(void *string)
{
free(*((char **) string));
}
}
#endif // ENABLE_DC
-static void bc_result_free(void *result)
+static FAST_FUNC void bc_result_free(void *result)
{
BcResult *r = (BcResult *) result;
return BC_STATUS_SUCCESS;
}
-static BcStatus bc_lex_token(BcLex *l)
+static FAST_FUNC BcStatus bc_lex_token(BcLex *l)
{
BcStatus s = BC_STATUS_SUCCESS;
char c = l->buf[l->i++], c2;
return BC_STATUS_SUCCESS;
}
-static BcStatus dc_lex_token(BcLex *l)
+static FAST_FUNC BcStatus dc_lex_token(BcLex *l)
{
BcStatus s = BC_STATUS_SUCCESS;
char c = l->buf[l->i++], c2;
return s;
}
-static BcStatus bc_parse_parse(BcParse *p)
+static FAST_FUNC BcStatus bc_parse_parse(BcParse *p)
{
BcStatus s;
return s;
}
-static BcStatus dc_parse_parse(BcParse *p)
+static FAST_FUNC BcStatus dc_parse_parse(BcParse *p)
{
BcStatus s;
}
#endif
else {
- BcProgramBuiltIn f = len ? bc_program_len : bc_program_scale;
- bc_num_ulong2num(&res.d.n, f(num));
+ bc_num_ulong2num(&res.d.n, len ? bc_program_len(num) : bc_program_scale(num));
}
bc_program_retire(&res, BC_RESULT_TEMP);