allocex-r3-generic.cpp revision dd3b708fb52e912a0a07fab811a5427d5abf15e6
/* $Id$ */
/** @file
* IPRT - Memory Allocation, Extended Alloc and Free Functions for Ring-3, generic.
*/
/*
* Copyright (C) 2006-2013 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* The contents of this file may alternatively be used under the terms
* of the Common Development and Distribution License Version 1.0
* (CDDL) only, as it comes in the "COPYING.CDDL" file of the
* VirtualBox OSE distribution, in which case the provisions of the
* CDDL are applicable instead of those of the GPL.
*
* You may elect to license modified versions of this file under the
* terms and conditions of either the GPL or the CDDL or both.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#define RTMEM_NO_WRAP_TO_EF_APIS
/*******************************************************************************
* Structures and Typedefs *
*******************************************************************************/
/**
* Heading for extended memory allocations in ring-3.
*/
typedef struct RTMEMHDRR3
{
/** Magic (RTMEMHDR_MAGIC). */
/** Block flags (RTMEMALLOCEX_FLAGS_*). */
/** The actual size of the block, header not included. */
/** The requested allocation size. */
} RTMEMHDRR3;
/** Pointer to a ring-3 extended memory header. */
typedef RTMEMHDRR3 *PRTMEMHDRR3;
RTDECL(int) RTMemAllocExTag(size_t cb, size_t cbAlignment, uint32_t fFlags, const char *pszTag, void **ppv) RT_NO_THROW
{
/*
* Validate and adjust input.
*/
AssertMsgReturn(!(fFlags & ~RTMEMALLOCEX_FLAGS_VALID_MASK), ("%#x\n", fFlags), VERR_INVALID_PARAMETER);
AssertMsgReturn(cbAlignment <= sizeof(void *), ("%zu (%#x)\n", cbAlignment, cbAlignment), VERR_UNSUPPORTED_ALIGNMENT);
if (fFlags & (RTMEMALLOCEX_FLAGS_16BIT_REACH | RTMEMALLOCEX_FLAGS_32BIT_REACH | RTMEMALLOCEX_FLAGS_ANY_CTX))
return VERR_NOT_SUPPORTED;
/*
* Align the request.
*/
if (cbAlignment)
else
AssertMsgReturn(cbAligned >= cb && cbAligned <= ~(size_t)0 / 2U, ("cbAligned=%#zx cb=%#zx", cbAligned, cb),
/*
* Allocate the requested memory.
*/
void *pv;
if (fFlags & RTMEMALLOCEX_FLAGS_EXEC)
{
}
else if (fFlags & RTMEMALLOCEX_FLAGS_ZEROED)
else
if (!pv)
return VERR_NO_MEMORY;
/*
* Fill in the header and return.
*/
return VINF_SUCCESS;
}
{
if (!pv)
return;
AssertMsg(pHdr->u32Magic == RTMEMHDR_MAGIC, ("pHdr->u32Magic=%RX32 pv=%p cb=%#x\n", pHdr->u32Magic, pv, cb));
else
}