⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 brk.2

📁 早期freebsd实现
💻 2
字号:
.\" Copyright (c) 1980, 1991, 1993.\"	The Regents of the University of California.  All rights reserved..\".\" Redistribution and use in source and binary forms, with or without.\" modification, are permitted provided that the following conditions.\" are met:.\" 1. Redistributions of source code must retain the above copyright.\"    notice, this list of conditions and the following disclaimer..\" 2. Redistributions in binary form must reproduce the above copyright.\"    notice, this list of conditions and the following disclaimer in the.\"    documentation and/or other materials provided with the distribution..\" 3. All advertising materials mentioning features or use of this software.\"    must display the following acknowledgement:.\"	This product includes software developed by the University of.\"	California, Berkeley and its contributors..\" 4. Neither the name of the University nor the names of its contributors.\"    may be used to endorse or promote products derived from this software.\"    without specific prior written permission..\".\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION).\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF.\" SUCH DAMAGE..\".\"     @(#)brk.2	8.2 (Berkeley) 12/11/93.\".Dd December 11, 1993.Dt BRK 2.Os BSD 4.Sh NAME.Nm brk ,.Nm sbrk.Nd change data segment size.Sh SYNOPSIS.Fd #include <sys/types.h>.Ft char.Fn *brk "const char *addr".Ft char *.Fn *sbrk "int incr".Sh DESCRIPTION.Bf -symbolicThe brk and sbrk functions are historical curiositiesleft over from earlier days before the advent of virtual memory management..EfThe.Fn brkfunctionsets the break or lowest addressof a process's data segment (uninitialized data) to.Fa addr(immediately above bss).Data addressing is restricted between.Fa addrand the lowest stack pointer to the stack segment.Memory is allocated by.Fa brkin page size pieces;if.Fa addris not evenly divisible by the system page size, it isincreased 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 ..\" .PpThe current value of the program break is reliably returned by.Dq Li sbrk(0)(see also .Xr end 3 ) .The.Xr getrlimit 2system call may be used to determinethe maximum permissible size of the.Em datasegment;it will not be possible to set the breakbeyond the.Em rlim_maxvalue returned from a call to.Xr getrlimit ,e.g..Dq qetext + rlp\(->rlim_max.(see.Xr end 3for the definition of.Em etext ) ..Sh RETURN VALUES.Nm Brkreturns a pointer to the new end of memory if successful;otherwise -1 with.Va errnoset to indicate why the allocation failed.The.Nm sbrkreturns a pointer to the base of the new storage if successful;otherwise -1 with.Va errnoset to indicate why the allocation failed..Sh ERRORS.Xr Sbrkwill fail and no additional memory will be allocated ifone of the following are true:.Bl -tag -width [ENOMEM].It Bq Er ENOMEMThe limit, as set by.Xr setrlimit 2 ,was exceeded..It Bq Er ENOMEMThe maximum possible size of a data segment (compiled into thesystem) was exceeded..It Bq Er ENOMEMInsufficient space existed in the swap areato support the expansion..El.Sh SEE ALSO.Xr execve 2 ,.Xr getrlimit 2 ,.Xr malloc 3 ,.Xr end 3.Sh BUGSSetting the break may fail due to a temporary lack ofswap space.  It is not possible to distinguish thisfrom a failure caused by exceeding the maximum size ofthe data segment without consulting .Xr getrlimit ..Sh HISTORYA.Nmfunction call appeared in Version 7 AT&T UNIX.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -