Mercurial > hg > octave-jordi > gnulib-hg
changeset 15997:d8fd2f096b83
crypto libraries: use stdalign
* lib/md4.c, lib/md5.c, lib/sha1.c, lib/sha256.c, lib/sha512.c:
Include <stdalign.h> and <stdint.h>. Do not include <stddef.h>.
Do not include <stdlib.h> twice, in md4.c.
(UNALIGNED_P): Simplify by using alignof. Use uintptr_t, not size_t,
because we are accessing a pointer's bit-pattern, not a size.
* modules/crypto/gc-md4 (Depends-on): Add stdalign.
* modules/crypto/gc-md5, modules/crypto/gc-sha1, modules/crypto/md4:
* modules/crypto/md5, modules/crypto/sha1, modules/crypto/sha256:
* modules/crypto/sha512: Likewise.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Sun, 16 Oct 2011 17:17:47 -0700 |
parents | 3c249f388e46 |
children | 9b28a5d31bb5 |
files | ChangeLog lib/md4.c lib/md5.c lib/sha1.c lib/sha256.c lib/sha512.c modules/crypto/gc-md4 modules/crypto/gc-md5 modules/crypto/gc-sha1 modules/crypto/md4 modules/crypto/md5 modules/crypto/sha1 modules/crypto/sha256 modules/crypto/sha512 |
diffstat | 14 files changed, 34 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -14,6 +14,17 @@ (alignof): Remove. * modules/argp (Depends-on): Add stdalign. + crypto libraries: use stdalign + * lib/md4.c, lib/md5.c, lib/sha1.c, lib/sha256.c, lib/sha512.c: + Include <stdalign.h> and <stdint.h>. Do not include <stddef.h>. + Do not include <stdlib.h> twice, in md4.c. + (UNALIGNED_P): Simplify by using alignof. Use uintptr_t, not size_t, + because we are accessing a pointer's bit-pattern, not a size. + * modules/crypto/gc-md4 (Depends-on): Add stdalign. + * modules/crypto/gc-md5, modules/crypto/gc-sha1, modules/crypto/md4: + * modules/crypto/md5, modules/crypto/sha1, modules/crypto/sha256: + * modules/crypto/sha512: Likewise. + 2011-10-27 Bruno Haible <bruno@clisp.org> raise test: Avoid a test failure on Linux/MIPS.
--- a/lib/md4.c +++ b/lib/md4.c @@ -24,8 +24,8 @@ #include "md4.h" -#include <stddef.h> -#include <stdlib.h> +#include <stdalign.h> +#include <stdint.h> #include <stdlib.h> #include <string.h> #include <sys/types.h> @@ -239,14 +239,7 @@ if (len >= 64) { #if !_STRING_ARCH_unaligned - /* To check alignment gcc has an appropriate operator. Other - compilers don't. */ -# if __GNUC__ >= 2 -# define UNALIGNED_P(p) (((uintptr_t) p) % __alignof__ (uint32_t) != 0) -# else -# define alignof(type) offsetof (struct { char c; type x; }, x) -# define UNALIGNED_P(p) (((size_t) p) % alignof (uint32_t) != 0) -# endif +# define UNALIGNED_P(p) ((uintptr_t) (p) % alignof (uint32_t) != 0) if (UNALIGNED_P (buffer)) while (len > 64) {
--- a/lib/md5.c +++ b/lib/md5.c @@ -24,7 +24,8 @@ #include "md5.h" -#include <stddef.h> +#include <stdalign.h> +#include <stdint.h> #include <stdlib.h> #include <string.h> #include <sys/types.h> @@ -254,8 +255,7 @@ if (len >= 64) { #if !_STRING_ARCH_unaligned -# define alignof(type) offsetof (struct { char c; type x; }, x) -# define UNALIGNED_P(p) (((size_t) p) % alignof (uint32_t) != 0) +# define UNALIGNED_P(p) ((uintptr_t) (p) % alignof (uint32_t) != 0) if (UNALIGNED_P (buffer)) while (len > 64) {
--- a/lib/sha1.c +++ b/lib/sha1.c @@ -26,7 +26,8 @@ #include "sha1.h" -#include <stddef.h> +#include <stdalign.h> +#include <stdint.h> #include <stdlib.h> #include <string.h> @@ -241,8 +242,7 @@ if (len >= 64) { #if !_STRING_ARCH_unaligned -# define alignof(type) offsetof (struct { char c; type x; }, x) -# define UNALIGNED_P(p) (((size_t) p) % alignof (uint32_t) != 0) +# define UNALIGNED_P(p) ((uintptr_t) (p) % alignof (uint32_t) != 0) if (UNALIGNED_P (buffer)) while (len > 64) {
--- a/lib/sha256.c +++ b/lib/sha256.c @@ -24,7 +24,8 @@ #include "sha256.h" -#include <stddef.h> +#include <stdalign.h> +#include <stdint.h> #include <stdlib.h> #include <string.h> @@ -373,8 +374,7 @@ if (len >= 64) { #if !_STRING_ARCH_unaligned -# define alignof(type) offsetof (struct { char c; type x; }, x) -# define UNALIGNED_P(p) (((size_t) p) % alignof (uint32_t) != 0) +# define UNALIGNED_P(p) ((uintptr_t) (p) % alignof (uint32_t) != 0) if (UNALIGNED_P (buffer)) while (len > 64) {
--- a/lib/sha512.c +++ b/lib/sha512.c @@ -24,7 +24,8 @@ #include "sha512.h" -#include <stddef.h> +#include <stdalign.h> +#include <stdint.h> #include <stdlib.h> #include <string.h> @@ -381,8 +382,7 @@ if (len >= 128) { #if !_STRING_ARCH_unaligned -# define alignof(type) offsetof (struct { char c; type x; }, x) -# define UNALIGNED_P(p) (((size_t) p) % alignof (u64) != 0) +# define UNALIGNED_P(p) ((uintptr_t) (p) % alignof (u64) != 0) if (UNALIGNED_P (buffer)) while (len > 128) {
--- a/modules/crypto/gc-md4 +++ b/modules/crypto/gc-md4 @@ -8,6 +8,7 @@ m4/md4.m4 Depends-on: +stdalign stdint crypto/gc
--- a/modules/crypto/gc-md5 +++ b/modules/crypto/gc-md5 @@ -8,6 +8,7 @@ m4/md5.m4 Depends-on: +stdalign stdint crypto/gc
--- a/modules/crypto/gc-sha1 +++ b/modules/crypto/gc-sha1 @@ -8,6 +8,7 @@ m4/sha1.m4 Depends-on: +stdalign stdint crypto/gc
--- a/modules/crypto/md4 +++ b/modules/crypto/md4 @@ -7,6 +7,7 @@ m4/md4.m4 Depends-on: +stdalign stdint configure.ac:
--- a/modules/crypto/md5 +++ b/modules/crypto/md5 @@ -7,6 +7,7 @@ m4/md5.m4 Depends-on: +stdalign stdint configure.ac:
--- a/modules/crypto/sha1 +++ b/modules/crypto/sha1 @@ -7,6 +7,7 @@ m4/sha1.m4 Depends-on: +stdalign stdint configure.ac: