124 size_t size;
125 rlim64_t size_ctl;
126 rlim64_t vmem_ctl;
127
128 /*
129 * Find the segment with a virtual address
130 * greater than the end of the current break.
131 */
132 nextseg = NULL;
133 mutex_enter(&p->p_lock);
134 brkbase = (caddr_t)p->p_brkbase;
135 brkend = (caddr_t)p->p_brkbase + p->p_brksize;
136 mutex_exit(&p->p_lock);
137
138 /*
139 * Since we can't return less than the current break,
140 * initialize the return value to the current break
141 */
142 retval = (long)brkend;
143
144 AS_LOCK_ENTER(as, &as->a_lock, RW_READER);
145 for (seg = as_findseg(as, brkend, 0); seg != NULL;
146 seg = AS_SEGNEXT(as, seg)) {
147 if (seg->s_base >= brkend) {
148 nextseg = seg;
149 break;
150 }
151 }
152
153 mutex_enter(&p->p_lock);
154 size_ctl = rctl_enforced_value(rctlproc_legacy[RLIMIT_DATA],
155 p->p_rctls, p);
156 vmem_ctl = rctl_enforced_value(rctlproc_legacy[RLIMIT_VMEM],
157 p->p_rctls, p);
158 mutex_exit(&p->p_lock);
159
160 /*
161 * First, calculate the maximum break value based on
162 * the user's RLIMIT_DATA, but also taking into account
163 * that this value cannot be greater than as->a_userlimit.
164 * We also take care to make sure that we don't overflow
195 /*
196 * Large Files: The following assertion has to pass
197 * through to ensure the correctness of the cast.
198 */
199 ASSERT32(vmem_ctl <= UINT32_MAX);
200
201 size = (size_t)(vmem_ctl & PAGEMASK);
202
203 if (as->a_size < size)
204 size -= as->a_size;
205 else
206 size = 0;
207 /*
208 * Take care to not overflow the calculation
209 */
210 if (as->a_userlimit - brkendpg > size)
211 retval = MIN((size_t)retval,
212 (size_t)(brkendpg + size));
213 }
214
215 AS_LOCK_EXIT(as, &as->a_lock);
216
217 /* truncate to same boundary as sbrk */
218
219 switch (get_udatamodel()) {
220 default:
221 case DATAMODEL_ILP32:
222 retval = retval & ~(8-1);
223 break;
224 case DATAMODEL_LP64:
225 retval = retval & ~(16-1);
226 break;
227 }
228 break;
229 }
230
231 case UL_GDESLIM: /* Return approximate number of open files */
232 {
233 rlim64_t fdno_ctl;
234
235 mutex_enter(&curproc->p_lock);
|
124 size_t size;
125 rlim64_t size_ctl;
126 rlim64_t vmem_ctl;
127
128 /*
129 * Find the segment with a virtual address
130 * greater than the end of the current break.
131 */
132 nextseg = NULL;
133 mutex_enter(&p->p_lock);
134 brkbase = (caddr_t)p->p_brkbase;
135 brkend = (caddr_t)p->p_brkbase + p->p_brksize;
136 mutex_exit(&p->p_lock);
137
138 /*
139 * Since we can't return less than the current break,
140 * initialize the return value to the current break
141 */
142 retval = (long)brkend;
143
144 AS_LOCK_ENTER(as, RW_READER);
145 for (seg = as_findseg(as, brkend, 0); seg != NULL;
146 seg = AS_SEGNEXT(as, seg)) {
147 if (seg->s_base >= brkend) {
148 nextseg = seg;
149 break;
150 }
151 }
152
153 mutex_enter(&p->p_lock);
154 size_ctl = rctl_enforced_value(rctlproc_legacy[RLIMIT_DATA],
155 p->p_rctls, p);
156 vmem_ctl = rctl_enforced_value(rctlproc_legacy[RLIMIT_VMEM],
157 p->p_rctls, p);
158 mutex_exit(&p->p_lock);
159
160 /*
161 * First, calculate the maximum break value based on
162 * the user's RLIMIT_DATA, but also taking into account
163 * that this value cannot be greater than as->a_userlimit.
164 * We also take care to make sure that we don't overflow
195 /*
196 * Large Files: The following assertion has to pass
197 * through to ensure the correctness of the cast.
198 */
199 ASSERT32(vmem_ctl <= UINT32_MAX);
200
201 size = (size_t)(vmem_ctl & PAGEMASK);
202
203 if (as->a_size < size)
204 size -= as->a_size;
205 else
206 size = 0;
207 /*
208 * Take care to not overflow the calculation
209 */
210 if (as->a_userlimit - brkendpg > size)
211 retval = MIN((size_t)retval,
212 (size_t)(brkendpg + size));
213 }
214
215 AS_LOCK_EXIT(as);
216
217 /* truncate to same boundary as sbrk */
218
219 switch (get_udatamodel()) {
220 default:
221 case DATAMODEL_ILP32:
222 retval = retval & ~(8-1);
223 break;
224 case DATAMODEL_LP64:
225 retval = retval & ~(16-1);
226 break;
227 }
228 break;
229 }
230
231 case UL_GDESLIM: /* Return approximate number of open files */
232 {
233 rlim64_t fdno_ctl;
234
235 mutex_enter(&curproc->p_lock);
|