```
pg_fld.c:97:40: error: expected ‘)’ before ‘in’ static inline uint64_t htonll(uint64_t in) ^ pg_fld.c:107:40: error: expected ‘)’ before ‘in’ static inline uint64_t ntohll(uint64_t in) ^ ```
There is a fairly specific ifdef that doesn't match other platforms that define htonll and ntohll such as Solaris: ``` #if !defined(__OS_darwin) || (defined(__OS_darwin) && !defined(NTOHLL)) ```
Would it be acceptable to change these to: ``` #ifndef htonll ```
For example: ``` diff --git a/modules/db_postgres/pg_fld.c b/modules/db_postgres/pg_fld.c index de62c14..d9b4911 100644 --- a/modules/db_postgres/pg_fld.c +++ b/modules/db_postgres/pg_fld.c @@ -93,7 +93,7 @@ union ull { uint32_t ui32[2]; };
-#if !defined(__OS_darwin) || (defined(__OS_darwin) && !defined(NTOHLL)) +#ifndef htonll static inline uint64_t htonll(uint64_t in) { union ull* p = (union ull*)∈ @@ -103,7 +103,7 @@ static inline uint64_t htonll(uint64_t in) #endif
-#if !defined(__OS_darwin) || (defined(__OS_darwin) && !defined(NTOHLL)) +#ifndef ntohll static inline uint64_t ntohll(uint64_t in) { union ull* p = (union ull*)∈ ```
--- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/issues/665
Can one be sure that htonll is a defined macro on all systems? Because the functions cannot be tested with `#ifdef`.
--- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/issues/665#issuecomment-225924745
Hi Daniel, I guess we can be 100% sure of ALL platforms but it is a macro on all the ones I tested:
SmartOS and Solaris 11: ``` #if !defined(_XPG4_2) || defined(__EXTENSIONS__) #define ntohll(x) (x) #define htonll(x) (x) #endif /* !_XPG4_2 || __EXTENSIONS__ */ ``` OSX: ``` #if defined(KERNEL) || (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE))
#define ntohll(x) ((__uint64_t)(x)) #define htonll(x) ((__uint64_t)(x))
#define NTOHL(x) (x) #define NTOHS(x) (x) #define NTOHLL(x) (x) #define HTONL(x) (x) #define HTONS(x) (x) #define HTONLL(x) (x) #endif /* defined(KERNEL) || (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)) */ ```
--- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/issues/665#issuecomment-225932711
Can you check if NTOHLL is defined on Solaris? It is quite common that a token supposed to be a define flag/macro uses uppercases.
--- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/issues/665#issuecomment-227960584
Hi Daniel, I must have not had enough coffee... testing the Solaris macros above only work on big endian machines. I've included the relevant parts of sys/byteorder.h below. Would it be acceptable to change these functions to ```_ntohll``` and ```_htonll``` to avoid the namespace conflict? The challenge with checking __OS_solaris is that this was a relatively recent addition, I think only available in Solaris 11 and the Ilumos derivatives.
``` #include <sys/isa_defs.h> #include <sys/int_types.h>
#if defined(__GNUC__) && defined(_ASM_INLINES) && \ (defined(__i386) || defined(__amd64)) #include <asm/byteorder.h> #endif
#ifdef __cplusplus extern "C" { #endif
/* * macros for conversion between host and (internet) network byte order */
#if defined(_BIG_ENDIAN) && !defined(ntohl) && !defined(__lint) /* big-endian */ #define ntohl(x) (x) #define ntohs(x) (x) #define htonl(x) (x) #define htons(x) (x) #if !defined(_XPG4_2) || defined(__EXTENSIONS__) #define ntohll(x) (x) #define htonll(x) (x) #endif /* !_XPG4_2 || __EXTENSIONS__ */
#elif !defined(ntohl) /* little-endian */
#ifndef _IN_PORT_T #define _IN_PORT_T typedef uint16_t in_port_t; #endif
#ifndef _IN_ADDR_T #define _IN_ADDR_T typedef uint32_t in_addr_t; #endif
#if !defined(_XPG4_2) || defined(__EXTENSIONS__) || defined(_XPG5) extern uint32_t htonl(uint32_t); extern uint16_t htons(uint16_t); extern uint32_t ntohl(uint32_t); extern uint16_t ntohs(uint16_t); #else extern in_addr_t htonl(in_addr_t); extern in_port_t htons(in_port_t); extern in_addr_t ntohl(in_addr_t); extern in_port_t ntohs(in_port_t); #endif /* !_XPG4_2 || __EXTENSIONS__ || _XPG5 */
#if defined(_LP64) || defined(_LONGLONG_TYPE) #if !defined(_XPG4_2) || defined(__EXTENSIONS__) extern uint64_t htonll(uint64_t); extern uint64_t ntohll(uint64_t); #endif /* !_XPG4_2 || __EXTENSIONS__ */ #endif /* _LP64 || _LONGLONG_TYPE */ #endif ```
--- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/issues/665#issuecomment-228072219
I am fine to rename the functions to avoid the conflict. make a pull request for it - there is CI build to see if there are compilations issues with PRs when using gcc or clang on linux.
--- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/issues/665#issuecomment-228125243
Closed #665 via #682.
--- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/issues/665#event-704897041