mirror of
https://github.com/postgres/postgres.git
synced 2025-11-09 06:21:09 +03:00
Replace most usages of ntoh[ls] and hton[sl] with pg_bswap.h.
All postgres internal usages are replaced, it's just libpq example usages that haven't been converted. External users of libpq can't generally rely on including postgres internal headers. Note that this includes replacing open-coded byte swapping of 64bit integers (using two 32 bit swaps) with a single 64bit swap. Where it looked applicable, I have removed netinet/in.h and arpa/inet.h usage, which previously provided the relevant functionality. It's perfectly possible that I missed other reasons for including those, the buildfarm will tell. Author: Andres Freund Discussion: https://postgr.es/m/20170927172019.gheidqy6xvlxb325@alap3.anarazel.de
This commit is contained in:
@@ -74,8 +74,6 @@
|
||||
#include <sys/socket.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/param.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
#include <limits.h>
|
||||
|
||||
@@ -107,6 +105,7 @@
|
||||
#include "miscadmin.h"
|
||||
#include "pg_getopt.h"
|
||||
#include "pgstat.h"
|
||||
#include "port/pg_bswap.h"
|
||||
#include "postmaster/autovacuum.h"
|
||||
#include "postmaster/bgworker_internals.h"
|
||||
#include "postmaster/fork_process.h"
|
||||
@@ -1072,7 +1071,7 @@ PostmasterMain(int argc, char *argv[])
|
||||
"_postgresql._tcp.",
|
||||
NULL,
|
||||
NULL,
|
||||
htons(PostPortNumber),
|
||||
pg_hton16(PostPortNumber),
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
@@ -1966,7 +1965,7 @@ ProcessStartupPacket(Port *port, bool SSLdone)
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
|
||||
len = ntohl(len);
|
||||
len = pg_ntoh32(len);
|
||||
len -= 4;
|
||||
|
||||
if (len < (int32) sizeof(ProtocolVersion) ||
|
||||
@@ -2002,7 +2001,7 @@ ProcessStartupPacket(Port *port, bool SSLdone)
|
||||
* The first field is either a protocol version number or a special
|
||||
* request code.
|
||||
*/
|
||||
port->proto = proto = ntohl(*((ProtocolVersion *) buf));
|
||||
port->proto = proto = pg_ntoh32(*((ProtocolVersion *) buf));
|
||||
|
||||
if (proto == CANCEL_REQUEST_CODE)
|
||||
{
|
||||
@@ -2281,8 +2280,8 @@ processCancelRequest(Port *port, void *pkt)
|
||||
int i;
|
||||
#endif
|
||||
|
||||
backendPID = (int) ntohl(canc->backendPID);
|
||||
cancelAuthCode = (int32) ntohl(canc->cancelAuthCode);
|
||||
backendPID = (int) pg_ntoh32(canc->backendPID);
|
||||
cancelAuthCode = (int32) pg_ntoh32(canc->cancelAuthCode);
|
||||
|
||||
/*
|
||||
* See if we have a matching backend. In the EXEC_BACKEND case, we can no
|
||||
|
||||
Reference in New Issue
Block a user