FreeBSD/sys/contrib/dev/acpica/compiler/asllength.c
/*******************************************************************************
 *
 * FUNCTION:    CgGetPackageLenByteCount
 *
 * PARAMETERS:  Op              - Parse node
 *              PackageLength   - Length to be encoded
 *
 * RETURN:      Required length of the package length encoding
 *
 * DESCRIPTION: Calculate the number of bytes required to encode the given
 *              package length.
 *
 ******************************************************************************/
CgGetPackageLenByteCount
PARAMETERS:  Op              - Parse node
PackageLength   - Length to be encoded

Required length of the package length encoding

Calculate the number of bytes required to encode the given
package length.
CgGetPackageLenByteCount PARAMETERS : Op - Parse node PackageLength - Length to be encoded Required length of the package length encoding Calculate the number of bytes required to encode the given package length .
static UINT8
CgGetPackageLenByteCount (
    ACPI_PARSE_OBJECT       *Op,
    UINT32                  PackageLength)
{
    if (PackageLength <= (0x0000003F - 1))
    {
        return (1);
    }
    else if (PackageLength <= (0x00000FFF - 2))
    {
        return (2);
    }
    else if (PackageLength <= (0x000FFFFF - 3))
    {
        return (3);
    }
    else if (PackageLength <= (0x0FFFFFFF - 4))
    {
        return (4);
    }
    else
    {
        AslError (ASL_ERROR, ASL_MSG_ENCODING_LENGTH, Op, NULL);
    }
    return (0);
}
static UINT8 CgGetPackageLenByteCount ( ACPI_PARSE_OBJECT * Op , UINT32 PackageLength ) { if ( PackageLength <= ( 0x0000003F - 1 ) ) { return ( 1 ) ; } else if ( PackageLength <= ( 0x00000FFF - 2 ) ) { return ( 2 ) ; } else if ( PackageLength <= ( 0x000FFFFF - 3 ) ) { return ( 3 ) ; } else if ( PackageLength <= ( 0x0FFFFFFF - 4 ) ) { return ( 4 ) ; } else { AslError ( ASL_ERROR , ASL_MSG_ENCODING_LENGTH , Op , NULL ) ; } return ( 0 ) ; }
FUNCTION:    CgGetPackageLenByteCount
 PARAMETERS:  Op              - Parse node
              PackageLength   - Length to be encoded
FUNCTION : CgGetPackageLenByteCount PARAMETERS : Op - Parse node PackageLength - Length to be encoded
/*
     * Determine the number of bytes required to encode the package length
     * Note: the package length includes the number of bytes used to encode
     * the package length, so we must account for this also.
     */ /* Fatal error - the package length is too large to encode */