sg.cpp revision 9df6a850ccaf90fbecc4c7bb6e4e761f6fa2ec12
/* $Id$ */
/** @file
* IPRT - S/G buffer handling.
*/
/*
* Copyright (C) 2010 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 *
*******************************************************************************/
{
void *pvBuf;
/* Check that the S/G buffer has memory left. */
{
*pcbData = 0;
return NULL;
}
&& (uintptr_t)pSgBuf->pvSegCur + pSgBuf->cbSegLeft <= (uintptr_t)pSgBuf->paSegs[pSgBuf->idxSeg].pvSeg + pSgBuf->paSegs[pSgBuf->idxSeg].cbSeg,
("pSgBuf->idxSeg=%d pSgBuf->cSegs=%d pSgBuf->pvSegCur=%p pSgBuf->cbSegLeft=%zd pSgBuf->paSegs[%d].pvSeg=%p pSgBuf->paSegs[%d].cbSeg=%zd\n",
pSgBuf->idxSeg, pSgBuf->paSegs[pSgBuf->idxSeg].pvSeg, pSgBuf->idxSeg, pSgBuf->paSegs[pSgBuf->idxSeg].cbSeg));
/* Advance to the next segment if required. */
{
{
}
}
else
return pvBuf;
}
{
}
{
}
{
}
{
if (!*pcbSeg)
}
{
AssertPtrReturn(pSgBufDst, 0);
AssertPtrReturn(pSgBufSrc, 0);
while (cbLeft)
{
void *pvBufDst;
void *pvBufSrc;
if (!cbThisCopy)
break;
cbLeft -= cbThisCopy;
}
}
{
AssertPtrReturn(pSgBuf1, 0);
AssertPtrReturn(pSgBuf2, 0);
/* Set up the temporary buffers */
while (cbLeft)
{
void *pvBuf1;
void *pvBuf2;
if (!cbCmp)
break;
if (rc)
return rc;
}
return 0;
}
{
AssertPtrReturn(pSgBuf1, 0);
AssertPtrReturn(pSgBuf2, 0);
if (!fAdvance)
{
/* Set up the temporary buffers */
pSgBuf1Tmp = &SgBuf1Tmp;
pSgBuf2Tmp = &SgBuf2Tmp;
}
else
{
}
while (cbLeft)
{
if (!cbCmp)
break;
if (rc)
{
if (pcbOff)
{
/* Search for the correct offset */
while ( cbThisCmp-- > 0
{
pbBuf1++;
pbBuf2++;
cbOff++;
}
}
return rc;
}
}
return 0;
}
{
AssertPtrReturn(pSgBuf, 0);
while (cbLeft)
{
if (!cbThisSet)
break;
}
}
{
AssertPtrReturn(pSgBuf, 0);
AssertPtrReturn(pvBuf, 0);
while (cbLeft)
{
if (!cbThisCopy)
break;
cbLeft -= cbThisCopy;
}
}
{
AssertPtrReturn(pSgBuf, 0);
AssertPtrReturn(pvBuf, 0);
while (cbLeft)
{
if (!cbThisCopy)
break;
cbLeft -= cbThisCopy;
}
}
{
AssertPtrReturn(pSgBuf, 0);
while (cbLeft)
{
if (!cbThisAdvance)
break;
cbLeft -= cbThisAdvance;
}
}
RTDECL(size_t) RTSgBufSegArrayCreate(PRTSGBUF pSgBuf, PRTSGSEG paSeg, unsigned *pcSeg, size_t cbData)
{
AssertPtrReturn(pSgBuf, 0);
AssertPtrReturn(pcSeg, 0);
unsigned cSeg = 0;
if (!paSeg)
{
{
cSeg = 1;
while ( cbData
{
idx++;
cSeg++;
}
}
}
else
{
while ( cbData
{
if (!cbThisSeg)
{
break;
}
cSeg++;
}
}
return cb;
}