VirtualBox

Changeset 341 in vbox for trunk


Ignore:
Timestamp:
Jan 26, 2007 12:49:23 AM (18 years ago)
Author:
vboxsync
Message:

Allocate exec memory in the first 2GB on linux. (bit of a hack currently)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r3/posix/alloc-posix.cpp

    r1 r341  
    4747RTDECL(void *) RTMemExecAlloc(size_t cb)
    4848{
     49    AssertMsg(cb, ("Allocating ZERO bytes is really not a good idea! Good luck with the next assertion!\n"));
     50
     51#if defined(__AMD64__) && defined(__LINUX__)
     52    /*
     53     * Use mmap to get low memory.
     54     */
     55    void *pv = mmap(NULL, RT_ALIGN_Z(cb, PAGE_SIZE), PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE | MAP_ANONYMOUS | MAP_32BIT, -1, 0);
     56    AssertMsgReturn(pv != MAP_FAILED, ("errno=%d cb=%#zx\n", errno, cb), NULL);
     57
     58#else
    4959    /*
    5060     * Allocate first.
    5161     */
    52     AssertMsg(cb, ("Allocating ZERO bytes is really not a good idea! Good luck with the next assertion!\n"));
    5362    cb = RT_ALIGN_Z(cb, 32);
    5463    void *pv = NULL;
     
    7584        }
    7685    }
     86#endif
    7787    return pv;
    7888}
     
    8797{
    8898    if (pv)
     99    {
     100#if defined(__AMD64__) && defined(__LINUX__)
     101        int rc = munmap(pv, 0);/** @todo fix me! */
     102        AssertMsg(!rc, ("munmap -> %d errno=%d\n", rc, errno));
     103#else
    89104        free(pv);
     105#endif
     106    }
    90107}
    91108
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