summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorimura <imura@FreeBSD.org>2005-09-19 08:11:04 +0000
committerimura <imura@FreeBSD.org>2005-09-19 08:11:04 +0000
commit6cabd0f5c3826b5b36c47abcf721d4d1d97938a8 (patch)
tree9f1a47d8ae639234b76cb7b93f490110ce33179e
parent198a5385718a1a4dee67d9ec60f8f83792aa060b (diff)
downloadFreeBSD-src-6cabd0f5c3826b5b36c47abcf721d4d1d97938a8.zip
FreeBSD-src-6cabd0f5c3826b5b36c47abcf721d4d1d97938a8.tar.gz
Fix get{w,d}{l,b}e, set{w,d}{l,b}e macros on big endian systems.
Obtained from: NetBSD
-rw-r--r--contrib/smbfs/include/netsmb/smb_lib.h25
1 files changed, 11 insertions, 14 deletions
diff --git a/contrib/smbfs/include/netsmb/smb_lib.h b/contrib/smbfs/include/netsmb/smb_lib.h
index ecf4518..ff12e6d 100644
--- a/contrib/smbfs/include/netsmb/smb_lib.h
+++ b/contrib/smbfs/include/netsmb/smb_lib.h
@@ -30,6 +30,7 @@
* SUCH DAMAGE.
*
* $Id: smb_lib.h,v 1.24 2001/12/20 15:19:43 bp Exp $
+ * $FreeBSD$
*/
#ifndef _NETSMB_SMB_LIB_H_
#define _NETSMB_SMB_LIB_H_
@@ -79,20 +80,16 @@
#define setdbe(buf,ofs,val) getdle(buf,ofs)=htonl(val)
#else /* (BYTE_ORDER == LITTLE_ENDIAN) */
-#error "Macros for Big-Endians are incomplete"
-#define getwle(buf,ofs) ((u_int16_t)(getb(buf, ofs) | (getb(buf, ofs + 1) << 8)))
-#define getdle(buf,ofs) ((u_int32_t)(getb(buf, ofs) | \
- (getb(buf, ofs + 1) << 8) | \
- (getb(buf, ofs + 2) << 16) | \
- (getb(buf, ofs + 3) << 24)))
-#define getwbe(buf,ofs) (*((u_int16_t*)(&((u_int8_t*)(buf))[ofs])))
-#define getdbe(buf,ofs) (*((u_int32_t*)(&((u_int8_t*)(buf))[ofs])))
-/*
-#define setwle(buf,ofs,val) getwle(buf,ofs)=val
-#define setdle(buf,ofs,val) getdle(buf,ofs)=val
-*/
-#define setwbe(buf,ofs,val) getwle(buf,ofs)=val
-#define setdbe(buf,ofs,val) getdle(buf,ofs)=val
+
+#define getwbe(buf,ofs) (*((u_int16_t*)(&((u_int8_t*)(buf))[ofs])))
+#define getdbe(buf,ofs) (*((u_int32_t*)(&((u_int8_t*)(buf))[ofs])))
+#define getwle(buf,ofs) (bswap16(getwbe(buf,ofs)))
+#define getdle(buf,ofs) (bswap32(getdbe(buf,ofs)))
+
+#define setwbe(buf,ofs,val) getwbe(buf,ofs)=val
+#define setwle(buf,ofs,val) getwbe(buf,ofs)=bswap16(val)
+#define setdbe(buf,ofs,val) getdbe(buf,ofs)=val
+#define setdle(buf,ofs,val) getdbe(buf,ofs)=bswap32(val)
#endif /* (BYTE_ORDER == LITTLE_ENDIAN) */
OpenPOWER on IntegriCloud