Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/external/bsd/sljit/dist/test_src Fix unspecified semanti...



details:   https://anonhg.NetBSD.org/src/rev/98e2434c7cd1
branches:  trunk
changeset: 932678:98e2434c7cd1
user:      kamil <kamil%NetBSD.org@localhost>
date:      Wed May 13 14:54:39 2020 +0000

description:
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 <zherczeg.u-szeged%partner.samsung.com@localhost>
Date: Mon, 6 Apr 2020 06:41:27 -0700
Subject: [PATCH] Rework 0x80..0 computation.

diffstat:

 sys/external/bsd/sljit/dist/test_src/sljitTest.c |  6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diffs (27 lines):

diff -r 7014b28e69e8 -r 98e2434c7cd1 sys/external/bsd/sljit/dist/test_src/sljitTest.c
--- a/sys/external/bsd/sljit/dist/test_src/sljitTest.c  Wed May 13 14:00:58 2020 +0000
+++ b/sys/external/bsd/sljit/dist/test_src/sljitTest.c  Wed May 13 14:54:39 2020 +0000
@@ -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 @@
        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 @@
        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);



Home | Main Index | Thread Index | Old Index