• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ RNDUP函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中RNDUP函数的典型用法代码示例。如果您正苦于以下问题:C++ RNDUP函数的具体用法?C++ RNDUP怎么用?C++ RNDUP使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了RNDUP函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: do_mem_alloc

/*
 * Simple memory allocator, allocates aligned physical memory.
 * Note that startup_kernel() only allocates memory, never frees.
 * Memory usage just grows in an upward direction.
 */
static void *
do_mem_alloc(uint32_t size, uint32_t align)
{
	uint_t i;
	uint64_t best;
	uint64_t start;
	uint64_t end;

	/*
	 * make sure size is a multiple of pagesize
	 */
	size = RNDUP(size, MMU_PAGESIZE);
	next_avail_addr = RNDUP(next_avail_addr, align);

	/*
	 * XXPV fixme joe
	 *
	 * a really large bootarchive that causes you to run out of memory
	 * may cause this to blow up
	 */
	/* LINTED E_UNEXPECTED_UINT_PROMOTION */
	best = (uint64_t)-size;
	for (i = 0; i < memlists_used; ++i) {
		start = memlists[i].addr;
#if defined(__xpv)
		start += mfn_base;
#endif
		end = start + memlists[i].size;

		/*
		 * did we find the desired address?
		 */
		if (start <= next_avail_addr && next_avail_addr + size <= end) {
			best = next_avail_addr;
			goto done;
		}

		/*
		 * if not is this address the best so far?
		 */
		if (start > next_avail_addr && start < best &&
		    RNDUP(start, align) + size <= end)
			best = RNDUP(start, align);
	}

	/*
	 * We didn't find exactly the address we wanted, due to going off the
	 * end of a memory region. Return the best found memory address.
	 */
done:
	next_avail_addr = best + size;
#if defined(__xpv)
	if (next_avail_addr > scratch_end)
		dboot_panic("Out of mem next_avail: 0x%lx, scratch_end: "
		    "0x%lx", (ulong_t)next_avail_addr,
		    (ulong_t)scratch_end);
#endif
	(void) memset((void *)(uintptr_t)best, 0, size);
	return ((void *)(uintptr_t)best);
}
开发者ID:metricinc,项目名称:illumos-gate,代码行数:65,代码来源:dboot_startkern.c


示例2: PLListListImport

PPLLIST PLListListImport(PPLLIST pList, PPLLIST pImport, HNDPLLITEM hNode)
  {
  PPLLNODE pParent, pi;
  ULONG cb;
  INT i;
  char buffer[256];        // only for TRACE messages

  if ( !pList ) return NULL;
  // allocation needed for the current item
  cb = pImport->cbTot - sizeof(PLLIST);
  // if the current allocation size is not enough reallocate the list
  sprintf (buffer, "total (pList->cbTot): %ld, new item: %ld, pImport->cbTot: %ld sizeof(PLLIST): %ld", pList->cbTot, cb, pImport->cbTot, sizeof(PLLIST));
  TRACE1("%s", buffer);
  sprintf (buffer, "try to reallocate %ld (0x%X),cb: %ld", RNDUP(pList->cbTot + cb, pList->cbGrow), RNDUP(pList->cbTot + cb, pList->cbGrow), cb );
  TRACE1("%s", buffer);
  TRACE2("sizeof(pList) %d (0x%X)", sizeof(pList), sizeof(pList));
  TRACE2("pointer to pList before realloc: 0x%X, pImport: 0x%X", pList, pImport);
  if ( (RNDUP(pList->cbTot, pList->cbGrow) >= (pList->cbTot + cb)) ||
       (NULL != (pList =
                 realloc(pList, RNDUP(pList->cbTot + cb, pList->cbGrow)))) )
    {
    TRACE1("pList after realloc 0x%X", pList);
    pi = (PPLLNODE)((PBYTE)pList + pList->cbTot);
    // get the address of the parent node
    pParent = PNODEFROMHITEM(pList, hNode);
    TRACE1("pParent 0x%X", pParent);
    PREVITEM(pList, pParent)->offNext = pList->cbTot;
    pParent->offLast = pList->cbTot;
    // copy the data from the previous list to the current list
    memcpy(pi, (PBYTE)pImport + sizeof(PLLIST), cb);
    // update the offsets
    pParent->count += pImport->count;
    TRACE1("pParent->count %ld", pParent->count);
    for ( i = 0, cb = pList->cbTot - sizeof(PLLIST); i < pImport->count; ++i )
      {
      if ( pi->offNext )
        {
        pi->offNext += cb;
        }
      else
        {
        pParent->offLast = (HNDPLLITEM)((PBYTE)pi - (PBYTE)pList);
        } /* endif */
      // if the current item is a node
      if ( pi->isNode )
        {
        updateImpListOffsets((PPLLIST)((PBYTE)pList + cb), pi, cb);
        pi->offFirst += cb;
        pi->offLast  += cb;
        pi->offParent = hNode;
        } /* endif */
      pi = (PPLLNODE)NEXTITEM(pList, pi);
      } /* endfor */
    pList->cbTot += pImport->cbTot - sizeof(PLLIST);
    TRACE1("pList->cbTot %ld", pList->cbTot);
    } /* endif */
  TRACE1("pList after realloc 0x%X", pList);
  return pList;
  }
