[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Alignment issue with sha1 code from gnulib
From: |
Bruno Haible |
Subject: |
Re: Alignment issue with sha1 code from gnulib |
Date: |
Thu, 31 Jan 2008 12:55:17 +0100 |
User-agent: |
KMail/1.5.4 |
Simon,
> I have pushed changes for md2, md4 and md5.
Here's an additional proposed refinement. With it, gcc generates much better
code (on x86: a single instruction instead of a function call of a function
with 5 instructions).
2008-01-31 Bruno Haible <address@hidden>
* lib/md4.c (set_uint32): Mark as inline.
* lib/md5.c (set_uint32): Likewise.
* lib/sha1.c (set_uint32): Likewise.
* m4/md4.m4 (gl_MD4): Require AC_C_INLINE.
* m4/md5.m4 (gl_MD5): Likewise.
* m4/sha1.m4 (gl_SHA1): Likewise.
*** lib/md4.c.orig 2008-01-31 12:50:56.000000000 +0100
--- lib/md4.c 2008-01-31 12:45:36.000000000 +0100
***************
*** 67,73 ****
/* Copy the 4 byte value from v into the memory location pointed to by *cp,
If your architecture allows unaligned access this is equivalent to
* (uint32_t *) cp = v */
! static void
set_uint32 (char *cp, uint32_t v)
{
memcpy (cp, &v, 4);
--- 67,73 ----
/* Copy the 4 byte value from v into the memory location pointed to by *cp,
If your architecture allows unaligned access this is equivalent to
* (uint32_t *) cp = v */
! static inline void
set_uint32 (char *cp, uint32_t v)
{
memcpy (cp, &v, 4);
*** lib/md5.c.orig 2008-01-31 12:50:56.000000000 +0100
--- lib/md5.c 2008-01-31 12:44:34.000000000 +0100
***************
*** 83,89 ****
/* Copy the 4 byte value from v into the memory location pointed to by *cp,
If your architecture allows unaligned access this is equivalent to
* (uint32_t *) cp = v */
! static void
set_uint32 (char *cp, uint32_t v)
{
memcpy (cp, &v, 4);
--- 83,89 ----
/* Copy the 4 byte value from v into the memory location pointed to by *cp,
If your architecture allows unaligned access this is equivalent to
* (uint32_t *) cp = v */
! static inline void
set_uint32 (char *cp, uint32_t v)
{
memcpy (cp, &v, 4);
*** lib/sha1.c.orig 2008-01-31 12:50:56.000000000 +0100
--- lib/sha1.c 2008-01-31 12:45:30.000000000 +0100
***************
*** 70,76 ****
/* Copy the 4 byte value from v into the memory location pointed to by *cp,
If your architecture allows unaligned access this is equivalent to
* (uint32_t *) cp = v */
! static void
set_uint32 (char *cp, uint32_t v)
{
memcpy (cp, &v, 4);
--- 70,76 ----
/* Copy the 4 byte value from v into the memory location pointed to by *cp,
If your architecture allows unaligned access this is equivalent to
* (uint32_t *) cp = v */
! static inline void
set_uint32 (char *cp, uint32_t v)
{
memcpy (cp, &v, 4);
*** m4/md4.m4.orig 2008-01-31 12:50:56.000000000 +0100
--- m4/md4.m4 2008-01-31 12:50:15.000000000 +0100
***************
*** 1,5 ****
! # md4.m4 serial 2
! dnl Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
--- 1,5 ----
! # md4.m4 serial 3
! dnl Copyright (C) 2002, 2003, 2004, 2005, 2006, 2008 Free Software
Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
***************
*** 10,13 ****
--- 10,14 ----
dnl Prerequisites of lib/md4.c.
AC_REQUIRE([AC_C_BIGENDIAN])
+ AC_REQUIRE([AC_C_INLINE])
])
*** m4/md5.m4.orig 2008-01-31 12:50:56.000000000 +0100
--- m4/md5.m4 2008-01-31 12:49:28.000000000 +0100
***************
*** 1,5 ****
! # md5.m4 serial 9
! dnl Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
--- 1,5 ----
! # md5.m4 serial 10
! dnl Copyright (C) 2002, 2003, 2004, 2005, 2006, 2008 Free Software
Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
***************
*** 10,14 ****
--- 10,15 ----
dnl Prerequisites of lib/md5.c.
AC_REQUIRE([AC_C_BIGENDIAN])
+ AC_REQUIRE([AC_C_INLINE])
:
])
*** m4/sha1.m4.orig 2008-01-31 12:50:56.000000000 +0100
--- m4/sha1.m4 2008-01-31 12:48:19.000000000 +0100
***************
*** 1,5 ****
! # sha1.m4 serial 7
! dnl Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
--- 1,5 ----
! # sha1.m4 serial 8
! dnl Copyright (C) 2002, 2003, 2004, 2005, 2006, 2008 Free Software
Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
***************
*** 10,14 ****
--- 10,15 ----
dnl Prerequisites of lib/sha1.c.
AC_REQUIRE([AC_C_BIGENDIAN])
+ AC_REQUIRE([AC_C_INLINE])
:
])
Re: Alignment issue with sha1 code from gnulib, Jim Meyering, 2008/01/31