From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-4.2 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [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 dcvr.yhbt.net (Postfix) with ESMTPS id EDC501F4B4 for ; Wed, 14 Oct 2020 15:19:13 +0000 (UTC) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 232D53937421; Wed, 14 Oct 2020 15:19:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 232D53937421 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1602688753; bh=/KW2TJMNSz0YlVZbMu31xkOVZQAI6DNV9SwGP1WUY9c=; h=To:Subject:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=ZAPfWuwOdO5xgnouQB+187JILqBU7EbC19/tPMJV6Sa05clZfQN7zyUioEB6NLUbz NAZpxDWQC9v7ad1BSZEU4w02B/7R6x4up9RMO5jeX2YK84MMugwYtgal+pf8EAcBwo yq7zBFOhftMUToVjmDD/OzPeEuTAilsnOJDu3ARU= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id 059B93857C5F for ; Wed, 14 Oct 2020 15:19:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 059B93857C5F Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-225-ybpRswg2NU2AfCWB__ok1g-1; Wed, 14 Oct 2020 11:19:07 -0400 X-MC-Unique: ybpRswg2NU2AfCWB__ok1g-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B08E5879535; Wed, 14 Oct 2020 15:19:06 +0000 (UTC) Received: from oldenburg2.str.redhat.com (ovpn-114-103.ams2.redhat.com [10.36.114.103]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 08B4E78800; Wed, 14 Oct 2020 15:19:05 +0000 (UTC) To: "Paul A. Clarke" Subject: Re: [PATCH 1/3] elf: Add glibc-hwcaps support for LD_LIBRARY_PATH References: <20201013162806.GA247259@li-24c3614c-2adc-11b2-a85c-85f334518bdb.ibm.com> <87v9fcoqn0.fsf@oldenburg2.str.redhat.com> <20201014151408.GA293362@li-24c3614c-2adc-11b2-a85c-85f334518bdb.ibm.com> Date: Wed, 14 Oct 2020 17:19:04 +0200 In-Reply-To: <20201014151408.GA293362@li-24c3614c-2adc-11b2-a85c-85f334518bdb.ibm.com> (Paul A. Clarke's message of "Wed, 14 Oct 2020 10:14:08 -0500") Message-ID: <875z7comxj.fsf@oldenburg2.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Florian Weimer via Libc-alpha Reply-To: Florian Weimer Cc: libc-alpha@sourceware.org Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" * Paul A. Clarke: >> Violating these preconditions result in undefined behavior at compile >> time, so I expected GCC (and Clang) to warn about that. But no such >> luck there. I asked two colleagues about what we can do on the GCC >> side. I do think GCC should warn about this under -Wall because it >> returns a totally made-up value. >> >> I think if we can get that fixed in GCC mainline, we don't have to >> clutter our code with asserts. >> > > With sufficient visibility, GCC can issue such warnings: > test.c:4:34: warning: left shift count >= width of type [-Wshift-count-overflow] > printf ("%x << 32 = %x\n", r, r << 32); > > ...so maybe it already "just works", but your patches don't exercise > that because they aren't broken. :-) I don't get the warning even when this happens. I tried with a reproducer. I don't know why that happens; GCC compiles the expression to a constant, so it must have seen the undefined computation. >> > While validating this function, I created an equivalent: >> > if (subdirs == 0) return 0; >> > if (active == 32) return -1; >> > uint32_t mask = -1; >> > /* Mask to include all subdirs. */ >> > mask >>= 32 - s; >> > /* Unmask all inactive. */ >> > mask &= ~(mask >> a); >> > return mask; >> > ...I found this more readable, but it's subjective. >> >> Yeah, what we really want here is LDB or DPB, or Erlang's bit syntax. 8-/ >> >> > Also, this routine makes a broad assumption that active subdirectories >> > are all contiguous and at the head of the list. Maybe this should be >> > renamed _dl_hwcaps_subdirs_build_range_bitmask (or ..._top_range_...), >> > with an updated comment that reflects its limited use-case. >> >> That makes sense. I think we can delay that until such a targer >> arrives. > > I'm not sure what you mean here. I'm going to use this comment for _dl_hwcaps_subdirs_build_bitmask: /* Returns a bitmask that marks the last ACTIVE subdirectories in a _dl_hwcaps_subdirs_active string (containing SUBDIRS directories in total) as active. Intended for use in _dl_hwcaps_subdirs_active implementations (if a contiguous tail of the list in _dl_hwcaps_subdirs is selected). */ We can rename the function if we add something else for building bitmasks and there's potential for confusion around that. Thanks, Florian -- Red Hat GmbH, https://de.redhat.com/ , Registered seat: Grasbrunn, Commercial register: Amtsgericht Muenchen, HRB 153243, Managing Directors: Charles Cachera, Brian Klemm, Laurie Krebs, Michael O'Neill