开发者ID:OS2World,项目名称:UTIL-FILE-DataSeeker,代码行数:59,代码来源:PLList.c


示例3: svcauth_gss_validate

static bool_t
svcauth_gss_validate(struct svc_req *rqst, struct svc_rpc_gss_data *gd, struct rpc_msg *msg)
{
	struct opaque_auth	*oa;
	gss_buffer_desc		 rpcbuf, checksum;
	OM_uint32		 maj_stat, min_stat, qop_state;
	u_char			 rpchdr[128];
	int32_t			*buf;

	log_debug("in svcauth_gss_validate()");

	memset(rpchdr, 0, sizeof(rpchdr));

	/* XXX - Reconstruct RPC header for signing (from xdr_callmsg). */
	oa = &msg->rm_call.cb_cred;
	if (oa->oa_length > MAX_AUTH_BYTES)
		return (FALSE);

	/* 8 XDR units from the IXDR macro calls. */
	if (sizeof(rpchdr) < (8 * BYTES_PER_XDR_UNIT +
			      RNDUP(oa->oa_length)))
		return (FALSE);

	buf = (int32_t *)(void *)rpchdr;
	IXDR_PUT_LONG(buf, msg->rm_xid);
	IXDR_PUT_ENUM(buf, msg->rm_direction);
	IXDR_PUT_LONG(buf, msg->rm_call.cb_rpcvers);
	IXDR_PUT_LONG(buf, msg->rm_call.cb_prog);
	IXDR_PUT_LONG(buf, msg->rm_call.cb_vers);
	IXDR_PUT_LONG(buf, msg->rm_call.cb_proc);
	IXDR_PUT_ENUM(buf, oa->oa_flavor);
	IXDR_PUT_LONG(buf, oa->oa_length);
	if (oa->oa_length) {
		memcpy((caddr_t)buf, oa->oa_base, oa->oa_length);
		buf += RNDUP(oa->oa_length) / sizeof(int32_t);
	}
	rpcbuf.value = rpchdr;
	rpcbuf.length = (u_char *)buf - rpchdr;

	checksum.value = msg->rm_call.cb_verf.oa_base;
	checksum.length = msg->rm_call.cb_verf.oa_length;

	maj_stat = gss_verify_mic(&min_stat, gd->ctx, &rpcbuf, &checksum,
				  &qop_state);

	if (maj_stat != GSS_S_COMPLETE) {
		log_status("gss_verify_mic", maj_stat, min_stat);
		if (log_badverf != NULL)
			(*log_badverf)(gd->client_name,
			       svcauth_gss_name,
			       rqst, msg, log_badverf_data);
		return (FALSE);
	}
	return (TRUE);
}
开发者ID:Akasurde,项目名称:krb5,代码行数:55,代码来源:svc_auth_gss.c


示例4: PLListExport

