From owner-man-jp-reviewer@jp.freebsd.org  Sat Sep  8 14:51:53 2001
Received: (from daemon@localhost)
	by castle.jp.freebsd.org (8.9.3+3.2W/8.7.3) id OAA55502;
	Sat, 8 Sep 2001 14:51:53 +0900 (JST)
	(envelope-from owner-man-jp-reviewer@jp.FreeBSD.org)
Received: from smtp1.interramp.com (smtp1.interramp.com [38.8.45.2])
	by castle.jp.freebsd.org (8.9.3+3.2W/8.7.3) with ESMTP id OAA55497
	for <man-jp-reviewer@jp.freebsd.org>; Sat, 8 Sep 2001 14:51:52 +0900 (JST)
	(envelope-from horikawa@psinet.com)
Received: from [205.164.248.206] (helo=localhost)
	by smtp1.interramp.com with esmtp (Exim 1.90 #1)
	for man-jp-reviewer@jp.freebsd.org
	id 15fb1w-0003mF-00; Sat, 8 Sep 2001 01:51:48 -0400
Date: Sat, 08 Sep 2001 01:50:39 -0400 (EDT)
Message-Id: <20010908.015039.30185953.horikawa@psinet.com>
To: man-jp-reviewer@jp.freebsd.org
From: Kazuo Horikawa <horikawa@psinet.com>
X-Mailer: Mew version 2.0 on Emacs 20.7 / Mule 4.0 (HANANOEN)
Mime-Version: 1.0
Content-Type: Multipart/Mixed;
 boundary="--Next_Part(Sat_Sep__8_01:50:39_2001_172)--"
Content-Transfer-Encoding: 7bit
Reply-To: man-jp-reviewer@jp.freebsd.org
Precedence: list
X-Distribute: distribute version 2.1 (Alpha) patchlevel 24e+010328
X-Sequence: man-jp-reviewer 3782
Subject: [man-jp-reviewer 3782] brk.2 rev 1.13.2.8
Errors-To: owner-man-jp-reviewer@jp.freebsd.org
Sender: owner-man-jp-reviewer@jp.freebsd.org
X-Originator: horikawa@psinet.com

----Next_Part(Sat_Sep__8_01:50:39_2001_172)--
Content-Type: Text/Plain; charset=iso-2022-jp
Content-Transfer-Encoding: 7bit

$BKY@n$G$9!#(B

brk.2 rev 1.13.2.8 $B$X$N:9J,$G$9!#(B
$B86J8:9J,$bE:IU$7$^$7$?!#(B

$B$^$?!"<!$N=$@5$b9T$$$^$7$?!#(B
 o It will not be possible to set the break beyond
   ``etext+rlim.rlim_max'' where the rlim.rlim_max value is returned
   from a call to getrlimit(RLIMIT_DATA &rlim).
   $B$N$H$3$m$O!"85Lu$,8mLu$@$C$?$N$GD>$7$^$7$?!#(B
   where rlim.rlim_max value is ... $B$O!"D>A0$N<0$G;HMQ$5$l$F$$$k(B
   rlim.rlim_max $B$K$D$$$F$N@bL@!#(B
 o $B%G!<%?%;%0%a%s%H$N:GBg%5%$%:$r1[$($k$3$H$G5/$3$5$l$?>c32(B
   $B=}32(B -> $B<:GT(B 
   $B!V=}32!W$G$bNI$$$N$+$b$7$l$^$;$s$,!"(Bbrk.2 $BFb$NB>$N2U=j$G(B failure
   $B$r!V<:GT!W$H$7$F$$$k$N$G!"$=$A$i$K$"$o$;$^$7$?!#(B

--- brk.2~	Sun Sep  2 12:43:09 2001
+++ brk.2	Sat Sep  8 01:23:59 2001
@@ -30,10 +30,10 @@
 .\" SUCH DAMAGE.
 .\"
 .\"     @(#)brk.2	8.4 (Berkeley) 5/1/95
-.\" %FreeBSD: src/lib/libc/sys/brk.2,v 1.13.2.7 2001/08/31 10:15:15 ru Exp %
+.\" %FreeBSD: src/lib/libc/sys/brk.2,v 1.13.2.8 2001/09/07 07:59:13 yar Exp %
 .\"
 .\" $FreeBSD: doc/ja_JP.eucJP/man/man2/brk.2,v 1.7 2001/09/02 00:05:25 horikawa Exp $
-.Dd May 1, 1995
+.Dd July 12, 1999
 .Dt BRK 2
 .Os
 .Sh $BL>>N(B
@@ -50,81 +50,120 @@
 .Fn sbrk "int incr"
 .Sh $B2r@b(B
 .Bf -symbolic
-brk $B4X?t$H(B sbrk $B4X?t$O!"2>A[%a%b%j4IM}$NE~Mh$NA0$N=i4|$NF|!9$+$i;D$5$l$?(B
-$BNr;KE*$K6=L#$"$k$b$N$G$9!#(B
+.Fn brk
+$B4X?t$H(B
+.Fn sbrk
+$B4X?t$O!"8=BeE*$J2>A[%a%b%j4IM}$,8=$l$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($?$3$H$K5/0x$9$k(B
+$B<:GT$H6hJL$9$k$3$H$O$G$-$^$;$s!#(B
 .Sh $BNr;K(B
 .Fn brk
 $B4X?t$O(B
--
$BKY@nOBM:(B

----Next_Part(Sat_Sep__8_01:50:39_2001_172)--
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="brk.2.diff"

===================================================================
RCS file: /c/ncvs/src/lib/libc/sys/brk.2,v
retrieving revision 1.13.2.7
retrieving revision 1.13.2.8
diff -u -p -r1.13.2.7 -r1.13.2.8
--- src/lib/libc/sys/brk.2	2001/08/31 10:15:15	1.13.2.7
+++ src/lib/libc/sys/brk.2	2001/09/07 07:59:13	1.13.2.8
@@ -30,9 +30,9 @@
 .\" SUCH DAMAGE.
 .\"
 .\"     @(#)brk.2	8.4 (Berkeley) 5/1/95
-.\" $FreeBSD: /c/ncvs/src/lib/libc/sys/brk.2,v 1.13.2.7 2001/08/31 10:15:15 ru Exp $
+.\" $FreeBSD: /c/ncvs/src/lib/libc/sys/brk.2,v 1.13.2.8 2001/09/07 07:59:13 yar Exp $
 .\"
-.Dd May 1, 1995
+.Dd July 12, 1999
 .Dt BRK 2
 .Os
 .Sh NAME
@@ -49,96 +49,128 @@
 .Fn sbrk "int incr"
 .Sh DESCRIPTION
 .Bf -symbolic
-The brk and sbrk functions are historical curiosities
-left over from earlier days before the advent of virtual memory management.
+The
+.Fn brk
+and
+.Fn sbrk
+functions are legacy interfaces from before the
+advent of modern virtual memory management.
 .Ef
+.Pp
+The
+.Fn brk
+and
+.Fn sbrk
+functions are used to change the amount of memory allocated in a
+process's data segment.
+They do this by moving the location of the
+.Dq break .
+The break is the first address after the end of the process's
+uninitialized data segment (also known as the
+.Dq BSS ) .
+.Pp
 The
 .Fn brk
 function
-sets the break or lowest address
-of a process's data segment (uninitialized data) to
-.Fa addr
-(immediately above bss).
-Data addressing is restricted between
-.Fa addr
-and the lowest stack pointer to the stack segment.
-Memory is allocated by
-.Fa brk
-in page size pieces;
-if
-.Fa addr
-is not evenly divisible by the system page size, it is
-increased to the next page boundary.
-.Pp
-.\" The
-.\" .Nm sbrk
-.\" function
-.\" allocates chunks of
-.\" .Fa incr
-.\" bytes
-.\" to the process's data space
-.\" and returns an address pointer.
-.\" The
-.\" .Xr malloc 3
-.\" function utilizes
-.\" .Nm sbrk .
-.\" .Pp
-The current value of the program break is reliably returned by
-.Dq Li sbrk(0)
-(see also
-.Xr end 3 ) .
+sets the break to
+.Fa addr .
+.Pp
+The
+.Fn sbrk
+function raises the break by
+.Fa incr
+bytes, thus allocating at least
+.Fa incr
+bytes of new memory in the data segment.
+If
+.Fa incr
+is negative,
+the break is lowered by
+.Fa incr
+bytes.
+.Sh NOTES
+While the actual process data segment size maintained by the kernel will only
+grow or shrink in page sizes, these functions allow setting the break
+to unaligned values (i.e., it may point to any address inside the last
+page of the data segment).
+.Pp
+The current value of the program break may be determined by calling
+.Fn sbrk 0 .
+See also
+.Xr end 3 .
+.Pp
 The
 .Xr getrlimit 2
 system call may be used to determine
 the maximum permissible size of the
-.Em data
-segment;
-it will not be possible to set the break
-beyond the
-.Em rlim_max
-value returned from a call to
-.Xr getrlimit 2 ,
-e.g.\&
-.Dq Va etext No + Va rlp\->rlim_max .
+data segment.
+It will not be possible to set the break
+beyond
+.Dq Va etext No + Va rlim.rlim_max
+where the
+.Va rlim.rlim_max
+value is returned from a call to
+.Fn getrlimit RLIMIT_DATA &rlim .
 (See
 .Xr end 3
 for the definition of
 .Va etext ) .
 .Sh RETURN VALUES
-.Rv -std brk
+The
+.Fn brk
+function returns
+.Po Vt "char *" Pc Ns 0
+if successful;
+otherwise the value
+.Po Vt "char *" Pc Ns \-1
+is returned and the global variable
+.Va errno
+is set to indicate the error.
 .Pp
 The
 .Fn sbrk
-function returns a pointer to the base of the new storage if successful;
-otherwise the value \-1 is returned and the global variable
+function returns the prior break value if successful;
+otherwise the value
+.Po Vt "char *" Pc Ns \-1
+is returned and the global variable
 .Va errno
 is set to indicate the error.
 .Sh ERRORS
-.Fn Brk
+.Fn brk
 or
 .Fn sbrk
-will fail and no additional memory will be allocated if
-one of the following are true:
+will fail if:
 .Bl -tag -width Er
+.It Bq Er EINVAL
+The requested break value was beyond the beginning of the data segment.
 .It Bq Er ENOMEM
-The limit, as set by
+The data segment size limit, as set by
 .Xr setrlimit 2 ,
 was exceeded.
 .It Bq Er ENOMEM
-The maximum possible size of a data segment (compiled into the
-system) was exceeded.
-.It Bq Er ENOMEM
 Insufficient space existed in the swap area
-to support the expansion.
+to support the expansion of the data segment.
 .El
 .Sh SEE ALSO
 .Xr execve 2 ,
 .Xr getrlimit 2 ,
+.Xr mmap 2 ,
 .Xr end 3 ,
+.Xr free 3 ,
 .Xr malloc 3
 .Sh BUGS
+Mixing
+.Fn brk
+or
+.Fn sbrk
+with
+.Xr malloc 3 ,
+.Xr free 3 ,
+or similar functions will result in non-portable program behavior.
+.Pp
 Setting the break may fail due to a temporary lack of
-swap space.  It is not possible to distinguish this
+swap space.
+It is not possible to distinguish this
 from a failure caused by exceeding the maximum size of
 the data segment without consulting
 .Xr getrlimit 2 .

----Next_Part(Sat_Sep__8_01:50:39_2001_172)----
