]>
Commit | Line | Data |
---|---|---|
04277e02 | 1 | /* Copyright (C) 1993-2019 Free Software Foundation, Inc. |
3c7b2587 UD |
2 | This file is part of the GNU C Library. |
3 | Contributed by Brendan Kehoe <brendan@zen.org>, 1993. | |
6932e444 | 4 | |
3c7b2587 | 5 | The GNU C Library is free software; you can redistribute it and/or |
3214b89b AJ |
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. | |
6932e444 | 9 | |
3c7b2587 UD |
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 | |
3214b89b | 13 | Lesser General Public License for more details. |
6932e444 | 14 | |
3214b89b | 15 | You should have received a copy of the GNU Lesser General Public |
ab84e3ff PE |
16 | License along with the GNU C Library. If not, see |
17 | <http://www.gnu.org/licenses/>. */ | |
6932e444 RM |
18 | |
19 | /* __brk is a special syscall under Linux since it never returns an | |
3c7b2587 UD |
20 | error. Instead, the error condition is indicated by returning the old |
21 | break value (instead of the new, requested one). */ | |
6932e444 RM |
22 | |
23 | #include <sysdep.h> | |
05e86071 | 24 | #define _ERRNO_H |
405916ef | 25 | #include <bits/errno.h> |
6932e444 | 26 | |
b870eeda UD |
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 | |
d6634820 | 35 | .comm __curbrk, 8 |
b870eeda | 36 | #endif |
6932e444 RM |
37 | |
38 | .text | |
13488b2e RH |
39 | .align 4 |
40 | .globl __brk | |
41 | .ent __brk | |
42 | .usepv __brk, std | |
43 | ||
44 | cfi_startproc | |
45 | __brk: | |
6932e444 | 46 | ldgp gp, 0(t12) |
13488b2e RH |
47 | subq sp, 16, sp |
48 | cfi_adjust_cfa_offset (16) | |
dd4b8913 | 49 | #ifdef PROF |
3c7b2587 | 50 | .set noat |
dd4b8913 UD |
51 | lda AT, _mcount |
52 | jsr AT, (AT), _mcount | |
3c7b2587 | 53 | .set at |
dd4b8913 | 54 | #endif |
6932e444 | 55 | |
c0fda13c UD |
56 | /* Save the requested brk across the system call. */ |
57 | stq a0, 0(sp) | |
58 | ||
939caadf | 59 | ldiq v0, __NR_brk |
6932e444 | 60 | call_pal PAL_callsys |
d6634820 | 61 | |
c0fda13c | 62 | ldq a0, 0(sp) |
13488b2e RH |
63 | addq sp, 16, sp |
64 | cfi_adjust_cfa_offset (-16) | |
c0fda13c | 65 | |
28c50ce9 | 66 | /* Be prepared for an OSF-style brk. */ |
13488b2e | 67 | bne a3, SYSCALL_ERROR_LABEL |
28c50ce9 UD |
68 | beq v0, $ok |
69 | ||
d6634820 RM |
70 | /* Correctly handle the brk(0) query case. */ |
71 | cmoveq a0, v0, a0 | |
28c50ce9 | 72 | xor a0, v0, t0 |
13488b2e RH |
73 | lda v0, ENOMEM |
74 | bne t0, SYSCALL_ERROR_LABEL | |
6932e444 RM |
75 | |
76 | /* Update __curbrk and return cleanly. */ | |
13488b2e | 77 | lda v0, 0 |
28c50ce9 | 78 | $ok: stq a0, __curbrk |
6932e444 RM |
79 | ret |
80 | ||
13488b2e RH |
81 | PSEUDO_END(__brk) |
82 | cfi_endproc | |
6932e444 RM |
83 | |
84 | weak_alias (__brk, brk) |