PPLLIST PLListExport(PPLLIST pList, HNDPLLITEM hNode,
                     BOOL inclNode, ULONG cbGrow)
  {
  PPLLIST pnew, p;
  ULONG cbTot;
  PPLLNODE pnode, pn;
  // check the cbGrow parameter
  if ( !cbGrow ) cbGrow = pList->cbGrow;
  // if hNode is 0 just duplicate the list
  if ( !hNode )
    {
    if ( NULL != (pnew = malloc(RNDUP(pList->cbTot, cbGrow))) )
      {
      memcpy(pnew, pList, pList->cbTot);
      pnew->cbGrow = cbGrow;
      } /* endif */
    pnew;
    } /* endif */
  // calculate the size of the allocation needed for the new list
  cbTot = sizeof(PLLIST);
  pnode = PNODEFROMHITEM(pList, hNode);
  // size of the current node (if requested)
  if ( inclNode ) cbTot += pnode->offFirst - hNode;
  // total size of the node content
  for ( pn = pnode; !pn->offNext; pn = PNODEFROMHITEM(pList, pn->offParent) ) ;
  cbTot += pn->offNext - pnode->offFirst;
  // allocate the new list
  if ( NULL != (pnew = malloc(RNDUP(cbTot, cbGrow))) )
    {
    pnew->cbTot = cbTot;
    pnew->offFirst = sizeof(PLLIST);
    pnew->offParent = 0;
    pnew->cbGrow = cbGrow;
    if ( inclNode )
      {
      memcpy((PBYTE)pnew + sizeof(PLLIST), pnode, cbTot - sizeof(PLLIST));
      pnew->count = 1;
      pnew->offLast = pnew->offFirst;
      updateExpListOffsets(pnew, (PPLLNODE)pnew,
                           hNode - sizeof(PLLIST));
      }
    else
      {
      memcpy((PBYTE)pnew + sizeof(PLLIST), FIRSTITEM(pList, pnode),
             cbTot - sizeof(PLLIST));
      pnew->count = pnode->count;
      pnew->offLast = pnode->offLast - pnode->offFirst + sizeof(PLLIST);
      updateExpListOffsets(pnew, (PPLLNODE)pnew,
                           pnode->offFirst - sizeof(PLLIST));
      } /* endif */
    } /* endif */
  return pnew;
  }
开发者ID:OS2World,项目名称:UTIL-FILE-DataSeeker,代码行数:53,代码来源:PLList.c


示例5: fix_buf_size

static u_int
fix_buf_size(u_int s)
{
	if (s < 100)
		s = 4000;
	return (RNDUP(s));
}
开发者ID:marayl,项目名称:openxdr,代码行数:7,代码来源:xdr_rec.c


示例6: xdrmblk_control

static bool_t
xdrmblk_control(XDR *xdrs, int request, void *info)
{
	mblk_t *m;
	int32_t *int32p;
	int len;

	switch (request) {
	case XDR_PEEK:
		/*
		 * Return the next 4 byte unit in the XDR stream.
		 */
		if (xdrs->x_handy < sizeof (int32_t))
			return (FALSE);

		/* LINTED pointer alignment */
		m = (mblk_t *)xdrs->x_base;
		if (m == NULL)
			return (FALSE);

		/*
		 * If the pointer is not aligned, fail the peek
		 */
		if (!IS_P2ALIGNED(m->b_rptr, sizeof (int32_t)))
			return (FALSE);

		int32p = (int32_t *)info;
		/* LINTED pointer alignment */
		*int32p = ntohl(*((int32_t *)(m->b_rptr)));
		return (TRUE);

	case XDR_SKIPBYTES:
		/* LINTED pointer alignment */
		m = (mblk_t *)xdrs->x_base;
		if (m == NULL)
			return (FALSE);
		int32p = (int32_t *)info;
		len = RNDUP((int)(*int32p));
		if (len < 0)
			return (FALSE);
		while ((xdrs->x_handy -= len) < 0) {
			if ((xdrs->x_handy += len) > 0) {
				m->b_rptr += xdrs->x_handy;
				len -= xdrs->x_handy;
			}
			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_wptr - m->b_rptr);
		}
		m->b_rptr += len;
		return (TRUE);

	default:
		return (FALSE);
	}
}
开发者ID:MatiasNAmendola,项目名称:AuroraUX-SunOS,代码行数:60,代码来源:xdr_mblk.c


