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

C++ RT_ALIGN_Z函数代码示例

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

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



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

示例1: RT_ALIGN_Z

RTCString::printfOutputCallback(void *pvArg, const char *pachChars, size_t cbChars)
{
    RTCString *pThis = (RTCString *)pvArg;
    if (cbChars)
    {
        size_t cchBoth = pThis->m_cch + cbChars;
        if (cchBoth >= pThis->m_cbAllocated)
        {
            /* Double the buffer size, if it's less that _4M. Align sizes like
               for append. */
            size_t cbAlloc = RT_ALIGN_Z(pThis->m_cbAllocated, IPRT_MINISTRING_APPEND_ALIGNMENT);
            cbAlloc += RT_MIN(cbAlloc, _4M);
            if (cbAlloc <= cchBoth)
                cbAlloc = RT_ALIGN_Z(cchBoth + 1, IPRT_MINISTRING_APPEND_ALIGNMENT);
            pThis->reserve(cbAlloc);
#ifndef RT_EXCEPTIONS_ENABLED
            AssertReleaseReturn(pThis->capacity() > cchBoth, 0);
#endif
        }

        memcpy(&pThis->m_psz[pThis->m_cch], pachChars, cbChars);
        pThis->m_cch = cchBoth;
        pThis->m_psz[cchBoth] = '\0';
    }
    return cbChars;
}
开发者ID:stefano-garzarella,项目名称:virtualbox-org-svn-vbox-trunk,代码行数:26,代码来源:ministring.cpp


示例2: rtAsn1DefaultAllocator_AlignSize

/**
 * Aligns allocation sizes a little.
 *
 * @returns Aligned size.
 * @param   cb                  Requested size.
 */
static size_t rtAsn1DefaultAllocator_AlignSize(size_t cb)
{
    if (cb >= 64)
        return RT_ALIGN_Z(cb, 64);
    if (cb >= 32)
        return RT_ALIGN_Z(cb, 32);
    if (cb >= 16)
        return RT_ALIGN_Z(cb, 16);
    return cb;
}
开发者ID:jeppeter,项目名称:vbox,代码行数:16,代码来源:asn1-default-allocator.cpp


示例3: RTDECL

RTDECL(int) RTUtf16ReallocTag(PRTUTF16 *ppwsz, size_t cbNew, const char *pszTag)
{
    PRTUTF16 pwszOld = *ppwsz;
    cbNew = RT_ALIGN_Z(cbNew, sizeof(RTUTF16));
    if (!cbNew)
    {
        RTMemFree(pwszOld);
        *ppwsz = NULL;
    }
    else if (pwszOld)
    {
        PRTUTF16 pwszNew = (PRTUTF16)RTMemReallocTag(pwszOld, cbNew, pszTag);
        if (!pwszNew)
            return VERR_NO_STR_MEMORY;
        pwszNew[cbNew / sizeof(RTUTF16) - 1] = '\0';
        *ppwsz = pwszNew;
    }
    else
    {
        PRTUTF16 pwszNew = (PRTUTF16)RTMemAllocTag(cbNew, pszTag);
        if (!pwszNew)
            return VERR_NO_UTF16_MEMORY;
        pwszNew[0] = '\0';
        pwszNew[cbNew / sizeof(RTUTF16) - 1] = '\0';
        *ppwsz = pwszNew;
    }
    return VINF_SUCCESS;
}
开发者ID:svn2github,项目名称:virtualbox,代码行数:28,代码来源:utf-16.cpp


示例4: RTR0DECL

/**
 * Frees memory allocated using RTMemContAlloc().
 *
 * @param   pv      Pointer to return from RTMemContAlloc().
 * @param   cb      The cb parameter passed to RTMemContAlloc().
 */
