Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit37a609b

Browse files
committed
Now that core functionality is depending on autoconf's AC_C_BIGENDIAN to be
right, there seems precious little reason to have a pile of hand-maintainedendianness definitions in src/include/port/*.h. Get rid of those, and makethe couple of places that used them depend on WORDS_BIGENDIAN instead.
1 parent3e23b68 commit37a609b

File tree

22 files changed

+66
-295
lines changed

22 files changed

+66
-295
lines changed

‎configure

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7788,8 +7788,7 @@ done
77887788

77897789

77907790

7791-
7792-
for ac_header in crypt.h dld.h endian.h fp_class.h getopt.h ieeefp.h langinfo.h poll.h pwd.h sys/ipc.h sys/poll.h sys/pstat.h sys/resource.h sys/select.h sys/sem.h sys/socket.h sys/shm.h sys/time.h sys/un.h termios.h utime.h wchar.h wctype.h kernel/OS.h kernel/image.h SupportDefs.h
7791+
for ac_header in crypt.h dld.h fp_class.h getopt.h ieeefp.h langinfo.h poll.h pwd.h sys/ipc.h sys/poll.h sys/pstat.h sys/resource.h sys/select.h sys/sem.h sys/socket.h sys/shm.h sys/time.h sys/un.h termios.h utime.h wchar.h wctype.h kernel/OS.h kernel/image.h SupportDefs.h
77937792
do
77947793
as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
77957794
if eval "test \"\${$as_ac_Header+set}\" = set"; then

‎configure.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
dnl Process this file with autoconf to produce a configure script.
2-
dnl $PostgreSQL: pgsql/configure.in,v 1.508 2007/04/0604:21:41 tgl Exp $
2+
dnl $PostgreSQL: pgsql/configure.in,v 1.509 2007/04/0605:36:50 tgl Exp $
33
dnl
44
dnl Developers, please strive to achieve this order:
55
dnl
@@ -773,7 +773,7 @@ fi
773773
##
774774

775775
dnl sys/socket.h is required by AC_FUNC_ACCEPT_ARGTYPES
776-
AC_CHECK_HEADERS([crypt.h dld.hendian.hfp_class.h getopt.h ieeefp.h langinfo.h poll.h pwd.h sys/ipc.h sys/poll.h sys/pstat.h sys/resource.h sys/select.h sys/sem.h sys/socket.h sys/shm.h sys/time.h sys/un.h termios.h utime.h wchar.h wctype.h kernel/OS.h kernel/image.h SupportDefs.h])
776+
AC_CHECK_HEADERS([crypt.h dld.h fp_class.h getopt.h ieeefp.h langinfo.h poll.h pwd.h sys/ipc.h sys/poll.h sys/pstat.h sys/resource.h sys/select.h sys/sem.h sys/socket.h sys/shm.h sys/time.h sys/un.h termios.h utime.h wchar.h wctype.h kernel/OS.h kernel/image.h SupportDefs.h])
777777

778778
# At least on IRIX, cpp test for netinet/tcp.h will fail unless
779779
# netinet/in.h is included first.

‎contrib/pgcrypto/crypt-blowfish.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* $PostgreSQL: pgsql/contrib/pgcrypto/crypt-blowfish.c,v 1.11 2006/03/11 04:38:30 momjian Exp $
2+
* $PostgreSQL: pgsql/contrib/pgcrypto/crypt-blowfish.c,v 1.12 2007/04/06 05:36:50 tgl Exp $
33
*
44
* This code comes from John the Ripper password cracker, with reentrant
55
* and crypt(3) interfaces added, but optimizations specific to password
@@ -436,19 +436,19 @@ BF_encode(char *dst, const BF_word * src, int size)
436436
}
437437

438438
staticvoid
439-
BF_swap(BF_word*x,intcount)
439+
BF_swap(BF_word*x,intcount)
440440
{
441-
staticintendianness_check=1;
442-
char*is_little_endian= (char*)&endianness_check;
441+
/* Swap on little-endian hardware, else do nothing */
442+
#ifndefWORDS_BIGENDIAN
443443
BF_wordtmp;
444444

445-
if (*is_little_endian)
446-
do
447-
{
448-
tmp=*x;
449-
tmp= (tmp <<16) | (tmp >>16);
450-
*x++= ((tmp&0x00FF00FF) <<8) | ((tmp >>8)&0x00FF00FF);
451-
}while (--count);
445+
do
446+
{
447+
tmp=*x;
448+
tmp=(tmp <<16) | (tmp >>16);
449+
*x++= ((tmp&0x00FF00FF)<<8) | ((tmp >>8)&0x00FF00FF);
450+
}while (--count);
451+
#endif
452452
}
453453

454454
#ifBF_SCALE

