C Does FreeBSD compiler support _int128?

Hello everybody! I am trying to compile a new Alpha emulator . The source file has next code:

Code:
typedef unsigned __int128 u128; /* 16 bytes (128 bits) in length */
When I have compiled it I've got a next error
Code:
../comutl/AXP_Utility.h:95:18: error: __int128 is not supported on this target
typedef unsigned __int128 u128; /* 16 bytes (128 bits) in length */
^
../comutl/AXP_Utility.h:100:9: error: __int128 is not supported on this target
typedef __int128 i128; /* 16 bytes (128 bits) in length */
^
Thanks for the help,
Oleg
 
Does FreeBSD has a tool to replace __int128 on the 32bit system?
None that I know of. For the sysutils/ipdbtools which I developed, I was in need for __uint128 operations for IPv6 address manipulations. And for this I added the set of basic unsigned 128 bit arithmetic functions to my code.

See:
https://github.com/cyclaero/ipdb/blob/master/binutils.h#L486
https://github.com/cyclaero/ipdb/blob/master/binutils.c#L174
https://github.com/cyclaero/ipdb/blob/master/uint128test.c

However, this is unsigned integer math only, and all arithmetic 128bit operations must be turned into function calls, for example: C = A + B needs to be turned into C = add_u128(A, B). Since in my code 128bit arithmetic needs to be done only at a few places, for me this was the quickest way to get my code working on 32bit targets, even on ARMv6 and ARMv7.

In your case, this might not be a viable solution because above is unsigned arithmetic only, and 128bit arithmetic might be scattered all over the place, which might involve a lot of work to replace all the operators by function calls.
 
I had to use __uint128_t some time ago on 64b system (itanium instructions decoder). I used the stdint.h, didn't define my own types.
Test code:

C:
        __uint128_t nr = ( __int128_t)0xCAFEBABEDEADC0DE << 64 | (__uint128_t)0xBEEFBEEFCAFE1337;

I don't recall the limitations of such usage though..
 
Modern versions of the Intel 64-bit (x86-64) architecture and of PowerPC both support 128 bit integer types. To me the important thing is not 128-bit arithmetic: other than cryptographic algorithms, I know of no use of such large integers, since there are no countable things that come in such large numbers, not even the number of nanoseconds in a century. But where it matters is to have atomic operations (such as CAS) for implementing lock-free algorithms.
 
Back
Top