/*
* Utility compute operations used by translated code.
*
* Copyright (c) 2003 Fabrice Bellard
* Copyright (c) 2007 Aurelien Jarno
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include <stdlib.h>
#ifndef VBOX
#include <stdint.h>
#else
#endif
#include "host-utils.h"
//#define DEBUG_MULDIV
/* Long integer helpers */
#if !defined(__x86_64__)
{
*plow += a;
/* carry test */
if (*plow < a)
(*phigh)++;
*phigh += b;
}
{
}
{
uint64_t v;
a0 = a;
a1 = a >> 32;
b0 = b;
b1 = b >> 32;
*plow = v;
*phigh = 0;
*phigh += v;
}
/* Unsigned 64x64 -> 128 multiplication */
{
#if defined(DEBUG_MULDIV)
printf("mulu64: 0x%016llx * 0x%016llx = 0x%016llx%016llx\n",
#endif
}
/* Signed 64x64 -> 128 multiplication */
{
sa = (a < 0);
if (sa)
a = -a;
sb = (b < 0);
if (sb)
b = -b;
}
#if defined(DEBUG_MULDIV)
printf("muls64: 0x%016llx * 0x%016llx = 0x%016llx%016llx\n",
#endif
}
#endif /* !defined(__x86_64__) */