Fix mdoc(7)/man(7) mix up.
[netbsd-mini2440.git] / lib / libc / arch / powerpc / sys / brk.S
blob6d6c39230350fed370b33898e65d37eb17a6f168
1 /*      $NetBSD: brk.S,v 1.9 2000/06/26 06:25:43 kleink Exp $   */
3 #include "SYS.h"
5         .globl  _C_LABEL(__curbrk)
6         .globl  _C_LABEL(__minbrk)
7         .globl  _C_LABEL(_end)
9 #ifdef WEAK_ALIAS
10 WEAK_ALIAS(brk, _brk)
11 #endif
13         .data
14 _C_LABEL(__minbrk):
15         .long   _C_LABEL(_end)          # XXX not used yet
17         .text
19 ENTRY(_brk)
20 #ifdef PIC
21         mflr    %r10
22         bl      _GLOBAL_OFFSET_TABLE_@local-4
23         mflr    %r9
24         mtlr    %r10
25         lwz     %r5,_C_LABEL(_end)@got(%r9)
26 #else
27         lis     %r5,_C_LABEL(_end)@ha   # r5 = &_end
28         addi    %r5,%r5,_C_LABEL(_end)@l
29 #endif
30         cmplw   %r5,%r3                 # if (&_end <= r3)
31         bgt     0f
32         mr      %r5,%r3                 # r5 = r3
34         mr      %r3,%r5                 # new break value
35         li      %r0,SYS_break
36         sc                              # assume, that r5 is kept
37         bso     1f
38 #ifdef PIC
39         lwz     %r6,_C_LABEL(__curbrk)@got(%r9)
40         stw     %r5,0(%r6)
41 #else
42         lis     %r6,_C_LABEL(__curbrk)@ha       # record new break
43         stw     %r5,_C_LABEL(__curbrk)@l(%r6)
44 #endif
45         blr                             # return 0
48         b       PIC_PLT(_C_LABEL(__cerror))