Linux bluetooth development
 help / color / mirror / Atom feed
* [Bluez-devel] [PATCH] Fix abuse of kernel headers.
@ 2003-04-25 13:25 David Woodhouse
  2003-04-25 17:43 ` Max Krasnyansky
  0 siblings, 1 reply; 7+ messages in thread
From: David Woodhouse @ 2003-04-25 13:25 UTC (permalink / raw)
  To: bluez-devel

Thou Shalt Not Use Private Kernel Headers In Userspace.
Thou Shalt Not Use Private Kernel Headers In Userspace.
Thou Shalt Not Use Private Kernel Headers In Userspace.
Thou Shalt Not Use Private Kernel Headers In Userspace.

--- bluez-hcidump-1.5/parser/parser.h~	Tue Oct 15 18:18:45 2002
+++ bluez-hcidump-1.5/parser/parser.h	Fri Apr 25 14:17:39 2003
@@ -29,8 +29,6 @@
 #include <sys/types.h>
 #include <netinet/in.h>
 
-#include <asm/unaligned.h>
-
 struct frame {
 	void	*data;
 	int	data_len;
@@ -102,7 +100,7 @@
 		printf("%*c", (level*2), ' ');
 }
 
-/* get_uXX functions do byte swaping */
+/* get_uXX functions do byte swapping */
 
 static inline __u8 get_u8(struct frame *frm)
 {
@@ -114,28 +112,35 @@
 
 static inline __u16 get_u16(struct frame *frm)
 {
-	__u16 *u16_ptr = frm->ptr;
+	__u8 *u8_ptr = frm->ptr;
 	frm->ptr += 2;
 	frm->len -= 2;
-	return ntohs(get_unaligned(u16_ptr));
+	return (u8_ptr[0] << 8) | u8_ptr[1];
 }
 
 static inline __u32 get_u32(struct frame *frm)
 {
-	__u32 *u32_ptr = frm->ptr;
+	__u8 *u8_ptr = frm->ptr;
 	frm->ptr += 4;
 	frm->len -= 4;
-	return ntohl(get_unaligned(u32_ptr));
+	return (u8_ptr[0] << 24) |(u8_ptr[1] << 16) | (u8_ptr[2] << 8) | u8_ptr[3];
 }
 
 static inline __u64 get_u64(struct frame *frm)
 {
-	__u64 *u64_ptr = frm->ptr;
-	__u64 u64 = get_unaligned(u64_ptr), tmp;
+	__u8 *u8_ptr = frm->ptr;
+	__u64 u64;
+
 	frm->ptr += 8;
 	frm->len -= 8;
-	tmp = ntohl(u64 & 0xffffffff);
-	u64 = (tmp << 32) | ntohl(u64 >> 32);
+	u64 = (__u64)u8_ptr[0] << 56;
+	u64 |= (__u64)u8_ptr[1] << 48;
+	u64 |= (__u64)u8_ptr[2] << 40;
+	u64 |= (__u64)u8_ptr[3] << 32;
+	u64 |= (__u64)u8_ptr[4] << 24;
+	u64 |= (__u64)u8_ptr[5] << 16;
+	u64 |= (__u64)u8_ptr[6] << 8;
+	u64 |= (__u64)u8_ptr[7];
 	return u64;
 }
 




-- 
dwmw2



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2003-04-29 10:15 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-04-25 13:25 [Bluez-devel] [PATCH] Fix abuse of kernel headers David Woodhouse
2003-04-25 17:43 ` Max Krasnyansky
2003-04-25 21:16   ` David Woodhouse
2003-04-25 22:49     ` Max Krasnyansky
2003-04-25 23:28       ` David Woodhouse
2003-04-28 21:49         ` Max Krasnyansky
2003-04-29 10:15           ` David Woodhouse

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox