Control: tag -1 patch

Hi,

it turns out that the alignof macro can probably be replaced by a GCC
builtin. The attached patch does that. I am not committing this to Salsa
right away because I am not 100% sure that __alignof__ (t) is
functionally equivalent to the macro that has become illegal in GCC 8:

    #define alignof(type)  offsetof (struct { char c; type x; }, x)

Cheers,
-Hilko
Index: guymager/md5.cpp
===================================================================
--- guymager.orig/md5.cpp
+++ guymager/md5.cpp
@@ -376,8 +376,7 @@ void MD5Append (t_pMD5Context pContext,
    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) (((size_t) p) % __alignof__ (uint32_t) != 0)
 
          if (UNALIGNED_P (pBuffer))
          {
Index: guymager/sha1.cpp
===================================================================
--- guymager.orig/sha1.cpp
+++ guymager/sha1.cpp
@@ -263,8 +263,7 @@ void SHA1Append (t_pSHA1Context pContext
    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) (((size_t) p) % __alignof__ (uint32_t) != 0)
          if (UNALIGNED_P (buffer))
             while (len > 64)
             {
Index: guymager/sha256.cpp
===================================================================
--- guymager.orig/sha256.cpp
+++ guymager/sha256.cpp
@@ -812,8 +812,7 @@ void SHA256Append (t_pSHA256Context pCon
    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) != 0)
+         #define UNALIGNED_P(p) (((size_t) p) % __alignof__ (uint32) != 0)
          if (UNALIGNED_P (buffer))
          {
             while (len > 64)

Reply via email to