4582539bc1b9cc36886a91eabcfc439ecc929a88
[platform/upstream/glibc.git] / sysdeps / unix / sysv / linux / alpha / brk.S
1 /* Copyright (C) 1993, 1995 Free Software Foundation, Inc.
2    Contributed by Brendan Kehoe (brendan@zen.org).
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public
15 License along with the GNU C Library; see the file COPYING.LIB.  If
16 not, write to the Free Software Foundation, Inc., 675 Mass Ave,
17 Cambridge, MA 02139, USA.  */
18
19 /* __brk is a special syscall under Linux since it never returns an
20 error.  Instead, the error condition is indicated by returning the old
21 break value (instead of the new, requested one).  */
22
23 #include <sysdep.h>
24 #include <errnos.h>
25
26 #ifndef       HAVE_GNU_LD
27 #define _end           end
28 #endif
29
30         .extern _end,8
31
32         .data
33
34         .globl __curbrk
35 __curbrk:
36         .quad _end
37
38         .text
39 LEAF(__brk, 0)
40         ldgp    gp, 0(t12)
41         .prologue 1
42
43         ldi     v0, __NR_brk
44         call_pal PAL_callsys
45         subq    a0, v0, t0
46         bne     t0, error
47
48         /* Update __curbrk and return cleanly.  */
49         stl     a0, __curbrk
50         mov     zero, v0
51         ret
52
53         /* What a horrible way to die.  */
54 error:  ldi     v0, ENOMEM
55         jmp     zero, syscall_error
56
57         .end __brk
58
59 weak_alias (__brk, brk)