Skip to content

Commit e4dccfd

Browse files
committed
From: t-ishii@sra.co.jp
6.3 postmaster is supposed to work with pre 6.3 protocol. This is true for little endian architecture servers. But for big endian machines such as Sparc the backward compatibility function do not work. Attached are patches to fix the problem.
1 parent b64a754 commit e4dccfd

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/backend/libpq/pqcomprim.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,20 @@
3434
#else
3535
#if BYTE_ORDER == BIG_ENDIAN
3636

37+
/*
3738
#define ntoh_s(n) (uint16)(((u_char *)&n)[1] << 8 \
3839
| ((u_char *)&n)[0])
3940
#define ntoh_l(n) (uint32)(((u_char *)&n)[3] << 24 \
4041
| ((u_char *)&n)[2] << 16 \
4142
| ((u_char *)&n)[1] << 8 \
4243
| ((u_char *)&n)[0])
44+
*/
45+
#define ntoh_s(n) (uint16)((((uint16)n & 0x00ff) << 8) | \
46+
(((uint16)n & 0xff00) >> 8))
47+
#define ntoh_l(n) (uint32)((((uint32)n & 0x000000ff) << 24) | \
48+
(((uint32)n & 0x0000ff00) << 8) | \
49+
(((uint32)n & 0x00ff0000) >> 8) | \
50+
(((uint32)n & 0xff000000) >> 24))
4351
#define hton_s(n) (ntoh_s(n))
4452
#define hton_l(n) (ntoh_l(n))
4553

0 commit comments

Comments
 (0)