]> Savannah Git Hosting - gnulib.git/commit
sha512-buffer: port back to 32-bit-only hosts
authorPaul Eggert <eggert@cs.ucla.edu>
Sun, 19 May 2024 02:02:48 +0000 (19:02 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Sun, 19 May 2024 02:04:36 +0000 (19:04 -0700)
commit6cf3388fa179a1e089a101703b403c7976ae6c8f
tree961775a16892e6f324b36ab4c65c6cf0cc4a2cf1
parentc7398c508d7e0222c1d7a74c14d93b23bf57fe05
sha512-buffer: port back to 32-bit-only hosts

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.
* lib/sha512.c (SWAP): Use u64bswap, not bswap_64, to port
to older platforms lacking 64-bit integers.
* lib/u64.h: Include stddef.h, for size_t.
Include byteswap.h, for bswap_64 (on platforms with 64-bit int),
bswap_32.
(u64rol): Now a function, not a macro, so that it evaluates
its args only once.
(u64uint32): New typedef.
(u64, u64hilo, u64lo): Use it.
(_GL_U64_MASK32): New macro.
(u64size, u64plus, u64shl, u64shr, u64plus): Use it as needed for
odd platforms where unsigned int is wider than 32 bits.
(u64lt): Return bool, not int.
* modules/u64 (Depends-on): Add byteswap, stdbool.
* tests/test-u64.c (main): Test u64bswap.
ChangeLog
lib/sha512.c
lib/u64.h
modules/u64
tests/test-u64.c