RTR0DECL(void) RTMemContFree(void *pv, size_t cb)
{
    if (pv)
    {
        int             cOrder;
        unsigned        cPages;
        unsigned        iPage;
        struct page    *paPages;
        IPRT_LINUX_SAVE_EFL_AC();

        /* validate */
        AssertMsg(!((uintptr_t)pv & PAGE_OFFSET_MASK), ("pv=%p\n", pv));
        Assert(cb > 0);

        /* calc order and get pages */
        cb = RT_ALIGN_Z(cb, PAGE_SIZE);
        cPages = cb >> PAGE_SHIFT;
        cOrder = CalcPowerOf2Order(cPages);
        paPages = virt_to_page(pv);

        /*
         * Restore page attributes freeing the pages.
         */
        for (iPage = 0; iPage < cPages; iPage++)
        {
            ClearPageReserved(&paPages[iPage]);
#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 4, 20) /** @todo find the exact kernel where change_page_attr was introduced. */
            MY_SET_PAGES_NOEXEC(&paPages[iPage], 1);
#endif
        }
        __free_pages(paPages, cOrder);
        IPRT_LINUX_RESTORE_EFL_AC();
    }
}
开发者ID:ailispaw,项目名称:vboxguest,代码行数:40,代码来源:alloc-r0drv-linux.c


示例5: DECLHIDDEN

/**
 * OS specific allocation function.
 */
DECLHIDDEN(int) rtR0MemAllocEx(size_t cb, uint32_t fFlags, PRTMEMHDR *ppHdr)
{
    size_t      cbAllocated = cb;
    PRTMEMHDR   pHdr;

#ifdef RT_ARCH_AMD64
    if (fFlags & RTMEMHDR_FLAG_EXEC)
    {
        AssertReturn(!(fFlags & RTMEMHDR_FLAG_ANY_CTX), NULL);
        cbAllocated = RT_ALIGN_Z(cb + sizeof(*pHdr), PAGE_SIZE) - sizeof(*pHdr);
        pHdr = (PRTMEMHDR)segkmem_alloc(heaptext_arena, cbAllocated + sizeof(*pHdr), KM_SLEEP);
    }
    else
#endif
    {
        unsigned fKmFlags = fFlags & RTMEMHDR_FLAG_ANY_CTX_ALLOC ? KM_NOSLEEP : KM_SLEEP;
        if (fFlags & RTMEMHDR_FLAG_ZEROED)
            pHdr = (PRTMEMHDR)kmem_zalloc(cb + sizeof(*pHdr), fKmFlags);
        else
            pHdr = (PRTMEMHDR)kmem_alloc(cb + sizeof(*pHdr), fKmFlags);
    }
    if (RT_UNLIKELY(!pHdr))
    {
        LogRel(("rtMemAllocEx(%u, %#x) failed\n", (unsigned)cb + sizeof(*pHdr), fFlags));
        return VERR_NO_MEMORY;
    }

    pHdr->u32Magic  = RTMEMHDR_MAGIC;
    pHdr->fFlags    = fFlags;
    pHdr->cb        = cbAllocated;
    pHdr->cbReq     = cb;

    *ppHdr = pHdr;
    return VINF_SUCCESS;
}
开发者ID:mutoso-mirrors,项目名称:vbox,代码行数:38,代码来源:alloc-r0drv-solaris.c


示例6: DECLCALLBACK

/**
 * @interface_method_impl{TXSTRANSPORT,pfnSendPkt}
 */
static DECLCALLBACK(int) txsTcpSendPkt(PCTXSPKTHDR pPktHdr)
{
    Assert(pPktHdr->cb >= sizeof(TXSPKTHDR));

    /*
     * Fail if no client connection.
     */
    RTSOCKET hTcpClient = g_hTcpClient;
    if (hTcpClient == NIL_RTSOCKET)
        return VERR_NET_NOT_CONNECTED;

    /*
     * Write it.
     */
    size_t cbToSend = RT_ALIGN_Z(pPktHdr->cb, TXSPKT_ALIGNMENT);
    int rc = RTTcpWrite(hTcpClient, pPktHdr, cbToSend);
    if (    RT_FAILURE(rc)
        &&  rc != VERR_INTERRUPTED)
    {
        /* assume fatal connection error. */
        Log(("RTTcpWrite -> %Rrc -> txsTcpDisconnectClient(%RTsock)\n", rc, g_hTcpClient));
        txsTcpDisconnectClient();
    }

    return rc;
}
开发者ID:sobomax,项目名称:virtualbox_64bit_edd,代码行数:29,代码来源:TestExecServiceTcp.cpp


示例7: RT_ALIGN_Z

static void *alloc_bounce_buffer(size_t *tmp_sizep, PRTCCPHYS physp, size_t
                                 xfer_size, const char *caller)
{
    size_t tmp_size;
    void *tmp;

    /* try for big first. */
    tmp_size = RT_ALIGN_Z(xfer_size, PAGE_SIZE);
    if (tmp_size > 16U*_1K)
        tmp_size = 16U*_1K;
    tmp = kmalloc(tmp_size, GFP_KERNEL);
    if (!tmp)
    {
        /* fall back on a page sized buffer. */
        tmp = kmalloc(PAGE_SIZE, GFP_KERNEL);
        if (!tmp)
        {
            LogRel(("%s: could not allocate bounce buffer for xfer_size=%zu %s\n", caller, xfer_size));
            return NULL;
        }
        tmp_size = PAGE_SIZE;
    }

    *tmp_sizep = tmp_size;
    *physp = virt_to_phys(tmp);
    return tmp;
}
开发者ID:carmark,项目名称:vbox,代码行数:27,代码来源:regops.c


示例8: RTDECL

RTDECL(void *) RTHeapOffsetAllocZ(RTHEAPOFFSET hHeap, size_t cb, size_t cbAlignment)
{
    PRTHEAPOFFSETINTERNAL pHeapInt = hHeap;
    PRTHEAPOFFSETBLOCK pBlock;

    /*
     * Validate and adjust the input.
     */
    AssertPtrReturn(pHeapInt, NULL);
    if (cb < RTHEAPOFFSET_MIN_BLOCK)
        cb = RTHEAPOFFSET_MIN_BLOCK;
    else
        cb = RT_ALIGN_Z(cb, RTHEAPOFFSET_ALIGNMENT);
    if (!cbAlignment)
        cbAlignment = RTHEAPOFFSET_ALIGNMENT;
    else
    {
        Assert(!(cbAlignment & (cbAlignment - 1)));
        Assert((cbAlignment & ~(cbAlignment - 1)) == cbAlignment);
        if (cbAlignment < RTHEAPOFFSET_ALIGNMENT)
            cbAlignment = RTHEAPOFFSET_ALIGNMENT;
    }

    /*
     * Do the allocation.
     */
    pBlock = rtHeapOffsetAllocBlock(pHeapInt, cb, cbAlignment);
    if (RT_LIKELY(pBlock))
    {
        void *pv = pBlock + 1;
        memset(pv, 0, cb);
        return pv;
    }
    return NULL;
}
开发者ID:jeppeter,项目名称:vbox,代码行数:35,代码来源:heapoffset.cpp


示例9: AssertReturn

RTCString &RTCString::appendCodePoint(RTUNICP uc)
{
    /*
     * Single byte encoding.
     */
    if (uc < 0x80)
        return RTCString::append((char)uc);

    /*
     * Multibyte encoding.
     * Assume max encoding length when resizing the string, that's simpler.
     */
    AssertReturn(uc <= UINT32_C(0x7fffffff), *this);

    if (m_cch + 6 >= m_cbAllocated)
    {
        reserve(RT_ALIGN_Z(m_cch + 6 + 1, IPRT_MINISTRING_APPEND_ALIGNMENT));
        // calls realloc(cbBoth) and sets m_cbAllocated; may throw bad_alloc.
#ifndef RT_EXCEPTIONS_ENABLED
        AssertRelease(capacity() > m_cch + 6);
#endif
    }

    char *pszNext = RTStrPutCp(&m_psz[m_cch], uc);
    m_cch = pszNext - m_psz;
    *pszNext = '\0';

    return *this;
}
开发者ID:stefano-garzarella,项目名称:virtualbox-org-svn-vbox-trunk,代码行数:29,代码来源:ministring.cpp


示例10: rtEnvCreate

/**
 * Internal worker that creates an environment handle with a specified capacity.
 *
 * @returns IPRT status code.
 * @param   ppIntEnv        Where to store the result.
 * @param   cAllocated      The initial array size.
 * @param   fCaseSensitive  Whether the environment block is case sensitive or
 *                          not.
 * @param   fPutEnvBlock    Indicates whether this is a special environment
 *                          block that will be used to record change another
 *                          block.  We will keep unsets in putenv format, i.e.
 *                          just the variable name without any equal sign.
 */
