Re: [PATCH] sha512-buffer: port back to 32-bit-only hosts

2024-05-20 Thread Bruno Haible
Paul Eggert wrote: > > uintN_t arithmetic is overflow-free, just like 'unsigned int' arithmetic. > > Not exactly. For example, this: > >uint16_t a = 46341, b = a * a; > > has undefined behavior on typical platforms with 32-bit int, because > 46341*46341 exceeds 2**31 - 1. Although many prog

Re: [PATCH] sha512-buffer: port back to 32-bit-only hosts

2024-05-19 Thread Paul Eggert
On 2024-05-19 14:37, Bruno Haible wrote: uintN_t arithmetic is overflow-free, just like 'unsigned int' arithmetic. Not exactly. For example, this: uint16_t a = 46341, b = a * a; has undefined behavior on typical platforms with 32-bit int, because 46341*46341 exceeds 2**31 - 1. Although man

Re: [PATCH] sha512-buffer: port back to 32-bit-only hosts

2024-05-19 Thread Bruno Haible
Hi Paul, > > Out of personal interest, do you happen to know what platforms Emacs > > builds on that lack 64-bit types? > > Emacs is a bit of a special case as it builds on verrry ooold platforms, > including platforms no longer supported by their suppliers, and we're > reasonably reluctant to

Re: [PATCH] sha512-buffer: port back to 32-bit-only hosts

2024-05-19 Thread Paul Eggert
On 2024-05-18 20:42, Collin Funk wrote: Out of personal interest, do you happen to know what platforms Emacs builds on that lack 64-bit types? Emacs is a bit of a special case as it builds on verrry ooold platforms, including platforms no longer supported by their suppliers, and we're reasona

Re: [PATCH] sha512-buffer: port back to 32-bit-only hosts

2024-05-19 Thread Bruno Haible
Collin Funk wrote: > Out of personal interest, do you happen to know what platforms Emacs > builds on that lack 64-bit types? This would have been my question as well. Because we are assuming the presence of 'long long' since 2019-12-22 [1], and 'long long' is 64-bits wide everywhere. I thought th

Re: [PATCH] sha512-buffer: port back to 32-bit-only hosts

2024-05-18 Thread Collin Funk
Hi Paul, Patch looks good. On 5/18/24 7:04 PM, Paul Eggert wrote: > Port to platforms lacking 64-bit integers (something that Emacs > still attempts to do, in theory) by adding an u64bswap primitive > to u64.h and using that, instead of using bswap_64. This fixes a > bug I made in commit 0d45ec7

[PATCH] sha512-buffer: port back to 32-bit-only hosts

2024-05-18 Thread Paul Eggert
Port to platforms lacking 64-bit integers (something that Emacs still attempts to do, in theory) by adding an u64bswap primitive to u64.h and using that, instead of using bswap_64. This fixes a bug I made in commit 0d45ec7c033c165ad73a6509c7fa84aa67edf4ea dated Sun Jun 17 14:35:37 2018 -0700. * li