uint128.h revision 972c3ecf2c929440ce70e51af38ba021101c8f7b
45e9809aff7304721fddb95654901b32195c9c7avboxsync * IPRT - RTUINT128U & uint128_t methods.
45e9809aff7304721fddb95654901b32195c9c7avboxsync * Copyright (C) 2011 Oracle Corporation
45e9809aff7304721fddb95654901b32195c9c7avboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
45e9809aff7304721fddb95654901b32195c9c7avboxsync * available from http://www.virtualbox.org. This file is free software;
45e9809aff7304721fddb95654901b32195c9c7avboxsync * you can redistribute it and/or modify it under the terms of the GNU
45e9809aff7304721fddb95654901b32195c9c7avboxsync * General Public License (GPL) as published by the Free Software
45e9809aff7304721fddb95654901b32195c9c7avboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
45e9809aff7304721fddb95654901b32195c9c7avboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
45e9809aff7304721fddb95654901b32195c9c7avboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
45e9809aff7304721fddb95654901b32195c9c7avboxsync * The contents of this file may alternatively be used under the terms
45e9809aff7304721fddb95654901b32195c9c7avboxsync * of the Common Development and Distribution License Version 1.0
45e9809aff7304721fddb95654901b32195c9c7avboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
45e9809aff7304721fddb95654901b32195c9c7avboxsync * VirtualBox OSE distribution, in which case the provisions of the
45e9809aff7304721fddb95654901b32195c9c7avboxsync * CDDL are applicable instead of those of the GPL.
45e9809aff7304721fddb95654901b32195c9c7avboxsync * You may elect to license modified versions of this file under the
45e9809aff7304721fddb95654901b32195c9c7avboxsync * terms and conditions of either the GPL or the CDDL or both.
45e9809aff7304721fddb95654901b32195c9c7avboxsync/** @defgroup grp_rt_once RTUInt128 - 128-bit Unsigned Integer Methods
45e9809aff7304721fddb95654901b32195c9c7avboxsync * @ingroup grp_rt
45e9809aff7304721fddb95654901b32195c9c7avboxsync * Test if a 128-bit unsigned integer value is zero.
45e9809aff7304721fddb95654901b32195c9c7avboxsync * @returns true if they are, false if they aren't.
45e9809aff7304721fddb95654901b32195c9c7avboxsync * @param pValue The input and output value.
45e9809aff7304721fddb95654901b32195c9c7avboxsyncDECLINLINE(bool) RTUInt128IsZero(PRTUINT128U pValue)
45e9809aff7304721fddb95654901b32195c9c7avboxsync * Set a 128-bit unsigned integer value to zero.
45e9809aff7304721fddb95654901b32195c9c7avboxsync * @returns pResult
45e9809aff7304721fddb95654901b32195c9c7avboxsync * @param pResult The result variable.
45e9809aff7304721fddb95654901b32195c9c7avboxsyncDECLINLINE(PRTUINT128U) RTUInt128SetZero(PRTUINT128U pResult)
45e9809aff7304721fddb95654901b32195c9c7avboxsync * Set a 128-bit unsigned integer value to the maximum value.
45e9809aff7304721fddb95654901b32195c9c7avboxsync * @returns pResult
45e9809aff7304721fddb95654901b32195c9c7avboxsync * @param pResult The result variable.
45e9809aff7304721fddb95654901b32195c9c7avboxsyncDECLINLINE(PRTUINT128U) RTUInt128SetMax(PRTUINT128U pResult)
45e9809aff7304721fddb95654901b32195c9c7avboxsync * Adds two 128-bit unsigned integer values.
45e9809aff7304721fddb95654901b32195c9c7avboxsync * @returns pResult
45e9809aff7304721fddb95654901b32195c9c7avboxsync * @param pResult The result variable.
45e9809aff7304721fddb95654901b32195c9c7avboxsync * @param pValue1 The first value.
45e9809aff7304721fddb95654901b32195c9c7avboxsync * @param pValue2 The second value.
45e9809aff7304721fddb95654901b32195c9c7avboxsyncDECLINLINE(PRTUINT128U) RTUInt128Add(PRTUINT128U pResult, PCRTUINT128U pValue1, PCRTUINT128U pValue2)
return pResult;
DECLINLINE(PRTUINT128U) RTUInt128AddU64(PRTUINT128U pResult, PCRTUINT128U pValue1, uint64_t uValue2)
return pResult;
DECLINLINE(PRTUINT128U) RTUInt128Sub(PRTUINT128U pResult, PCRTUINT128U pValue1, PCRTUINT128U pValue2)
return pResult;
DECLINLINE(PRTUINT128U) RTUInt128Mul(PRTUINT128U pResult, PCRTUINT128U pValue1, PCRTUINT128U pValue2)
return pResult;
#if defined(RT_ARCH_AMD64)
DECLINLINE(PRTUINT128U) RTUInt128MulByU64(PRTUINT128U pResult, PCRTUINT128U pValue1, uint64_t uValue2)
return pResult;
DECLINLINE(PRTUINT128U) RTUInt128MulU64ByU64(PRTUINT128U pResult, uint64_t uValue1, uint64_t uValue2)
#ifdef RT_ARCH_AMD64
return pResult;
DECLINLINE(PRTUINT128U) RTUInt128DivRem(PRTUINT128U pQuotient, PRTUINT128U pRemainder, PCRTUINT128U pValue1, PCRTUINT128U pValue2);
DECLINLINE(PRTUINT128U) RTUInt128Div(PRTUINT128U pResult, PCRTUINT128U pValue1, PCRTUINT128U pValue2)
DECLINLINE(PRTUINT128U) RTUInt128Mod(PRTUINT128U pResult, PCRTUINT128U pValue1, PCRTUINT128U pValue2)
return pResult;
DECLINLINE(PRTUINT128U) RTUInt128And(PRTUINT128U pResult, PCRTUINT128U pValue1, PCRTUINT128U pValue2)
return pResult;
DECLINLINE(PRTUINT128U) RTUInt128Or( PRTUINT128U pResult, PCRTUINT128U pValue1, PCRTUINT128U pValue2)
return pResult;
DECLINLINE(PRTUINT128U) RTUInt128Xor(PRTUINT128U pResult, PCRTUINT128U pValue1, PCRTUINT128U pValue2)
return pResult;
return pResult;
return pResult;
return pResult;
return pResult;
return pResult;
return pValueResult;
return pValueResult;
return pValueResult;
return pValueResult;
return pValueResult;
return pValue1Result;
return pValue1Result;
return pValue1Result;
return pValue1Result;
return pValue1Result;
return pValue1Result;
return pValue1Result;
return pValueResult;
return pValue1Result;
return pValue1Result;
return pValue1Result;
if (cBits > 0)
else if (cBits < 0)
return pValueResult;
return pValueResult;
return pValueResult;
return pValueResult;
bool fRc;
fRc = false;
return fRc;
DECLINLINE(PRTUINT128U) RTUInt128BitSetRange(PRTUINT128U pValueResult, unsigned iFirstBit, unsigned cBits)
while (cBits-- > 0)
return pValueResult;
return cBits;
DECLINLINE(PRTUINT128U) RTUInt128DivRem(PRTUINT128U pQuotient, PRTUINT128U pRemainder, PCRTUINT128U pValue1, PCRTUINT128U pValue2)
int iDiff;
return NULL;
return pQuotient;
if (iDiff < 0)
else if (iDiff == 0)
if (iBitAdder)
iBitAdder--;
iBitAdder--;
return pQuotient;