1995-12-03 10:00:22 +00:00
|
|
|
/* brk system call for Linux/i386.
|
2016-01-04 16:05:18 +00:00
|
|
|
Copyright (C) 1995-2016 Free Software Foundation, Inc.
|
1996-11-28 04:16:09 +00:00
|
|
|
This file is part of the GNU C Library.
|
|
|
|
|
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
2001-07-06 04:58:11 +00:00
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2.1 of the License, or (at your option) any later version.
|
1996-11-28 04:16:09 +00:00
|
|
|
|
|
|
|
The GNU C Library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
2001-07-06 04:58:11 +00:00
|
|
|
Lesser General Public License for more details.
|
1996-11-28 04:16:09 +00:00
|
|
|
|
2001-07-06 04:58:11 +00:00
|
|
|
You should have received a copy of the GNU Lesser General Public
|
2012-02-09 23:18:22 +00:00
|
|
|
License along with the GNU C Library; if not, see
|
|
|
|
<http://www.gnu.org/licenses/>. */
|
1995-12-03 10:00:22 +00:00
|
|
|
|
|
|
|
#include <errno.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <sysdep.h>
|
|
|
|
|
1996-05-27 20:43:56 +00:00
|
|
|
/* This must be initialized data because commons can't have aliases. */
|
|
|
|
void *__curbrk = 0;
|
1995-12-03 10:00:22 +00:00
|
|
|
|
1996-05-23 01:34:23 +00:00
|
|
|
/* Old braindamage in GCC's crtstuff.c requires this symbol in an attempt
|
|
|
|
to work around different old braindamage in the old Linux ELF dynamic
|
|
|
|
linker. */
|
|
|
|
weak_alias (__curbrk, ___brk_addr)
|
|
|
|
|
1995-12-03 10:00:22 +00:00
|
|
|
int
|
|
|
|
__brk (void *addr)
|
|
|
|
{
|
2003-01-09 04:19:03 +00:00
|
|
|
INTERNAL_SYSCALL_DECL (err);
|
2015-10-14 10:45:32 +00:00
|
|
|
void *newbrk = (void *) INTERNAL_SYSCALL (brk, err, 1, addr);
|
1995-12-03 10:00:22 +00:00
|
|
|
__curbrk = newbrk;
|
|
|
|
if (newbrk < addr)
|
2015-10-14 10:45:32 +00:00
|
|
|
return INLINE_SYSCALL_ERROR_RETURN_VALUE (ENOMEM);
|
1995-12-03 10:00:22 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
weak_alias (__brk, brk)
|