about summary refs log tree commit diff
path: root/sysdeps
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@gmail.com>2011-09-05 12:46:12 -0400
committerUlrich Drepper <drepper@gmail.com>2011-09-05 12:46:12 -0400
commit3b142ce5728f6d683f3375fb33099ebf243f6681 (patch)
tree896f73d70426cd798e72bd786c0cb000d55b50ad /sysdeps
parent2f0ad8f3a470fa5e9aeb9c5a41984f96ae58d7ba (diff)
parent5f4318d102d604e2f80bc97927e2d80f76063639 (diff)
downloadglibc-3b142ce5728f6d683f3375fb33099ebf243f6681.tar.gz
glibc-3b142ce5728f6d683f3375fb33099ebf243f6681.tar.xz
glibc-3b142ce5728f6d683f3375fb33099ebf243f6681.zip
Merge branch 'master' of ssh://sourceware.org/git/glibc
Conflicts:
	ChangeLog
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/i386/dl-trampoline.S4
-rw-r--r--sysdeps/sparc/dl-procinfo.c9
-rw-r--r--sysdeps/sparc/dl-procinfo.h5
-rw-r--r--sysdeps/sparc/sparc32/bits/atomic.h8
-rw-r--r--sysdeps/sparc/sparc32/dl-machine.h3
-rw-r--r--sysdeps/sparc/sparc64/multiarch/memcpy.S8
-rw-r--r--sysdeps/sparc/sparc64/multiarch/memset.S6
-rw-r--r--sysdeps/sparc/sysdep.h45
-rw-r--r--sysdeps/unix/sparc/sysdep.h24
-rw-r--r--sysdeps/unix/sysv/linux/sparc/sparc32/sysdep.h110
-rw-r--r--sysdeps/unix/sysv/linux/sparc/sparc64/sysdep.h108
-rw-r--r--sysdeps/unix/sysv/linux/sparc/sysdep.h89
12 files changed, 266 insertions, 153 deletions
diff --git a/sysdeps/i386/dl-trampoline.S b/sysdeps/i386/dl-trampoline.S
index 73b08ba67e..19e313e6ba 100644
--- a/sysdeps/i386/dl-trampoline.S
+++ b/sysdeps/i386/dl-trampoline.S
@@ -1,5 +1,5 @@
 /* PLT trampolines.  i386 version.
-   Copyright (C) 2004, 2005, 2007 Free Software Foundation, Inc.
+   Copyright (C) 2004, 2005, 2007, 2011 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
@@ -99,7 +99,7 @@ _dl_runtime_profile:
 	    +4      %edx
 	   %esp     free
 	*/
-	cfi_adjust_cfa_offset (12)
+	cfi_adjust_cfa_offset (8)
 1:	movl %ebx, (%esp)
 	cfi_rel_offset (ebx, 0)
 	movl %edx, %ebx		# This is the frame buffer size
diff --git a/sysdeps/sparc/dl-procinfo.c b/sysdeps/sparc/dl-procinfo.c
index db7e867468..4a629caa1e 100644
--- a/sysdeps/sparc/dl-procinfo.c
+++ b/sysdeps/sparc/dl-procinfo.c
@@ -1,5 +1,5 @@
 /* Data for Linux/sparc version of processor capability information.
-   Copyright (C) 2002,2003,2006 Free Software Foundation, Inc.
+   Copyright (C) 2002,2003,2006,2011 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Jakub Jelinek <jakub@redhat.com>, 2002.
 
@@ -47,10 +47,13 @@
 #if !defined PROCINFO_DECL && defined SHARED
   ._dl_sparc_cap_flags
 #else
-PROCINFO_CLASS const char _dl_sparc_cap_flags[8][7]
+PROCINFO_CLASS const char _dl_sparc_cap_flags[24][11]
 #endif
 #ifndef PROCINFO_DECL
-  = { "flush", "stbar", "swap", "muldiv", "v9", "ultra3", "v9v", "v9v2" }
+  = { "flush", "stbar", "swap", "muldiv", "v9", "ultra3", "v9v", "v9v2",
+      "mul32", "div32", "fsmuld", "v8plus", "popc", "vis", "vis2",
+      "ASIBlkInit", "fmaf", "vis3", "hpc", "random", "trans", "fjfmau",
+      "ima", "cspare" }
 #endif
 #if !defined SHARED || defined PROCINFO_DECL
 ;
diff --git a/sysdeps/sparc/dl-procinfo.h b/sysdeps/sparc/dl-procinfo.h
index 04ebda751b..1aea45867b 100644
--- a/sysdeps/sparc/dl-procinfo.h
+++ b/sysdeps/sparc/dl-procinfo.h
@@ -1,5 +1,5 @@
 /* Linux/sparc version of processor capability information handling macros.
-   Copyright (C) 1999,2000,2001,2002,2003,2004,2006
+   Copyright (C) 1999,2000,2001,2002,2003,2004,2006,2011
 	Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Jakub Jelinek <jj@ultra.linux.cz>, 1999.
@@ -23,8 +23,9 @@
 #define _DL_PROCINFO_H	1
 
 #include <ldsodefs.h>
+#include <sysdep.h>
 
-#define _DL_HWCAP_COUNT 8
+#define _DL_HWCAP_COUNT 24
 
 static inline int
 __attribute__ ((unused))
diff --git a/sysdeps/sparc/sparc32/bits/atomic.h b/sysdeps/sparc/sparc32/bits/atomic.h
index ef553f7270..b9b51245ff 100644
--- a/sysdeps/sparc/sparc32/bits/atomic.h
+++ b/sysdeps/sparc/sparc32/bits/atomic.h
@@ -1,5 +1,5 @@
 /* Atomic operations.  sparc32 version.
-   Copyright (C) 2003, 2004, 2006 Free Software Foundation, Inc.
+   Copyright (C) 2003, 2004, 2006, 2011 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Jakub Jelinek <jakub@redhat.com>, 2003.
 
@@ -22,6 +22,7 @@
 #define _BITS_ATOMIC_H	1
 
 #include <stdint.h>
+#include <sysdep.h>
 
 typedef int8_t atomic8_t;
 typedef uint8_t uatomic8_t;
@@ -238,13 +239,10 @@ volatile unsigned char __sparc32_atomic_locks[64]
    apps on v9 CPUs e.g. with process shared primitives, use cas insn
    on v9 CPUs and ldstub on pre-v9.  */
 
-/* Avoid <ldsodefs.h> include here.  */
 extern uint64_t _dl_hwcap __attribute__((weak));
-# define __ATOMIC_HWCAP_SPARC_V9	16
 # define __atomic_is_v9 \
   (__builtin_expect (&_dl_hwcap != 0, 1) \
-   && __builtin_expect (_dl_hwcap & __ATOMIC_HWCAP_SPARC_V9, \
-			__ATOMIC_HWCAP_SPARC_V9))
+   && __builtin_expect (_dl_hwcap & HWCAP_SPARC_V9, HWCAP_SPARC_V9))
 
 # define atomic_compare_and_exchange_val_acq(mem, newval, oldval) \
   ({								      \
diff --git a/sysdeps/sparc/sparc32/dl-machine.h b/sysdeps/sparc/sparc32/dl-machine.h
index f8e8fe4179..f2bc94a07d 100644
--- a/sysdeps/sparc/sparc32/dl-machine.h
+++ b/sysdeps/sparc/sparc32/dl-machine.h
@@ -1,5 +1,5 @@
 /* Machine-dependent ELF dynamic relocation inline functions.  SPARC version.
-   Copyright (C) 1996-2003, 2004, 2005, 2006, 2007, 2010
+   Copyright (C) 1996-2003, 2004, 2005, 2006, 2007, 2010, 2011
    Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
@@ -26,6 +26,7 @@
 #include <string.h>
 #include <sys/param.h>
 #include <ldsodefs.h>
+#include <sysdep.h>
 #include <tls.h>
 #include <dl-plt.h>
 
diff --git a/sysdeps/sparc/sparc64/multiarch/memcpy.S b/sysdeps/sparc/sparc64/multiarch/memcpy.S
index c12dc3bbed..c022a40526 100644
--- a/sysdeps/sparc/sparc64/multiarch/memcpy.S
+++ b/sysdeps/sparc/sparc64/multiarch/memcpy.S
@@ -1,5 +1,5 @@
 /* Multiple versions of memcpy
-   Copyright (C) 2010 Free Software Foundation, Inc.
+   Copyright (C) 2010, 2011 Free Software Foundation, Inc.
    Contributed by David S. Miller (davem@davemloft.net)
    This file is part of the GNU C Library.
 
@@ -33,9 +33,9 @@ ENTRY(memcpy)
 1:	add	%o7, %o3, %o3
 	mov	%o5, %o7
 # endif
-	andcc	%o0, 0x80, %g0	! HWCAP_SPARC_N2
+	andcc	%o0, HWCAP_SPARC_N2, %g0
 	be	1f
-	 andcc	%o0, 0x40, %g0	! HWCAP_SPARC_BLKINIT
+	 andcc	%o0, HWCAP_SPARC_BLKINIT, %g0
 # ifdef SHARED
 	sethi	%gdop_hix22(__memcpy_niagara2), %o1
 	xor	%o1, %gdop_lox10(__memcpy_niagara2), %o1
@@ -45,7 +45,7 @@ ENTRY(memcpy)
 	ba	10f
 	 nop
 1:	be	1f
-	 andcc	%o0, 0x20, %g0	! HWCAP_SPARC_ULTRA3
+	 andcc	%o0, HWCAP_SPARC_ULTRA3, %g0
 # ifdef SHARED
 	sethi	%gdop_hix22(__memcpy_niagara1), %o1
 	xor	%o1, %gdop_lox10(__memcpy_niagara1), %o1
diff --git a/sysdeps/sparc/sparc64/multiarch/memset.S b/sysdeps/sparc/sparc64/multiarch/memset.S
index 2e27448742..e2674d7adf 100644
--- a/sysdeps/sparc/sparc64/multiarch/memset.S
+++ b/sysdeps/sparc/sparc64/multiarch/memset.S
@@ -1,5 +1,5 @@
 /* Multiple versions of memset and bzero
-   Copyright (C) 2010 Free Software Foundation, Inc.
+   Copyright (C) 2010, 2011 Free Software Foundation, Inc.
    Contributed by David S. Miller (davem@davemloft.net)
    This file is part of the GNU C Library.
 
@@ -33,7 +33,7 @@ ENTRY(memset)
 1:	add	%o7, %o3, %o3
 	mov	%o5, %o7
 # endif
-	andcc	%o0, 0x40, %g0	! HWCAP_SPARC_BLKINIT
+	andcc	%o0, HWCAP_SPARC_BLKINIT, %g0
 	be	9f
 	 nop
 # ifdef SHARED
@@ -69,7 +69,7 @@ ENTRY(__bzero)
 1:	add	%o7, %o3, %o3
 	mov	%o5, %o7
 # endif
-	andcc	%o0, 0x40, %g0	! HWCAP_SPARC_BLKINIT
+	andcc	%o0, HWCAP_SPARC_BLKINIT, %g0
 	be	9f
 	 nop
 # ifdef SHARED
diff --git a/sysdeps/sparc/sysdep.h b/sysdeps/sparc/sysdep.h
new file mode 100644
index 0000000000..bba41416d8
--- /dev/null
+++ b/sysdeps/sparc/sysdep.h
@@ -0,0 +1,45 @@
+/* Copyright (C) 2011 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 Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 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
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* Bits present in AT_HWCAP on SPARC.  */
+
+#define HWCAP_SPARC_FLUSH	0x00000001
+#define HWCAP_SPARC_STBAR	0x00000002
+#define HWCAP_SPARC_SWAP	0x00000004
+#define HWCAP_SPARC_MULDIV	0x00000008
+#define HWCAP_SPARC_V9		0x00000010
+#define HWCAP_SPARC_ULTRA3	0x00000020
+#define HWCAP_SPARC_BLKINIT	0x00000040
+#define HWCAP_SPARC_N2		0x00000080
+#define HWCAP_SPARC_MUL32	0x00000100
+#define HWCAP_SPARC_DIV32	0x00000200
+#define HWCAP_SPARC_FSMULD	0x00000400
+#define HWCAP_SPARC_V8PLUS	0x00000800
+#define HWCAP_SPARC_POPC	0x00001000
+#define HWCAP_SPARC_VIS		0x00002000
+#define HWCAP_SPARC_VIS2	0x00004000
+#define HWCAP_SPARC_ASI_BLK_INIT 0x00008000
+#define HWCAP_SPARC_FMAF	0x00010000
+#define HWCAP_SPARC_VIS3	0x00020000
+#define HWCAP_SPARC_HPC		0x00040000
+#define HWCAP_SPARC_RANDOM	0x00080000
+#define HWCAP_SPARC_TRANS	0x00100000
+#define HWCAP_SPARC_FJFMAU	0x00200000
+#define HWCAP_SPARC_IMA		0x00400000
+#define HWCAP_SPARC_ASI_CACHE_SPARING \
+				0x00800000
diff --git a/sysdeps/unix/sparc/sysdep.h b/sysdeps/unix/sparc/sysdep.h
index 24225d9622..590b7abc4a 100644
--- a/sysdeps/unix/sparc/sysdep.h
+++ b/sysdeps/unix/sparc/sysdep.h
@@ -1,4 +1,5 @@
-/* Copyright (C) 1993, 1994, 1995, 1997, 2003 Free Software Foundation, Inc.
+/* Copyright (C) 1993, 1994, 1995, 1997, 2003, 2011
+        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
@@ -17,6 +18,7 @@
    02111-1307 USA.  */
 
 #include <sysdeps/unix/sysdep.h>
+#include <sysdeps/sparc/sysdep.h>
 
 #ifdef	__ASSEMBLER__
 
@@ -27,6 +29,26 @@
 #define	syscall_error	C_SYMBOL_NAME(__syscall_error)
 #endif
 
+#ifdef PIC
+#define SETUP_PIC_REG(reg, tmp)						\
+	.ifndef __sparc_get_pc_thunk.reg;				\
+	.section .text.__sparc_get_pc_thunk.reg,"axG",@progbits,__sparc_get_pc_thunk.reg,comdat; \
+	.align	 32;							\
+	.weak	 __sparc_get_pc_thunk.reg;				\
+	.hidden	 __sparc_get_pc_thunk.reg;				\
+	.type	 __sparc_get_pc_thunk.reg, #function;			\
+__sparc_get_pc_thunk.reg:		   				\
+	jmp	%o7 + 8;						\
+	 add	%o7, %reg, %##reg;					\
+	.previous;							\
+	.endif;								\
+	sethi	%hi(_GLOBAL_OFFSET_TABLE_-4), %##reg;			\
+	mov	%o7, %##tmp;		      				\
+	call	__sparc_get_pc_thunk.reg;				\
+	 or	%##reg, %lo(_GLOBAL_OFFSET_TABLE_+4), %##reg;		\
+	mov	%##tmp, %o7;
+#endif
+
 #ifdef HAVE_ELF
 #define	ENTRY(name)		\
   .global C_SYMBOL_NAME(name);	\
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/sysdep.h b/sysdeps/unix/sysv/linux/sparc/sparc32/sysdep.h
index 3cb0a48c95..8af045dc2b 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc32/sysdep.h
+++ b/sysdeps/unix/sysv/linux/sparc/sparc32/sysdep.h
@@ -57,20 +57,14 @@ C_LABEL(name)				\
 
 #define LOC(name)  .L##name
 
-	/* If the offset to __syscall_error fits into a signed 22-bit
-	 * immediate branch offset, the linker will relax the call into
-	 * a normal branch.
-	 */
 #define PSEUDO(name, syscall_name, args)	\
 	.text;					\
-	.globl		__syscall_error;	\
 ENTRY(name);					\
 	LOADSYSCALL(syscall_name);		\
 	ta		0x10;			\
 	bcc		1f;			\
-	 mov		%o7, %g1;		\
-	call		__syscall_error;	\
-	 mov		%g1, %o7;		\
+	 nop;					\
+	SYSCALL_ERROR_HANDLER			\
 1:
 
 #define PSEUDO_NOERRNO(name, syscall_name, args)\
@@ -88,50 +82,70 @@ ENTRY(name);					\
 #define PSEUDO_END(name)			\
 	END(name)
 
-#else  /* __ASSEMBLER__ */
-
-#if defined SHARED && defined DO_VERSIONING && defined PIC \
-    && !defined NO_HIDDEN && !defined NOT_IN_libc
-# define CALL_ERRNO_LOCATION "call   __GI___errno_location;"
+#ifndef PIC
+# define SYSCALL_ERROR_HANDLER			\
+	mov	%o7, %g1;			\
+	call	__syscall_error;		\
+	 mov	%g1, %o7;
 #else
-# define CALL_ERRNO_LOCATION "call   __errno_location;"
-#endif
+# if RTLD_PRIVATE_ERRNO
+#  define SYSCALL_ERROR_HANDLER			\
+0:	SETUP_PIC_REG(o2,g1)			\
+	sethi	%hi(rtld_errno), %g1;		\
+	or	%g1, %lo(rtld_errno), %g1;	\
+	ld	[%o2 + %g1], %g1;		\
+	st	%o0, [%g1];			\
+	jmp	%o7 + 8;			\
+	 mov	-1, %o0;
+# elif defined _LIBC_REENTRANT
+
+#  if USE___THREAD
+#   ifndef NOT_IN_libc
+#    define SYSCALL_ERROR_ERRNO __libc_errno
+#   else
+#    define SYSCALL_ERROR_ERRNO errno
+#   endif
+#   define SYSCALL_ERROR_HANDLER				\
+0:	SETUP_PIC_REG(o2,g1)					\
+	sethi	%tie_hi22(SYSCALL_ERROR_ERRNO), %g1;		\
+	add	%g1, %tie_lo10(SYSCALL_ERROR_ERRNO), %g1;	\
+	ld	[%o2 + %g1], %g1, %tie_ld(SYSCALL_ERROR_ERRNO);	\
+	st	%o0, [%g7 + %g1]; 				\
+	jmp	%o7 + 8;    					\
+	 mov	-1, %o0;
+#  else
+#  define SYSCALL_ERROR_HANDLER		\
+0:	save	%sp, -96, %sp;		\
+	cfi_def_cfa_register(%fp);	\
+	cfi_window_save;		\
+	cfi_register (%o7, %i7);	\
+	call	__errno_location;	\
+	 nop;				\
+	st	%i0, [%o0];		\
+	jmp	%i7 + 8;		\
+	 restore %g0, -1, %o0;
+#  endif
+# else
+#  define SYSCALL_ERROR_HANDLER		\
+0:	SETUP_PIC_REG(o2,g1)		\
+	sethi	%hi(errno), %g1;	\
+	or	%g1, %lo(errno), %g1;	\
+	ld	[%o2 + %g1], %g1;	\
+	st	%o0, [%g1];		\
+	jmp	%o7 + 8;		\
+	 mov	-1, %o0;
+# endif	/* _LIBC_REENTRANT */
+#endif	/* PIC */
+
+
+#else  /* __ASSEMBLER__ */
 
 #define __SYSCALL_STRING						\
 	"ta	0x10;"							\
-	"bcs	2f;"							\
-	" nop;"								\
-	"1:"								\
-	".subsection 2;"						\
-	"2:"								\
-	"save	%%sp, -192, %%sp;"					\
-	CALL_ERRNO_LOCATION						\
-	" nop;"								\
-	"st	%%i0,[%%o0];"						\
-	"ba	1b;"							\
-	" restore %%g0, -1, %%o0;"					\
-	".previous;"
-
-#define __CLONE_SYSCALL_STRING						\
-	"ta	0x10;"							\
-	"bcs	2f;"							\
-	" sub	%%o1, 1, %%o1;"						\
-	"and	%%o0, %%o1, %%o0;"					\
-	"1:"								\
-	".subsection 2;"						\
-	"2:"								\
-	"save	%%sp, -192, %%sp;"					\
-	CALL_ERRNO_LOCATION						\
-	" nop;"								\
-	"st	%%i0, [%%o0];"						\
-	"ba	1b;"							\
-	" restore %%g0, -1, %%o0;"					\
-	".previous;"
-
-#define __INTERNAL_SYSCALL_STRING					\
-	"ta	0x10;"							\
-	"bcs,a	1f;"							\
-	" sub	%%g0, %%o0, %%o0;"					\
+	"bcc	1f;"							\
+	" mov	0, %%g1;"						\
+	"sub	%%g0, %%o0, %%o0;"					\
+	"mov	1, %%g1;"						\
 	"1:"
 
 #define __SYSCALL_CLOBBERS						\
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/sysdep.h b/sysdeps/unix/sysv/linux/sparc/sparc64/sysdep.h
index 79fa13de75..bdd1d45bd7 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc64/sysdep.h
+++ b/sysdeps/unix/sysv/linux/sparc/sparc64/sysdep.h
@@ -21,7 +21,7 @@
 #ifndef _LINUX_SPARC64_SYSDEP_H
 #define _LINUX_SPARC64_SYSDEP_H 1
 
-#include <sysdeps/unix/sysdep.h>
+#include <sysdeps/unix/sparc/sysdep.h>
 
 #ifdef IS_IN_rtld
 # include <dl-sysdep.h>		/* Defines RTLD_PRIVATE_ERRNO.  */
@@ -64,20 +64,14 @@ C_LABEL(name)				\
 	cfi_endproc;			\
 	.size name, . - name
 
-	/* If the offset to __syscall_error fits into a signed 22-bit
-	 * immediate branch offset, the linker will relax the call into
-	 * a normal branch.
-	 */
 #define PSEUDO(name, syscall_name, args)	\
 	.text;					\
-	.globl		__syscall_error;	\
 ENTRY(name);					\
 	LOADSYSCALL(syscall_name);		\
 	ta		0x6d;			\
 	bcc,pt		%xcc, 1f;		\
-	 mov		%o7, %g1;		\
-	call		__syscall_error;	\
-	 mov		%g1, %o7;		\
+	 nop;					\
+	SYSCALL_ERROR_HANDLER			\
 1:
 
 #define	PSEUDO_NOERRNO(name, syscall_name, args)\
@@ -95,51 +89,69 @@ ENTRY(name);					\
 #define PSEUDO_END(name)			\
 	END(name)
 
-
-/* Careful here!  This "ret" define can interfere; use jmpl if unsure.  */
-#define ret		retl; nop
-#define ret_NOERRNO	retl; nop
-#define ret_ERRVAL	retl; nop
-#define r0              %o0
-#define r1              %o1
-#define MOVE(x,y)       mov x, y
+#ifndef PIC
+# define SYSCALL_ERROR_HANDLER			\
+	mov	%o7, %g1;			\
+	call	__syscall_error;		\
+	 mov	%g1, %o7;
+#else
+# if RTLD_PRIVATE_ERRNO
+#  define SYSCALL_ERROR_HANDLER			\
+0:	SETUP_PIC_REG(o2,g1)			\
+	sethi	%hi(rtld_errno), %g1;		\
+	or	%g1, %lo(rtld_errno), %g1;	\
+	ldx	[%o2 + %g1], %g1;		\
+	st	%o0, [%g1];			\
+	jmp	%o7 + 8;			\
+	 mov	-1, %o0;
+# elif defined _LIBC_REENTRANT
+
+#  if USE___THREAD
+#   ifndef NOT_IN_libc
+#    define SYSCALL_ERROR_ERRNO __libc_errno
+#   else
+#    define SYSCALL_ERROR_ERRNO errno
+#   endif
+#   define SYSCALL_ERROR_HANDLER				\
+0:	SETUP_PIC_REG(o2,g1)					\
+	sethi	%tie_hi22(SYSCALL_ERROR_ERRNO), %g1;		\
+	add	%g1, %tie_lo10(SYSCALL_ERROR_ERRNO), %g1;	\
+	ldx	[%o2 + %g1], %g1, %tie_ldx(SYSCALL_ERROR_ERRNO);\
+	st	%o0, [%g7 + %g1]; 				\
+	jmp	%o7 + 8;    					\
+	 mov	-1, %o0;
+#  else
+#  define SYSCALL_ERROR_HANDLER		\
+0:	save	%sp, -176, %sp;		\
+	cfi_def_cfa_register(%fp);	\
+	cfi_window_save;		\
+	cfi_register (%o7, %i7);	\
+	call	__errno_location;	\
+	 nop;				\
+	st	%i0, [%o0];		\
+	jmp	%i7 + 8;		\
+	 restore %g0, -1, %o0;
+#  endif
+# else
+#  define SYSCALL_ERROR_HANDLER		\
+0:	SETUP_PIC_REG(o2,g1)		\
+	sethi	%hi(errno), %g1;	\
+	or	%g1, %lo(errno), %g1;	\
+	ldx	[%o2 + %g1], %g1;	\
+	st	%o0, [%g1];		\
+	jmp	%o7 + 8;		\
+	 mov	-1, %o0;
+# endif	/* _LIBC_REENTRANT */
+#endif	/* PIC */
 
 #else  /* __ASSEMBLER__ */
 
-#if defined SHARED && defined DO_VERSIONING && defined PIC \
-    && !defined NO_HIDDEN && !defined NOT_IN_libc
-# define CALL_ERRNO_LOCATION "call   __GI___errno_location;"
-#else
-# define CALL_ERRNO_LOCATION "call   __errno_location;"
-#endif
-
 #define __SYSCALL_STRING						\
 	"ta	0x6d;"							\
 	"bcc,pt	%%xcc, 1f;"						\
-	" nop;"								\
-	"save	%%sp, -192, %%sp;"					\
-	CALL_ERRNO_LOCATION						\
-	" nop;"								\
-	"st	%%i0,[%%o0];"						\
-	"restore %%g0, -1, %%o0;"					\
-	"1:"
-
-#define __CLONE_SYSCALL_STRING						\
-	"ta	0x6d;"							\
-	"bcc,pt	%%xcc, 1f;"						\
-	" sub	%%o1, 1, %%o1;"						\
-	"save	%%sp, -192, %%sp;"					\
-	CALL_ERRNO_LOCATION						\
-	" mov	-1, %%i1;"						\
-	"st	%%i0,[%%o0];"						\
-	"restore %%g0, -1, %%o0;"					\
-	"1:"								\
-	"and	%%o0, %%o1, %%o0"
-
-#define __INTERNAL_SYSCALL_STRING					\
-	"ta	0x6d;"							\
-	"bcs,a,pt %%xcc, 1f;"						\
-	" sub	%%g0, %%o0, %%o0;"					\
+	" mov	0, %%g1;"						\
+	"sub	%%g0, %%o0, %%o0;"					\
+	"mov	1, %%g1;"						\
 	"1:"
 
 #define __SYSCALL_CLOBBERS						\
diff --git a/sysdeps/unix/sysv/linux/sparc/sysdep.h b/sysdeps/unix/sysv/linux/sparc/sysdep.h
index 101638a53f..f69e1a92ff 100644
--- a/sysdeps/unix/sysv/linux/sparc/sysdep.h
+++ b/sysdeps/unix/sysv/linux/sparc/sysdep.h
@@ -21,101 +21,109 @@
 #define _LINUX_SPARC_SYSDEP_H 1
 
 #undef INLINE_SYSCALL
-#define INLINE_SYSCALL(name, nr, args...) \
-  inline_syscall##nr(__SYSCALL_STRING, __NR_##name, args)
+#define INLINE_SYSCALL(name, nr, args...) 				\
+({	INTERNAL_SYSCALL_DECL(err);  					\
+	unsigned int resultvar = INTERNAL_SYSCALL(name, err, nr, args);	\
+	if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (resultvar, err), 0)) \
+	  {		     			       		   	\
+	    __set_errno (INTERNAL_SYSCALL_ERRNO (resultvar, err));	\
+	    resultvar = 0xffffffff;			    		\
+	  } 	      							\
+	(int) resultvar;						\
+})
 
 #undef INTERNAL_SYSCALL_DECL
-#define INTERNAL_SYSCALL_DECL(err) do { } while (0)
+#define INTERNAL_SYSCALL_DECL(err) \
+	register long err __asm__("g1");
 
 #undef INTERNAL_SYSCALL
 #define INTERNAL_SYSCALL(name, err, nr, args...) \
-  inline_syscall##nr(__INTERNAL_SYSCALL_STRING, __NR_##name, args)
+  inline_syscall##nr(__SYSCALL_STRING, err, __NR_##name, args)
 
 #undef INTERNAL_SYSCALL_NCS
 #define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
-  inline_syscall##nr(__INTERNAL_SYSCALL_STRING, name, args)
+  inline_syscall##nr(__SYSCALL_STRING, err, name, args)
 
 #undef INTERNAL_SYSCALL_ERROR_P
-#define INTERNAL_SYSCALL_ERROR_P(val, err) \
-  ((unsigned long) (val) >= -515L)
+#define INTERNAL_SYSCALL_ERROR_P(val, err) ((err) != 0)
 
 #undef INTERNAL_SYSCALL_ERRNO
 #define INTERNAL_SYSCALL_ERRNO(val, err)	(-(val))
 
-#define inline_syscall0(string,name,dummy...)				\
+#define inline_syscall0(string,err,name,dummy...)			\
 ({									\
 	register long __o0 __asm__ ("o0");				\
-	register long __g1 __asm__ ("g1") = name;			\
-	__asm __volatile (string : "=r" (__g1), "=r" (__o0) :		\
-			  "0" (__g1) :					\
+	err = name;							\
+	__asm __volatile (string : "=r" (err), "=r" (__o0) :		\
+			  "0" (err) :					\
 			  __SYSCALL_CLOBBERS);				\
 	__o0;								\
 })
 
-#define inline_syscall1(string,name,arg1)				\
+#define inline_syscall1(string,err,name,arg1)				\
 ({									\
 	register long __o0 __asm__ ("o0") = (long)(arg1);		\
-	register long __g1 __asm__ ("g1") = name;			\
-	__asm __volatile (string : "=r" (__g1), "=r" (__o0) :		\
-			  "0" (__g1), "1" (__o0) :			\
+	err = name;							\
+	__asm __volatile (string : "=r" (err), "=r" (__o0) :		\
+			  "0" (err), "1" (__o0) :			\
 			  __SYSCALL_CLOBBERS);				\
 	__o0;								\
 })
 
-#define inline_syscall2(string,name,arg1,arg2)				\
+#define inline_syscall2(string,err,name,arg1,arg2)			\
 ({									\
 	register long __o0 __asm__ ("o0") = (long)(arg1);		\
 	register long __o1 __asm__ ("o1") = (long)(arg2);		\
-	register long __g1 __asm__ ("g1") = name;			\
-	__asm __volatile (string : "=r" (__g1), "=r" (__o0) :		\
-			  "0" (__g1), "1" (__o0), "r" (__o1) :		\
+	err = name;							\
+	__asm __volatile (string : "=r" (err), "=r" (__o0) :		\
+			  "0" (err), "1" (__o0), "r" (__o1) :		\
 			  __SYSCALL_CLOBBERS);				\
 	__o0;								\
 })
 
-#define inline_syscall3(string,name,arg1,arg2,arg3)			\
+#define inline_syscall3(string,err,name,arg1,arg2,arg3)			\
 ({									\
 	register long __o0 __asm__ ("o0") = (long)(arg1);		\
 	register long __o1 __asm__ ("o1") = (long)(arg2);		\
 	register long __o2 __asm__ ("o2") = (long)(arg3);		\
-	register long __g1 __asm__ ("g1") = name;			\
-	__asm __volatile (string : "=r" (__g1), "=r" (__o0) :		\
-			  "0" (__g1), "1" (__o0), "r" (__o1),		\
+	err = name;							\
+	__asm __volatile (string : "=r" (err), "=r" (__o0) :		\
+			  "0" (err), "1" (__o0), "r" (__o1),		\
 			  "r" (__o2) :					\
 			  __SYSCALL_CLOBBERS);				\
 	__o0;								\
 })
 
-#define inline_syscall4(string,name,arg1,arg2,arg3,arg4)		\
+#define inline_syscall4(string,err,name,arg1,arg2,arg3,arg4)		\
 ({									\
 	register long __o0 __asm__ ("o0") = (long)(arg1);		\
 	register long __o1 __asm__ ("o1") = (long)(arg2);		\
 	register long __o2 __asm__ ("o2") = (long)(arg3);		\
 	register long __o3 __asm__ ("o3") = (long)(arg4);		\
-	register long __g1 __asm__ ("g1") = name;			\
-	__asm __volatile (string : "=r" (__g1), "=r" (__o0) :		\
-			  "0" (__g1), "1" (__o0), "r" (__o1),		\
+	err = name;							\
+	__asm __volatile (string : "=r" (err), "=r" (__o0) :		\
+			  "0" (err), "1" (__o0), "r" (__o1),		\
 			  "r" (__o2), "r" (__o3) :			\
 			  __SYSCALL_CLOBBERS);				\
 	__o0;								\
 })
 
-#define inline_syscall5(string,name,arg1,arg2,arg3,arg4,arg5)		\
+#define inline_syscall5(string,err,name,arg1,arg2,arg3,arg4,arg5)	\
 ({									\
 	register long __o0 __asm__ ("o0") = (long)(arg1);		\
 	register long __o1 __asm__ ("o1") = (long)(arg2);		\
 	register long __o2 __asm__ ("o2") = (long)(arg3);		\
 	register long __o3 __asm__ ("o3") = (long)(arg4);		\
 	register long __o4 __asm__ ("o4") = (long)(arg5);		\
-	register long __g1 __asm__ ("g1") = name;			\
-	__asm __volatile (string : "=r" (__g1), "=r" (__o0) :		\
-			  "0" (__g1), "1" (__o0), "r" (__o1),		\
+	err = name;							\
+	__asm __volatile (string : "=r" (err), "=r" (__o0) :		\
+			  "0" (err), "1" (__o0), "r" (__o1),		\
 			  "r" (__o2), "r" (__o3), "r" (__o4) :		\
 			  __SYSCALL_CLOBBERS);				\
 	__o0;								\
 })
 
-#define inline_syscall6(string,name,arg1,arg2,arg3,arg4,arg5,arg6)	\
+#define inline_syscall6(string,err,name,arg1,arg2,arg3,arg4,arg5,arg6)	\
 ({									\
 	register long __o0 __asm__ ("o0") = (long)(arg1);		\
 	register long __o1 __asm__ ("o1") = (long)(arg2);		\
@@ -123,9 +131,9 @@
 	register long __o3 __asm__ ("o3") = (long)(arg4);		\
 	register long __o4 __asm__ ("o4") = (long)(arg5);		\
 	register long __o5 __asm__ ("o5") = (long)(arg6);		\
-	register long __g1 __asm__ ("g1") = name;			\
-	__asm __volatile (string : "=r" (__g1), "=r" (__o0) :		\
-			  "0" (__g1), "1" (__o0), "r" (__o1),		\
+	err = name;							\
+	__asm __volatile (string : "=r" (err), "=r" (__o0) :		\
+			  "0" (err), "1" (__o0), "r" (__o1),		\
 			  "r" (__o2), "r" (__o3), "r" (__o4),		\
 			  "r" (__o5) :					\
 			  __SYSCALL_CLOBBERS);				\
@@ -140,11 +148,20 @@
 	register long __o3 __asm__ ("o3") = (long)(arg4);		\
 	register long __o4 __asm__ ("o4") = (long)(arg5);		\
 	register long __g1 __asm__ ("g1") = __NR_clone;			\
-	__asm __volatile (__CLONE_SYSCALL_STRING :			\
+	__asm __volatile (__SYSCALL_STRING :				\
 			  "=r" (__g1), "=r" (__o0), "=r" (__o1)	:	\
 			  "0" (__g1), "1" (__o0), "2" (__o1),		\
 			  "r" (__o2), "r" (__o3), "r" (__o4) :		\
 			  __SYSCALL_CLOBBERS);				\
+	if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (__o0, __g1), 0)) \
+	  {		     			       		   	\
+	    __set_errno (INTERNAL_SYSCALL_ERRNO (__o0, __g1));		\
+	    __o0 = -1L;			    				\
+	  } 	      							\
+	else								\
+	  { 	      							\
+	    __o0 &= (__o1 - 1);						\
+	  } 	    	    						\
 	__o0;								\
 })