From: Bruce Momjian Date: Thu, 29 Nov 2001 19:40:37 +0000 (+0000) Subject: * When postgres.h does not define BYTE_ENDIAN pgcrypto X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=c672c2d2a5dba8e84fa555bc241de694e1bcf0c6;p=users%2Fbernd%2Fpostgres.git * When postgres.h does not define BYTE_ENDIAN pgcrypto produces garbage. I learned the hard way that #if UNDEFINED_1 == UNDEFINED_2 #error "gcc is idiot" #endif prints "gcc is idiot" ... Affected are MD5/SHA1 in internal library, and also HMAC-MD5/HMAC-SHA1/ crypt-md5 which use them. Blowfish is ok, also Rijndael on at least x86. Big thanks to Daniel Holtzman who send me a build log which contained warning: md5.c:246: warning: `X' defined but not used Yes, gcc is that helpful... Please apply this. -- marko --- diff --git a/contrib/pgcrypto/blf.c b/contrib/pgcrypto/blf.c index efba19055f..0caa33d4e3 100644 --- a/contrib/pgcrypto/blf.c +++ b/contrib/pgcrypto/blf.c @@ -41,6 +41,8 @@ */ #include +#include "px.h" + #include "blf.h" #undef inline diff --git a/contrib/pgcrypto/crypt-blowfish.c b/contrib/pgcrypto/crypt-blowfish.c index 8ec2b188e0..8e41771be9 100644 --- a/contrib/pgcrypto/crypt-blowfish.c +++ b/contrib/pgcrypto/crypt-blowfish.c @@ -32,7 +32,9 @@ #include "postgres.h" +#include "px.h" #include "px-crypt.h" + #define __set_errno(v) #ifndef __set_errno diff --git a/contrib/pgcrypto/crypt-des.c b/contrib/pgcrypto/crypt-des.c index 53df2a19fb..bcb6b5b5c7 100644 --- a/contrib/pgcrypto/crypt-des.c +++ b/contrib/pgcrypto/crypt-des.c @@ -60,6 +60,7 @@ #include "postgres.h" +#include "px.h" #include "px-crypt.h" /* for ntohl/htonl */ diff --git a/contrib/pgcrypto/crypt-gensalt.c b/contrib/pgcrypto/crypt-gensalt.c index 9c017b0e4d..c58e794789 100644 --- a/contrib/pgcrypto/crypt-gensalt.c +++ b/contrib/pgcrypto/crypt-gensalt.c @@ -12,6 +12,7 @@ #include "postgres.h" +#include "px.h" #include "px-crypt.h" #include diff --git a/contrib/pgcrypto/md5.c b/contrib/pgcrypto/md5.c index 6a37f2f8ec..e66e21a6ed 100644 --- a/contrib/pgcrypto/md5.c +++ b/contrib/pgcrypto/md5.c @@ -31,6 +31,7 @@ */ #include "postgres.h" +#include "px.h" #include "md5.h" diff --git a/contrib/pgcrypto/px.h b/contrib/pgcrypto/px.h index d8252a5a91..4e22245d3e 100644 --- a/contrib/pgcrypto/px.h +++ b/contrib/pgcrypto/px.h @@ -32,6 +32,15 @@ #ifndef __PX_H #define __PX_H +#ifdef HAVE_ENDIAN_H +#include +#endif + +#ifndef BYTE_ORDER +#error BYTE_ORDER must be defined as LITTLE_ENDIAN or BIG_ENDIAN +#endif + + #if 1 #define px_alloc(s) palloc(s) diff --git a/contrib/pgcrypto/rijndael.c b/contrib/pgcrypto/rijndael.c index c534f58cd8..094f4a8fa5 100644 --- a/contrib/pgcrypto/rijndael.c +++ b/contrib/pgcrypto/rijndael.c @@ -39,6 +39,7 @@ Mean: 500 cycles = 51.2 mbits/sec */ #include +#include "px.h" #include "rijndael.h" diff --git a/contrib/pgcrypto/sha1.c b/contrib/pgcrypto/sha1.c index 1c1a1d5f90..5be954d769 100644 --- a/contrib/pgcrypto/sha1.c +++ b/contrib/pgcrypto/sha1.c @@ -36,6 +36,7 @@ */ #include "postgres.h" +#include "px.h" #include "sha1.h"