diff options
author | Denys Vlasenko | 2018-12-06 12:34:39 +0100 |
---|---|---|
committer | Denys Vlasenko | 2018-12-06 12:34:39 +0100 |
commit | 2fa11b6d35bcb02064df6d518ee660e39a69615c (patch) | |
tree | 7f635ee0914e6e33f7d259cd4a22318aa67d0ae0 /miscutils | |
parent | 1ff8862149706b81fec67ae496b3b2c12b6c793f (diff) | |
download | busybox-2fa11b6d35bcb02064df6d518ee660e39a69615c.zip busybox-2fa11b6d35bcb02064df6d518ee660e39a69615c.tar.gz |
bc: add comment about BC_NUM_DEF_SIZE
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'miscutils')
-rw-r--r-- | miscutils/bc.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/miscutils/bc.c b/miscutils/bc.c index 19e567b..eae91e9 100644 --- a/miscutils/bc.c +++ b/miscutils/bc.c @@ -205,9 +205,6 @@ typedef struct BcVec { BcVecFree dtor; } BcVec; -#define bc_vec_pop(v) (bc_vec_npop((v), 1)) -#define bc_vec_top(v) (bc_vec_item_rev((v), 0)) - typedef signed char BcDig; typedef struct BcNum { @@ -218,16 +215,17 @@ typedef struct BcNum { bool neg; } BcNum; -#define BC_NUM_MIN_BASE ((unsigned long) 2) -#define BC_NUM_MAX_IBASE ((unsigned long) 16) -#define BC_NUM_DEF_SIZE (16) -#define BC_NUM_PRINT_WIDTH (69) +#define BC_NUM_MIN_BASE ((unsigned long) 2) +#define BC_NUM_MAX_IBASE ((unsigned long) 16) +// larger value might speed up BIGNUM calculations a bit: +#define BC_NUM_DEF_SIZE (16) +#define BC_NUM_PRINT_WIDTH (69) -#define BC_NUM_KARATSUBA_LEN (32) +#define BC_NUM_KARATSUBA_LEN (32) -#define BC_NUM_NEG(n, neg) ((((ssize_t)(n)) ^ -((ssize_t)(neg))) + (neg)) -#define BC_NUM_ONE(n) ((n)->len == 1 && (n)->rdx == 0 && (n)->num[0] == 1) -#define BC_NUM_INT(n) ((n)->len - (n)->rdx) +#define BC_NUM_NEG(n, neg) ((((ssize_t)(n)) ^ -((ssize_t)(neg))) + (neg)) +#define BC_NUM_ONE(n) ((n)->len == 1 && (n)->rdx == 0 && (n)->num[0] == 1) +#define BC_NUM_INT(n) ((n)->len - (n)->rdx) #define BC_NUM_AREQ(a, b) \ (BC_MAX((a)->rdx, (b)->rdx) + BC_MAX(BC_NUM_INT(a), BC_NUM_INT(b)) + 1) #define BC_NUM_MREQ(a, b, scale) \ @@ -1078,6 +1076,9 @@ static void bc_vec_expand(BcVec *v, size_t req) } } +#define bc_vec_pop(v) (bc_vec_npop((v), 1)) +#define bc_vec_top(v) (bc_vec_item_rev((v), 0)) + static void bc_vec_npop(BcVec *v, size_t n) { if (!v->dtor) |