Commit 94056660 authored by Guillaume Melquiond's avatar Guillaume Melquiond

Clean C drivers a bit.

parent 892f05d5
......@@ -289,8 +289,8 @@ module mach.int.UInt64GMP
\n return result;\
\n}\
\n\
\nstruct __lsld64_result\
\n{ uint64_t __field_0;\
\nstruct __lsld64_result {\
\n uint64_t __field_0;\
\n uint64_t __field_1;\
\n};\
\n\
......
......@@ -33,43 +33,28 @@ end
blacklist "binverttab"
module mach.int.UInt64GMP
interface
"\ntypedef unsigned __int128 uint128_t;\
\n\
\nstruct __mul64_double_result\
\n{ uint64_t __field_0;\
\n uint64_t __field_1;\
\n};\
\n\
\nstatic inline struct __mul64_double_result mul64_double(uint64_t x, uint64_t y)\
\n{\
\n uint128_t z = (uint128_t)x * (uint128_t)y;\
\n struct __mul64_double_result result = { z, z >> 64 };\
\n return result;\
\n}\
\n\
\nstatic inline uint64_t div64_2by1(uint64_t ul, uint64_t uh, uint64_t d)\
\n{\
\n return (((uint128_t)uh << 64) | ul) / d;\
\n}\
"
(* "
static 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;
}
static uint64_t div64_2by1(uint64_t ul, uint64_t uh, uint64_t d)
{
uint64_t q;
uint64_t _dummy __attribute__((unused));
udiv_qrnnd(q,_dummy,uh,ul,d);
return q;
}
" *)
interface "\
\ntypedef unsigned __int128 uint128_t;\
\n\
\nstruct __mul64_double_result {\
\n uint64_t __field_0;\
\n uint64_t __field_1;\
\n};\
\n\
\nstatic inline struct __mul64_double_result\
\nmul64_double(uint64_t x, uint64_t y)\
\n{\
\n uint128_t z = (uint128_t)x * (uint128_t)y;\
\n struct __mul64_double_result result = { z, z >> 64 };\
\n return result;\
\n}\
\n\
\nstatic inline uint64_t\
\ndiv64_2by1(uint64_t ul, uint64_t uh, uint64_t d)\
\n{\
\n return (((uint128_t)uh << 64) | ul) / d;\
\n}\
"
syntax val mul_double "mul64_double"
syntax val div2by1 "div64_2by1"
......
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