summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2020-06-19 14:18:14 +0000
committerAndy Wingo <wingo@pobox.com>2020-06-19 14:18:14 +0000
commit921f13a03bf8c4d0b923d8f16c8f972ec27f21e6 (patch)
tree0f6d17dd053c3b53d578f0e4dd05a2135d12782c
parent3260f7deebf4148f7c268e9a56cdab7a221e3da5 (diff)
parentffba9b08c471568f1d7e24a0cae889a954cae515 (diff)
downloadguile-921f13a03bf8c4d0b923d8f16c8f972ec27f21e6.tar.gz
Merge branch 'fix-rotate-by-zero' into 'master'
Fix undefined behavior in ARMv7 assembler See merge request wingo/lightening!4
-rw-r--r--lightening/arm-cpu.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/lightening/arm-cpu.c b/lightening/arm-cpu.c
index 0e38883ef..4445266af 100644
--- a/lightening/arm-cpu.c
+++ b/lightening/arm-cpu.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012-2017, 2019 Free Software Foundation, Inc.
+ * Copyright (C) 2012-2017,2019-2020 Free Software Foundation, Inc.
*
* This file is part of GNU lightning.
*
@@ -195,8 +195,15 @@ emit_wide_thumb(jit_state_t *_jit, uint32_t inst)
emit_u16_with_pool(_jit, inst & 0xffff);
}
-/* from binutils */
-# define rotate_left(v, n) (v << n | v >> (32 - n))
+static uint32_t
+rotate_left(uint32_t v, uint32_t n) {
+ if (n == 0) {
+ return v;
+ }
+ ASSERT(n < 32);
+ return (v << n | v >> (32 - n));
+}
+
static int
encode_arm_immediate(unsigned int v)
{