‎contrib/pgcrypto/md5.c

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929
* SUCH DAMAGE.
3030
*
31-
* $PostgreSQL: pgsql/contrib/pgcrypto/md5.c,v 1.13 2005/07/11 15:07:59 tgl Exp $
31+
* $PostgreSQL: pgsql/contrib/pgcrypto/md5.c,v 1.14 2007/04/06 05:36:50 tgl Exp $
3232
*/
3333

3434
#include"postgres.h"
@@ -38,11 +38,6 @@
3838
#include"px.h"
3939
#include"md5.h"
4040

41-
/* sanity check */
42-
#if !defined(BYTE_ORDER)|| (BYTE_ORDER!=LITTLE_ENDIAN&&BYTE_ORDER!=BIG_ENDIAN)
43-
#error Define BYTE_ORDER to be equal to either LITTLE_ENDIAN or BIG_ENDIAN
44-
#endif
45-
4641
#defineSHIFT(X,s) (((X) << (s)) | ((X) >> (32 - (s))))
4742

4843
#defineF(X,Y,Z) (((X) & (Y)) | ((~X) & (Z)))
@@ -201,10 +196,9 @@ md5_pad(md5_ctxt * ctxt)
201196
}
202197

203198
/* 8 byte word */
204-
#ifBYTE_ORDER==LITTLE_ENDIAN
199+
#ifndefWORDS_BIGENDIAN
205200
memmove(&ctxt->md5_buf[56],&ctxt->md5_n8[0],8);
206-
#endif
207-
#ifBYTE_ORDER==BIG_ENDIAN
201+
#else
208202
ctxt->md5_buf[56]=ctxt->md5_n8[7];
209203
ctxt->md5_buf[57]=ctxt->md5_n8[6];
210204
ctxt->md5_buf[58]=ctxt->md5_n8[5];
@@ -222,10 +216,9 @@ void
222216
md5_result(uint8*digest,md5_ctxt*ctxt)
223217
{
224218
/* 4 byte words */
225-
#ifBYTE_ORDER==LITTLE_ENDIAN
219+
#ifndefWORDS_BIGENDIAN
226220
memmove(digest,&ctxt->md5_st8[0],16);
227-
#endif
228-
#ifBYTE_ORDER==BIG_ENDIAN
221+
#else
229222
digest[0]=ctxt->md5_st8[3];
230223
digest[1]=ctxt->md5_st8[2];
231224
digest[2]=ctxt->md5_st8[1];
@@ -245,7 +238,7 @@ md5_result(uint8 *digest, md5_ctxt * ctxt)
245238
#endif
246239
}
247240

248-
#ifBYTE_ORDER==BIG_ENDIAN
241+
#ifdefWORDS_BIGENDIAN
249242
staticuint32X[16];
250243
#endif
251244

@@ -257,10 +250,9 @@ md5_calc(uint8 *b64, md5_ctxt * ctxt)
257250
uint32C=ctxt->md5_stc;
258251
uint32D=ctxt->md5_std;
259252

260-
#ifBYTE_ORDER==LITTLE_ENDIAN
253+
#ifndefWORDS_BIGENDIAN
261254
uint32*X= (uint32*)b64;
262-
#endif
263-
#ifBYTE_ORDER==BIG_ENDIAN
255+
#else
264256
/* 4 byte words */
265257
/* what a brute force but fast! */
266258
uint8*y= (uint8*)X;

‎contrib/pgcrypto/px.h

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,14 @@
2626
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2727
* SUCH DAMAGE.
2828
*
29-
* $PostgreSQL: pgsql/contrib/pgcrypto/px.h,v 1.16 2005/10/15 02:49:06 momjian Exp $
29+
* $PostgreSQL: pgsql/contrib/pgcrypto/px.h,v 1.17 2007/04/06 05:36:50 tgl Exp $
3030
*/
3131

3232
#ifndef__PX_H
3333
#define__PX_H
3434

3535
#include<sys/types.h>
3636
#include<sys/param.h>
37-
#ifdefHAVE_ENDIAN_H
38-
#include<endian.h>
39-
#endif
40-
41-
#ifndefBYTE_ORDER
42-
#error BYTE_ORDER must be defined as LITTLE_ENDIAN or BIG_ENDIAN
43-
#endif
4437

4538
/* keep debug messages? */
4639
#definePX_DEBUG

‎contrib/pgcrypto/rijndael.c

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*$OpenBSD: rijndael.c,v 1.6 2000/12/09 18:51:34 markus Exp $ */
22

3-
/* $PostgreSQL: pgsql/contrib/pgcrypto/rijndael.c,v 1.12 2005/10/15 02:49:06 momjian Exp $ */
3+
/* $PostgreSQL: pgsql/contrib/pgcrypto/rijndael.c,v 1.13 2007/04/06 05:36:50 tgl Exp $ */
44