示例7: check_higher

/*
 * During memory allocation, find the highest address not used yet.
 */
static void
check_higher(paddr_t a)
{
	if (a < next_avail_addr)
		return;
	next_avail_addr = RNDUP(a + 1, MMU_PAGESIZE);
	DBG(next_avail_addr);
}
开发者ID:metricinc,项目名称:illumos-gate,代码行数:11,代码来源:dboot_startkern.c


示例8: fix_buf_size

static unsigned
fix_buf_size(
	register unsigned s)
{

	if (s < 100)
		s = 4000;
	return (RNDUP(s));
}
开发者ID:khallock,项目名称:LDM,代码行数:9,代码来源:xdr_rec.c


示例9: heapIncrease

static void* heapIncrease(Heap_t uhp, size_t* plen, int* pfl)
  {
  PVOID p = NULL;
  *plen = (size_t)RNDUP(*plen, CB_HEAPBLOCK);
  *pfl = !_BLOCK_CLEAN;
  logwrite("increaseHeap  -                    size : %8u\n", *plen, 0);
  if ( DosSubAllocMem(pbasemem, &p, *plen) )
    return NULL;
  return p;
  }
开发者ID:OS2World,项目名称:UTIL-FILE-DataSeeker,代码行数:10,代码来源:memmgr.c


示例10: PLListDup

PPLLIST PLListDup(PPLLIST pList, ULONG cb)
  {
  PPLLIST plist;
  if ( pList && !cb )
    cb = RNDUP(pList->cbTot, pList->cbGrow);
  TRACE1("allocate %d bytes", cb);
  if ( NULL != (plist = malloc(cb)) )
    {
    if ( pList ) memcpy(plist, pList, pList->cbTot);
    } /* endif */
  return plist;
  }
开发者ID:OS2World,项目名称:UTIL-FILE-DataSeeker,代码行数:12,代码来源:PLList.c


示例11: __svcauth_sys

/*
 * System (Unix) longhand authenticator
 */
enum auth_stat
__svcauth_sys(struct svc_req *rqst, struct rpc_msg *msg)
{
	struct authsys_parms *aup;
	int32_t *buf;
	struct authsys_area *area;
	uint_t auth_len;
	uint_t str_len, gid_len;
	int i;

	/* LINTED pointer cast */
	area = (struct authsys_area *)rqst->rq_clntcred;
	aup = &area->area_aup;
	aup->aup_machname = area->area_machname;
	aup->aup_gids = area->area_gids;
	auth_len = msg->rm_call.cb_cred.oa_length;
	if (auth_len == 0)
		return (AUTH_BADCRED);

	/* LINTED pointer cast */
	buf = (int32_t *)msg->rm_call.cb_cred.oa_base;

	aup->aup_time = IXDR_GET_INT32(buf);
	str_len = IXDR_GET_U_INT32(buf);
	if (str_len > MAX_MACHINE_NAME)
		return (AUTH_BADCRED);
	(void) memcpy(aup->aup_machname, buf, str_len);
	aup->aup_machname[str_len] = 0;
	str_len = RNDUP(str_len);
	buf += str_len / (int)sizeof (int32_t);
	aup->aup_uid = IXDR_GET_INT32(buf);
	aup->aup_gid = IXDR_GET_INT32(buf);
	gid_len = IXDR_GET_U_INT32(buf);
	if (gid_len > NGRPS)
		return (AUTH_BADCRED);
	aup->aup_len = gid_len;
	for (i = 0; i < gid_len; i++) {
		aup->aup_gids[i] = (gid_t)IXDR_GET_INT32(buf);
	}
	/*
	 * five is the smallest unix credentials structure -
	 * timestamp, hostname len (0), uid, gid, and gids len (0).
	 */
	if ((5 + gid_len) * BYTES_PER_XDR_UNIT + str_len > auth_len)
		return (AUTH_BADCRED);

	rqst->rq_xprt->xp_verf.oa_flavor = AUTH_NULL;
	rqst->rq_xprt->xp_verf.oa_length = 0;

	return (AUTH_OK);
}
开发者ID:jimklimov,项目名称:illumos-gate,代码行数:54,代码来源:svc_auth_sys.c


