mirror of
https://github.com/postgres/postgres.git
synced 2025-07-02 09:02:37 +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:
@ -17,8 +17,6 @@
|
||||
#include <ctype.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include "access/heapam.h"
|
||||
#include "access/htup_details.h"
|
||||
@ -38,6 +36,7 @@
|
||||
#include "optimizer/planner.h"
|
||||
#include "nodes/makefuncs.h"
|
||||
#include "parser/parse_relation.h"
|
||||
#include "port/pg_bswap.h"
|
||||
#include "rewrite/rewriteHandler.h"
|
||||
#include "storage/fd.h"
|
||||
#include "tcop/tcopprot.h"
|
||||
@ -671,7 +670,7 @@ CopySendInt32(CopyState cstate, int32 val)
|
||||
{
|
||||
uint32 buf;
|
||||
|
||||
buf = htonl((uint32) val);
|
||||
buf = pg_hton32((uint32) val);
|
||||
CopySendData(cstate, &buf, sizeof(buf));
|
||||
}
|
||||
|
||||
@ -690,7 +689,7 @@ CopyGetInt32(CopyState cstate, int32 *val)
|
||||
*val = 0; /* suppress compiler warning */
|
||||
return false;
|
||||
}
|
||||
*val = (int32) ntohl(buf);
|
||||
*val = (int32) pg_ntoh32(buf);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -702,7 +701,7 @@ CopySendInt16(CopyState cstate, int16 val)
|
||||
{
|
||||
uint16 buf;
|
||||
|
||||
buf = htons((uint16) val);
|
||||
buf = pg_hton16((uint16) val);
|
||||
CopySendData(cstate, &buf, sizeof(buf));
|
||||
}
|
||||
|
||||
@ -719,7 +718,7 @@ CopyGetInt16(CopyState cstate, int16 *val)
|
||||
*val = 0; /* suppress compiler warning */
|
||||
return false;
|
||||
}
|
||||
*val = (int16) ntohs(buf);
|
||||
*val = (int16) pg_ntoh16(buf);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user