1BRK(2) 386BSD Programmer's Manual BRK(2) 2 3NNAAMMEE 4 bbrrkk, ssbbrrkk - change data segment size 5 6SSYYNNOOPPSSIISS 7 ##iinncclluuddee <<ssyyss//ttyyppeess..hh>> 8 9 _c_h_a_r 10 **bbrrkk(_c_o_n_s_t _c_h_a_r *_a_d_d_r) 11 12 _c_h_a_r * 13 **ssbbrrkk(_i_n_t _i_n_c_r) 14 15DDEESSCCRRIIPPTTIIOONN 16 TThhee bbrrkk aanndd ssbbrrkk ffuunnccttiioonnss aarree hhiissttoorriiccaall ccuurriioossiittiieess lleefftt oovveerr ffrroomm 17 eeaarrlliieerr ddaayyss bbeeffoorree tthhee aaddvveenntt ooff vviirrttuuaall mmeemmoorryy mmaannaaggeemmeenntt.. The bbrrkk() 18 function sets the break or lowest address of a process's data segment 19 (unilitialized data) to _a_d_d_r (immediately above bss). Data addressing is 20 restricted between _a_d_d_r and the lowest stack pointer to the stack 21 segment. Memory is allocated by _b_r_k in page size pieces; if _a_d_d_r is not 22 evenly divisible by the system page size, it is increased to the next 23 page boundary. 24 25 The current value of the program break is reliably returned by 26 ``sbrk(0)'' (see also end(3)). The getrlimit(2) system call may be used 27 to determine the maximum permissible size of the _d_a_t_a segment; it will 28 not be possible to set the break beyond the _r_l_i_m__m_a_x value returned from 29 a call to getrlimit, e.g. ``qetext + rlp->rlim_max.'' (see end(3) for 30 the definition of _e_t_e_x_t). 31 32RREETTUURRNN VVAALLUUEESS 33 BBrrkk returns 0 if successful; -1 if the process requests more memory than 34 than allowed by the system limit. The ssbbrrkk function returns 0 if 35 successful, otherwise the error EOPNOTSUPP is returned. 36 37SSEEEE AALLSSOO 38 execve(2), getrlimit(2), malloc(3), end(3) 39 40BBUUGGSS 41 Setting the break may fail due to a temporary lack of swap space. It is 42 not possible to distinguish this from a failure caused by exceeding the 43 maximum size of the data segment without consulting getrlimit. 44 45HHIISSTTOORRYY 46 A bbrrkk function call appeared in Version 7 AT&T UNIX. 47 484th Berkeley Distribution March 10, 1991 1 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67