about summary refs log tree commit diff stats
path: root/miasm2/jitter/vm_mngr.h
diff options
context:
space:
mode:
authorFabrice Desclaux <fabrice.desclaux@cea.fr>2017-07-25 13:48:27 +0200
committerFabrice Desclaux <fabrice.desclaux@cea.fr>2017-07-25 14:58:22 +0200
commite440a51fdcd27ac08ec40c9c9fed78895302e980 (patch)
treed1e257c0866fd6fb3481063d6f593c1e51e1a2a8 /miasm2/jitter/vm_mngr.h
parentb088e965b09abedad4e62664c05b06a65522a80e (diff)
downloadmiasm-e440a51fdcd27ac08ec40c9c9fed78895302e980.tar.gz
miasm-e440a51fdcd27ac08ec40c9c9fed78895302e980.zip
Jitter: fix shifter macro
Diffstat (limited to '')
-rw-r--r--miasm2/jitter/vm_mngr.h48
1 files changed, 18 insertions, 30 deletions
diff --git a/miasm2/jitter/vm_mngr.h b/miasm2/jitter/vm_mngr.h
index 74ad49ad..757c3b3e 100644
--- a/miasm2/jitter/vm_mngr.h
+++ b/miasm2/jitter/vm_mngr.h
@@ -199,10 +199,7 @@ unsigned int my_imul08(unsigned int a, unsigned int b);
 
 int is_mapped(vm_mngr_t* vm_mngr, uint64_t addr, uint64_t size);
 void vm_throw(vm_mngr_t* vm_mngr, unsigned long flags);
-int shift_right_arith(unsigned int size, int a, unsigned int b);
 
-uint64_t shift_right_logic(uint64_t size, uint64_t a, uint64_t b);
-uint64_t shift_left_logic(uint64_t size, uint64_t a, uint64_t b);
 unsigned int mul_lo_op(unsigned int size, unsigned int a, unsigned int b);
 unsigned int mul_hi_op(unsigned int size, unsigned int a, unsigned int b);
 unsigned int imul_lo_op_08(char a, char b);
@@ -402,32 +399,23 @@ unsigned int load_segment_limit(unsigned int d);
 unsigned int load_segment_limit_ok(unsigned int d);
 
 unsigned int load_tr_segment_selector(unsigned int d);
-#define shift_right_arith_08(a, b)\
-	((((char)(a)) >> ((int)(b)&0x1f))&0xff)
-#define shift_right_arith_16(a, b)\
-	((((short)(a)) >> ((int)(b)&0x1f))&0xffff)
-#define shift_right_arith_32(a, b)\
-	((((int)(a)) >> ((int)(b)&0x1f))&0xffffffff)
-#define shift_right_arith_64(a, b)\
-	((((int64_t)(a)) >> ((int64_t)(b)&0x3f))&0xffffffffffffffff)
-
-
-#define shift_right_logic_08(a, b)\
-	((((unsigned char)(a)) >> ((unsigned int)(b)&0x1f))&0xff)
-#define shift_right_logic_16(a, b)\
-	((((unsigned short)(a)) >> ((unsigned int)(b)&0x1f))&0xffff)
-#define shift_right_logic_32(a, b)\
-	((((unsigned int)(a)) >> ((unsigned int)(b)&0x1f))&0xffffffff)
-#define shift_right_logic_64(a, b)\
-	((((uint64_t)(a)) >> ((uint64_t)(b)&0x3f))&0xffffffffffffffff)
-
-#define shift_left_logic_08(a, b)\
-	(((a)<<((b)&0x1f))&0xff)
-#define shift_left_logic_16(a, b)\
-	(((a)<<((b)&0x1f))&0xffff)
-#define shift_left_logic_32(a, b)\
-	(((a)<<((b)&0x1f))&0xffffffff)
-#define shift_left_logic_64(a, b)\
-	(((a)<<((b)&0x3f))&0xffffffffffffffff)
+
+
+#define SHIFT_RIGHT_ARITH(size, value, shift)				\
+	((uint ## size ## _t)((((uint64_t) (shift)) > ((size) - 1))?	\
+			      (((int ## size ## _t) (value)) < 0 ? -1 : 0) : \
+			      (((int ## size ## _t) (value)) >> (shift))))
+
+#define SHIFT_RIGHT_LOGIC(size, value, shift)				\
+	((uint ## size ## _t)((((uint64_t) (shift)) > ((size) - 1))?	\
+			      0 :					\
+			      (((uint ## size ## _t) (value)) >> (shift))))
+
+#define SHIFT_LEFT_LOGIC(size, value, shift)		\
+	((uint ## size ## _t)((((uint64_t) (shift)) > ((size) - 1))?	\
+			      0 :					\
+			      (((uint ## size ## _t) (value)) << (shift))))
+
+
 
 #endif