Re: [PATCH] byteswap: port better to limited platforms

2024-05-18 Thread Bruno Haible
Paul Eggert wrote: > > $ gcc -Wall -S foo.c > > foo.c:1: warning: integer constant is too large for ‘long’ type > > I don't see how that would produce incorrect code for byteswap.h. Indeed, gcc 4.4.7 warns but produces a long long value (no truncation). > The longer story is C89 lacked 'long lon

Re: [PATCH] byteswap: port better to limited platforms

2024-05-18 Thread Paul Eggert
On 2024-05-17 16:51, Bruno Haible wrote: -- foo.c -- unsigned long long x = 0xff00; --- $ gcc -Wall -S foo.c foo.c:1: warning: integer constant is too large for ‘long’ type I don

Re: [PATCH] byteswap: port better to limited platforms

2024-05-17 Thread Collin Funk
On 5/17/24 3:49 PM, Paul Eggert wrote: > POSIX does not require uint64_t, and the C standard > does not require uint16_t or uint32_t either, so port > to platforms that lack these types. The POSIX limitation > is the only significant one in practice. I ran into this > issue when updating Emacs, w

Re: [PATCH] byteswap: port better to limited platforms

2024-05-17 Thread Collin Funk
On 5/17/24 4:51 PM, Bruno Haible wrote: > I think this produces wrong code with gcc 4.4.7 and older. See: > > -- foo.c -- > unsigned long long x = 0xff00; > --- > > $ gcc -Wall -S f

Re: [PATCH] byteswap: port better to limited platforms

2024-05-17 Thread Bruno Haible
Paul Eggert wrote: > -#else > - return x) & 0xff00ull) >> 56) > - | (((x) & 0x00ffull) >> 40) > - | (((x) & 0xff00ull) >> 24) > - | (((x) & 0x00ffull) >> 8) > - | (((x) & 0xff00ull) << 8) > -