]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/unix/sysv/linux/i386/brk.c
Update copyright notices with scripts/update-copyrights
[thirdparty/glibc.git] / sysdeps / unix / sysv / linux / i386 / brk.c
CommitLineData
683158e0 1/* brk system call for Linux/i386.
d4697bc9 2 Copyright (C) 1995-2014 Free Software Foundation, Inc.
c6645251
UD
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
41bdb6e2
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.
c6645251
UD
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
41bdb6e2 13 Lesser General Public License for more details.
c6645251 14
41bdb6e2 15 You should have received a copy of the GNU Lesser General Public
59ba27a6
PE
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
683158e0
RM
18
19#include <errno.h>
20#include <unistd.h>
21#include <sysdep.h>
22
2a4dcf76
RM
23/* This must be initialized data because commons can't have aliases. */
24void *__curbrk = 0;
683158e0 25
e685238c
RM
26/* Old braindamage in GCC's crtstuff.c requires this symbol in an attempt
27 to work around different old braindamage in the old Linux ELF dynamic
28 linker. */
29weak_alias (__curbrk, ___brk_addr)
30
683158e0
RM
31int
32__brk (void *addr)
33{
70d9946a 34 void *newbrk;
df45b31e 35
6aca81bb 36 INTERNAL_SYSCALL_DECL (err);
70d9946a 37 newbrk = (void *) INTERNAL_SYSCALL (brk, err, 1, addr);
683158e0
RM
38
39 __curbrk = newbrk;
40
41 if (newbrk < addr)
42 {
c4029823 43 __set_errno (ENOMEM);
683158e0
RM
44 return -1;
45 }
46
47 return 0;
48}
49weak_alias (__brk, brk)