static int rtEnvCreate(PRTENVINTERNAL *ppIntEnv, size_t cAllocated, bool fCaseSensitive, bool fPutEnvBlock)
{
    /*
     * Allocate environment handle.
     */
    PRTENVINTERNAL pIntEnv = (PRTENVINTERNAL)RTMemAlloc(sizeof(*pIntEnv));
    if (pIntEnv)
    {
        /*
         * Pre-allocate the variable array.
         */
        pIntEnv->u32Magic = RTENV_MAGIC;
        pIntEnv->fPutEnvBlock = fPutEnvBlock;
        pIntEnv->pfnCompare = fCaseSensitive ? RTStrNCmp : RTStrNICmp;
        pIntEnv->papszEnvOtherCP = NULL;
        pIntEnv->cVars = 0;
        pIntEnv->cAllocated = RT_ALIGN_Z(RT_MAX(cAllocated, RTENV_GROW_SIZE), RTENV_GROW_SIZE);
        pIntEnv->papszEnv = (char **)RTMemAllocZ(sizeof(pIntEnv->papszEnv[0]) * pIntEnv->cAllocated);
        if (pIntEnv->papszEnv)
        {
            *ppIntEnv = pIntEnv;
            return VINF_SUCCESS;
        }

        RTMemFree(pIntEnv);
    }

    return VERR_NO_MEMORY;
}
开发者ID:stefano-garzarella,项目名称:virtualbox-org-svn-vbox-trunk,代码行数:42,代码来源:env-generic.cpp


示例11: DECLHIDDEN

DECLHIDDEN(int) rtMemAllocEx16BitReach(size_t cbAlloc, uint32_t fFlags, void **ppv)
{
    cbAlloc = RT_ALIGN_Z(cbAlloc, PAGE_SIZE);
    AssertReturn(cbAlloc <= _64K - PAGE_SIZE, VERR_NO_MEMORY);

    /* Seems this doesn't work on W7/64... */
    return rtMemAllocExInRange(cbAlloc, fFlags, ppv, PAGE_SIZE, _64K - cbAlloc);
}
开发者ID:jeppeter,项目名称:vbox,代码行数:8,代码来源:allocex-win.cpp


示例12: dbgfR3TraceEnable

/**
 * Initializes the tracing.
 *
 * @returns VBox status code
 * @param   pVM         The cross context VM structure.
 * @param   cbEntry     The trace entry size.
 * @param   cEntries    The number of entries.
 */
static int dbgfR3TraceEnable(PVM pVM, uint32_t cbEntry, uint32_t cEntries)
{
    /*
     * Don't enable it twice.
     */
    if (pVM->hTraceBufR3 != NIL_RTTRACEBUF)
        return VERR_ALREADY_EXISTS;

    /*
     * Resolve default parameter values.
     */
    int rc;
    if (!cbEntry)
    {
        rc = CFGMR3QueryU32Def(CFGMR3GetChild(CFGMR3GetRoot(pVM), "DBGF"), "TraceBufEntrySize", &cbEntry, 128);
        AssertRCReturn(rc, rc);
    }
    if (!cEntries)
    {
        rc = CFGMR3QueryU32Def(CFGMR3GetChild(CFGMR3GetRoot(pVM), "DBGF"), "TraceBufEntries", &cEntries, 4096);
        AssertRCReturn(rc, rc);
    }

    /*
     * Figure the required size.
     */
    RTTRACEBUF  hTraceBuf;
    size_t      cbBlock = 0;
    rc = RTTraceBufCarve(&hTraceBuf, cEntries, cbEntry, 0 /*fFlags*/, NULL, &cbBlock);
    if (rc != VERR_BUFFER_OVERFLOW)
    {
        AssertReturn(!RT_SUCCESS_NP(rc), VERR_IPE_UNEXPECTED_INFO_STATUS);
        return rc;
    }

    /*
     * Allocate a hyper heap block and carve a trace buffer out of it.
     *
     * Note! We ASSUME that the returned trace buffer handle has the same value
     *       as the heap block.
     */
    cbBlock = RT_ALIGN_Z(cbBlock, PAGE_SIZE);
    void *pvBlock;
    rc = MMR3HyperAllocOnceNoRel(pVM, cbBlock, PAGE_SIZE, MM_TAG_DBGF, &pvBlock);
    if (RT_FAILURE(rc))
        return rc;

    rc = RTTraceBufCarve(&hTraceBuf, cEntries, cbEntry, 0 /*fFlags*/, pvBlock, &cbBlock);
    AssertRCReturn(rc, rc);
    AssertRelease(hTraceBuf == (RTTRACEBUF)pvBlock);
    AssertRelease((void *)hTraceBuf == pvBlock);

    pVM->hTraceBufR3 = hTraceBuf;
    pVM->hTraceBufR0 = MMHyperCCToR0(pVM, hTraceBuf);
    pVM->hTraceBufRC = MMHyperCCToRC(pVM, hTraceBuf);
    return VINF_SUCCESS;
}
开发者ID:svn2github,项目名称:virtualbox,代码行数:65,代码来源:DBGFR3Trace.cpp


示例13: vboxfuseNodeAlloc

/**
 * Allocates a new node and initialize the node part of it.
 *
 * The returned node has one reference.
 *
 * @returns VBox status code.
 *
 * @param   cbNode      The size of the node.
 * @param   pszName     The name of the node.
 * @param   enmType     The node type.
 * @param   pDir        The directory (parent).
 * @param   ppNode      Where to return the pointer to the node.
 */
static int vboxfuseNodeAlloc(size_t cbNode, const char *pszName, VBOXFUSETYPE enmType, PVBOXFUSEDIR pDir,
                             PVBOXFUSENODE *ppNode)
{
    Assert(cbNode >= sizeof(VBOXFUSENODE));

    /*
     * Allocate the memory for it and init the critical section.
     */
    size_t cchName = strlen(pszName);
    PVBOXFUSENODE pNode = (PVBOXFUSENODE)RTMemAlloc(cchName + 1 + RT_ALIGN_Z(cbNode, 8));
    if (!pNode)
        return VERR_NO_MEMORY;

    int rc = RTCritSectInit(&pNode->CritSect);
    if (RT_FAILURE(rc))
    {
        RTMemFree(pNode);
        return rc;
    }

    /*
     * Initialize the members.
     */
    pNode->pszName = (char *)memcpy((uint8_t *)pNode + RT_ALIGN_Z(cbNode, 8), pszName, cchName + 1);
    pNode->cchName = cchName;
    pNode->enmType = enmType;
    pNode->cRefs   = 1;
    pNode->pDir    = pDir;
#if 0
    pNode->fMode   = enmType == VBOXFUSETYPE_DIRECTORY ? S_IFDIR | 0755 : S_IFREG | 0644;
#else
    pNode->fMode   = enmType == VBOXFUSETYPE_DIRECTORY ? S_IFDIR | 0777 : S_IFREG | 0666;
#endif
    pNode->Uid     = 0;
    pNode->Gid     = 0;
    pNode->cLinks  = 0;
    pNode->Ino     = g_NextIno++; /** @todo make this safe! */
    pNode->cbPrimary = 0;

    *ppNode = pNode;
    return VINF_SUCCESS;
}
开发者ID:leopucci,项目名称:VirtualMonitor,代码行数:55,代码来源:VBoxFUSE.cpp


示例14: RTDECL

RTDECL(PRTUTF16) RTUtf16AllocTag(size_t cb, const char *pszTag)
{
    if (cb > sizeof(RTUTF16))
        cb = RT_ALIGN_Z(cb, sizeof(RTUTF16));
    else
        cb = sizeof(RTUTF16);
    PRTUTF16 pwsz = (PRTUTF16)RTMemAllocTag(cb, pszTag);
    if (pwsz)
        *pwsz = '\0';
    return pwsz;
}
开发者ID:mcenirm,项目名称:vbox,代码行数:11,代码来源:utf-16.cpp


示例15: Elf64NoteSectionSize

/**
 * Returns the size of the NOTE section given the name and size of the data.
 *
 * @param pszName           Name of the note section.
 * @param cb                Size of the data portion of the note section.
 *
 * @return The size of the NOTE section as rounded to the file alignment.
 */
