Fix signedness problem that was showing up on ARM.
authorDavid Given <dg@cowlark.com>
Tue, 21 May 2013 23:16:16 +0000 (00:16 +0100)
committerDavid Given <dg@cowlark.com>
Tue, 21 May 2013 23:16:16 +0000 (00:16 +0100)
--HG--
branch : dtrg-videocore

mach/vc4/as/mach5.c

index b1ce314..f3671bf 100644 (file)
@@ -5,6 +5,8 @@
  * See the file 'Copying' in the root of the distribution for the full text.
  */
 
+#include <stdint.h>
+
 #define maskx(v, x) (v & ((1<<(x))-1))
 
 static void toobig(void)
@@ -120,7 +122,7 @@ void branch_instr(int bl, int cc, struct expr_t* expr)
                        /* The VC4 branch instructions express distance in 2-byte
                         * words. */
 
-                       int d = (expr->val - pc) / 2;
+                       int d = ((int32_t)expr->val - (int32_t)pc) / 2;
 
                /* We now know the worst case for the instruction layout. At
                 * this point we can emit the instructions, which may shrink