示例12: PLListNodeAdd

PPLLIST PLListNodeAdd(PPLLIST pList, HNDPLLITEM hNode, PHNDPLLITEM pNode,
                      PPLLISTADDITEM pFunc, PVOID pParm)
  {
  PPLLNODE pParent, pi;
  ULONG cbItem;
  size_t stSize;
  char buffer[128];

  if ( !pList || !pFunc ) return NULL;
  // allocation needed for the current item
  cbItem = pFunc(NULL, pParm) + sizeof(PLLNODE);
  // if the current allocation size is not enough reallocate the list
  stSize = RNDUP(pList->cbTot + cbItem, pList->cbGrow);
  sprintf (buffer, "new size to allocate %ld, total: %ld, item: %ld", stSize, pList->cbTot, cbItem);
  TRACE1("%s", buffer);
  if ( (RNDUP(pList->cbTot, pList->cbGrow) >= (pList->cbTot + cbItem)) ||
       (NULL != (pList =
                 realloc(pList, stSize ))) )
    {
    TRACE1("pList after realloc: 0x%X", pList);
    pi = (PPLLNODE)((PBYTE)pList + pList->cbTot);
    if ( pNode ) *pNode = pList->cbTot;
    // get the address of the parent node
    pParent = PNODEFROMHITEM(pList, hNode);
    PREVITEM(pList, pParent)->offNext = pList->cbTot;
    pParent->offLast = pList->cbTot;
    pi->offFirst = (pList->cbTot += cbItem);
    pi->offNext = 0;
    pi->isNode = 1;
    pi->offLast = 0;
    pi->offParent = (ULONG)hNode;
    pi->count = 0;
    // set the item data via the callback procedure
    pFunc(pi + 1, pParm);
    pParent->count++;             // update the items count
    } /* endif */
  return pList;
  }
开发者ID:OS2World,项目名称:UTIL-FILE-DataSeeker,代码行数:38,代码来源:PLList.c


示例13: PLListItemAdd

PPLLIST PLListItemAdd(PPLLIST pList, HNDPLLITEM hNode, PHNDPLLITEM phItem,
                      PPLLISTADDITEM pFunc, PVOID pParm)
  {
  PPLLNODE pParent;
  ULONG cbItem;
  PPLLITEM pi;
  if ( !pList || !pFunc ) return NULL;
  // allocation needed for the current item
  cbItem = pFunc(NULL, pParm) + sizeof(PLLITEM);
  // if the current allocation size is not enough reallocate the list
  if ( RNDUP(pList->cbTot, pList->cbGrow) < RNDUP(pList->cbTot + cbItem, pList->cbGrow) )
    {
    TRACE("reallocating");
    TRACE2("pList->cbTot: %ld, cbItem: %ld", pList->cbTot, cbItem);
    pList = realloc(pList, RNDUP(pList->cbTot + cbItem, pList->cbGrow));
    TRACE("reallocating OKAY");
    }
  if ( pList )
    {
    pi = (PPLLITEM)((PBYTE)pList + pList->cbTot);
    if ( phItem ) *phItem = pList->cbTot;
    // get the address of the parent node
    pParent = PNODEFROMHITEM(pList, hNode);
    PREVITEM(pList, pParent)->offNext = pList->cbTot;
    pParent->offLast = pList->cbTot;
    pList->cbTot += cbItem;
    pi->offNext = 0;
    pi->isNode = 0;
    // set the other item data via the callback procedure
    pFunc(pi + 1, pParm);
    pParent->count++;             // update the items count
    } /* endif */
  if ( pList == NULL )
    {
    TRACE("ERROR: reallocate");
    }
  return pList;
  }
开发者ID:OS2World,项目名称:UTIL-FILE-DataSeeker,代码行数:38,代码来源:PLList.c


示例14: svcauth_gss_validate

