blob: 18836ba594eb09da6bac3f12bf7eaec28d5f33c2 [file] [log] [blame]
yuezonghe824eb0c2024-06-27 02:32:26 -07001/*
2 * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
3 *
4 * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
5 */
6
7#include <errno.h>
8#include <unistd.h>
9#include <sys/syscall.h>
10
11libc_hidden_proto(brk)
12
13#define __NR___syscall_brk __NR_brk
14static inline _syscall1(void *, __syscall_brk, void *, end)
15
16/* This must be initialized data because commons can't have aliases. */
17void * __curbrk attribute_hidden = 0;
18
19int brk(void *addr)
20{
21 void *newbrk = __syscall_brk(addr);
22
23 __curbrk = newbrk;
24
25 if (newbrk < addr) {
26 __set_errno (ENOMEM);
27 return -1;
28 }
29
30 return 0;
31}
32libc_hidden_def(brk)