summaryrefslogtreecommitdiffstats
path: root/usr/klibc/brk.c
blob: df0bb7bd9d1adae1d10d156cac1b585395e0cee2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/* brk.c - Change data segment size */

/* Written 2000 by Werner Almesberger */

#include <stddef.h>
#include <unistd.h>
#include <sys/types.h>
#include "malloc.h"

#if !_KLIBC_NO_MMU		/* uClinux doesn't have brk() */

char *__current_brk;

/*
 * The Linux brk() isn't what most people expect, so we call the
 * system call __brk() and provide a wrapper.
 */
int brk(void *end_data_segment)
{
	char *new_brk;

	new_brk = __brk(end_data_segment);
	if (new_brk != end_data_segment)
		return -1;
	__current_brk = new_brk;
	return 0;
}

#endif