static uint64_t Elf64NoteSectionSize(const char *pszName, uint64_t cbData)
{
    uint64_t cbNote = sizeof(Elf64_Nhdr);

    size_t cbName      = strlen(pszName) + 1;
    size_t cbNameAlign = RT_ALIGN_Z(cbName, g_NoteAlign);

    cbNote += cbNameAlign;
    cbNote += RT_ALIGN_64(cbData, g_NoteAlign);
    return cbNote;
}
开发者ID:sobomax,项目名称:virtualbox_64bit_edd,代码行数:19,代码来源:DBGFCoreWrite.cpp


示例16: DECLHIDDEN

DECLHIDDEN(int) rtR0MemAllocEx(size_t cb, uint32_t fFlags, PRTMEMHDR *ppHdr)
{
    size_t      cbAllocated = cb;
    PRTMEMHDR   pHdr        = NULL;

#ifdef RT_ARCH_AMD64
    /*
     * Things are a bit more complicated on AMD64 for executable memory
     * because we need to be in the ~2GB..~0 range for code.
     */
    if (fFlags & RTMEMHDR_FLAG_EXEC)
    {
        if (fFlags & RTMEMHDR_FLAG_ANY_CTX)
            return VERR_NOT_SUPPORTED;

# ifdef USE_KMEM_ALLOC_PROT
        pHdr = (PRTMEMHDR)kmem_alloc_prot(kernel_map, cb + sizeof(*pHdr),
                                          VM_PROT_ALL, VM_PROT_ALL, KERNBASE);
# else
        vm_object_t pVmObject = NULL;
        vm_offset_t Addr = KERNBASE;
        cbAllocated = RT_ALIGN_Z(cb + sizeof(*pHdr), PAGE_SIZE);

        pVmObject = vm_object_allocate(OBJT_DEFAULT, cbAllocated >> PAGE_SHIFT);
        if (!pVmObject)
            return VERR_NO_EXEC_MEMORY;

        /* Addr contains a start address vm_map_find will start searching for suitable space at. */
        int rc = vm_map_find(kernel_map, pVmObject, 0, &Addr,
                             cbAllocated, TRUE, VM_PROT_ALL, VM_PROT_ALL, 0);
        if (rc == KERN_SUCCESS)
        {
            rc = vm_map_wire(kernel_map, Addr, Addr + cbAllocated,
                             VM_MAP_WIRE_SYSTEM | VM_MAP_WIRE_NOHOLES);
            if (rc == KERN_SUCCESS)
            {
                pHdr = (PRTMEMHDR)Addr;

                if (fFlags & RTMEMHDR_FLAG_ZEROED)
                    bzero(pHdr, cbAllocated);
            }
            else
                vm_map_remove(kernel_map,
                              Addr,
                              Addr + cbAllocated);
        }
        else
            vm_object_deallocate(pVmObject);
# endif
    }
    else
#endif
    {
开发者ID:leopucci,项目名称:VirtualMonitor,代码行数:53,代码来源:alloc-r0drv-freebsd.c


示例17: VirtioRingSize

/**
 * Returns the size of the ring in bytes given the number of elements and
 * alignment requirements.
 *
 * @param cElements         Number of elements.
 * @param Align             Alignment (must be a power of two).
 *
 * @return Size of the Virtio ring.
 */
size_t VirtioRingSize(uint64_t cElements, ulong_t Align)
{
    size_t cb = 0;
    cb  = cElements * sizeof(VIRTIORINGDESC);   /* Ring descriptors. */
    cb += 2 * sizeof(uint16_t);                 /* Available flags and index. */
    cb += cElements * sizeof(uint16_t);         /* Available descriptors. */

    size_t cbAlign = RT_ALIGN_Z(cb, Align);
    cbAlign += 2 * sizeof(uint16_t);                    /* Used flags and index. */
    cbAlign += cElements * sizeof(VIRTIORINGUSEDELEM);  /* Used descriptors. */

    return cbAlign;
}
开发者ID:mdaniel,项目名称:virtualbox-org-svn-vbox-trunk,代码行数:22,代码来源:VirtioRing-solaris.c


示例18: RTDECL

RTDECL(PRTASN1ARRAYALLOCATION) RTAsn1MemInitArrayAllocation(PRTASN1ARRAYALLOCATION pAllocation,
                                                            PCRTASN1ALLOCATORVTABLE pAllocator, size_t cbEntry)
{
    Assert(cbEntry >= sizeof(RTASN1CORE));
    Assert(cbEntry < _1M);
    Assert(RT_ALIGN_Z(cbEntry, sizeof(void *)) == cbEntry);
    pAllocation->cbEntry            = (uint32_t)cbEntry;
    pAllocation->cPointersAllocated = 0;
    pAllocation->cEntriesAllocated  = 0;
    pAllocation->cResizeCalls       = 0;
    pAllocation->uReserved0         = 0;
    pAllocation->pAllocator         = pAllocator;
    return pAllocation;
}
开发者ID:mdaniel,项目名称:virtualbox-org-svn-vbox-trunk,代码行数:14,代码来源:asn1-basics.cpp


示例19: DECLCALLBACK

/**
 * @interface_method_impl{PDMINETWORKUP,pfnAllocBuf}
 */
static DECLCALLBACK(int) drvNicNetworkUp_AllocBuf(PPDMINETWORKUP pInterface, size_t cbMin,
                                                  PCPDMNETWORKGSO pGso, PPPDMSCATTERGATHER ppSgBuf)
{
	PDRVNIC pThis = PDMINETWORKUP_2_DRVNIC(pInterface);

	/*
	 * Allocate a scatter / gather buffer descriptor that is immediately
	 * followed by the buffer space of its single segment.  The GSO context
	 * comes after that again.
	 */
	PPDMSCATTERGATHER pSgBuf = (PPDMSCATTERGATHER)RTMemAlloc(RT_ALIGN_Z(sizeof(*pSgBuf), 16)
	                                                         + RT_ALIGN_Z(cbMin, 16)
	                                                         + (pGso ? RT_ALIGN_Z(sizeof(*pGso), 16) : 0));
	if (!pSgBuf)
		return VERR_NO_MEMORY;

	/*
	 * Initialize the S/G buffer and return.
	 */
	pSgBuf->fFlags         = PDMSCATTERGATHER_FLAGS_MAGIC | PDMSCATTERGATHER_FLAGS_OWNER_1;
	pSgBuf->cbUsed         = 0;
	pSgBuf->cbAvailable    = RT_ALIGN_Z(cbMin, 16);
	pSgBuf->pvAllocator    = NULL;
	if (!pGso)
		pSgBuf->pvUser     = NULL;
	else
	{
		pSgBuf->pvUser     = (uint8_t *)(pSgBuf + 1) + pSgBuf->cbAvailable;
		*(PPDMNETWORKGSO)pSgBuf->pvUser = *pGso;
	}
	pSgBuf->cSegs          = 1;
	pSgBuf->aSegs[0].cbSeg = pSgBuf->cbAvailable;
	pSgBuf->aSegs[0].pvSeg = pSgBuf + 1;

	*ppSgBuf = pSgBuf;
	return VINF_SUCCESS;
}
开发者ID:0xxx,项目名称:genode,代码行数:40,代码来源:network.cpp


示例20: RTR0DECL

RTR0DECL(void) RTMemContFree(void *pv, size_t cb)
{
    RT_ASSERT_PREEMPTIBLE();
    if (pv)
    {
        Assert(cb > 0);
        AssertMsg(!((uintptr_t)pv & PAGE_OFFSET_MASK), ("pv=%p\n", pv));
        IPRT_DARWIN_SAVE_EFL_AC();

        cb = RT_ALIGN_Z(cb, PAGE_SIZE);
        IOFreeContiguous(pv, cb);

        IPRT_DARWIN_RESTORE_EFL_AC();
    }
}
开发者ID:mdaniel,项目名称:virtualbox-org-svn-vbox-trunk,代码行数:15,代码来源:alloc-r0drv-darwin.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ RT_CONN_FLAGS函数代码示例发布时间:2022-05-30
下一篇:
C++ RTWF函数代码示例发布时间: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