Skip to content

Commit

Permalink
msg: inline net2host64() and host2net64()
Browse files Browse the repository at this point in the history
These functions are just wrappers. Make it possible for the compiler to
optimize the calls when compiled with optimization.

Signed-off-by: Michael Walle <[email protected]>
  • Loading branch information
mwalle authored and richardcochran committed Jul 21, 2018
1 parent 8f484e8 commit 57c2b46
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
12 changes: 0 additions & 12 deletions msg.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
#include <string.h>
#include <time.h>

#include <asm/byteorder.h>

#include "contain.h"
#include "msg.h"
#include "print.h"
Expand Down Expand Up @@ -80,16 +78,6 @@ static void announce_post_recv(struct announce_msg *m)
m->stepsRemoved = ntohs(m->stepsRemoved);
}

int64_t host2net64(int64_t val)
{
return __cpu_to_be64(val);
}

int64_t net2host64(int64_t val)
{
return __be64_to_cpu(val);
}

static int hdr_post_recv(struct ptp_header *m)
{
if ((m->ver & VERSION_MASK) != VERSION)
Expand Down
11 changes: 9 additions & 2 deletions msg.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <stdio.h>
#include <sys/queue.h>
#include <time.h>
#include <asm/byteorder.h>

#include "address.h"
#include "ddt.h"
Expand Down Expand Up @@ -427,11 +428,17 @@ static inline Boolean one_step(struct ptp_message *m)
/**
* Convert a 64 bit word into network byte order.
*/
int64_t host2net64(int64_t val);
static inline int64_t host2net64(int64_t val)
{
return __cpu_to_be64(val);
}

/**
* Convert a 64 bit word into host byte order.
*/
int64_t net2host64(int64_t val);
static inline int64_t net2host64(int64_t val)
{
return __be64_to_cpu(val);
}

#endif

0 comments on commit 57c2b46

Please sign in to comment.