Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 02 May 2004 13:26:13 +0800
From:      Deng XueFeng <dsnofe@hotmail.com>
To:        freebsd-hackers@freebsd.org
Subject:   Is this LOST??
Message-ID:  <20040502132115.C583.DSNOFE@hotmail.com>

index | next in thread | raw e-mail

[-- Attachment #1 --]
I found the htonl implemention in libc for i386 is not sync with the
kern.

sys use bswap for swaping the int. but libc still use xchg.
IS THIS LOST?

Here is the patches.
----------------------------CUT HERE------------------------
--- /usr/src/lib/libc/i386/net/htonl.S.orig	Sun May  2 12:13:13 2004
+++ /usr/src/lib/libc/i386/net/htonl.S	Sun May  2 12:22:02 2004
@@ -46,7 +46,5 @@
         .set CNAME(htonl),CNAME(__htonl)
 ENTRY(__htonl)
 	movl	4(%esp),%eax
-	xchgb	%al,%ah
-	roll	$16,%eax
-	xchgb	%al,%ah
+	bswap   %eax
 	ret
-----------------------------END HERE----------------------
----------------------------CUT HERE------------------------
--- /usr/src/lib/libc/i386/net/ntohl.S.orig	Sun May  2 12:13:21 2004
+++ /usr/src/lib/libc/i386/net/ntohl.S	Sun May  2 12:19:16 2004
@@ -46,7 +46,5 @@
         .set CNAME(ntohl),CNAME(__ntohl)
 ENTRY(__ntohl)
 	movl	4(%esp),%eax
-	xchgb	%al,%ah
-	roll	$16,%eax
-	xchgb	%al,%ah
+	bswap	%eax
 	ret
-----------------------------END HERE----------------------


Sincerely,
Deng XueFeng

[-- Attachment #2 --]
--- /usr/src/lib/libc/i386/net/htonl.S.orig	Sun May  2 12:13:13 2004
+++ /usr/src/lib/libc/i386/net/htonl.S	Sun May  2 12:22:02 2004
@@ -46,7 +46,5 @@
         .set CNAME(htonl),CNAME(__htonl)
 ENTRY(__htonl)
 	movl	4(%esp),%eax
-	xchgb	%al,%ah
-	roll	$16,%eax
-	xchgb	%al,%ah
+	bswap   %eax
 	ret

[-- Attachment #3 --]
--- /usr/src/lib/libc/i386/net/ntohl.S.orig	Sun May  2 12:13:21 2004
+++ /usr/src/lib/libc/i386/net/ntohl.S	Sun May  2 12:19:16 2004
@@ -46,7 +46,5 @@
         .set CNAME(ntohl),CNAME(__ntohl)
 ENTRY(__ntohl)
 	movl	4(%esp),%eax
-	xchgb	%al,%ah
-	roll	$16,%eax
-	xchgb	%al,%ah
+	bswap	%eax
 	ret
help

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040502132115.C583.DSNOFE>