mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +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:
@ -62,13 +62,10 @@
|
||||
|
||||
#include "postgres.h"
|
||||
#include "miscadmin.h"
|
||||
#include "port/pg_bswap.h"
|
||||
|
||||
#include "px-crypt.h"
|
||||
|
||||
/* for ntohl/htonl */
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#define _PASSWORD_EFMT1 '_'
|
||||
|
||||
static const char _crypt_a64[] =
|
||||
@ -408,8 +405,8 @@ des_setkey(const char *key)
|
||||
if (!des_initialised)
|
||||
des_init();
|
||||
|
||||
rawkey0 = ntohl(*(const uint32 *) key);
|
||||
rawkey1 = ntohl(*(const uint32 *) (key + 4));
|
||||
rawkey0 = pg_ntoh32(*(const uint32 *) key);
|
||||
rawkey1 = pg_ntoh32(*(const uint32 *) (key + 4));
|
||||
|
||||
if ((rawkey0 | rawkey1)
|
||||
&& rawkey0 == old_rawkey0
|
||||
@ -634,15 +631,15 @@ des_cipher(const char *in, char *out, long salt, int count)
|
||||
/* copy data to avoid assuming input is word-aligned */
|
||||
memcpy(buffer, in, sizeof(buffer));
|
||||
|
||||
rawl = ntohl(buffer[0]);
|
||||
rawr = ntohl(buffer[1]);
|
||||
rawl = pg_ntoh32(buffer[0]);
|
||||
rawr = pg_ntoh32(buffer[1]);
|
||||
|
||||
retval = do_des(rawl, rawr, &l_out, &r_out, count);
|
||||
if (retval)
|
||||
return retval;
|
||||
|
||||
buffer[0] = htonl(l_out);
|
||||
buffer[1] = htonl(r_out);
|
||||
buffer[0] = pg_hton32(l_out);
|
||||
buffer[1] = pg_hton32(r_out);
|
||||
|
||||
/* copy data to avoid assuming output is word-aligned */
|
||||
memcpy(out, buffer, sizeof(buffer));
|
||||
|
@ -14,13 +14,10 @@
|
||||
#include "postgres.h"
|
||||
|
||||
#include "fmgr.h"
|
||||
#include "port/pg_bswap.h"
|
||||
#include "utils/builtins.h"
|
||||
#include "utils/uuid.h"
|
||||
|
||||
/* for ntohl/htonl */
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
/*
|
||||
* It's possible that there's more than one uuid.h header file present.
|
||||
* We expect configure to set the HAVE_ symbol for only the one we want.
|
||||
@ -90,16 +87,16 @@ typedef struct
|
||||
|
||||
#define UUID_TO_NETWORK(uu) \
|
||||
do { \
|
||||
uu.time_low = htonl(uu.time_low); \
|
||||
uu.time_mid = htons(uu.time_mid); \
|
||||
uu.time_hi_and_version = htons(uu.time_hi_and_version); \
|
||||
uu.time_low = pg_hton32(uu.time_low); \
|
||||
uu.time_mid = pg_hton16(uu.time_mid); \
|
||||
uu.time_hi_and_version = pg_hton16(uu.time_hi_and_version); \
|
||||
} while (0)
|
||||
|
||||
#define UUID_TO_LOCAL(uu) \
|
||||
do { \
|
||||
uu.time_low = ntohl(uu.time_low); \
|
||||
uu.time_mid = ntohs(uu.time_mid); \
|
||||
uu.time_hi_and_version = ntohs(uu.time_hi_and_version); \
|
||||
uu.time_low = pg_ntoh32(uu.time_low); \
|
||||
uu.time_mid = pg_ntoh16(uu.time_mid); \
|
||||
uu.time_hi_and_version = pg_ntoh16(uu.time_hi_and_version); \
|
||||
} while (0)
|
||||
|
||||
#define UUID_V3_OR_V5(uu, v) \
|
||||
|
Reference in New Issue
Block a user