From 4fdd9c132af71b1dd84aef5ddb47cd54d4b964a1 Mon Sep 17 00:00:00 2001 From: bernie Date: Tue, 12 Apr 2005 04:08:49 +0000 Subject: [PATCH] host_to_net(16|32)(), net_to_host(16|32)(): New functions. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@410 38d2e660-2303-0410-9eaa-f027e97ec537 --- mware/byteorder.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/mware/byteorder.h b/mware/byteorder.h index dc5e74ee..10c8b6f4 100755 --- a/mware/byteorder.h +++ b/mware/byteorder.h @@ -15,6 +15,9 @@ /*#* *#* $Log$ + *#* Revision 1.7 2005/04/12 04:08:49 bernie + *#* host_to_net(16|32)(), net_to_host(16|32)(): New functions. + *#* *#* Revision 1.6 2005/04/11 19:10:28 bernie *#* Include top-level headers from cfg/ subdir. *#* @@ -81,4 +84,24 @@ INLINE uint32_t cpu_to_le32(uint32_t x) return (CPU_BYTE_ORDER == CPU_BIG_ENDIAN) ? swab32(x) : x; } +INLINE uint16_t host_to_net16(uint16_t x) +{ + return (CPU_BYTE_ORDER == CPU_BIG_ENDIAN) ? x : swab16(x); +} + +INLINE uint16_t net_to_host16(uint16_t x) +{ + return (CPU_BYTE_ORDER == CPU_BIG_ENDIAN) ? x : swab16(x); +} + +INLINE uint32_t host_to_net32(uint32_t x) +{ + return (CPU_BYTE_ORDER == CPU_BIG_ENDIAN) ? x : swab32(x); +} + +INLINE uint32_t net_to_host32(uint32_t x) +{ + return (CPU_BYTE_ORDER == CPU_BIG_ENDIAN) ? x : swab32(x); +} + #endif /* MWARE_BYTEORDER_H */ -- 2.25.1