static bool_t xdrmblk_putint32(XDR *xdrs, int32_t *int32p) { mblk_t *m; /* LINTED pointer alignment */ m = (mblk_t *)xdrs->x_base; if (m == NULL) return (FALSE); if ((xdrs->x_handy -= (int)sizeof (int32_t)) < 0) { if (m->b_cont == NULL) { m->b_cont = xdrmblk_alloc((int)(uintptr_t) xdrs->x_private); } m = m->b_cont; xdrs->x_base = (caddr_t)m; if (m == NULL) { xdrs->x_handy = 0; return (FALSE); } xdrs->x_handy = (int)(m->b_datap->db_lim - m->b_rptr - sizeof (int32_t)); ASSERT(m->b_rptr == m->b_wptr); ASSERT(m->b_rptr >= m->b_datap->db_base); ASSERT(m->b_rptr < m->b_datap->db_lim); } /* LINTED pointer alignment */ *(int32_t *)m->b_wptr = htonl(*int32p); m->b_wptr += sizeof (int32_t); ASSERT(m->b_wptr <= m->b_datap->db_lim); return (TRUE); }
static bool_t xdrmblk_putint32(XDR *xdrs, int32_t *int32p) { mblk_t *m; struct xdrmblk_params *p; /* LINTED pointer alignment */ m = (mblk_t *)xdrs->x_base; if (m == NULL) return (FALSE); p = (struct xdrmblk_params *)xdrs->x_private; while (!IS_P2ALIGNED(m->b_wptr, sizeof (int32_t)) || xdrs->x_handy < sizeof (int32_t)) { if (m->b_cont == NULL) { ASSERT(p->sz >= sizeof (int32_t)); m->b_cont = xdrmblk_alloc(p->sz); } m = m->b_cont; xdrs->x_base = (caddr_t)m; p->apos += p->rpos; p->rpos = 0; if (m == NULL) { xdrs->x_handy = 0; return (FALSE); } xdrs->x_handy = (int)MBLKTAIL(m); ASSERT(m->b_rptr == m->b_wptr); ASSERT(m->b_rptr >= m->b_datap->db_base); ASSERT(m->b_rptr < m->b_datap->db_lim); } /* LINTED pointer alignment */ *(int32_t *)m->b_wptr = htonl(*int32p); m->b_wptr += sizeof (int32_t); xdrs->x_handy -= sizeof (int32_t); p->rpos += sizeof (int32_t); ASSERT(m->b_wptr <= m->b_datap->db_lim); return (TRUE); }
static bool_t xdrmblk_putbytes(XDR *xdrs, caddr_t addr, int len) { mblk_t *m; uint_t i; /* LINTED pointer alignment */ m = (mblk_t *)xdrs->x_base; if (m == NULL) return (FALSE); /* * Performance tweak: converted explicit bcopy() * call to simple in-line. This function is called * to process things like readdir reply filenames * which are small strings--typically 12 bytes or less. * Overhead of calling bcopy() is obnoxious for such * small copies. */ while ((xdrs->x_handy -= len) < 0) { if ((xdrs->x_handy += len) > 0) { if (xdrs->x_handy < XDRMBLK_BCOPY_LIMIT) { for (i = 0; i < (uint_t)xdrs->x_handy; i++) *m->b_wptr++ = *addr++; } else { bcopy(addr, m->b_wptr, xdrs->x_handy); m->b_wptr += xdrs->x_handy; addr += xdrs->x_handy; } len -= xdrs->x_handy; } /* * We don't have enough space, so allocate the * amount we need, or x_private, whichever is larger. * It is better to let the underlying transport divide * large chunks than to try and guess what is best. */ if (m->b_cont == NULL) m->b_cont = xdrmblk_alloc(MAX(len, (int)(uintptr_t)xdrs->x_private)); m = m->b_cont; xdrs->x_base = (caddr_t)m; if (m == NULL) { xdrs->x_handy = 0; return (FALSE); } xdrs->x_handy = (int)(m->b_datap->db_lim - m->b_rptr); ASSERT(m->b_rptr == m->b_wptr); ASSERT(m->b_rptr >= m->b_datap->db_base); ASSERT(m->b_rptr < m->b_datap->db_lim); } if (len < XDRMBLK_BCOPY_LIMIT) { for (i = 0; i < len; i++) *m->b_wptr++ = *addr++; } else { bcopy(addr, m->b_wptr, len); m->b_wptr += len; } ASSERT(m->b_wptr <= m->b_datap->db_lim); return (TRUE); }