55
/* This is an independent implementation of the encryption algorithm:*/
66
/**/
@@ -47,12 +47,6 @@ Mean: 500 cycles = 51.2 mbits/sec
4747
#include"px.h"
4848
#include"rijndael.h"
4949

50-
/* sanity check */
51-
#if !defined(BYTE_ORDER)|| (BYTE_ORDER!=LITTLE_ENDIAN&&BYTE_ORDER!=BIG_ENDIAN)
52-
#error Define BYTE_ORDER to be equal to either LITTLE_ENDIAN or BIG_ENDIAN
53-
#endif
54-
55-
5650
#definePRE_CALC_TABLES
5751
#defineLARGE_TABLES
5852

@@ -73,11 +67,7 @@ static void gen_tabs(void);
7367

7468
#definebyte(x,n)((u1byte)((x) >> (8 * (n))))
7569

76-
#ifBYTE_ORDER!=LITTLE_ENDIAN
77-
#defineBYTE_SWAP
78-
#endif
79-
80-
#ifdefBYTE_SWAP
70+
#ifdefWORDS_BIGENDIAN
8171
#defineio_swap(x)bswap(x)
8272
#else
8373
#defineio_swap(x)(x)

‎contrib/pgcrypto/sha1.c

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929
* SUCH DAMAGE.
3030
*
31-
* $PostgreSQL: pgsql/contrib/pgcrypto/sha1.c,v 1.16 2005/07/11 15:07:59 tgl Exp $
31+
* $PostgreSQL: pgsql/contrib/pgcrypto/sha1.c,v 1.17 2007/04/06 05:36:50 tgl Exp $
3232
*/
3333
/*
3434
* FIPS pub 180-1: Secure Hash Algorithm (SHA-1)
@@ -43,11 +43,6 @@
4343
#include"px.h"
4444
#include"sha1.h"
4545

46-
/* sanity check */
47-
#if !defined(BYTE_ORDER)|| (BYTE_ORDER!=LITTLE_ENDIAN&&BYTE_ORDER!=BIG_ENDIAN)
48-
#error Define BYTE_ORDER to be equal to either LITTLE_ENDIAN or BIG_ENDIAN
49-
#endif
50-
5146
/* constant table */
5247
staticuint32_K[]= {0x5a827999,0x6ed9eba1,0x8f1bbcdc,0xca62c1d6};
5348

@@ -98,7 +93,7 @@ sha1_step(struct sha1_ctxt * ctxt)
9893
s;
9994
uint32tmp;
10095

101-
#ifBYTE_ORDER==LITTLE_ENDIAN
96+
#ifndefWORDS_BIGENDIAN
10297
structsha1_ctxttctxt;
10398

10499
memmove(&tctxt.m.b8[0],&ctxt->m.b8[0],64);
@@ -264,7 +259,7 @@ sha1_pad(struct sha1_ctxt * ctxt)
264259
memset(&ctxt->m.b8[padstart],0,padlen-8);
265260
COUNT+= (padlen-8);
266261
COUNT %=64;
267-
#ifBYTE_ORDER==BIG_ENDIAN
262+
#ifdefWORDS_BIGENDIAN
268263
PUTPAD(ctxt->c.b8[0]);
269264
PUTPAD(ctxt->c.b8[1]);
270265
PUTPAD(ctxt->c.b8[2]);
@@ -320,7 +315,7 @@ sha1_result(struct sha1_ctxt * ctxt, uint8 *digest0)
320315

321316
digest= (uint8*)digest0;
322317
sha1_pad(ctxt);
323-
#ifBYTE_ORDER==BIG_ENDIAN
318+
#ifdefWORDS_BIGENDIAN
324319
memmove(digest,&ctxt->h.b8[0],20);
325320
#else
326321
digest[0]=ctxt->h.b8[3];

‎contrib/pgcrypto/sha2.c

Lines changed: 9 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
*
3434
* $From: sha2.c,v 1.1 2001/11/08 00:01:51 adg Exp adg $
3535
*
36-
* $PostgreSQL: pgsql/contrib/pgcrypto/sha2.c,v 1.8 2006/10/04 00:29:46 momjian Exp $
36+
* $PostgreSQL: pgsql/contrib/pgcrypto/sha2.c,v 1.9 2007/04/06 05:36:50 tgl Exp $
3737
*/
3838

3939
#include"postgres.h"
@@ -56,40 +56,6 @@
5656
*
5757
*/
5858

