host_to_net(16|32)(), net_to_host(16|32)(): New functions.
authorbernie <bernie@38d2e660-2303-0410-9eaa-f027e97ec537>
Tue, 12 Apr 2005 04:08:49 +0000 (04:08 +0000)
committerbernie <bernie@38d2e660-2303-0410-9eaa-f027e97ec537>
Tue, 12 Apr 2005 04:08:49 +0000 (04:08 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@410 38d2e660-2303-0410-9eaa-f027e97ec537

mware/byteorder.h

index dc5e74ee85b8baec9ca084b29394089c114d0d06..10c8b6f4931c2daac62b344f5c4bc3a385b002e2 100755 (executable)
@@ -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 */