From: Joseph Myers <josmyers@redhat.com>
To: Jakub Jelinek <jakub@redhat.com>
Cc: libc-alpha@sourceware.org
Subject: Re: [PATCH] Use gcc __builtin_stdc_* builtins in stdbit.h if possible
Date: Sat, 20 Jan 2024 23:27:17 +0000 (UTC) [thread overview]
Message-ID: <7aa693ad-514e-7b7a-8d3-2c59af649ca@redhat.com> (raw)
In-Reply-To: <ZawLOilk2vh1EDYP@tucnak>
On Sat, 20 Jan 2024, Jakub Jelinek wrote:
> +# define stdc_leading_zeros_uc(x) \
> + (__builtin_stdc_leading_zeros ((unsigned char) (x)))
> +# define stdc_leading_zeros_us(x) \
> + (__builtin_stdc_leading_zeros ((unsigned short) (x)))
> +# define stdc_leading_zeros_ui(x) \
> + (__builtin_stdc_leading_zeros ((unsigned int) (x)))
> +# define stdc_leading_zeros_ul(x) \
> + (__builtin_stdc_leading_zeros ((unsigned long int) (x)))
> +# define stdc_leading_zeros_ull(x) \
> + (__builtin_stdc_leading_zeros ((unsigned long long int) (x)))
I don't like defining any of the type-specific functions as macros using
casts (as opposed to implicit conversions); implicit conversions ensure
they have appropriate diagnostics for bad argument types that might be
lost with a cast (in particular, if someone passes a pointer to one of the
functions taking a pointer-sized integer, getting an error from the
implicit conversion is desirable, rather that a cast from pointer to
integer without a diagnostic).
--
Joseph S. Myers
josmyers@redhat.com
next prev parent reply other threads:[~2024-01-20 23:27 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-20 18:04 Jakub Jelinek
2024-01-20 23:27 ` Joseph Myers [this message]
2024-01-22 9:19 ` [PATCH] v2: " Jakub Jelinek
2024-01-22 17:58 ` Joseph Myers
2024-01-26 10:12 ` [PATCH] v3: " Jakub Jelinek
2024-01-29 21:07 ` Joseph Myers
2024-01-29 21:18 ` Jakub Jelinek
2024-01-29 21:30 ` Joseph Myers
2024-01-29 22:10 ` [PATCH] v4: " Jakub Jelinek
2024-01-30 0:28 ` Andreas K. Huettel
2024-01-31 18:03 ` Joseph Myers
2024-02-01 10:12 ` Mark Wielaard
2024-02-01 10:23 ` Mark Wielaard
2024-02-01 10:33 ` [PATCH] Fix up stdbit.texi Jakub Jelinek
2024-02-01 11:05 ` Mark Wielaard
2024-02-01 14:42 ` Carlos O'Donell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7aa693ad-514e-7b7a-8d3-2c59af649ca@redhat.com \
--to=josmyers@redhat.com \
--cc=jakub@redhat.com \
--cc=libc-alpha@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).