static int
svcauth_gss_validate(struct svc_req *req,
		     struct svc_rpc_gss_data *gd,
		     struct rpc_msg *msg)
{
	struct opaque_auth *oa;
	gss_buffer_desc rpcbuf, checksum;
	OM_uint32 maj_stat, min_stat, qop_state;
	u_char rpchdr[RPCHDR_LEN];
	int32_t *buf;

	memset(rpchdr, 0, RPCHDR_LEN);

	/* XXX - Reconstruct RPC header for signing (from xdr_callmsg). */
	oa = &msg->rm_call.cb_cred;
	if (oa->oa_length > MAX_AUTH_BYTES)
		return GSS_S_CALL_BAD_STRUCTURE;
	/* XXX since MAX_AUTH_BYTES is 400, the following code trivially
	 * overruns (up to 431 per Coverity, but compare RPCHDR_LEN with
	 * what is marshalled below). */

	buf = (int32_t *) rpchdr;
	IXDR_PUT_LONG(buf, msg->rm_xid);
	IXDR_PUT_ENUM(buf, msg->rm_direction);
	IXDR_PUT_LONG(buf, msg->rm_call.cb_rpcvers);
	IXDR_PUT_LONG(buf, msg->rm_call.cb_prog);
	IXDR_PUT_LONG(buf, msg->rm_call.cb_vers);
	IXDR_PUT_LONG(buf, msg->rm_call.cb_proc);
	IXDR_PUT_ENUM(buf, oa->oa_flavor);
	IXDR_PUT_LONG(buf, oa->oa_length);
	if (oa->oa_length) {
		memcpy((caddr_t) buf, oa->oa_base, oa->oa_length);
		buf += RNDUP(oa->oa_length) / sizeof(int32_t);
	}
	rpcbuf.value = rpchdr;
	rpcbuf.length = (u_char *) buf - rpchdr;

	checksum.value = msg->rm_call.cb_verf.oa_base;
	checksum.length = msg->rm_call.cb_verf.oa_length;

	maj_stat =
	    gss_verify_mic(&min_stat, gd->ctx, &rpcbuf, &checksum, &qop_state);

	if (maj_stat != GSS_S_COMPLETE) {
		__warnx(TIRPC_DEBUG_FLAG_AUTH, "%s: %d %d", __func__, maj_stat,
			min_stat);
		return (maj_stat);
	}
	return GSS_S_COMPLETE;
}
开发者ID:nfs-ganesha,项目名称:ntirpc,代码行数:50,代码来源:svc_auth_gss.c


示例15: PLListNew

PPLLIST PLListNew(ULONG cbGrow)
  {
  PPLLIST pList;
  if ( !cbGrow ) cbGrow = SLPL_DEFCBGROW;
  if ( NULL != (pList = malloc(RNDUP(sizeof(PLLIST), cbGrow))) )
    {
    pList->isNode = 1;
    pList->offLast = pList->cbTot = pList->offFirst = sizeof(PLLIST);
    pList->offParent = pList->count = 0;
    pList->cbGrow = cbGrow;
    TRACE4("addr=0x%X, size requested=%d, actual size=%d, pList->count=%d", pList, cbGrow, RNDUP(sizeof(PLLIST), cbGrow), pList->count );
    return pList;
    } /* endif */
  return NULL;
  }
开发者ID:OS2World,项目名称:UTIL-FILE-DataSeeker,代码行数:15,代码来源:PLList.c


示例16: xdr_fastfhandle

bool_t
xdr_fastfhandle(XDR *xdrs, fhandle_t **fh)
{
	int32_t *ptr;

	if (xdrs->x_op != XDR_DECODE)
		return (FALSE);

	ptr = XDR_INLINE(xdrs, RNDUP(sizeof (fhandle_t)));
	if (ptr != NULL) {
		*fh = (fhandle_t *)ptr;
		return (TRUE);
	}

	return (FALSE);
}
开发者ID:libkeiser,项目名称:illumos-nexenta,代码行数:16,代码来源:nfs_xdr.c


示例17: xdrmem_control

