aboutsummaryrefslogtreecommitdiffstats
path: root/vppinfra/vppinfra/byte_order.h
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2016-08-15 11:12:27 -0400
committerDave Barach <dave@barachs.net>2016-08-15 11:12:40 -0400
commitc379999665febd12ec55bfb3a7545224f2b39d3d (patch)
tree8bf0c11e52c2162e1239b6c3f4a5f74b62a07409 /vppinfra/vppinfra/byte_order.h
parentb3d93dacfde8ab21bbce171fff2971b2ed7bce6a (diff)
VPP-327 Coding standards cleanup for vppinfra
Fix additional a few additional deviations reported elsewhere by checkstyle Change-Id: I026a8ae1c5b1856bbe3c4a555e1b690e7501b045 Signed-off-by: Dave Barach <dave@barachs.net>
Diffstat (limited to 'vppinfra/vppinfra/byte_order.h')
-rw-r--r--vppinfra/vppinfra/byte_order.h78
1 files changed, 41 insertions, 37 deletions
diff --git a/vppinfra/vppinfra/byte_order.h b/vppinfra/vppinfra/byte_order.h
index b2c26e5fdee..b263538c6fe 100644
--- a/vppinfra/vppinfra/byte_order.h
+++ b/vppinfra/vppinfra/byte_order.h
@@ -55,54 +55,58 @@
always_inline u16
clib_byte_swap_u16 (u16 x)
-{ return (x >> 8) | (x << 8); }
+{
+ return (x >> 8) | (x << 8);
+}
always_inline i16
clib_byte_swap_i16 (i16 x)
-{ return clib_byte_swap_u16 (x); }
+{
+ return clib_byte_swap_u16 (x);
+}
always_inline u32
clib_byte_swap_u32 (u32 x)
{
#if defined (i386) || defined (__x86_64__)
- if (! __builtin_constant_p (x))
+ if (!__builtin_constant_p (x))
{
- asm volatile ("bswap %0" : "=r" (x) : "0" (x));
+ asm volatile ("bswap %0":"=r" (x):"0" (x));
return x;
}
#endif
- return ((x << 24)
- | ((x & 0xff00) << 8)
- | ((x >> 8) & 0xff00)
- | (x >> 24));
+ return ((x << 24) | ((x & 0xff00) << 8) | ((x >> 8) & 0xff00) | (x >> 24));
}
always_inline i32
clib_byte_swap_i32 (i32 x)
-{ return clib_byte_swap_u32 (x); }
+{
+ return clib_byte_swap_u32 (x);
+}
always_inline u64
clib_byte_swap_u64 (u64 x)
{
#if defined (__x86_64__)
- if (! __builtin_constant_p (x))
+ if (!__builtin_constant_p (x))
{
- asm volatile ("bswapq %0" : "=r" (x) : "0" (x));
+ asm volatile ("bswapq %0":"=r" (x):"0" (x));
return x;
}
#endif
#define _(x,n,i) \
((((x) >> (8*(i))) & 0xff) << (8*((n)-(i)-1)))
- return (_ (x, 8, 0) | _ (x, 8, 1)
- | _ (x, 8, 2) | _ (x, 8, 3)
- | _ (x, 8, 4) | _ (x, 8, 5)
- | _ (x, 8, 6) | _ (x, 8, 7));
+ return (_(x, 8, 0) | _(x, 8, 1)
+ | _(x, 8, 2) | _(x, 8, 3)
+ | _(x, 8, 4) | _(x, 8, 5) | _(x, 8, 6) | _(x, 8, 7));
#undef _
}
always_inline i64
clib_byte_swap_i64 (i64 x)
-{ return clib_byte_swap_u64 (x); }
+{
+ return clib_byte_swap_u64 (x);
+}
#define _(sex,type) \
/* HOST -> SEX */ \
@@ -142,22 +146,15 @@ clib_##sex##_to_host_unaligned_mem_##type (type * x) \
{ return clib_host_to_##sex##_unaligned_mem_##type (x); }
#ifndef __cplusplus
-_ (little, u16)
-_ (little, u32)
-_ (little, u64)
-_ (little, i16)
-_ (little, i32)
-_ (little, i64)
-_ (big, u16)
-_ (big, u32)
-_ (big, u64)
-_ (big, i16)
-_ (big, i32)
-_ (big, i64)
+_(little, u16)
+_(little, u32)
+_(little, u64)
+_(little, i16)
+_(little, i32)
+_(little, i64)
+_(big, u16) _(big, u32) _(big, u64) _(big, i16) _(big, i32) _(big, i64)
#endif
-
#undef _
-
/* Network "net" alias for "big". */
#define _(type) \
always_inline type \
@@ -183,16 +180,23 @@ clib_host_to_net_mem_##type (type * x) \
always_inline type \
clib_host_to_net_unaligned_mem_##type (type * x) \
{ return clib_host_to_big_unaligned_mem_##type (x); }
-
#ifndef __cplusplus
-_ (u16);
-_ (i16);
-_ (u32);
-_ (i32);
-_ (u64);
-_ (i64);
+ _(u16);
+_(i16);
+_(u32);
+_(i32);
+_(u64);
+_(i64);
#endif
#undef _
#endif /* included_clib_byte_order_h */
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */