Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libc/arch Minimize differences between powerpc and power...
details: https://anonhg.NetBSD.org/src/rev/96f277c4949d
branches: trunk
changeset: 331755:96f277c4949d
user: matt <matt%NetBSD.org@localhost>
date: Sat Aug 23 02:24:22 2014 +0000
description:
Minimize differences between powerpc and powerpc64
Fix powerpc64 assembly to use right instructions for 64bit CPUs.
Use hidden for __curbrk and __minbrk to avoid GOT/TOC relocations.
diffstat:
lib/libc/arch/powerpc/SYS.h | 17 +++-----
lib/libc/arch/powerpc/sys/__clone.S | 12 +++---
lib/libc/arch/powerpc/sys/__syscall.S | 10 ++--
lib/libc/arch/powerpc/sys/brk.S | 44 +++++++++++++----------
lib/libc/arch/powerpc/sys/getcontext.S | 10 ++--
lib/libc/arch/powerpc/sys/pipe.S | 10 ++--
lib/libc/arch/powerpc/sys/sbrk.S | 30 +++++++---------
lib/libc/arch/powerpc64/Makefile.inc | 6 ++-
lib/libc/arch/powerpc64/SYS.h | 27 +++++++-------
lib/libc/arch/powerpc64/gen/__setjmp14.S | 17 +++-----
lib/libc/arch/powerpc64/gen/__sigsetjmp14.S | 15 +++----
lib/libc/arch/powerpc64/genassym.cf | 45 ++++++++++++++++++++++++
lib/libc/arch/powerpc64/sys/__clone.S | 15 ++++---
lib/libc/arch/powerpc64/sys/__sigtramp2.S | 3 +-
lib/libc/arch/powerpc64/sys/__syscall.S | 21 ++++++++++-
lib/libc/arch/powerpc64/sys/__vfork14.S | 3 +-
lib/libc/arch/powerpc64/sys/brk.S | 39 ++++++++++----------
lib/libc/arch/powerpc64/sys/cerror.S | 33 ++++++++---------
lib/libc/arch/powerpc64/sys/fork.S | 3 +-
lib/libc/arch/powerpc64/sys/getcontext.S | 20 +++++-----
lib/libc/arch/powerpc64/sys/pipe.S | 12 +++---
lib/libc/arch/powerpc64/sys/ptrace.S | 53 +++++++++++++---------------
lib/libc/arch/powerpc64/sys/sbrk.S | 29 ++++-----------
lib/libc/arch/powerpc64/sys/syscall.S | 6 +--
24 files changed, 261 insertions(+), 219 deletions(-)
diffs (truncated from 967 to 300 lines):
diff -r b05129e573ab -r 96f277c4949d lib/libc/arch/powerpc/SYS.h
--- a/lib/libc/arch/powerpc/SYS.h Sat Aug 23 02:21:44 2014 +0000
+++ b/lib/libc/arch/powerpc/SYS.h Sat Aug 23 02:24:22 2014 +0000
@@ -1,24 +1,21 @@
-/* $NetBSD: SYS.h,v 1.12 2011/01/15 07:31:12 matt Exp $ */
+/* $NetBSD: SYS.h,v 1.13 2014/08/23 02:24:22 matt Exp $ */
#include <machine/asm.h>
#include <sys/syscall.h>
-#ifdef __STDC__
+#define BRANCH_TO_CERROR() b _C_LABEL(__cerror)
+
#define _DOSYSCALL(x) li %r0,(SYS_ ## x) ;\
sc
-#else
-#define _DOSYSCALL(x) li %r0,(SYS_/**/x) ;\
- sc
-#endif /* __STDC__ */
#define _SYSCALL_NOERROR(x,y) .text ;\
- .align 2 ;\
+ .p2align 2 ;\
ENTRY(x) ;\
_DOSYSCALL(y)
#define _SYSCALL(x,y) .text ;\
- .align 2 ;\
- 2: b _C_LABEL(__cerror) ;\
+ .p2align 2 ;\
+ 2: BRANCH_TO_CERROR() ;\
_SYSCALL_NOERROR(x,y) ;\
bso 2b
@@ -32,7 +29,7 @@
#define PSEUDO(x,y) _SYSCALL_NOERROR(x,y) ;\
bnslr ;\
- b _C_LABEL(__cerror) ;\
+ BRANCH_TO_CERROR() ;\
END(x)
#define RSYSCALL_NOERROR(x) PSEUDO_NOERROR(x,x)
diff -r b05129e573ab -r 96f277c4949d lib/libc/arch/powerpc/sys/__clone.S
--- a/lib/libc/arch/powerpc/sys/__clone.S Sat Aug 23 02:21:44 2014 +0000
+++ b/lib/libc/arch/powerpc/sys/__clone.S Sat Aug 23 02:24:22 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: __clone.S,v 1.5 2013/09/12 15:36:15 joerg Exp $ */
+/* $NetBSD: __clone.S,v 1.6 2014/08/23 02:24:22 matt Exp $ */
/*-
* Copyright (c) 2001 Tsubai Masanari. All rights reserved.
@@ -30,7 +30,7 @@
#include "SYS.h"
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: __clone.S,v 1.5 2013/09/12 15:36:15 joerg Exp $")
+__RCSID("$NetBSD: __clone.S,v 1.6 2014/08/23 02:24:22 matt Exp $")
#endif /* LIBC_SCCS && !lint */
#ifdef WEAK_ALIAS
@@ -44,9 +44,9 @@
/*
* Sanity checks: func and stack may not be NULL.
*/
- cmpwi %r3,0
+ cmpptri %r3,0
beq 1f
- cmpwi %r4,0
+ cmpptri %r4,0
beq 1f
mr %r7,%r3 /* Save fn in r7. */
@@ -54,7 +54,7 @@
_DOSYSCALL(__clone) /* (flags, stack) */
bso 2f /* error... */
- cmpwi %r3,0
+ cmpptri %r3,0
bnelr /* We're the parent, just return. */
mtlr %r7 /* fn */
@@ -69,5 +69,5 @@
1:
li %r3,EINVAL
2:
- b _C_LABEL(__cerror)
+ BRANCH_TO_CERROR()
END(__clone)
diff -r b05129e573ab -r 96f277c4949d lib/libc/arch/powerpc/sys/__syscall.S
--- a/lib/libc/arch/powerpc/sys/__syscall.S Sat Aug 23 02:21:44 2014 +0000
+++ b/lib/libc/arch/powerpc/sys/__syscall.S Sat Aug 23 02:24:22 2014 +0000
@@ -1,9 +1,9 @@
-/* $NetBSD: __syscall.S,v 1.2 2014/02/01 20:26:21 matt Exp $ */
+/* $NetBSD: __syscall.S,v 1.3 2014/08/23 02:24:22 matt Exp $ */
-#include <powerpc/asm.h>
+#include "SYS.h"
.text
- .align 2
+ .p2align 2
ENTRY(__syscall)
mr %r0,%r3 /* syscall number */
mr %r3,%r4
@@ -13,10 +13,10 @@
mr %r7,%r8
mr %r8,%r9
mr %r9,%r10
- lwz %r10,8(%r1) /* final argument is on the stack */
+ ldreg %r10,(2*__SIZEOF_POINTER__)(%r1) /* final argument is on the stack */
sc
bnslr
- b _C_LABEL(__cerror)
+ BRANCH_TO_CERROR()
END(__syscall)
STRONG_ALIAS(syscall, __syscall)
diff -r b05129e573ab -r 96f277c4949d lib/libc/arch/powerpc/sys/brk.S
--- a/lib/libc/arch/powerpc/sys/brk.S Sat Aug 23 02:21:44 2014 +0000
+++ b/lib/libc/arch/powerpc/sys/brk.S Sat Aug 23 02:24:22 2014 +0000
@@ -1,12 +1,14 @@
-/* $NetBSD: brk.S,v 1.13 2013/09/12 15:36:15 joerg Exp $ */
+/* $NetBSD: brk.S,v 1.14 2014/08/23 02:24:22 matt Exp $ */
#include "SYS.h"
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: brk.S,v 1.13 2013/09/12 15:36:15 joerg Exp $")
+__RCSID("$NetBSD: brk.S,v 1.14 2014/08/23 02:24:22 matt Exp $")
#endif /* LIBC_SCCS && !lint */
+ .hidden _C_LABEL(__curbrk)
.globl _C_LABEL(__curbrk)
+ .hidden _C_LABEL(__minbrk)
.globl _C_LABEL(__minbrk)
.globl _C_LABEL(_end)
@@ -15,36 +17,38 @@
#endif
.data
+ .p2align 2
_C_LABEL(__minbrk):
- .long _C_LABEL(_end) # XXX not used yet
+ .long _C_LABEL(_end)
+_C_LABEL(__curbrk):
+ .long _C_LABEL(_end)
- .text
ENTRY(_brk)
#ifdef __PIC__
- mflr %r10
- PIC_GOTSETUP(%r9)
- mtlr %r10
- lwz %r5,_C_LABEL(_end)@got(%r9)
+ mflr %r0
+ bcl 20,31,.LPIC0
+.LPIC0: mflr %r9
+ mtlr %r0
+ addis %r9,%r9,(_C_LABEL(__minbrk)-.LPIC0)@ha
+ ldptru %r5,(_C_LABEL(__minbrk)-.LPIC0)@l(%r9) # r5 = &_end
#else
- lis %r5,_C_LABEL(_end)@ha # r5 = &_end
- addi %r5,%r5,_C_LABEL(_end)@l
+ lis %r9,_C_LABEL(__minbrk)@ha
+ ldptru %r5,_C_LABEL(__minbrk)@l(%r9) # r5 = &_end
#endif
- cmplw %r5,%r3 # if (&_end <= r3)
+ cmpptrl %r5,%r3 # if (__minbrk <= r3)
+#ifdef __PPC_ISEL__
+ iselgt %r3,%r5,%r3
+#else
bgt 0f
mr %r5,%r3 # r5 = r3
0:
mr %r3,%r5 # new break value
- _DOSYSCALL(break) # assume, that r5 is kept
+#endif
+ _DOSYSCALL(break) # assume that r5 is preserved
bso 1f
-#ifdef __PIC__
- lwz %r6,_C_LABEL(__curbrk)@got(%r9)
- stw %r5,0(%r6)
-#else
- lis %r6,_C_LABEL(__curbrk)@ha # record new break
- stw %r5,_C_LABEL(__curbrk)@l(%r6)
-#endif
+ stptr %r5,__SIZEOF_POINTER__(%r9)
blr # return 0
1:
- b _C_LABEL(__cerror)
+ BRANCH_TO_CERROR()
END(_brk)
diff -r b05129e573ab -r 96f277c4949d lib/libc/arch/powerpc/sys/getcontext.S
--- a/lib/libc/arch/powerpc/sys/getcontext.S Sat Aug 23 02:21:44 2014 +0000
+++ b/lib/libc/arch/powerpc/sys/getcontext.S Sat Aug 23 02:24:22 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: getcontext.S,v 1.5 2011/01/15 07:31:13 matt Exp $ */
+/* $NetBSD: getcontext.S,v 1.6 2014/08/23 02:24:22 matt Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -33,7 +33,7 @@
#include "assym.h"
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: getcontext.S,v 1.5 2011/01/15 07:31:13 matt Exp $")
+__RCSID("$NetBSD: getcontext.S,v 1.6 2014/08/23 02:24:22 matt Exp $")
#endif /* LIBC_SCCS && !lint */
#ifdef WEAK_ALIAS
@@ -45,9 +45,9 @@
_DOSYSCALL(getcontext)
bso 1f
mflr %r4
- stw %r4,UC_GREGS_PC(%r5) # saved pc <- lr
- stw %r3,UC_GREGS_R3(%r5) # arrange for return value 0
+ stptr %r4,UC_GREGS_PC(%r5) # saved pc <- lr
+ stint %r3,UC_GREGS_R3(%r5) # arrange for return value 0
blr
1:
- b _C_LABEL(__cerror)
+ BRANCH_TO_CERROR()
END(_getcontext)
diff -r b05129e573ab -r 96f277c4949d lib/libc/arch/powerpc/sys/pipe.S
--- a/lib/libc/arch/powerpc/sys/pipe.S Sat Aug 23 02:21:44 2014 +0000
+++ b/lib/libc/arch/powerpc/sys/pipe.S Sat Aug 23 02:24:22 2014 +0000
@@ -1,9 +1,9 @@
-/* $NetBSD: pipe.S,v 1.8 2011/01/15 07:31:13 matt Exp $ */
+/* $NetBSD: pipe.S,v 1.9 2014/08/23 02:24:22 matt Exp $ */
#include "SYS.h"
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: pipe.S,v 1.8 2011/01/15 07:31:13 matt Exp $")
+__RCSID("$NetBSD: pipe.S,v 1.9 2014/08/23 02:24:22 matt Exp $")
#endif /* LIBC_SCCS && !lint */
#ifdef WEAK_ALIAS
@@ -14,10 +14,10 @@
mr %r5,%r3 # save pointer
_DOSYSCALL(pipe) # assume, that r5 is kept
bso 1f
- stw %r3,0(%r5) # success, store fds
- stw %r4,4(%r5)
+ stint %r3,0(%r5) # success, store fds
+ stint %r4,4(%r5)
li %r3,0
blr # and return 0
1:
- b _C_LABEL(__cerror)
+ BRANCH_TO_CERROR()
END(_pipe)
diff -r b05129e573ab -r 96f277c4949d lib/libc/arch/powerpc/sys/sbrk.S
--- a/lib/libc/arch/powerpc/sys/sbrk.S Sat Aug 23 02:21:44 2014 +0000
+++ b/lib/libc/arch/powerpc/sys/sbrk.S Sat Aug 23 02:24:22 2014 +0000
@@ -1,41 +1,37 @@
-/* $NetBSD: sbrk.S,v 1.12 2013/09/12 15:36:15 joerg Exp $ */
+/* $NetBSD: sbrk.S,v 1.13 2014/08/23 02:24:22 matt Exp $ */
#include "SYS.h"
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: sbrk.S,v 1.12 2013/09/12 15:36:15 joerg Exp $")
+__RCSID("$NetBSD: sbrk.S,v 1.13 2014/08/23 02:24:22 matt Exp $")
#endif /* LIBC_SCCS && !lint */
+ .hidden _C_LABEL(__curbrk)
.globl _C_LABEL(__curbrk)
- .globl _C_LABEL(_end)
#ifdef WEAK_ALIAS
WEAK_ALIAS(sbrk, _sbrk)
#endif
- .data
-_C_LABEL(__curbrk):
- .long _C_LABEL(_end)
- .text
-
ENTRY(_sbrk)
#ifdef __PIC__
- mflr %r10
- PIC_GOTSETUP(%r5)
- mtlr %r10
- lwz %r5,_C_LABEL(__curbrk)@got(%r5)
- lwz %r6,0(%r5)
+ mflr %r0
+ bcl 20,31,.LPIC0
+.LPIC0: mflr %r5
+ mtlr %r0
+ addis %r8,%r5,(_C_LABEL(__curbrk)-.LPIC0)@ha
+ ldptru %r6,(_C_LABEL(__curbrk)-.LPIC0)@l(%r8)
#else
- lis %r5,_C_LABEL(__curbrk)@ha
- lwzu %r6,_C_LABEL(__curbrk)@l(%r5) # r6 = old break, r5 = &curbrk
+ lis %r8,_C_LABEL(__curbrk)@ha
+ ldptru %r6,_C_LABEL(__curbrk)@l(%r8) # r6 = old break, r5 = &curbrk
Home |
Main Index |
Thread Index |
Old Index