diff options
| author | Denys Vlasenko <vda.linux@googlemail.com> | 2018-12-11 17:56:09 +0100 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2018-12-11 17:56:09 +0100 |
| commit | c2d15dff42d3f8a805d5437bb5063d3131f800c4 (patch) | |
| tree | 494e0d7d41cc9ae3e7c95f2e165a5eeb12371d73 | |
| parent | c355c4a7d620477cc2d7e05b0616976eb2120d17 (diff) | |
| download | busybox-w32-c2d15dff42d3f8a805d5437bb5063d3131f800c4.tar.gz busybox-w32-c2d15dff42d3f8a805d5437bb5063d3131f800c4.tar.bz2 busybox-w32-c2d15dff42d3f8a805d5437bb5063d3131f800c4.zip | |
bc: move declarations around, no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| -rw-r--r-- | miscutils/bc.c | 78 |
1 files changed, 39 insertions, 39 deletions
diff --git a/miscutils/bc.c b/miscutils/bc.c index 5a4c92a1c..6fb6c8139 100644 --- a/miscutils/bc.c +++ b/miscutils/bc.c | |||
| @@ -221,20 +221,6 @@ typedef struct BcNum { | |||
| 221 | 221 | ||
| 222 | #define BC_NUM_KARATSUBA_LEN (32) | 222 | #define BC_NUM_KARATSUBA_LEN (32) |
| 223 | 223 | ||
| 224 | typedef void (*BcNumDigitOp)(size_t, size_t, bool) FAST_FUNC; | ||
| 225 | |||
| 226 | typedef BcStatus (*BcNumBinaryOp)(BcNum *, BcNum *, BcNum *, size_t) FAST_FUNC; | ||
| 227 | |||
| 228 | static BcStatus bc_num_add(BcNum *a, BcNum *b, BcNum *c, size_t scale) FAST_FUNC; | ||
| 229 | static BcStatus bc_num_sub(BcNum *a, BcNum *b, BcNum *c, size_t scale) FAST_FUNC; | ||
| 230 | static BcStatus bc_num_mul(BcNum *a, BcNum *b, BcNum *c, size_t scale) FAST_FUNC; | ||
| 231 | static BcStatus bc_num_div(BcNum *a, BcNum *b, BcNum *c, size_t scale) FAST_FUNC; | ||
| 232 | static BcStatus bc_num_mod(BcNum *a, BcNum *b, BcNum *c, size_t scale) FAST_FUNC; | ||
| 233 | static BcStatus bc_num_pow(BcNum *a, BcNum *b, BcNum *c, size_t scale) FAST_FUNC; | ||
| 234 | static BcStatus bc_num_sqrt(BcNum *a, BcNum *b, size_t scale); | ||
| 235 | static BcStatus bc_num_divmod(BcNum *a, BcNum *b, BcNum *c, BcNum *d, | ||
| 236 | size_t scale); | ||
| 237 | |||
| 238 | typedef enum BcInst { | 224 | typedef enum BcInst { |
| 239 | 225 | ||
| 240 | #if ENABLE_BC | 226 | #if ENABLE_BC |
| @@ -931,6 +917,45 @@ dc_parse_insts[] = { | |||
| 931 | }; | 917 | }; |
| 932 | #endif // ENABLE_DC | 918 | #endif // ENABLE_DC |
| 933 | 919 | ||
| 920 | // In configurations where errors abort instead of propagating error | ||
| 921 | // return code up the call chain, functions returning BC_STATUS | ||
| 922 | // actually don't return anything, they always succeed and return "void". | ||
| 923 | // A macro wrapper is provided, which makes this statement work: | ||
| 924 | // s = zbc_func(...) | ||
| 925 | // and makes it visible to the compiler that s is always zero, | ||
| 926 | // allowing compiler to optimize dead code after the statement. | ||
| 927 | // | ||
| 928 | // To make code more readable, each such function has a "z" | ||
| 929 | // ("always returning zero") prefix, i.e. zbc_foo or zdc_foo. | ||
| 930 | // | ||
| 931 | #if ENABLE_FEATURE_BC_SIGNALS || ENABLE_FEATURE_CLEAN_UP | ||
| 932 | # define ERRORFUNC /*nothing*/ | ||
| 933 | # define ERROR_RETURN(a) a | ||
| 934 | # define ERRORS_ARE_FATAL 0 | ||
| 935 | # define BC_STATUS BcStatus | ||
| 936 | # define RETURN_STATUS(v) return (v) | ||
| 937 | #else | ||
| 938 | # define ERRORFUNC NORETURN | ||
| 939 | # define ERROR_RETURN(a) /*nothing*/ | ||
| 940 | # define ERRORS_ARE_FATAL 1 | ||
| 941 | # define BC_STATUS void | ||
| 942 | # define RETURN_STATUS(v) do { ((void)(v)); return; } while (0) | ||
| 943 | #endif | ||
| 944 | |||
| 945 | typedef void (*BcNumDigitOp)(size_t, size_t, bool) FAST_FUNC; | ||
| 946 | |||
| 947 | typedef BcStatus (*BcNumBinaryOp)(BcNum *, BcNum *, BcNum *, size_t) FAST_FUNC; | ||
| 948 | |||
| 949 | static BcStatus bc_num_add(BcNum *a, BcNum *b, BcNum *c, size_t scale) FAST_FUNC; | ||
| 950 | static BcStatus bc_num_sub(BcNum *a, BcNum *b, BcNum *c, size_t scale) FAST_FUNC; | ||
| 951 | static BcStatus bc_num_mul(BcNum *a, BcNum *b, BcNum *c, size_t scale) FAST_FUNC; | ||
| 952 | static BcStatus bc_num_div(BcNum *a, BcNum *b, BcNum *c, size_t scale) FAST_FUNC; | ||
| 953 | static BcStatus bc_num_mod(BcNum *a, BcNum *b, BcNum *c, size_t scale) FAST_FUNC; | ||
| 954 | static BcStatus bc_num_pow(BcNum *a, BcNum *b, BcNum *c, size_t scale) FAST_FUNC; | ||
| 955 | static BcStatus bc_num_sqrt(BcNum *a, BcNum *b, size_t scale); | ||
| 956 | static BcStatus bc_num_divmod(BcNum *a, BcNum *b, BcNum *c, BcNum *d, | ||
| 957 | size_t scale); | ||
| 958 | |||
| 934 | static const BcNumBinaryOp bc_program_ops[] = { | 959 | static const BcNumBinaryOp bc_program_ops[] = { |
| 935 | bc_num_pow, bc_num_mul, bc_num_div, bc_num_mod, bc_num_add, bc_num_sub, | 960 | bc_num_pow, bc_num_mul, bc_num_div, bc_num_mod, bc_num_add, bc_num_sub, |
| 936 | }; | 961 | }; |
| @@ -976,31 +1001,6 @@ static void bc_verror_msg(const char *fmt, va_list p) | |||
| 976 | } | 1001 | } |
| 977 | } | 1002 | } |
| 978 | 1003 | ||
| 979 | // In configurations where errors abort instead of propagating error | ||
| 980 | // return code up the call chain, functions returning BC_STATUS | ||
| 981 | // actually don't return anything, they always succeed and return "void". | ||
| 982 | // A macro wrapper is provided, which makes this statement work: | ||
| 983 | // s = zbc_func(...) | ||
| 984 | // and makes it visible to the compiler that s is always zero, | ||
| 985 | // allowing compiler to optimize dead code after the statement. | ||
| 986 | // | ||
| 987 | // To make code more readable, each such function has a "z" | ||
| 988 | // ("always returning zero") prefix, i.e. zbc_foo or zdc_foo. | ||
| 989 | // | ||
| 990 | #if ENABLE_FEATURE_BC_SIGNALS || ENABLE_FEATURE_CLEAN_UP | ||
| 991 | # define ERRORFUNC /*nothing*/ | ||
| 992 | # define ERROR_RETURN(a) a | ||
| 993 | # define ERRORS_ARE_FATAL 0 | ||
| 994 | # define BC_STATUS BcStatus | ||
| 995 | # define RETURN_STATUS(v) return (v) | ||
| 996 | #else | ||
| 997 | # define ERRORFUNC NORETURN | ||
| 998 | # define ERROR_RETURN(a) /*nothing*/ | ||
| 999 | # define ERRORS_ARE_FATAL 1 | ||
| 1000 | # define BC_STATUS void | ||
| 1001 | # define RETURN_STATUS(v) do { ((void)(v)); return; } while (0) | ||
| 1002 | #endif | ||
| 1003 | |||
| 1004 | static NOINLINE ERRORFUNC int bc_error_fmt(const char *fmt, ...) | 1004 | static NOINLINE ERRORFUNC int bc_error_fmt(const char *fmt, ...) |
| 1005 | { | 1005 | { |
| 1006 | va_list p; | 1006 | va_list p; |
