On 5/12/24 1:30 PM, Paul Eggert wrote:
> I sense a bit of confusion here. Although POSIX allows symbols
> like be16toh to be macros, I don't see where it allows be16toh(X) to evaluate
> X more than once, so an expression like be16toh(i++) has well-defined
> behavior even though it has a side ef
On 2024-05-12 12:47, Collin Funk wrote:
Yeah, I read the POSIX draft and it says that they may be macros. I
doubt the byteswap.h and endian.h functions are used with non-constant
expression arguments that often.
I sense a bit of confusion here. Although POSIX allows
symbols like be16toh to be
On 5/12/24 1:02 PM, Bruno Haible wrote:
> The simple fix to your worry is: Let the user use '-Wall' routinely.
> gcc has a warning option '-Wsequence-point', included in '-Wall'.
> clang has a warning option '-Wunsequenced', included in '-Wall'.
> The do the job, and I have not seen them produce fa
Collin Funk wrote:
> I worry though that in some cases programs will be accustomed to
> glibc's behavior. Since all of the functions are just macros to static
> inline functions in arguments will only be evaluated
> once. It seems like it could be the cause of some unexpected bugs...
The simple f
On Sun, May 12, 2024 at 3:23 PM Collin Funk wrote:
> A few months ago there was a suggestion on emacs-devel to use
> __builtin_bswap functions when available [1]. While I agree that GCC
> can deal with the optimizations properly, I noted an important
> difference between the macros in byteswap.h.
On 5/12/24 12:38 PM, Paul Eggert wrote:
>> Also if we can agree upon making sure these are defined as functions,
>> what is the proper way to test it in a configure script? My instinct
>> tells me that assigning a function pointer to bswap_16, etc. would
>> fail if they are macros
>
> I don't see
On 2024-05-12 12:23, Collin Funk wrote:
I think the best decision is to use
'extern inline' to match the behavior of glibc.
Yes, with the usual _GL_EXTERN business.
Also if we can agree upon making sure these are defined as functions,
what is the proper way to test it in a configure script?
A few months ago there was a suggestion on emacs-devel to use
__builtin_bswap functions when available [1]. While I agree that GCC
can deal with the optimizations properly, I noted an important
difference between the macros in byteswap.h.in and inline functions
provided by glibc.
Using this test p