|
Packit |
6c4009 |
/* Copyright (C) 1993-2018 Free Software Foundation, Inc.
|
|
Packit |
6c4009 |
This file is part of the GNU C Library.
|
|
Packit |
6c4009 |
Contributed by Brendan Kehoe <brendan@zen.org>, 1993.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
The GNU C Library is free software; you can redistribute it and/or
|
|
Packit |
6c4009 |
modify it under the terms of the GNU Lesser General Public
|
|
Packit |
6c4009 |
License as published by the Free Software Foundation; either
|
|
Packit |
6c4009 |
version 2.1 of the License, or (at your option) any later version.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
The GNU C Library is distributed in the hope that it will be useful,
|
|
Packit |
6c4009 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
6c4009 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
6c4009 |
Lesser General Public License for more details.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
You should have received a copy of the GNU Lesser General Public
|
|
Packit |
6c4009 |
License along with the GNU C Library. If not, see
|
|
Packit |
6c4009 |
<http://www.gnu.org/licenses/>. */
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* __brk is a special syscall under Linux since it never returns an
|
|
Packit |
6c4009 |
error. Instead, the error condition is indicated by returning the old
|
|
Packit |
6c4009 |
break value (instead of the new, requested one). */
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#include <sysdep.h>
|
|
Packit |
6c4009 |
#define _ERRNO_H
|
|
Packit |
6c4009 |
#include <bits/errno.h>
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#ifdef PIC
|
|
Packit |
6c4009 |
.section .bss
|
|
Packit |
6c4009 |
.align 3
|
|
Packit |
6c4009 |
.globl __curbrk
|
|
Packit |
6c4009 |
__curbrk: .skip 8
|
|
Packit |
6c4009 |
.type __curbrk,@object
|
|
Packit |
6c4009 |
.size __curbrk,8
|
|
Packit |
6c4009 |
#else
|
|
Packit |
6c4009 |
.comm __curbrk, 8
|
|
Packit |
6c4009 |
#endif
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
.text
|
|
Packit |
6c4009 |
.align 4
|
|
Packit |
6c4009 |
.globl __brk
|
|
Packit |
6c4009 |
.ent __brk
|
|
Packit |
6c4009 |
.usepv __brk, std
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
cfi_startproc
|
|
Packit |
6c4009 |
__brk:
|
|
Packit |
6c4009 |
ldgp gp, 0(t12)
|
|
Packit |
6c4009 |
subq sp, 16, sp
|
|
Packit |
6c4009 |
cfi_adjust_cfa_offset (16)
|
|
Packit |
6c4009 |
#ifdef PROF
|
|
Packit |
6c4009 |
.set noat
|
|
Packit |
6c4009 |
lda AT, _mcount
|
|
Packit |
6c4009 |
jsr AT, (AT), _mcount
|
|
Packit |
6c4009 |
.set at
|
|
Packit |
6c4009 |
#endif
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Save the requested brk across the system call. */
|
|
Packit |
6c4009 |
stq a0, 0(sp)
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
ldiq v0, __NR_brk
|
|
Packit |
6c4009 |
call_pal PAL_callsys
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
ldq a0, 0(sp)
|
|
Packit |
6c4009 |
addq sp, 16, sp
|
|
Packit |
6c4009 |
cfi_adjust_cfa_offset (-16)
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Be prepared for an OSF-style brk. */
|
|
Packit |
6c4009 |
bne a3, SYSCALL_ERROR_LABEL
|
|
Packit |
6c4009 |
beq v0, $ok
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Correctly handle the brk(0) query case. */
|
|
Packit |
6c4009 |
cmoveq a0, v0, a0
|
|
Packit |
6c4009 |
xor a0, v0, t0
|
|
Packit |
6c4009 |
lda v0, ENOMEM
|
|
Packit |
6c4009 |
bne t0, SYSCALL_ERROR_LABEL
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Update __curbrk and return cleanly. */
|
|
Packit |
6c4009 |
lda v0, 0
|
|
Packit |
6c4009 |
$ok: stq a0, __curbrk
|
|
Packit |
6c4009 |
ret
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
PSEUDO_END(__brk)
|
|
Packit |
6c4009 |
cfi_endproc
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
weak_alias (__brk, brk)
|