From patchwork Wed Jan 20 23:04:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Edelsohn X-Patchwork-Id: 1429479 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=GGKTdd0T; dkim-atps=neutral Received: from sourceware.org (unknown [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DLh122jr7z9sW1 for ; Thu, 21 Jan 2021 10:04:21 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2EFD43971824; Wed, 20 Jan 2021 23:04:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2EFD43971824 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1611183857; bh=sm9orWznaPB1yxnF5Z20dSGwTwsyGNcSPzL9H30ayO8=; h=Date:Subject:To:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=GGKTdd0Tqe0c1Y5eyLvJDlmWBot43e9oU1lumvrY9zqu7NXbh++C4ZQGXsvNRWd54 Emltkrp8wXvp6Vm0QnhgcV3dLQTYxpGln/oKxH5XexSapa5H/l5MR1bDF5d/Idvu6z OSMUbJAC0F4P+oNRtGWLoIN4Tg/7y3m1c+2ZdOkI= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by sourceware.org (Postfix) with ESMTPS id D9C173854833; Wed, 20 Jan 2021 23:04:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org D9C173854833 Received: by mail-wm1-x32b.google.com with SMTP id i63so4157940wma.4; Wed, 20 Jan 2021 15:04:14 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=sm9orWznaPB1yxnF5Z20dSGwTwsyGNcSPzL9H30ayO8=; b=tuQJ3phA7MTMH8KoWVDyQ4nDZj9ALjXb9h+KfTbj6SzoqQ0g6VoMAFRFArD/LJQXeN 1t/6xR/kAstOKpfrN+jDIgFlxQnzdf+EOLXpTsDobaofTdfQLeta+Fvxwr+YfAYJlzYb SoYztihxeIE6JQZLFzhoa9CLu9s04G2WyoYkhSVM8+hwKvw9gecp22MavrHDQA+BGrHE clsS2s3pwwi/ZLO9fliP7aW7qa3K3syAvnVhgI6nKnm5Z8xtGOiiTsz0t3Pd/N4F42Yu 8n2mpGTlq1I7afamAnmKeWTXWj7LwoqNDTmyD73FMNQL942aVNPCz1VjJ5advKVh+rbF TRrA== X-Gm-Message-State: AOAM533FvHNK5xH0JKdMa9uqxrROC2wMcndaJ1NIGg/QhnmhXKJoo1pU dF5RB+eUC6yUd2pqT9eW3Xm3b4dL3dt9JUHmhspwQRYDN0E= X-Google-Smtp-Source: ABdhPJwEDacynHAw3vxArfn9QYsdaSGc5h6aVqL3TKuC07x/fp1Gxstihq5VuRPIimh9R8lPIMuugfgYKJSxxFgWL3c= X-Received: by 2002:a1c:2947:: with SMTP id p68mr6247637wmp.163.1611183853490; Wed, 20 Jan 2021 15:04:13 -0800 (PST) MIME-Version: 1.0 Date: Wed, 20 Jan 2021 18:04:01 -0500 Message-ID: Subject: [PATCH,AIX] ctype_inline.h cast and thread-safe access to __lc_type To: GCC Patches , "libstdc++" X-Spam-Status: No, score=-8.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: David Edelsohn via Gcc-patches From: David Edelsohn Reply-To: David Edelsohn Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" aix: make ctype_inline.h thread-safe and avoid _OBJ_DATA char subscript. g++.dg/warn/Wstringop-overflow-6.C tests for a bogus overflow warning in system headers. This testcase was generating a -Wchar-subscript warning on AIX because ctype_inline.h was subscripting AIX _OBJ_DATA using a char. The _M_table case cast the subscript to unsigned char, but the _OBJ_DATA case did not. The investigation also exposed that AIX has added a thread-safe variant of access to __lc_type that had not been applied to the libstdc++ implementation. This patch casts the subscript to unsigned char and adds the THREAD_SAFE variant. libstdc++ always is compiled with pthreads, but it is good to make the situation explicit and to document the appropriate usage. Bootstrapped on powerpc-ibm-aix7.2.3.0. * config/os/aix/ctype_inline.h (bool ctype:: is): Cast _OBJ_DATA subscript to unsigned char. Add _THREAD_SAFE access to __lc_type. (const char* ctype:: is): Same. const char* @@ -57,7 +61,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION *__vec++ = _M_table[static_cast(*__low++)]; else while (__low < __high) - *__vec++ = __OBJ_DATA(__lc_ctype)->mask[*__low++]; +#ifdef _THREAD_SAFE + *__vec++ = __OBJ_DATA((*__lc_ctype_ptr))->mask[static_cast(*__low++)]; +#else + *__vec++ = __OBJ_DATA(__lc_ctype)->mask[static_cast(*__low++)]; +#endif return __high; } diff --git a/libstdc++-v3/config/os/aix/ctype_inline.h b/libstdc++-v3/config/os/aix/ctype_inline.h index 1faa19d8678..696fcfbf85a 100644 --- a/libstdc++-v3/config/os/aix/ctype_inline.h +++ b/libstdc++-v3/config/os/aix/ctype_inline.h @@ -45,7 +45,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION if(_M_table) return _M_table[static_cast(__c)] & __m; else - return __OBJ_DATA(__lc_ctype)->mask[__c] & __m; +#ifdef _THREAD_SAFE + return __OBJ_DATA((*__lc_ctype_ptr))->mask[static_cast(__c)] & __m; +#else + return __OBJ_DATA(__lc_ctype)->mask[static_cast(__c)] & __m; +#endif }