Print this page
os/grow: define 'p' under the same ifdef as it's consumed


 482                 if (error == EAGAIN) {
 483                         cmn_err(CE_WARN, "Sorry, no swap space to grow stack "
 484                             "for pid %d (%s)", p->p_pid, PTOU(p)->u_comm);
 485                 }
 486                 return (error);
 487         }
 488         p->p_stksize = newsize;
 489         return (0);
 490 }
 491 
 492 /*
 493  * Find address for user to map.
 494  * If MAP_FIXED is not specified, we can pick any address we want, but we will
 495  * first try the value in *addrp if it is non-NULL.  Thus this is implementing
 496  * a way to try and get a preferred address.
 497  */
 498 int
 499 choose_addr(struct as *as, caddr_t *addrp, size_t len, offset_t off,
 500     int vacalign, uint_t flags)
 501 {

 502         proc_t *p = curproc;

 503         caddr_t basep = (caddr_t)(uintptr_t)((uintptr_t)*addrp & PAGEMASK);
 504         size_t lenp;
 505 
 506         ASSERT(AS_ISCLAIMGAP(as));      /* searches should be serialized */
 507 
 508         /*
 509          * If we have been provided a hint, we should still expand the lenp
 510          * to be the rest of the address space.  This will allow us to
 511          * treat the hint as a strong desire to be "nearby" the provided
 512          * address.  If we can't satisfy the hint, as_gap() will walk forward.
 513          */
 514         if (flags & _MAP_LOW32)
 515                 lenp = (caddr_t)USERLIMIT32 - basep;
 516 #if defined(__amd64)
 517         else if (p->p_model == DATAMODEL_NATIVE)
 518                 lenp = p->p_usrstack - basep -
 519                     ((p->p_stk_ctl + PAGEOFFSET) & PAGEMASK);
 520 #endif
 521         else
 522                 lenp = as->a_userlimit - basep;




 482                 if (error == EAGAIN) {
 483                         cmn_err(CE_WARN, "Sorry, no swap space to grow stack "
 484                             "for pid %d (%s)", p->p_pid, PTOU(p)->u_comm);
 485                 }
 486                 return (error);
 487         }
 488         p->p_stksize = newsize;
 489         return (0);
 490 }
 491 
 492 /*
 493  * Find address for user to map.
 494  * If MAP_FIXED is not specified, we can pick any address we want, but we will
 495  * first try the value in *addrp if it is non-NULL.  Thus this is implementing
 496  * a way to try and get a preferred address.
 497  */
 498 int
 499 choose_addr(struct as *as, caddr_t *addrp, size_t len, offset_t off,
 500     int vacalign, uint_t flags)
 501 {
 502 #if defined(__amd64)
 503         proc_t *p = curproc;
 504 #endif
 505         caddr_t basep = (caddr_t)(uintptr_t)((uintptr_t)*addrp & PAGEMASK);
 506         size_t lenp;
 507 
 508         ASSERT(AS_ISCLAIMGAP(as));      /* searches should be serialized */
 509 
 510         /*
 511          * If we have been provided a hint, we should still expand the lenp
 512          * to be the rest of the address space.  This will allow us to
 513          * treat the hint as a strong desire to be "nearby" the provided
 514          * address.  If we can't satisfy the hint, as_gap() will walk forward.
 515          */
 516         if (flags & _MAP_LOW32)
 517                 lenp = (caddr_t)USERLIMIT32 - basep;
 518 #if defined(__amd64)
 519         else if (p->p_model == DATAMODEL_NATIVE)
 520                 lenp = p->p_usrstack - basep -
 521                     ((p->p_stk_ctl + PAGEOFFSET) & PAGEMASK);
 522 #endif
 523         else
 524                 lenp = as->a_userlimit - basep;