Module Name:    src
Committed By:   kamil
Date:           Wed May 13 14:54:39 UTC 2020

Modified Files:
        src/sys/external/bsd/sljit/dist/test_src: sljitTest.c

Log Message:
Fix unspecified semantics in left shift

Undefined Behavior in
/usr/src/sys/external/bsd/sljit/dist/test_src/sljitTest.c:568:113,
left shift of 1 by 63 places cannot be represented in type 'sljit_sw' (aka 
'long')

Undefined Behavior in
/usr/src/sys/external/bsd/sljit/dist/test_src/sljitTest.c:585:73,
left shift of 1 by 63 places cannot be represented in type 'long long'

Cherry-pick upstream patch:

>From 4c741e240668ab4cc4fdb67b67d8a566f98e07bf Mon Sep 17 00:00:00 2001
From: Zoltan Herczeg <[email protected]>
Date: Mon, 6 Apr 2020 06:41:27 -0700
Subject: [PATCH] Rework 0x80..0 computation.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/external/bsd/sljit/dist/test_src/sljitTest.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/sljit/dist/test_src/sljitTest.c
diff -u src/sys/external/bsd/sljit/dist/test_src/sljitTest.c:1.8 src/sys/external/bsd/sljit/dist/test_src/sljitTest.c:1.9
--- src/sys/external/bsd/sljit/dist/test_src/sljitTest.c:1.8	Sun Jan 20 23:14:16 2019
+++ src/sys/external/bsd/sljit/dist/test_src/sljitTest.c	Wed May 13 14:54:39 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: sljitTest.c,v 1.8 2019/01/20 23:14:16 alnsn Exp $	*/
+/*	$NetBSD: sljitTest.c,v 1.9 2020/05/13 14:54:39 kamil Exp $	*/
 
 /*
  *    Stack-less Just-In-Time compiler
@@ -565,7 +565,7 @@ static void test8(void)
 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_S0), sizeof(sljit_sw) * 5, SLJIT_R2, 0);
 	sljit_emit_op2(compiler, SLJIT_SUB | SLJIT_SET_Z | SLJIT_SET_OVERFLOW, SLJIT_UNUSED, 0, SLJIT_R0, 0, SLJIT_R1, 0);
 	sljit_emit_op2(compiler, SLJIT_SUB | SLJIT_SET_Z | SLJIT_SET_OVERFLOW, SLJIT_UNUSED, 0, SLJIT_MEM1(SLJIT_S0), 0, SLJIT_R0, 0);
-	sljit_emit_op1(compiler, SLJIT_NEG | SLJIT_SET_Z | SLJIT_SET_OVERFLOW, SLJIT_UNUSED, 0, SLJIT_IMM, (sljit_sw)1 << ((sizeof(sljit_sw) << 3) - 1));
+	sljit_emit_op1(compiler, SLJIT_NEG | SLJIT_SET_Z | SLJIT_SET_OVERFLOW, SLJIT_UNUSED, 0, SLJIT_IMM, -(sljit_sw)(~(sljit_uw)0 >> 1) - 1);
 	sljit_emit_op_flags(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_S0), sizeof(sljit_sw) * 6, SLJIT_UNUSED, 0, SLJIT_OVERFLOW);
 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_R0, 0, SLJIT_IMM, -1);
 	sljit_emit_op1(compiler, SLJIT_NOT | SLJIT_SET_Z, SLJIT_R1, 0, SLJIT_R0, 0);
@@ -582,7 +582,7 @@ static void test8(void)
 	sljit_emit_op2(compiler, SLJIT_AND | SLJIT_SET_Z, SLJIT_UNUSED, 0, SLJIT_MEM1(SLJIT_S0), 0, SLJIT_MEM1(SLJIT_S0), 0);
 	sljit_emit_op2(compiler, SLJIT_AND | SLJIT_SET_Z, SLJIT_UNUSED, 0, SLJIT_MEM1(SLJIT_S0), 0, SLJIT_IMM, 0x1);
 	sljit_emit_op_flags(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_S0), sizeof(sljit_sw) * 10, SLJIT_UNUSED, 0, SLJIT_NOT_ZERO);
-	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_R0, 0, SLJIT_IMM, SLJIT_W(1) << ((sizeof(sljit_sw) << 3) - 1));
+	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_R0, 0, SLJIT_IMM, -(sljit_sw)(~(sljit_uw)0 >> 1) - 1);
 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_R1, 0, SLJIT_IMM, 0);
 	sljit_emit_op2(compiler, SLJIT_SUB | SLJIT_SET_OVERFLOW, SLJIT_UNUSED, 0, SLJIT_R1, 0, SLJIT_R0, 0);
 	sljit_emit_op_flags(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_S0), sizeof(sljit_sw) * 11, SLJIT_UNUSED, 0, SLJIT_OVERFLOW);

Reply via email to