Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
3ded6fd5
Commit
3ded6fd5
authored
Jul 01, 1997
by
Thomas G. Lockhart
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix code to do the right thing with mixed-endian clients and servers.
parent
bf3bcb6a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
11 deletions
+15
-11
src/backend/libpq/pqcomprim.c
src/backend/libpq/pqcomprim.c
+15
-11
No files found.
src/backend/libpq/pqcomprim.c
View file @
3ded6fd5
...
@@ -10,8 +10,9 @@
...
@@ -10,8 +10,9 @@
/* --------------------------------------------------------------------- */
/* --------------------------------------------------------------------- */
/* Is the other way around than system ntoh/hton, so we roll our own
/* These definitions for ntoh/hton are the other way around from the
here */
* default system definitions, so we roll our own here.
*/
#ifndef BYTE_ORDER
#ifndef BYTE_ORDER
#error BYTE_ORDER must be defined as LITTLE_ENDIAN, BIG_ENDIAN or PDP_ENDIAN
#error BYTE_ORDER must be defined as LITTLE_ENDIAN, BIG_ENDIAN or PDP_ENDIAN
...
@@ -24,11 +25,13 @@
...
@@ -24,11 +25,13 @@
# define hton_l(n) n
# define hton_l(n) n
#else
/* BYTE_ORDER != LITTLE_ENDIAN */
#else
/* BYTE_ORDER != LITTLE_ENDIAN */
# if BYTE_ORDER == BIG_ENDIAN
# if BYTE_ORDER == BIG_ENDIAN
# define ntoh_s(n) (u_short)(((u_char *) &n)[0] << 8 | ((u_char *) &n)[1])
# define ntoh_s(n) (u_short)(((u_char *)&n)[1] << 8 \
# define ntoh_l(n) (u_long)(((u_char *)&n)[0] << 24 | \
| ((u_char *)&n)[0])
((u_char *)&n)[1] << 16 | \
# define ntoh_l(n) (u_long) (((u_char *)&n)[3] << 24 \
((u_char *)&n)[2] << 8 | ((u_char *)&n)[3])
| ((u_char *)&n)[2] << 16 \
# define hton_s(n) (u_short)(((u_char *) &n)[2] << 8 | ((u_char *) &n)[3])
| ((u_char *)&n)[1] << 8 \
| ((u_char *)&n)[0])
# define hton_s(n) (ntoh_s(n))
# define hton_l(n) (ntoh_l(n))
# define hton_l(n) (ntoh_l(n))
# else
/* BYTE_ORDER != BIG_ENDIAN */
# else
/* BYTE_ORDER != BIG_ENDIAN */
# if BYTE_ORDER == PDP_ENDIAN
# if BYTE_ORDER == PDP_ENDIAN
...
@@ -43,9 +46,10 @@
...
@@ -43,9 +46,10 @@
int
pqPutShort
(
int
integer
,
FILE
*
f
)
int
pqPutShort
(
int
integer
,
FILE
*
f
)
{
{
int
retval
=
0
;
int
retval
=
0
;
u_short
n
;
u_short
n
,
s
;
n
=
hton_s
(
integer
);
s
=
integer
;
n
=
hton_s
(
s
);
if
(
fwrite
(
&
n
,
sizeof
(
u_short
),
1
,
f
)
!=
1
)
if
(
fwrite
(
&
n
,
sizeof
(
u_short
),
1
,
f
)
!=
1
)
retval
=
EOF
;
retval
=
EOF
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment