[sr-dev] [kamailio/kamailio] db_postgres compilation fails if htonll is defined (#665)

sjthomason notifications at github.com
Thu Jun 23 16:42:57 CEST 2016


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sip-router.org/pipermail/sr-dev/attachments/20160623/7dd5d426/attachment.html>


More information about the sr-dev mailing list