msg: inline net2host64() and host2net64()

These functions are just wrappers. Make it possible for the compiler to
optimize the calls when compiled with optimization.

Signed-off-by: Michael Walle <michael@walle.cc>
master
Michael Walle 2018-07-10 11:55:44 +02:00 committed by Richard Cochran
parent 8f484e8312
commit 57c2b46604
2 changed files with 9 additions and 14 deletions

12
msg.c
View File

@ -22,8 +22,6 @@
#include <string.h> #include <string.h>
#include <time.h> #include <time.h>
#include <asm/byteorder.h>
#include "contain.h" #include "contain.h"
#include "msg.h" #include "msg.h"
#include "print.h" #include "print.h"
@ -80,16 +78,6 @@ static void announce_post_recv(struct announce_msg *m)
m->stepsRemoved = ntohs(m->stepsRemoved); 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) static int hdr_post_recv(struct ptp_header *m)
{ {
if ((m->ver & VERSION_MASK) != VERSION) if ((m->ver & VERSION_MASK) != VERSION)

11
msg.h
View File

@ -23,6 +23,7 @@
#include <stdio.h> #include <stdio.h>
#include <sys/queue.h> #include <sys/queue.h>
#include <time.h> #include <time.h>
#include <asm/byteorder.h>
#include "address.h" #include "address.h"
#include "ddt.h" #include "ddt.h"
@ -427,11 +428,17 @@ static inline Boolean one_step(struct ptp_message *m)
/** /**
* Convert a 64 bit word into network byte order. * 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. * 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 #endif