diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2018-06-25 06:53:56 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2018-06-25 06:53:56 -0700 |
commit | cd69e10e027f0407c6fb7f14cdb0c1f833e744c8 (patch) | |
tree | 143861bc0ca4a4f5643ca2509d21c4a55e7f0dda /vm.c | |
parent | 7d0fc1b26a3b42189621723ba5169f2e09d0c5d8 (diff) | |
download | txr-cd69e10e027f0407c6fb7f14cdb0c1f833e744c8.tar.gz txr-cd69e10e027f0407c6fb7f14cdb0c1f833e744c8.tar.bz2 txr-cd69e10e027f0407c6fb7f14cdb0c1f833e744c8.zip |
vm: replace open-coded ternary with max macro.
* vm.c (max): New macro.
(vm_call, vm_apply, vm_gcall, vm_gapply): Use max macro in
calculating args allocation.
Diffstat (limited to 'vm.c')
-rw-r--r-- | vm.c | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -51,6 +51,8 @@ typedef u32_t vm_word_t; +#define max(a, b) ((a) > (b) ? (a) : (b)) + #define zalloca(size) memset(alloca(size), 0, size) struct vm_desc_links { @@ -438,7 +440,7 @@ NOINLINE static void vm_call(struct vm *vm, vm_word_t insn) vm_word_t argw = vm->code[vm->ip++]; unsigned fun = vm_arg_operand_lo(argw); val result; - args_decl (args, nargs < ARGS_MIN ? ARGS_MIN : nargs); + args_decl (args, max(nargs, ARGS_MIN)); if (nargs--) { args_add(args, vm_get(vm->dspl, vm_arg_operand_hi(argw))); @@ -467,7 +469,7 @@ NOINLINE static void vm_apply(struct vm *vm, vm_word_t insn) vm_word_t argw = vm->code[vm->ip++]; unsigned fun = vm_arg_operand_lo(argw); val result; - args_decl (args, nargs < ARGS_MIN ? ARGS_MIN : nargs); + args_decl (args, max(nargs, ARGS_MIN)); if (nargs--) { args_add(args, vm_getz(vm->dspl, vm_arg_operand_hi(argw))); @@ -513,7 +515,7 @@ NOINLINE static void vm_gcall(struct vm *vm, vm_word_t insn) vm_word_t argw = vm->code[vm->ip++]; unsigned fun = vm_arg_operand_lo(argw); val result; - args_decl (args, nargs < ARGS_MIN ? ARGS_MIN : nargs); + args_decl (args, max(nargs, ARGS_MIN)); if (nargs--) { args_add(args, vm_getz(vm->dspl, vm_arg_operand_hi(argw))); @@ -542,7 +544,7 @@ NOINLINE static void vm_gapply(struct vm *vm, vm_word_t insn) vm_word_t argw = vm->code[vm->ip++]; unsigned fun = vm_arg_operand_lo(argw); val result; - args_decl (args, nargs < ARGS_MIN ? ARGS_MIN : nargs); + args_decl (args, max(nargs, ARGS_MIN)); if (nargs--) { args_add(args, vm_getz(vm->dspl, vm_arg_operand_hi(argw))); |