Commit 7899c661 authored by Guillaume Melquiond's avatar Guillaume Melquiond

Update overlay for pure 64-bit mode.

Add a definition for __builtin_expect along the way.
parent 94056660
#ifndef UINT64GMP_H_INCLUDED
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
#include <assert.h>
#include <alloca.h>
typedef unsigned __int128 uint128_t;
struct __mul64_double_result
{ uint64_t __field_0;
uint64_t __field_1;
struct __mul64_double_result {
uint64_t __field_0;
uint64_t __field_1;
};
#define __builtin_expect(x,y) (x)
#define UWtype uint64_t
#define UHWtype uint32_t
......@@ -89,9 +84,9 @@ uint64_t __field_1;
static inline struct __mul64_double_result mul64_double(uint64_t x, uint64_t y)
{
struct __mul64_double_result result;
umul_ppmm (result.__field_1, result.__field_0, x, y);
return result;
struct __mul64_double_result result;
umul_ppmm (result.__field_1, result.__field_0, x, y);
return result;
}
static inline uint64_t div64_2by1(uint64_t ul, uint64_t uh, uint64_t d)
......@@ -99,72 +94,72 @@ static inline uint64_t div64_2by1(uint64_t ul, uint64_t uh, uint64_t d)
uint64_t q, r;
__udiv_qrnnd_c (q, r, uh, ul, d);
return q;
//return (((uint128_t)uh << 64) | ul) / d;
}
struct __add64_with_carry_result
{ uint64_t __field_0;
uint64_t __field_1;
struct __add64_with_carry_result {
uint64_t __field_0;
uint64_t __field_1;
};
static inline struct __add64_with_carry_result
add64_with_carry(uint64_t x, uint64_t y, uint64_t c)
{
struct __add64_with_carry_result result;
uint64_t r = x + y + c;
result.__field_0 = r;
if (r == x) result.__field_1 = c;
else result.__field_1 = (r < x);
return result;
struct __add64_with_carry_result result;
uint64_t r = x + y + c;
result.__field_0 = r;
if (r == x) result.__field_1 = c;
else result.__field_1 = (r < x);
return result;
}
struct __sub64_with_borrow_result
{ uint64_t __field_0;
uint64_t __field_1;
struct __sub64_with_borrow_result {
uint64_t __field_0;
uint64_t __field_1;
};
static inline struct __sub64_with_borrow_result
sub64_with_borrow(uint64_t x, uint64_t y, uint64_t b)
{
struct __sub64_with_borrow_result result;
uint64_t r = x - y - b;
result.__field_0 = r;
if (r > x) result.__field_1 = 1;
else if (r == x) result.__field_1 = b;
else result.__field_1 = 0;
return result;
struct __sub64_with_borrow_result result;
uint64_t r = x - y - b;
result.__field_0 = r;
if (r > x) result.__field_1 = 1;
else if (r == x) result.__field_1 = b;
else result.__field_1 = 0;
return result;
}
struct __add64_3_result
{ uint64_t __field_0;
uint64_t __field_1;
struct __add64_3_result {
uint64_t __field_0;
uint64_t __field_1;
};
static inline struct __add64_3_result add64_3(uint64_t x, uint64_t y, uint64_t z)
static inline struct __add64_3_result
add64_3(uint64_t x, uint64_t y, uint64_t z)
{
struct __add64_3_result result;
uint64_t r, c1, c2;
r = x + y;
c1 = r < y;
r += z;
c2 = r < z;
result.__field_1 = c1 + c2;
result.__field_0 = r;
return result;
struct __add64_3_result result;
uint64_t r, c1, c2;
r = x + y;
c1 = r < y;
r += z;
c2 = r < z;
result.__field_1 = c1 + c2;
result.__field_0 = r;
return result;
}
struct __lsld64_result
{ uint64_t __field_0;
uint64_t __field_1;
struct __lsld64_result {
uint64_t __field_0;
uint64_t __field_1;
};
static inline struct __lsld64_result lsld64(uint64_t x, uint64_t cnt)
static inline struct __lsld64_result
lsld64(uint64_t x, uint64_t cnt)
{
struct __lsld64_result result;
result.__field_1 = x >> (64 - cnt);
result.__field_0 = x << cnt;
return result;
struct __lsld64_result result;
result.__field_1 = x >> (64 - cnt);
result.__field_0 = x << cnt;
return result;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment