about summary refs log tree commit diff
path: root/sysdeps/i386
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/i386')
-rw-r--r--sysdeps/i386/bits/htontoh.h79
-rw-r--r--sysdeps/i386/dl-machine.h5
-rw-r--r--sysdeps/i386/fpu/bits/mathinline.h24
-rw-r--r--sysdeps/i386/htonl.S39
-rw-r--r--sysdeps/i386/htons.S38
-rw-r--r--sysdeps/i386/i486/htonl.S37
6 files changed, 207 insertions, 15 deletions
diff --git a/sysdeps/i386/bits/htontoh.h b/sysdeps/i386/bits/htontoh.h
new file mode 100644
index 0000000000..590b509875
--- /dev/null
+++ b/sysdeps/i386/bits/htontoh.h
@@ -0,0 +1,79 @@
+/* Copyright (C) 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#ifndef _NETINET_IN_H
+# error "Don't include this file directly, use <netinet/in.h>"
+#endif
+
+#if defined __GNUC__ && __GNUC__ >= 2
+/* We can use inline assembler instructions to optimize the code.  */
+
+/* To swap the bytes in a word the i486 processors and up provide the
+   `bswap' opcode.  On i386 we have to use three instructions.  */
+# if !defined __i486__ && !defined __pentium__ && !defined __pentiumpro__
+
+extern __inline u_int32_t
+__ntohl (u_int32_t netlong)
+{
+  register u_int32_t hostlong;
+
+  __asm__ ("rorw $8, %w0; rorl $16, %0; rorw $8, %w0"
+	   : "=r" (hostlong)
+	   : "0" (netlong));
+
+  return hostlong;
+}
+
+# else
+
+extern __inline u_int32_t
+__ntohl (u_int32_t netlong)
+{
+  register u_int32_t hostlong;
+
+  __asm__ ("bswap %0" : "=r" (hostlong) : "0" (netlong));
+
+  return hostlong;
+}
+
+# endif
+
+/* For a short word we have a simple solution.  */
+extern __inline u_int16_t
+__ntohs (u_int16_t netshort)
+{
+  register u_int16_t hostshort;
+
+  __asm__ ("rorw $8, %w0" : "=r" (hostshort) : "0" (netshort));
+}
+
+
+/* The other direction can be handled with the same functions.  */
+extern __inline u_int32_t
+__htonl (u_int32_t hostlong)
+{
+  return __ntohl (hostlong);
+}
+
+extern __inline u_int16_t
+__htons (u_int16_t hostshort)
+{
+  return __ntohs (hostshort);
+}
+
+#endif /* GNU CC */
diff --git a/sysdeps/i386/dl-machine.h b/sysdeps/i386/dl-machine.h
index a83356fce1..0388cbe510 100644
--- a/sysdeps/i386/dl-machine.h
+++ b/sysdeps/i386/dl-machine.h
@@ -276,9 +276,8 @@ elf_machine_rel (struct link_map *map, const Elf32_Rel *reloc,
 
 	      strtab = ((void *) map->l_addr
 			+ map->l_info[DT_STRTAB]->d_un.d_ptr);
-	      _dl_sysdep_error ("Symbol `", strtab + refsym->st_name,
-				"' in `",
-				_dl_argv[0] ?: "<program name unknown>",
+	      _dl_sysdep_error (_dl_argv[0] ?: "<program name unknown>",
+				": Symbol `", strtab + refsym->st_name,
 				"' has different size in shared object, "
 				"consider re-linking\n", NULL);
 	    }
diff --git a/sysdeps/i386/fpu/bits/mathinline.h b/sysdeps/i386/fpu/bits/mathinline.h
index 42dae92a2a..4228959d23 100644
--- a/sysdeps/i386/fpu/bits/mathinline.h
+++ b/sysdeps/i386/fpu/bits/mathinline.h
@@ -30,42 +30,42 @@
 # define isgreater(x, y) \
      ({ int result;							      \
 	__asm__ ("fucompp; fnstsw; andb $0x45, %%ah; setz %%al;"	      \
-		 "andl $0xff, %0"					      \
-		 : "=a" (result) : "t" (x), "u" (y) : "cc");		      \
+		 "andl $0x01, %0"					      \
+		 : "=a" (result) : "u" (y), "t" (x) : "cc", "st", "st(1)");   \
 	result; })
 
 # define isgreaterequal(x, y) \
      ({ int result;							      \
 	__asm__ ("fucompp; fnstsw; testb $0x05, %%ah; setz %%al;"	      \
-		 "andl $0xff, %0"					      \
-		 : "=a" (result) : "t" (x), "u" (y) : "cc");		      \
+		 "andl $0x01, %0"					      \
+		 : "=a" (result) : "u" (y), "t" (x) : "cc", "st", "st(1)");   \
 	result; })
 
 # define isless(x, y) \
      ({ int result;							      \
 	__asm__ ("fucompp; fnstsw; xorb $0x01, %%ah; testb $0x45, %%ah;"      \
-		 "setz %%al; andl $0xff, %0"				      \
-		 : "=a" (result) : "t" (x), "u" (y) : "cc");		      \
+		 "setz %%al; andl $0x01, %0"				      \
+		 : "=a" (result) : "u" (y), "t" (x) : "cc", "st", "st(1)");   \
 	result; })
 
 # define islessequal(x, y) \
      ({ int result;							      \
 	__asm__ ("fucompp; fnstsw; xorb $0x01, %%ah; testb $0x05, %%ah;"      \
-		 "setz %%al; andl $0xff, %0"				      \
-		 : "=a" (result) : "t" (x), "u" (y) : "cc");		      \
+		 "setz %%al; andl $0x01, %0"				      \
+		 : "=a" (result) : "u" (y), "t" (x) : "cc", "st", "st(1)");   \
 	result; })
 
 # define islessgreater(x, y) \
      ({ int result;							      \
 	__asm__ ("fucompp; fnstsw; testb $0x44, %%ah; setz %%al;"	      \
-		 "andl $0xff, %0"					      \
-		 : "=a" (result) : "t" (x), "u" (y) : "cc");		      \
+		 "andl $0x01, %0"					      \
+		 : "=a" (result) : "u" (y), "t" (x) : "cc", "st", "st(1)");   \
 	result; })
 
 # define isunordered(x, y) \
      ({ int result;							      \
-	__asm__ ("fucompp; fnstsw; sahf; setp %%al; andl $0xff, %0"	      \
-		 : "=a" (result) : "t" (x), "u" (y) : "cc");		      \
+	__asm__ ("fucompp; fnstsw; sahf; setp %%al; andl $0x01, %0"	      \
+		 : "=a" (result) : "u" (y), "t" (x) : "cc", "st", "st(1)");   \
 	result; })
 #endif
 
diff --git a/sysdeps/i386/htonl.S b/sysdeps/i386/htonl.S
new file mode 100644
index 0000000000..73dd1e9bea
--- /dev/null
+++ b/sysdeps/i386/htonl.S
@@ -0,0 +1,39 @@
+/* Change byte order in word.  For Intel 80386.
+   Copyright (C) 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#include <sysdep.h>
+#include "asm-syntax.h"
+
+/*
+   INPUT PARAMETERS:
+   word		(sp + 4)
+*/
+
+	.text
+ENTRY (__htonl)
+	movl	4(%esp), %eax
+	rorw	$8, %ax
+	rorl	$16, %eax
+	rorw	$8, %ax
+	ret
+END (__htonl)
+
+strong_alias (__htonl, __ntohl)
+weak_alias (__htonl, htonl)
+weak_alias (__ntohl, ntohl)
diff --git a/sysdeps/i386/htons.S b/sysdeps/i386/htons.S
new file mode 100644
index 0000000000..5d0f59c92b
--- /dev/null
+++ b/sysdeps/i386/htons.S
@@ -0,0 +1,38 @@
+/* Change byte order in word.  For Intel 80x86, x >= 3.
+   Copyright (C) 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#include <sysdep.h>
+#include "asm-syntax.h"
+
+/*
+   INPUT PARAMETERS:
+   word		(sp + 4)
+*/
+
+	.text
+ENTRY (__htons)
+	movl	4(%esp), %eax
+	andl	$0xffff, %eax
+	rorw	$8, %ax
+	ret
+END (__htons)
+
+strong_alias (__htons, __ntohs)
+weak_alias (__htons, htons)
+weak_alias (__ntohs, ntohs)
diff --git a/sysdeps/i386/i486/htonl.S b/sysdeps/i386/i486/htonl.S
new file mode 100644
index 0000000000..cf3a94fc76
--- /dev/null
+++ b/sysdeps/i386/i486/htonl.S
@@ -0,0 +1,37 @@
+/* Change byte order in word.  For Intel 80x86, x >= 4.
+   Copyright (C) 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#include <sysdep.h>
+#include "asm-syntax.h"
+
+/*
+   INPUT PARAMETERS:
+   word		(sp + 4)
+*/
+
+	.text
+ENTRY (__htonl)
+	movl	4(%esp), %eax
+	bswap	%eax
+	ret
+END (__htonl)
+
+strong_alias (__htonl, __ntohl)
+weak_alias (__htonl, htonl)
+weak_alias (__ntohl, ntohl)