Skip to content

Commit

Permalink
migration/rdma: define htonll/ntohll only if not predefined
Browse files Browse the repository at this point in the history
Solaris has #defines for htonll and ntohll which cause syntax errors
when compiling code that attempts to (re)define these functions..

Signed-off-by: Nick Briggs <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Peter Xu <[email protected]>
  • Loading branch information
nbriggs authored and xzpeter committed Jan 16, 2024
1 parent eb9f6da commit 44ce1b5
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions migration/rdma.c
Original file line number Diff line number Diff line change
Expand Up @@ -238,20 +238,24 @@ static const char *control_desc(unsigned int rdma_control)
return strs[rdma_control];
}

#if !defined(htonll)
static uint64_t htonll(uint64_t v)
{
union { uint32_t lv[2]; uint64_t llv; } u;
u.lv[0] = htonl(v >> 32);
u.lv[1] = htonl(v & 0xFFFFFFFFULL);
return u.llv;
}
#endif

#if !defined(ntohll)
static uint64_t ntohll(uint64_t v)
{
union { uint32_t lv[2]; uint64_t llv; } u;
u.llv = v;
return ((uint64_t)ntohl(u.lv[0]) << 32) | (uint64_t) ntohl(u.lv[1]);
}
#endif

static void dest_block_to_network(RDMADestBlock *db)
{
Expand Down

0 comments on commit 44ce1b5

Please sign in to comment.