summaryrefslogtreecommitdiff
path: root/contrib/uuid-ossp
diff options
context:
space:
mode:
authorAndres Freund <andres@anarazel.de>2017-10-01 15:36:14 -0700
committerAndres Freund <andres@anarazel.de>2017-10-01 15:36:14 -0700
commit0ba99c84e8c7138143059b281063d4cca5a2bfea (patch)
tree521367c1888ca186fa229efc3489fb4298c8dc08 /contrib/uuid-ossp
parent1f2830f9df9f0196ba541c1e253463afe657cb67 (diff)
downloadpostgresql-0ba99c84e8c7138143059b281063d4cca5a2bfea.tar.gz
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
Diffstat (limited to 'contrib/uuid-ossp')
-rw-r--r--contrib/uuid-ossp/uuid-ossp.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/contrib/uuid-ossp/uuid-ossp.c b/contrib/uuid-ossp/uuid-ossp.c
index 55bc609415..fce4bc9140 100644
--- a/contrib/uuid-ossp/uuid-ossp.c
+++ b/contrib/uuid-ossp/uuid-ossp.c
@@ -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) \