static bool_t
xdrmem_control(XDR *xdrs, int request, void *info)
{
	xdr_bytesrec *xptr;
	int32_t *l;
	int len;

	switch (request) {

	case XDR_GET_BYTES_AVAIL:
		xptr = (xdr_bytesrec *)info;
		xptr->xc_is_last_record = TRUE;
		xptr->xc_num_avail = xdrs->x_handy;
		return (TRUE);

	case XDR_PEEK:
		/*
		 * Return the next 4 byte unit in the XDR stream.
		 */
		if (xdrs->x_handy < sizeof (int32_t))
			return (FALSE);
		l = (int32_t *)info;
		*l = (int32_t)ntohl((uint32_t)
		    (*((int32_t *)(xdrs->x_private))));
		return (TRUE);

	case XDR_SKIPBYTES:
		/*
		 * Skip the next N bytes in the XDR stream.
		 */
		l = (int32_t *)info;
		len = RNDUP((int)(*l));
		if (xdrs->x_handy < len)
			return (FALSE);
		xdrs->x_handy -= len;
		xdrs->x_private = (char *)xdrs->x_private + len;
		return (TRUE);

	}
	return (FALSE);
}
开发者ID:dcui,项目名称:FreeBSD-9.3_kernel,代码行数:41,代码来源:xdr_mem.c


示例18: calc_length

uint_t
calc_length(uint_t len)
{
	len = RNDUP(len);

	if (len <= 64 * 1024) {
		if (len > 32 * 1024) {
			len = 64 * 1024;
		} else {
			if (len > 16 * 1024) {
				len = 32 * 1024;
			} else {
				if (len > 8 * 1024) {
					len = 16 * 1024;
				} else {
					len = 8 * 1024;
				}
			}
		}
	}
	return (len);
}
开发者ID:MatiasNAmendola,项目名称:AuroraUX-SunOS,代码行数:22,代码来源:clnt_rdma.c


示例19: xdr_fhandle

/*
 * File access handle
 * The fhandle struct is treated a opaque data on the wire
 */
bool_t
xdr_fhandle(XDR *xdrs, fhandle_t *fh)
{
	int32_t *ptr;
	int32_t *fhp;

	if (xdrs->x_op == XDR_FREE)
		return (TRUE);

	ptr = XDR_INLINE(xdrs, RNDUP(sizeof (fhandle_t)));
	if (ptr != NULL) {
		fhp = (int32_t *)fh;
		if (xdrs->x_op == XDR_DECODE) {
			*fhp++ = *ptr++;
			*fhp++ = *ptr++;
			*fhp++ = *ptr++;
			*fhp++ = *ptr++;
			*fhp++ = *ptr++;
			*fhp++ = *ptr++;
			*fhp++ = *ptr++;
			*fhp = *ptr;
		} else {
			*ptr++ = *fhp++;
			*ptr++ = *fhp++;
			*ptr++ = *fhp++;
			*ptr++ = *fhp++;
			*ptr++ = *fhp++;
			*ptr++ = *fhp++;
			*ptr++ = *fhp++;
			*ptr = *fhp;
		}
		return (TRUE);
	}

	return (xdr_opaque(xdrs, (caddr_t)fh, NFS_FHSIZE));
}
开发者ID:libkeiser,项目名称:illumos-nexenta,代码行数:40,代码来源:nfs_xdr.c


示例20: xdr_callmsg

/*
 * XDR a call message
 */