59-
60-
/*** SHA-256/384/512 Machine Architecture Definitions *****************/
61-
/*
62-
* BYTE_ORDER NOTE:
63-
*
64-
* Please make sure that your system defines BYTE_ORDER. If your
65-
* architecture is little-endian, make sure it also defines
66-
* LITTLE_ENDIAN and that the two (BYTE_ORDER and LITTLE_ENDIAN) are
67-
* equivilent.
68-
*
69-
* If your system does not define the above, then you can do so by
70-
* hand like this:
71-
*
72-
* #define LITTLE_ENDIAN 1234
73-
* #define BIG_ENDIAN 4321
74-
*
75-
* And for little-endian machines, add:
76-
*
77-
* #define BYTE_ORDER LITTLE_ENDIAN
78-
*
79-
* Or for big-endian machines:
80-
*
81-
* #define BYTE_ORDER BIG_ENDIAN
82-
*
83-
* The FreeBSD machine this was written on defines BYTE_ORDER
84-
* appropriately by including <sys/types.h> (which in turn includes
85-
* <machine/endian.h> where the appropriate definitions are actually
86-
* made).
87-
*/
88-
#if !defined(BYTE_ORDER)|| (BYTE_ORDER!=LITTLE_ENDIAN&&BYTE_ORDER!=BIG_ENDIAN)
89-
#error Define BYTE_ORDER to be equal to either LITTLE_ENDIAN or BIG_ENDIAN
90-
#endif
91-
92-
9359
/*** SHA-256/384/512 Various Length Definitions ***********************/
9460
/* NOTE: Most of these are in sha2.h */
9561
#defineSHA256_SHORT_BLOCK_LENGTH(SHA256_BLOCK_LENGTH - 8)
@@ -98,7 +64,7 @@
9864

9965

10066
/*** ENDIAN REVERSAL MACROS *******************************************/
101-
#ifBYTE_ORDER==LITTLE_ENDIAN
67+
#ifndefWORDS_BIGENDIAN
10268
#defineREVERSE32(w,x){ \
10369
uint32 tmp = (w); \
10470
tmp = (tmp >> 16) | (tmp << 16); \
@@ -112,7 +78,7 @@
11278
(x) = ((tmp & 0xffff0000ffff0000ULL) >> 16) | \
11379
((tmp & 0x0000ffff0000ffffULL) << 16); \
11480
}
115-
#endif/*BYTE_ORDER == LITTLE_ENDIAN */
81+
#endif/*not bigendian */
11682

11783
/*
11884
* Macro for incrementally adding the unsigned 64-bit integer n to the
@@ -539,7 +505,7 @@ SHA256_Last(SHA256_CTX * context)
539505
unsignedintusedspace;
540506

541507
usedspace= (context->bitcount >>3) %SHA256_BLOCK_LENGTH;
542-
#ifBYTE_ORDER==LITTLE_ENDIAN
508+
#ifndefWORDS_BIGENDIAN
543509
/* Convert FROM host byte order */
544510
REVERSE64(context->bitcount,context->bitcount);
545511
#endif
@@ -589,7 +555,7 @@ SHA256_Final(uint8 digest[], SHA256_CTX * context)
589555
{
590556
SHA256_Last(context);
591557

592-
#ifBYTE_ORDER==LITTLE_ENDIAN
558+
#ifndefWORDS_BIGENDIAN
593559
{
594560
/* Convert TO host byte order */
595561
intj;
@@ -865,7 +831,7 @@ SHA512_Last(SHA512_CTX * context)
865831
unsignedintusedspace;
866832

867833
usedspace= (context->bitcount[0] >>3) %SHA512_BLOCK_LENGTH;
868-
#ifBYTE_ORDER==LITTLE_ENDIAN
834+
#ifndefWORDS_BIGENDIAN
869835
/* Convert FROM host byte order */
870836
REVERSE64(context->bitcount[0],context->bitcount[0]);
871837
REVERSE64(context->bitcount[1],context->bitcount[1]);
@@ -918,7 +884,7 @@ SHA512_Final(uint8 digest[], SHA512_CTX * context)
918884
SHA512_Last(context);
919885

920886
/* Save the hash data for output: */
921-
#ifBYTE_ORDER==LITTLE_ENDIAN
887+
#ifndefWORDS_BIGENDIAN
922888
{
923889
/* Convert TO host byte order */
924890
intj;
@@ -963,7 +929,7 @@ SHA384_Final(uint8 digest[], SHA384_CTX * context)
963929
SHA512_Last((SHA512_CTX*)context);
964930

965931
/* Save the hash data for output: */
966-
#ifBYTE_ORDER==LITTLE_ENDIAN
932+
#ifndefWORDS_BIGENDIAN
967933
{
968934
/* Convert TO host byte order */
969935
intj;
@@ -1006,7 +972,7 @@ SHA224_Final(uint8 digest[], SHA224_CTX * context)
1006972
{
1007973
SHA256_Last(context);
1008974

1009-
#ifBYTE_ORDER==LITTLE_ENDIAN
975+
#ifndefWORDS_BIGENDIAN
1010976
{
1011977
/* Convert TO host byte order */
1012978
intj;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp