]> git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/unix/sysv/linux/alpha/brk.S
Update copyright dates with scripts/update-copyrights.
[thirdparty/glibc.git] / sysdeps / unix / sysv / linux / alpha / brk.S
1 /* Copyright (C) 1993-2016 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Brendan Kehoe <brendan@zen.org>, 1993.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library. If not, see
17 <http://www.gnu.org/licenses/>. */
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 #define _ERRNO_H
25 #include <bits/errno.h>
26
27 #ifdef PIC
28 .section .bss
29 .align 3
30 .globl __curbrk
31 __curbrk: .skip 8
32 .type __curbrk,@object
33 .size __curbrk,8
34 #else
35 .comm __curbrk, 8
36 #endif
37
38 .text
39 .align 4
40 .globl __brk
41 .ent __brk
42 .usepv __brk, std
43
44 cfi_startproc
45 __brk:
46 ldgp gp, 0(t12)
47 subq sp, 16, sp
48 cfi_adjust_cfa_offset (16)
49 #ifdef PROF
50 .set noat
51 lda AT, _mcount
52 jsr AT, (AT), _mcount
53 .set at
54 #endif
55
56 /* Save the requested brk across the system call. */
57 stq a0, 0(sp)
58
59 ldiq v0, __NR_brk
60 call_pal PAL_callsys
61
62 ldq a0, 0(sp)
63 addq sp, 16, sp
64 cfi_adjust_cfa_offset (-16)
65
66 /* Be prepared for an OSF-style brk. */
67 bne a3, SYSCALL_ERROR_LABEL
68 beq v0, $ok
69
70 /* Correctly handle the brk(0) query case. */
71 cmoveq a0, v0, a0
72 xor a0, v0, t0
73 lda v0, ENOMEM
74 bne t0, SYSCALL_ERROR_LABEL
75
76 /* Update __curbrk and return cleanly. */
77 lda v0, 0
78 $ok: stq a0, __curbrk
79 ret
80
81 PSEUDO_END(__brk)
82 cfi_endproc
83
84 weak_alias (__brk, brk)