-.\" Copyright (c) 1993 Michael Haardt
-.\" (michael@moria.de),
+.\" Copyright (c) 1993 Michael Haardt, (michael@moria.de)
+.\" and Copyright 2006, 2008, Michael Kerrisk <tmk.manpages@gmail.com>
.\" Fri Apr 2 11:32:09 MET DST 1993
.\"
.\" %%%LICENSE_START(GPLv2+_DOC_FULL)
.\" Modified Wed Jul 21 19:52:58 1993 by Rik Faith <faith@cs.unc.edu>
.\" Modified Sun Aug 21 17:40:38 1994 by Rik Faith <faith@cs.unc.edu>
.\"
-.TH BRK 2 2015-07-23 "Linux" "Linux Programmer's Manual"
+.TH BRK 2 2016-03-15 "Linux" "Linux Programmer's Manual"
.SH NAME
brk, sbrk \- change data segment size
.SH SYNOPSIS
.B #include <unistd.h>
-.sp
+.PP
.BI "int brk(void *" addr );
-.sp
+.PP
.BI "void *sbrk(intptr_t " increment );
-.sp
+.PP
.in -4n
Feature Test Macro Requirements for glibc (see
.BR feature_test_macros (7)):
.in
-.sp
+.PP
.BR brk (),
.BR sbrk ():
.ad l
.RS 4
.PD 0
.TP 4
-Since glibc 2.12:
+Since glibc 2.19:
+.nf
+_DEFAULT_SOURCE ||
+ (_XOPEN_SOURCE\ >=\ 500) &&
+.\" (_XOPEN_SOURCE\ >=\ 500 ||
+.\" _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED) &&
+ ! (_POSIX_C_SOURCE\ >=\ 200112L)
+.fi
+.TP 4
+From glibc 2.12 to 2.19:
.nf
_BSD_SOURCE || _SVID_SOURCE ||
- (_XOPEN_SOURCE\ >=\ 500 ||
- _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED) &&
- ! (_POSIX_C_SOURCE\ >=\ 200112L || _XOPEN_SOURCE\ >=\ 600)
+ (_XOPEN_SOURCE\ >=\ 500) &&
+.\" (_XOPEN_SOURCE\ >=\ 500 ||
+.\" _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED) &&
+ ! (_POSIX_C_SOURCE\ >=\ 200112L)
.fi
.TP 4
Before glibc 2.12:
-_BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE\ >=\ 500 ||
- _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED
+_BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE\ >=\ 500
+.\" || _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED
.PD
.RE
.ad b
Increasing the program break has the effect of
allocating memory to the process;
decreasing the break deallocates memory.
-
+.PP
.BR brk ()
sets the end of the data segment to the value specified by
.IR addr ,
when that value is reasonable, the system has enough memory,
and the process does not exceed its maximum data size (see
.BR setrlimit (2)).
-
+.PP
.BR sbrk ()
increments the program's data space by
.I increment
.I errno
is set to
.BR ENOMEM .
-
+.PP
On success,
.BR sbrk ()
returns the previous program break.
.BR malloc (3)
memory allocation package is the
portable and comfortable way of allocating memory.
-
+.PP
Various systems use various types for the argument of
.BR sbrk ().
Common are \fIint\fP, \fIssize_t\fP, \fIptrdiff_t\fP, \fIintptr_t\fP.
(i.e., checks whether the new break is less than
.IR addr )
to provide the 0 and \-1 return values described above.
-
+.PP
On Linux,
.BR sbrk ()
is implemented as a library function that uses the