From patchwork Mon May 30 14:12:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Jose E. Marchesi" X-Patchwork-Id: 627834 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3rJJK307wQz9t3Z for ; Tue, 31 May 2016 00:04:38 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b=V4ZSOTqF; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:mime-version :content-type; q=dns; s=default; b=D+oJnWVhyoJ02dRBvSPEsm2n1PFM6 xwr2s5PRyO94LjFWqM/yNuz6n51CL393qgwAJn5rG5WAAXSKewc7BpPZXc9sGujt WMUDli0kcff6K0GWdDmAbJ0nrjvYuaC8LwoqIMCFAbjOJxktg6JldIe92Yak/Xg2 gJmbcbKduWLO8o= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:mime-version :content-type; s=default; bh=KmskHyBziW0yjptG/Ppxadkf8yk=; b=V4Z SOTqFkZN8G1Sw2E50xLE6xT9/9bXRpBNoLrvG4WGtKJEKqwgOFnD8jZiunfJR0eT Tr47yn7CaUQFPfBF80y/pZDUWtV3v1c5dQEU4K5FRdQtmhYJEhytWFfzBREg9t7X NmXc5ZOUaKaKa5P1ATUxJpbcDOe6CDSIQs0lmej0= Received: (qmail 98130 invoked by alias); 30 May 2016 14:04:33 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 98116 invoked by uid 89); 30 May 2016 14:04:32 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.3 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_PASS, UNPARSEABLE_RELAY autolearn=ham version=3.3.2 spammy=(unknown) X-HELO: aserp1040.oracle.com From: jose.marchesi@oracle.com (Jose E. Marchesi) To: libc-alpha@sourceware.org Subject: [PATCH] Fix string/test-strncmp.c to work with wide chars. Date: Mon, 30 May 2016 16:12:02 +0200 Message-ID: <87twhfski5.fsf@oracle.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) MIME-Version: 1.0 wcsmbs/test-wcsncmp.c (i.e. string/test-strncmp with defined WIDE) triggers a signal in aligment-strict platforms, like sparc*-*-*. This patch fixes string/test-strncmp.c to work properly when the test is performed on arrays of wide chars. This includes passing align1 and align2 to do_test as bytes, and to use more meaningful values for middle chars and large chars. Tested in sparc64-*-* and sparcv9-*-*. No regressions. 2016-05-30 Jose E. Marchesi * string/test-strncmp.c [WIDE] (MIDCHAR): Defined. [WIDE} (LARGECHAR): Likewise. (MIDCHAR): Likewise. (LARGECHAR): Likewise. (test_main): Adapted to operate on with wide chars. --- ChangeLog | 13 ++++++++ string/test-strncmp.c | 86 +++++++++++++++++++++++++++------------------------ 2 files changed, 58 insertions(+), 41 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8f119fa..0686772 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2016-05-30 Jose E. Marchesi + + * string/test-strncmp.c [WIDE] (MIDCHAR): Defined. + [WIDE} (LARGECHAR): Likewise. + (MIDCHAR): Likewise. + (LARGECHAR): Likewise. + (test_main): Adapted to operate on with wide chars. + +2016-05-25 Jose E. Marchesi + + * string/test-strncmp.c (do_test): ALIGN is an offset to CHAR* + pointers, not char*. + 2016-05-24 Joseph Myers [BZ #15479] diff --git a/string/test-strncmp.c b/string/test-strncmp.c index 8c0a331..318773f 100644 --- a/string/test-strncmp.c +++ b/string/test-strncmp.c @@ -38,6 +38,8 @@ # define CHAR wchar_t # define UCHAR wchar_t # define CHARBYTES 4 +# define MIDCHAR 0x7fffffff +# define LARGECHAR 0xfffffffe # define CHAR__MAX WCHAR_MAX # define CHAR__MIN WCHAR_MIN @@ -88,6 +90,8 @@ stupid_wcsncmp (const CHAR *s1, const CHAR *s2, size_t n) # define CHAR char # define UCHAR unsigned char # define CHARBYTES 1 +# define MIDCHAR 0x7f +# define LARGECHAR 0xfe # define CHAR__MAX CHAR_MAX # define CHAR__MIN CHAR_MIN @@ -414,56 +418,56 @@ test_main (void) for (i =0; i < 16; ++i) { - do_test (0, 0, 8, i, 127, 0); - do_test (0, 0, 8, i, 127, -1); - do_test (0, 0, 8, i, 127, 1); - do_test (i, i, 8, i, 127, 0); - do_test (i, i, 8, i, 127, 1); - do_test (i, i, 8, i, 127, -1); - do_test (i, 2 * i, 8, i, 127, 0); - do_test (2 * i, i, 8, i, 127, 1); - do_test (i, 3 * i, 8, i, 127, -1); - do_test (0, 0, 8, i, 255, 0); - do_test (0, 0, 8, i, 255, -1); - do_test (0, 0, 8, i, 255, 1); - do_test (i, i, 8, i, 255, 0); - do_test (i, i, 8, i, 255, 1); - do_test (i, i, 8, i, 255, -1); - do_test (i, 2 * i, 8, i, 255, 0); - do_test (2 * i, i, 8, i, 255, 1); - do_test (i, 3 * i, 8, i, 255, -1); + do_test (0, 0, 8, i, MIDCHAR, 0); + do_test (0, 0, 8, i, MIDCHAR, -1); + do_test (0, 0, 8, i, MIDCHAR, 1); + do_test (CHARBYTES * i, CHARBYTES * i, 8, i, MIDCHAR, 0); + do_test (CHARBYTES * i, CHARBYTES * i, 8, i, MIDCHAR, 1); + do_test (CHARBYTES * i, CHARBYTES * i, 8, i, MIDCHAR, -1); + do_test (CHARBYTES * i, 2 * CHARBYTES * i, 8, i, MIDCHAR, 0); + do_test (2 * CHARBYTES * i, CHARBYTES * i, 8, i, MIDCHAR, 1); + do_test (CHARBYTES * i, 3 * CHARBYTES * i, 8, i, MIDCHAR, -1); + do_test (0, 0, 8, i, LARGECHAR, 0); + do_test (0, 0, 8, i, LARGECHAR, -1); + do_test (0, 0, 8, i, LARGECHAR, 1); + do_test (CHARBYTES * i, CHARBYTES * i, 8, i, LARGECHAR, 0); + do_test (CHARBYTES * i, CHARBYTES * i, 8, i, LARGECHAR, 1); + do_test (CHARBYTES * i, CHARBYTES * i, 8, i, LARGECHAR, -1); + do_test (CHARBYTES * i, 2 * CHARBYTES * i, 8, i, LARGECHAR, 0); + do_test (2 * CHARBYTES * i, CHARBYTES * i, 8, i, LARGECHAR, 1); + do_test (CHARBYTES * i, 3 * CHARBYTES * i, 8, i, LARGECHAR, -1); } for (i = 1; i < 8; ++i) { - do_test (0, 0, 8 << i, 16 << i, 127, 0); - do_test (0, 0, 8 << i, 16 << i, 127, 1); - do_test (0, 0, 8 << i, 16 << i, 127, -1); - do_test (0, 0, 8 << i, 16 << i, 255, 0); - do_test (0, 0, 8 << i, 16 << i, 255, 1); - do_test (0, 0, 8 << i, 16 << i, 255, -1); - do_test (8 - i, 2 * i, 8 << i, 16 << i, 127, 0); - do_test (8 - i, 2 * i, 8 << i, 16 << i, 127, 1); - do_test (2 * i, i, 8 << i, 16 << i, 255, 0); - do_test (2 * i, i, 8 << i, 16 << i, 255, 1); + do_test (0, 0, 8 << i, 16 << i, MIDCHAR, 0); + do_test (0, 0, 8 << i, 16 << i, MIDCHAR, 1); + do_test (0, 0, 8 << i, 16 << i, MIDCHAR, -1); + do_test (0, 0, 8 << i, 16 << i, LARGECHAR, 0); + do_test (0, 0, 8 << i, 16 << i, LARGECHAR, 1); + do_test (0, 0, 8 << i, 16 << i, LARGECHAR, -1); + do_test (CHARBYTES * (8 - i), 2 * CHARBYTES * i, 8 << i, 16 << i, MIDCHAR, 0); + do_test (CHARBYTES * (8 - i), 2 * CHARBYTES * i, 8 << i, 16 << i, MIDCHAR, 1); + do_test (2 * CHARBYTES * i, CHARBYTES * i, 8 << i, 16 << i, LARGECHAR, 0); + do_test (2 * CHARBYTES * i, CHARBYTES * i, 8 << i, 16 << i, LARGECHAR, 1); } - do_test_limit (0, 0, 0, 0, 127, 0); - do_test_limit (4, 0, 21, 20, 127, 0); - do_test_limit (0, 4, 21, 20, 127, 0); - do_test_limit (8, 0, 25, 24, 127, 0); - do_test_limit (0, 8, 25, 24, 127, 0); + do_test_limit (0, 0, 0, 0, MIDCHAR, 0); + do_test_limit (CHARBYTES * 4, 0, 21, 20, MIDCHAR, 0); + do_test_limit (0, CHARBYTES * 4, 21, 20, MIDCHAR, 0); + do_test_limit (CHARBYTES * 8, 0, 25, 24, MIDCHAR, 0); + do_test_limit (0, CHARBYTES * 8, 25, 24, MIDCHAR, 0); for (i = 0; i < 8; ++i) { - do_test_limit (0, 0, 17 - i, 16 - i, 127, 0); - do_test_limit (0, 0, 17 - i, 16 - i, 255, 0); - do_test_limit (0, 0, 15 - i, 16 - i, 127, 0); - do_test_limit (0, 0, 15 - i, 16 - i, 127, 1); - do_test_limit (0, 0, 15 - i, 16 - i, 127, -1); - do_test_limit (0, 0, 15 - i, 16 - i, 255, 0); - do_test_limit (0, 0, 15 - i, 16 - i, 255, 1); - do_test_limit (0, 0, 15 - i, 16 - i, 255, -1); + do_test_limit (0, 0, 17 - i, 16 - i, MIDCHAR, 0); + do_test_limit (0, 0, 17 - i, 16 - i, LARGECHAR, 0); + do_test_limit (0, 0, 15 - i, 16 - i, MIDCHAR, 0); + do_test_limit (0, 0, 15 - i, 16 - i, MIDCHAR, 1); + do_test_limit (0, 0, 15 - i, 16 - i, MIDCHAR, -1); + do_test_limit (0, 0, 15 - i, 16 - i, LARGECHAR, 0); + do_test_limit (0, 0, 15 - i, 16 - i, LARGECHAR, 1); + do_test_limit (0, 0, 15 - i, 16 - i, LARGECHAR, -1); } do_random_tests ();