From 6d64574118a5ebef70734eafd8f431a3d12c4f6b Mon Sep 17 00:00:00 2001 From: Spencer Thomason Date: Fri, 24 Jun 2016 00:01:59 -0700 Subject: [PATCH] db_postgres: rename ntohll and htonll functions - fix namespace conflict on platforms where these are present in system libs (cherry picked from commit 2ebdbec8af56027c9c94fe5e67975c9a319b9620) (cherry picked from commit e3f53ef6158057b090c398f5afc0b2bcdf747430) (cherry picked from commit 1740191c9003d567433fec242fea91ff9353665d) --- modules/db_postgres/pg_fld.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/modules/db_postgres/pg_fld.c b/modules/db_postgres/pg_fld.c index de62c14f9d9..00fcd5e80ac 100644 --- a/modules/db_postgres/pg_fld.c +++ b/modules/db_postgres/pg_fld.c @@ -93,23 +93,19 @@ union ull { uint32_t ui32[2]; }; -#if !defined(__OS_darwin) || (defined(__OS_darwin) && !defined(NTOHLL)) -static inline uint64_t htonll(uint64_t in) +static inline uint64_t _htonll(uint64_t in) { union ull* p = (union ull*)∈ return ((uint64_t)htonl(p->ui32[0]) << 32) + (uint64_t)htonl(p->ui32[1]); } -#endif -#if !defined(__OS_darwin) || (defined(__OS_darwin) && !defined(NTOHLL)) -static inline uint64_t ntohll(uint64_t in) +static inline uint64_t _ntohll(uint64_t in) { union ull* p = (union ull*)∈ return ((uint64_t)ntohl(p->ui32[0]) << 32) + (uint64_t)ntohl(p->ui32[1]); } -#endif static inline void db_int2pg_int4(struct pg_params* dst, int i, @@ -145,7 +141,7 @@ static inline void db_int2pg_timestamp(struct pg_params* dst, int i, } else { pfld->v.dbl = (double)src->v.int4 - (double)PG_EPOCH_TIME; } - pfld->v.int8 = htonll(pfld->v.int8); + pfld->v.int8 = _htonll(pfld->v.int8); dst->fmt[i] = 1; dst->val[i] = pfld->v.byte; @@ -208,7 +204,7 @@ static inline void db_float2pg_float8(struct pg_params* dst, int i, db_fld_t* sr { struct pg_fld* pfld = DB_GET_PAYLOAD(src); pfld->v.dbl = src->v.flt; - pfld->v.int8 = htonll(pfld->v.int8); + pfld->v.int8 = _htonll(pfld->v.int8); dst->fmt[i] = 1; dst->val[i] = pfld->v.byte; @@ -219,7 +215,7 @@ static inline void db_float2pg_float8(struct pg_params* dst, int i, db_fld_t* sr static inline void db_double2pg_float8(struct pg_params* dst, int i, db_fld_t* src) { struct pg_fld* pfld = DB_GET_PAYLOAD(src); - pfld->v.int8 = htonll(src->v.int8); + pfld->v.int8 = _htonll(src->v.int8); dst->fmt[i] = 1; dst->val[i] = pfld->v.byte; @@ -686,7 +682,7 @@ static inline int pg_int4_2_db_int(db_fld_t* fld, char* val, int len) static inline int pg_int8_2_db_int(db_fld_t* fld, char* val, int len) { - fld->v.int8 = (int64_t)ntohll(*((int64_t*)val)); + fld->v.int8 = (int64_t)_ntohll(*((int64_t*)val)); return 0; } @@ -732,10 +728,10 @@ static inline int pg_timestamp2db_int(db_fld_t* fld, char* val, int len, { if (flags & PG_INT8_TIMESTAMP) { /* int8 format */ - fld->v.int4 = (int64_t)ntohll(((int64_t*)val)[0]) / (int64_t)1000000 + PG_EPOCH_TIME; + fld->v.int4 = (int64_t)_ntohll(((int64_t*)val)[0]) / (int64_t)1000000 + PG_EPOCH_TIME; } else { /* double format */ - fld->v.int4 = PG_EPOCH_TIME + ntohll(((int64_t*)val)[0]); + fld->v.int4 = PG_EPOCH_TIME + _ntohll(((int64_t*)val)[0]); } return 0; } @@ -775,7 +771,7 @@ static inline int pg_float42db_double(db_fld_t* fld, char* val, int len) static inline int pg_float82db_double(db_fld_t* fld, char* val, int len) { - fld->v.int8 = ntohll(*(uint64_t*)val); + fld->v.int8 = _ntohll(*(uint64_t*)val); return 0; }