summaryrefslogtreecommitdiff
path: root/src/bin/pg_basebackup/streamutil.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin/pg_basebackup/streamutil.c')
-rw-r--r--src/bin/pg_basebackup/streamutil.c34
1 files changed, 7 insertions, 27 deletions
diff --git a/src/bin/pg_basebackup/streamutil.c b/src/bin/pg_basebackup/streamutil.c
index 81fef8cd516..a57ff8f2c47 100644
--- a/src/bin/pg_basebackup/streamutil.c
+++ b/src/bin/pg_basebackup/streamutil.c
@@ -17,18 +17,15 @@
#include <sys/time.h>
#include <unistd.h>
-/* for ntohl/htonl */
-#include <netinet/in.h>
-#include <arpa/inet.h>
-
/* local includes */
#include "receivelog.h"
#include "streamutil.h"
#include "access/xlog_internal.h"
-#include "pqexpbuffer.h"
#include "common/fe_memutils.h"
#include "datatype/timestamp.h"
+#include "port/pg_bswap.h"
+#include "pqexpbuffer.h"
#define ERRCODE_DUPLICATE_OBJECT "42710"
@@ -576,17 +573,9 @@ feTimestampDifferenceExceeds(TimestampTz start_time,
void
fe_sendint64(int64 i, char *buf)
{
- uint32 n32;
+ uint64 n64 = pg_hton64(i);
- /* High order half first, since we're doing MSB-first */
- n32 = (uint32) (i >> 32);
- n32 = htonl(n32);
- memcpy(&buf[0], &n32, 4);
-
- /* Now the low order half */
- n32 = (uint32) i;
- n32 = htonl(n32);
- memcpy(&buf[4], &n32, 4);
+ memcpy(buf, &n64, sizeof(n64));
}
/*
@@ -595,18 +584,9 @@ fe_sendint64(int64 i, char *buf)
int64
fe_recvint64(char *buf)
{
- int64 result;
- uint32 h32;
- uint32 l32;
-
- memcpy(&h32, buf, 4);
- memcpy(&l32, buf + 4, 4);
- h32 = ntohl(h32);
- l32 = ntohl(l32);
+ uint64 n64;
- result = h32;
- result <<= 32;
- result |= l32;
+ memcpy(&n64, buf, sizeof(n64));
- return result;
+ return pg_ntoh64(n64);
}