bool_t
xdr_callmsg(XDR *xdrs, struct rpc_msg *cmsg)
{
	rpc_inline_t *buf;
	struct opaque_auth *oa;

	if (xdrs->x_op == XDR_ENCODE) {
		if (cmsg->rm_call.cb_cred.oa_length > MAX_AUTH_BYTES)
			return (FALSE);
		if (cmsg->rm_call.cb_verf.oa_length > MAX_AUTH_BYTES)
			return (FALSE);
		buf = XDR_INLINE(xdrs, 8 * BYTES_PER_XDR_UNIT
			+ RNDUP(cmsg->rm_call.cb_cred.oa_length)
			+ 2 * BYTES_PER_XDR_UNIT
			+ RNDUP(cmsg->rm_call.cb_verf.oa_length));
		if (buf != NULL) {
			IXDR_PUT_INT32(buf, cmsg->rm_xid);
			IXDR_PUT_ENUM(buf, cmsg->rm_direction);
			if (cmsg->rm_direction != CALL)
				return (FALSE);
			IXDR_PUT_INT32(buf, cmsg->rm_call.cb_rpcvers);
			if (cmsg->rm_call.cb_rpcvers != RPC_MSG_VERSION)
				return (FALSE);
			IXDR_PUT_INT32(buf, cmsg->rm_call.cb_prog);
			IXDR_PUT_INT32(buf, cmsg->rm_call.cb_vers);
			IXDR_PUT_INT32(buf, cmsg->rm_call.cb_proc);
			oa = &cmsg->rm_call.cb_cred;
			IXDR_PUT_ENUM(buf, oa->oa_flavor);
			IXDR_PUT_INT32(buf, oa->oa_length);
			if (oa->oa_length) {
				(void) memcpy(buf, oa->oa_base, oa->oa_length);
				buf += RNDUP(oa->oa_length) / sizeof (int32_t);
			}
			oa = &cmsg->rm_call.cb_verf;
			IXDR_PUT_ENUM(buf, oa->oa_flavor);
			IXDR_PUT_INT32(buf, oa->oa_length);
			if (oa->oa_length) {
				(void) memcpy(buf, oa->oa_base, oa->oa_length);
				/*
				 * no real need....
				 * buf += RNDUP(oa->oa_length) / sizeof
				 * (int32_t);
				 */
			}
			return (TRUE);
		}
	}
	if (xdrs->x_op == XDR_DECODE) {
		buf = XDR_INLINE(xdrs, 8 * BYTES_PER_XDR_UNIT);
		if (buf != NULL) {
			cmsg->rm_xid = IXDR_GET_INT32(buf);
			cmsg->rm_direction = IXDR_GET_ENUM(buf, enum msg_type);
			if (cmsg->rm_direction != CALL)
				return (FALSE);
			cmsg->rm_call.cb_rpcvers = IXDR_GET_INT32(buf);
			if (cmsg->rm_call.cb_rpcvers != RPC_MSG_VERSION)
				return (FALSE);
			cmsg->rm_call.cb_prog = IXDR_GET_INT32(buf);
			cmsg->rm_call.cb_vers = IXDR_GET_INT32(buf);
			cmsg->rm_call.cb_proc = IXDR_GET_INT32(buf);
			oa = &cmsg->rm_call.cb_cred;
			oa->oa_flavor = IXDR_GET_ENUM(buf, enum_t);
			oa->oa_length = IXDR_GET_INT32(buf);
			if (oa->oa_length) {
				if (oa->oa_length > MAX_AUTH_BYTES)
					return (FALSE);
				if (oa->oa_base == NULL) {
					oa->oa_base = malloc(oa->oa_length);
					if (oa->oa_base == NULL) {
						syslog(LOG_ERR,
							"xdr_callmsg : "
							"out of memory.");
						return (FALSE);
					}
				}
				buf = XDR_INLINE(xdrs, RNDUP(oa->oa_length));
				if (buf == NULL) {
					if (xdr_opaque(xdrs, oa->oa_base,
					    oa->oa_length) == FALSE)
						return (FALSE);
				} else {
					(void) memcpy(oa->oa_base,
					    buf, (size_t)oa->oa_length);
					/*
					 * no real need....
					 * buf += RNDUP(oa->oa_length) /
					 *	(int)sizeof (int32_t);
					 */
				}
			}
			oa = &cmsg->rm_call.cb_verf;
			buf = XDR_INLINE(xdrs, 2 * BYTES_PER_XDR_UNIT);
			if (buf == NULL) {
				if (xdr_enum(xdrs, &oa->oa_flavor) == FALSE ||
				    xdr_u_int(xdrs, &oa->oa_length) == FALSE)
					return (FALSE);
			} else {
//.........这里部分代码省略.........
开发者ID:BjoKaSH,项目名称:mac-zfs,代码行数:101,代码来源:rpc_callmsg.c



注:本文中的RNDUP函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ RND_RAND函数代码示例发布时间:2022-05-30
下一篇:
C++ RND函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap