]> git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/unix/sysv/linux/sparc/sparc64/brk.S
Update.
[thirdparty/glibc.git] / sysdeps / unix / sysv / linux / sparc / sparc64 / brk.S
1 /* Copyright (C) 1997 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Richard Henderson <richard@gnu.ai.mit.edu>, 1997.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 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 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public
16 License along with the GNU C Library; see the file COPYING.LIB. If not,
17 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. */
19
20 /* __brk is a special syscall under Linux since it never returns an
21 error. Instead, the error condition is indicated by returning the old
22 break value (instead of the new, requested one). */
23
24 #include <sysdep.h>
25 #define _ERRNO_H
26 #include <bits/errno.h>
27
28 #ifdef PIC
29 .section .bss
30 .align 8
31 .globl __curbrk
32 __curbrk: .skip 8
33 .type __curbrk,@object
34 .size __curbrk,8
35 #else
36 .common __curbrk, 8, 8
37 #endif
38
39 .text
40 ENTRY(__brk)
41 save %sp, -192, %sp
42 #ifdef PIC
43 1: call 2f
44 sethi %hi(_GLOBAL_OFFSET_TABLE_-(1b-.)), %l7
45 2: or %l7, %lo(_GLOBAL_OFFSET_TABLE_-(1b-.)), %l7
46 add %l7, %o7, %l7
47 #endif
48
49 LOADSYSCALL(brk)
50 mov %i0, %o0
51
52 ta 0x6d
53
54 /* All the ways we can fail... */
55 bcs,pn %xcc, .Lerr1
56 nop
57 brz,pt %i0, .Lok
58 subcc %i0, %o0, %g0
59 bne,pn %xcc, .Lerr0
60 nop
61
62 /* Update __curbrk and return cleanly. */
63 .Lok: sethi %hi(__curbrk), %g1
64 or %g1, %lo(__curbrk), %g1
65 #ifdef PIC
66 ldx [%l7+%g1], %g1
67 #endif
68 stx %o0, [%g1]
69 mov %g0, %i0
70
71 /* Don't use "ret" cause the preprocessor will eat it. */
72 jmpl %i7+8, %g0
73 restore
74
75 /* What a horrible way to die. */
76 .Lerr0: set ENOMEM, %o0
77 .Lerr1:
78 #ifndef _LIBC_REENTRANT
79 sethi %hi(errno), %g1
80 or %g1, %lo(errno), %g1
81 #ifdef PIC
82 ldx [%l7+%g1], %g1
83 #endif
84 st %o0, [%g1]
85 #else
86 call __errno_location
87 mov %o0,%l1
88 st %l1, [%o0]
89 #endif
90 sub %g0, 1, %i0
91 jmpl %i7+8, %g0
92 restore
93
94 .size __brk, .-__brk
95
96 weak_alias (__brk, brk)