Print this page
Code review comments from jeffpc
*** 120,130 ****
{
uintptr_t old_brk;
uintptr_t ret_brk;
uintptr_t high_brk;
uintptr_t new_brk;
! int brk_result;
if (!primary_link_map) {
errno = ENOTSUP;
return ((void *)-1);
}
--- 120,130 ----
{
uintptr_t old_brk;
uintptr_t ret_brk;
uintptr_t high_brk;
uintptr_t new_brk;
! intptr_t brk_result;
if (!primary_link_map) {
errno = ENOTSUP;
return ((void *)-1);
}
*** 136,148 ****
low_align = MAX(low_align, ALIGNSZ);
high_align = MAX(high_align, ALIGNSZ);
lmutex_lock(&__sbrk_lock);
! if (_nd == NULL) {
_nd = (void *)_brk_unlocked(0);
- }
old_brk = (uintptr_t)BRKALIGN(_nd);
ret_brk = P2ROUNDUP(old_brk, low_align);
high_brk = ret_brk + min_size;
new_brk = P2ROUNDUP(high_brk, high_align);
--- 136,147 ----
low_align = MAX(low_align, ALIGNSZ);
high_align = MAX(high_align, ALIGNSZ);
lmutex_lock(&__sbrk_lock);
! if (_nd == NULL)
_nd = (void *)_brk_unlocked(0);
old_brk = (uintptr_t)BRKALIGN(_nd);
ret_brk = P2ROUNDUP(old_brk, low_align);
high_brk = ret_brk + min_size;
new_brk = P2ROUNDUP(high_brk, high_align);
*** 154,164 ****
lmutex_unlock(&__sbrk_lock);
errno = ENOMEM;
return ((void *)-1);
}
! if ((brk_result = (int)_brk_unlocked((void *)new_brk)) == 0)
_nd = (void *)new_brk;
lmutex_unlock(&__sbrk_lock);
if (brk_result != 0)
return ((void *)-1);
--- 153,163 ----
lmutex_unlock(&__sbrk_lock);
errno = ENOMEM;
return ((void *)-1);
}
! if ((brk_result = _brk_unlocked((void *)new_brk)) == 0)
_nd = (void *)new_brk;
lmutex_unlock(&__sbrk_lock);
if (brk_result != 0)
return ((void *)-1);
*** 169,179 ****
}
int
brk(void *new_brk)
{
! int result;
/*
* brk(2) will return the current brk if given an argument of 0, so we
* need to fail it here
*/
--- 168,178 ----
}
int
brk(void *new_brk)
{
! intptr_t result;
/*
* brk(2) will return the current brk if given an argument of 0, so we
* need to fail it here
*/
*** 190,200 ****
* Need to align this here; _brk_unlocked won't do it for us.
*/
new_brk = BRKALIGN(new_brk);
lmutex_lock(&__sbrk_lock);
! if ((result = (int)_brk_unlocked(new_brk)) == 0)
_nd = new_brk;
lmutex_unlock(&__sbrk_lock);
return (result);
}
--- 189,199 ----
* Need to align this here; _brk_unlocked won't do it for us.
*/
new_brk = BRKALIGN(new_brk);
lmutex_lock(&__sbrk_lock);
! if ((result = _brk_unlocked(new_brk)) == 0)
_nd = new_brk;
lmutex_unlock(&__sbrk_lock);
return (result);
}