/*******************************************************************************
*
* Module Name: utmath - Integer math support routines
*
******************************************************************************/
/*
* Copyright (C) 2000 - 2016, Intel Corp.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* Alternatively, this software may be distributed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
* NO WARRANTY
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGES.
*/
#include "acpi.h"
#include "accommon.h"
ACPI_MODULE_NAME ("utmath")
/*
* Optional support for 64-bit double-precision integer divide. This code
* is configurable and is implemented in order to support 32-bit kernel
* environments where a 64-bit double-precision math library is not available.
*
* by-zero) appears after this optional section of code.
*/
#ifndef ACPI_USE_NATIVE_DIVIDE
/* Structures used only for 64-bit divide */
typedef struct uint64_struct
{
typedef union uint64_overlay
{
/*******************************************************************************
*
* FUNCTION: AcpiUtShortDivide
*
* PARAMETERS: Dividend - 64-bit dividend
* Divisor - 32-bit divisor
* OutQuotient - Pointer to where the quotient is returned
* OutRemainder - Pointer to where the remainder is returned
*
* RETURN: Status (Checks for divide-by-zero)
*
* DESCRIPTION: Perform a short (maximum 64 bits divided by 32 bits)
* divide and modulo. The result is a 64-bit quotient and a
* 32-bit remainder.
*
******************************************************************************/
{
/* Always check for a zero divisor */
if (Divisor == 0)
{
}
/*
* The quotient is 64 bits, the remainder is always 32 bits,
* and is generated by the second divide.
*/
/* Return only what was requested */
if (OutQuotient)
{
}
if (OutRemainder)
{
}
}
/*******************************************************************************
*
* FUNCTION: AcpiUtDivide
*
* PARAMETERS: InDividend - Dividend
* InDivisor - Divisor
* OutQuotient - Pointer to where the quotient is returned
* OutRemainder - Pointer to where the remainder is returned
*
* RETURN: Status (Checks for divide-by-zero)
*
* DESCRIPTION: Perform a divide and modulo.
*
******************************************************************************/
{
/* Always check for a zero divisor */
if (InDivisor == 0)
{
}
{
/*
* 1) Simplest case is where the divisor is 32 bits, we can
* just do two divides
*/
/*
* The quotient is 64 bits, the remainder is always 32 bits,
* and is generated by the second divide.
*/
}
else
{
/*
* 2) The general case where the divisor is a full 64 bits
* is more difficult
*/
/* Normalize the operands (shift until the divisor is < 32 bits) */
do
{
/* Partial divide */
/*
* The quotient is always 32 bits, and simply requires
* adjustment. The 64-bit remainder must be generated.
*/
{
{
{
{
}
}
else
{
}
}
{
}
}
}
/* Return only what was requested */
if (OutQuotient)
{
}
if (OutRemainder)
{
}
}
#else
/*******************************************************************************
*
* FUNCTION: AcpiUtShortDivide, AcpiUtDivide
*
* PARAMETERS: See function headers above
*
* DESCRIPTION: Native versions of the UtDivide functions. Use these if either
* 1) The target is a 64-bit platform and therefore 64-bit
* integer math is supported directly by the machine.
* 2) The target is a 32-bit or 16-bit platform, and the
* double-precision integer math library is available to
* perform the divide.
*
******************************************************************************/
{
/* Always check for a zero divisor */
if (Divisor == 0)
{
}
/* Return only what was requested */
if (OutQuotient)
{
}
if (OutRemainder)
{
}
}
{
/* Always check for a zero divisor */
if (InDivisor == 0)
{
}
/* Return only what was requested */
if (OutQuotient)
{
}
if (OutRemainder)
{
}
}
#endif