diff mbox series

[v17,03/18] trace-cmd: Add implementations of htonll() and ntohll()

Message ID 20191203103522.482684-4-tz.stoyanov@gmail.com (mailing list archive)
State Superseded
Headers show
Series Timestamp synchronization of host - guest tracing session | expand

Commit Message

Tzvetomir Stoyanov (VMware) Dec. 3, 2019, 10:35 a.m. UTC
From: Tzvetomir Stoyanov <tstoyanov@vmware.com>

Implementations of htonll() and ntohll() are added as
macros, if they are not already defined.

Signed-off-by: Tzvetomir Stoyanov <tstoyanov@vmware.com>
---
 include/trace-cmd/trace-msg.h | 10 ++++++++++
 1 file changed, 10 insertions(+)

Comments

Steven Rostedt Dec. 20, 2019, 1:50 p.m. UTC | #1
On Tue,  3 Dec 2019 12:35:07 +0200
"Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com> wrote:

> From: Tzvetomir Stoyanov <tstoyanov@vmware.com>
> 
> Implementations of htonll() and ntohll() are added as
> macros, if they are not already defined.

I'm somewhat nervous about this being in a global header, as it is
mostly generic. I wonder if we should prefix these with "tracecmd_"
just to avoid any name collisions.

We could update this later when we make trace-cmd into a library.

-- Steve


> 
> Signed-off-by: Tzvetomir Stoyanov <tstoyanov@vmware.com>
> ---
>  include/trace-cmd/trace-msg.h | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/include/trace-cmd/trace-msg.h b/include/trace-cmd/trace-msg.h
> index aab8a69..654ca43 100644
> --- a/include/trace-cmd/trace-msg.h
> +++ b/include/trace-cmd/trace-msg.h
> @@ -12,4 +12,14 @@
>  
>  extern unsigned int page_size;
>  
> +#ifndef htonll
> +# if __BYTE_ORDER == __LITTLE_ENDIAN
> +#define htonll(x) __bswap_64(x)
> +#define ntohll(x) __bswap_64(x)
> +#else
> +#define htonll(x) (x)
> +#define ntohll(x) (x)
> +#endif
> +#endif
> +
>  #endif /* _TRACE_MSG_H_ */
Tzvetomir Stoyanov (VMware) Jan. 6, 2020, 2:30 p.m. UTC | #2
On Fri, Dec 20, 2019 at 3:50 PM Steven Rostedt <rostedt@goodmis.org> wrote:
>
> On Tue,  3 Dec 2019 12:35:07 +0200
> "Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com> wrote:
>
> > From: Tzvetomir Stoyanov <tstoyanov@vmware.com>
> >
> > Implementations of htonll() and ntohll() are added as
> > macros, if they are not already defined.
>
> I'm somewhat nervous about this being in a global header, as it is
> mostly generic. I wonder if we should prefix these with "tracecmd_"
> just to avoid any name collisions.
>
> We could update this later when we make trace-cmd into a library.
>

I can move them to trace-msg.c file, as these are used only there.
Note that a lot of clean-ups are required for libtracecmd.

> -- Steve
>
>
> >
> > Signed-off-by: Tzvetomir Stoyanov <tstoyanov@vmware.com>
> > ---
> >  include/trace-cmd/trace-msg.h | 10 ++++++++++
> >  1 file changed, 10 insertions(+)
> >
> > diff --git a/include/trace-cmd/trace-msg.h b/include/trace-cmd/trace-msg.h
> > index aab8a69..654ca43 100644
> > --- a/include/trace-cmd/trace-msg.h
> > +++ b/include/trace-cmd/trace-msg.h
> > @@ -12,4 +12,14 @@
> >
> >  extern unsigned int page_size;
> >
> > +#ifndef htonll
> > +# if __BYTE_ORDER == __LITTLE_ENDIAN
> > +#define htonll(x) __bswap_64(x)
> > +#define ntohll(x) __bswap_64(x)
> > +#else
> > +#define htonll(x) (x)
> > +#define ntohll(x) (x)
> > +#endif
> > +#endif
> > +
> >  #endif /* _TRACE_MSG_H_ */
>
diff mbox series

Patch

diff --git a/include/trace-cmd/trace-msg.h b/include/trace-cmd/trace-msg.h
index aab8a69..654ca43 100644
--- a/include/trace-cmd/trace-msg.h
+++ b/include/trace-cmd/trace-msg.h
@@ -12,4 +12,14 @@ 
 
 extern unsigned int page_size;
 
+#ifndef htonll
+# if __BYTE_ORDER == __LITTLE_ENDIAN
+#define htonll(x) __bswap_64(x)
+#define ntohll(x) __bswap_64(x)
+#else
+#define htonll(x) (x)
+#define ntohll(x) (x)
+#endif
+#endif
+
 #endif /* _TRACE_MSG_H_ */