VirtualBox

Changeset 97907 in vbox for trunk


Ignore:
Timestamp:
Dec 29, 2022 6:33:45 PM (2 years ago)
Author:
vboxsync
Message:

IPRT: Removed the RTMemExecAlloc interface.

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/mangling.h

    r97905 r97907  
    16011601# define RTMemEfTmpFreeZ                                RT_MANGLER(RTMemEfTmpFreeZ)
    16021602# define RTMemEfTmpFreeZNP                              RT_MANGLER(RTMemEfTmpFreeZNP)
    1603 # define RTMemExecAllocTag                              RT_MANGLER(RTMemExecAllocTag)
    1604 # define RTMemExecFree                                  RT_MANGLER(RTMemExecFree)
    16051603# define RTMemFree                                      RT_MANGLER(RTMemFree)
    16061604# define RTMemFreeZ                                     RT_MANGLER(RTMemFreeZ)
  • trunk/include/iprt/mem.h

    r97905 r97907  
    438438RTDECL(void) RTMemFreeEx(void *pv, size_t cb) RT_NO_THROW_PROTO;
    439439
    440 
    441 
    442 /**
    443  * Allocates memory which may contain code (default tag).
    444  *
    445  * @returns Pointer to the allocated memory.
    446  * @returns NULL on failure.
    447  * @param   cb      Size in bytes of the memory block to allocate.
    448  */
    449 #define RTMemExecAlloc(cb)              RTMemExecAllocTag((cb), RTMEM_TAG)
    450 
    451 /**
    452  * Allocates memory which may contain code (custom tag).
    453  *
    454  * @returns Pointer to the allocated memory.
    455  * @returns NULL on failure.
    456  * @param   cb      Size in bytes of the memory block to allocate.
    457  * @param   pszTag  Allocation tag used for statistics and such.
    458  */
    459 RTDECL(void *)  RTMemExecAllocTag(size_t cb, const char *pszTag) RT_NO_THROW_PROTO;
    460 
    461 /**
    462  * Free executable/read/write memory allocated by RTMemExecAlloc().
    463  *
    464  * @param   pv      Pointer to memory block.
    465  * @param   cb      The allocation size.
    466  */
    467 RTDECL(void)    RTMemExecFree(void *pv, size_t cb) RT_NO_THROW_PROTO;
    468 
    469440/**
    470441 * Allocate page aligned memory with default tag.
  • trunk/src/VBox/Runtime/VBox/VBoxRTImp.def

    r96504 r97907  
    13921392    RTMemEfTmpFree
    13931393    RTMemEfTmpFreeNP
    1394     RTMemExecAllocTag
    1395     RTMemExecFree
    13961394    RTMemFree
    13971395    RTMemPageAllocTag
  • trunk/src/VBox/Runtime/r0drv/alloc-r0drv.cpp

    r96407 r97907  
    322322}
    323323RT_EXPORT_SYMBOL(RTMemFreeZ);
    324 
    325 
    326 
    327 
    328 
    329 
    330 RTDECL(void *)    RTMemExecAllocTag(size_t cb, const char *pszTag) RT_NO_THROW_DEF
    331 {
    332     PRTMEMHDR pHdr;
    333 #ifdef RT_OS_SOLARIS /** @todo figure out why */
    334     RT_ASSERT_INTS_ON();
    335 #else
    336     RT_ASSERT_PREEMPTIBLE();
    337 #endif
    338     RT_NOREF_PV(pszTag);
    339 
    340 
    341     pHdr = rtR0MemAlloc(cb + RTR0MEM_FENCE_EXTRA, RTMEMHDR_FLAG_EXEC);
    342     if (pHdr)
    343     {
    344 #ifdef RTR0MEM_STRICT
    345         pHdr->cbReq = (uint32_t)cb; Assert(pHdr->cbReq == cb);
    346         memcpy((uint8_t *)(pHdr + 1) + cb, &g_abFence[0], RTR0MEM_FENCE_EXTRA);
    347 #endif
    348         return pHdr + 1;
    349     }
    350     return NULL;
    351 }
    352 RT_EXPORT_SYMBOL(RTMemExecAllocTag);
    353 
    354 
    355 RTDECL(void)      RTMemExecFree(void *pv, size_t cb) RT_NO_THROW_DEF
    356 {
    357     PRTMEMHDR pHdr;
    358     RT_ASSERT_INTS_ON();
    359     RT_NOREF_PV(cb);
    360 
    361     if (!pv)
    362         return;
    363     pHdr = (PRTMEMHDR)pv - 1;
    364     if (pHdr->u32Magic == RTMEMHDR_MAGIC)
    365     {
    366         Assert(!(pHdr->fFlags & RTMEMHDR_FLAG_ALLOC_EX));
    367 #ifdef RTR0MEM_STRICT
    368         AssertReleaseMsg(!memcmp((uint8_t *)(pHdr + 1) + pHdr->cbReq, &g_abFence[0], RTR0MEM_FENCE_EXTRA),
    369                          ("pHdr=%p pv=%p cbReq=%u cb=%u fFlags=%#x\n"
    370                           "fence:    %.*Rhxs\n"
    371                           "expected: %.*Rhxs\n",
    372                           pHdr, pv, pHdr->cbReq, pHdr->cb, pHdr->fFlags,
    373                           RTR0MEM_FENCE_EXTRA, (uint8_t *)(pHdr + 1) + pHdr->cbReq,
    374                           RTR0MEM_FENCE_EXTRA, &g_abFence[0]));
    375 #endif
    376         rtR0MemFree(pHdr);
    377     }
    378     else
    379         AssertMsgFailed(("pHdr->u32Magic=%RX32 pv=%p\n", pHdr->u32Magic, pv));
    380 }
    381 RT_EXPORT_SYMBOL(RTMemExecFree);
    382 
    383 
    384324
    385325
  • trunk/src/VBox/Runtime/r3/posix/rtmempage-exec-mmap-heap-posix.cpp

    r96407 r97907  
    1 /* $Id$ */
     1* $Id$ */
    22/** @file
    33 * IPRT - RTMemPage*, POSIX with heap.
     
    796796}
    797797
    798 
    799 
    800 
    801 
    802 RTDECL(void *) RTMemExecAllocTag(size_t cb, const char *pszTag) RT_NO_THROW_DEF
    803 {
    804     return rtMemPagePosixAlloc(cb, pszTag, 0, &g_MemExecPosixHeap);
    805 }
    806 
    807 
    808 RTDECL(void) RTMemExecFree(void *pv, size_t cb) RT_NO_THROW_DEF
    809 {
    810     return rtMemPagePosixFree(pv, cb, &g_MemExecPosixHeap);
    811 }
    812 
  • trunk/src/VBox/Runtime/r3/posix/rtmempage-exec-mmap-posix.cpp

    r96407 r97907  
    181181}
    182182
    183 
    184 
    185 
    186 
    187 RTDECL(void *) RTMemExecAllocTag(size_t cb, const char *pszTag) RT_NO_THROW_DEF
    188 {
    189     return rtMemPagePosixAlloc(cb, pszTag, 0, PROT_EXEC);
    190 }
    191 
    192 
    193 RTDECL(void) RTMemExecFree(void *pv, size_t cb) RT_NO_THROW_DEF
    194 {
    195     return rtMemPagePosixFree(pv, cb);
    196 }
    197 
  • trunk/src/VBox/Runtime/r3/win/alloc-win.cpp

    r96407 r97907  
    5656
    5757
    58 RTDECL(void *) RTMemExecAllocTag(size_t cb, const char *pszTag) RT_NO_THROW_DEF
    59 {
    60     RT_NOREF_PV(pszTag);
    61 
    62     /*
    63      * Allocate first.
    64      */
    65     AssertMsg(cb, ("Allocating ZERO bytes is really not a good idea! Good luck with the next assertion!\n"));
    66 #ifdef USE_VIRTUAL_ALLOC
    67     cb = RT_ALIGN_Z(cb, PAGE_SIZE);
    68     void *pv = VirtualAlloc(NULL, cb, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
    69     AssertMsg(pv, ("VirtualAlloc(%zx) failed!!!\n", cb));
    70 #else
    71     cb = RT_ALIGN_Z(cb, 32);
    72     void *pv = malloc(cb);
    73     AssertMsg(pv, ("malloc(%d) failed!!!\n", cb));
    74     if (pv)
    75     {
    76         memset(pv, 0xcc, cb);
    77         void   *pvProt = (void *)((uintptr_t)pv & ~(uintptr_t)PAGE_OFFSET_MASK);
    78         size_t  cbProt = ((uintptr_t)pv & PAGE_OFFSET_MASK) + cb;
    79         cbProt = RT_ALIGN_Z(cbProt, PAGE_SIZE);
    80         DWORD fFlags = 0;
    81         if (!VirtualProtect(pvProt, cbProt, PAGE_EXECUTE_READWRITE, &fFlags))
    82         {
    83             AssertMsgFailed(("VirtualProtect(%p, %#x,,) -> lasterr=%d\n", pvProt, cbProt, GetLastError()));
    84             free(pv);
    85             pv = NULL;
    86         }
    87     }
    88 #endif
    89     return pv;
    90 }
    91 
    92 
    93 RTDECL(void)    RTMemExecFree(void *pv, size_t cb) RT_NO_THROW_DEF
    94 {
    95     RT_NOREF_PV(cb);
    96 
    97     if (pv)
    98 #ifdef USE_VIRTUAL_ALLOC
    99         if (!VirtualFree(pv, 0, MEM_RELEASE))
    100             AssertMsgFailed(("pv=%p lasterr=%d\n", pv, GetLastError()));
    101 #else
    102         free(pv);
    103 #endif
    104 }
    105 
    106 
    10758RTDECL(void *) RTMemPageAllocTag(size_t cb, const char *pszTag) RT_NO_THROW_DEF
    10859{
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette