From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id BC3A03858D38 for ; Sat, 18 Nov 2023 10:23:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BC3A03858D38 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org BC3A03858D38 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700302996; cv=none; b=Y2sz1pcHrzXz2DU2s4l2gOjGZm/lAgDixRtXdlcvlk83UOg/uyMjerIlt9jbc7su/X+guvtW+INpwk9YknXP+GRjwUg0Cgnd9fl8Vr1DRHZcIckUcNifcpjEmhiVPdIH8N8JEt29Br7Vi17v+a4wO0EukdntBGJp2OlGhFKoUZI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700302996; c=relaxed/simple; bh=yq+zfWbU4OwOHjoC8B9hrCwa5jsqk9m3qXnNy61sOXM=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=GcIl1uXr5BBswk0KKVjCf9Hvz6bQg2R7EqLsJOzsPzwr0VS/Y2vCaCeUbrioXrt29CEZuHvfmss0BrP9Wag08sOw3FPneqpQ7QlFlcx0pq+362QEK9Cj0mKbusCxJkWEdKT2Y9RL6oU9cLRwf4BMDtC97rLMV/zTN+KH2FjPSi4= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700302993; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references; bh=FRxneXmIw5ziK8lBVmcUsL511MF/AKNExGelli2eHNA=; b=WfhB3SrfJifkvEA3cDk7BgT7s8IFwgU1jnUHUyHlcM9ggzvVBbU2PsdgWuQP0y8wx+HCs2 nRTxc1avtzkyTAxz4KYn0B0pzLcmrf67aOTXmPOvJwyI8Y0W6dti3GYzddk6di8N+AhKFW lXbt48GvCtqYGYnglW+c2OmhFKF+h8k= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-331-VFOJhKoDNDyp4HXsequuHA-1; Sat, 18 Nov 2023 05:23:10 -0500 X-MC-Unique: VFOJhKoDNDyp4HXsequuHA-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E9FD63C00201; Sat, 18 Nov 2023 10:23:08 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.194.53]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7962A1C060AE; Sat, 18 Nov 2023 10:23:08 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 3AIAN0p73195707 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Sat, 18 Nov 2023 11:23:06 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 3AIAN0O13195706; Sat, 18 Nov 2023 11:23:00 +0100 Date: Sat, 18 Nov 2023 11:22:59 +0100 From: Jakub Jelinek To: Florian Weimer Cc: Joseph Myers , libc-alpha@sourceware.org Subject: Re: [RFC] stdbit.h implementation Message-ID: Reply-To: Jakub Jelinek References: <299d386f-ae57-b48c-cc9-82fb41f5ebd@codesourcery.com> <87h6ljnzgv.fsf@oldenburg.str.redhat.com> MIME-Version: 1.0 In-Reply-To: <87h6ljnzgv.fsf@oldenburg.str.redhat.com> X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Sat, Nov 18, 2023 at 11:10:56AM +0100, Florian Weimer wrote: > * Jakub Jelinek: > > > +# define __stdc_type_width(x) \ > > + __builtin_popcountg ((__typeof (x)) ~(__typeof (x)) 0) > > > +# define stdc_leading_zeros(x) \ > > + ((unsigned int) \ > > + __builtin_clzg (x, __stdc_type_width (x))) > > These macros will not be very useful if they expand their arguments > multiple times because the preprocessor output becomes too big if > expressions are nested. I think we learned that with the type-generic > math facilities. That is the case of the previously posted macros (some of them) as well: #define stdc_first_leading_one(x) \ (sizeof (x) == 8 ? stdc_first_leading_one_ull (x) \ : sizeof (x) == 4 ? stdc_first_leading_one_ui (x) \ : sizeof (x) == 2 ? stdc_first_leading_one_us (x) \ : stdc_first_leading_one_uc (x)) Do we really need to add compiler builtins for all those 14 type-generic macros because of that? Ok, stdc_first_leading_one with the (__builtin_clzg (x, -1) + 1U) definition and stdc_first_trailing_one with the (__builtin_ctzg (x, -1) + 1U) one stdc_count_ones with ((unsigned int) __builtin_popcountg (x)) actually wouldn't need one. Jakub