Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing __u/int128 support #288

Closed
kassane opened this issue Oct 27, 2023 · 13 comments
Closed

Missing __u/int128 support #288

kassane opened this issue Oct 27, 2023 · 13 comments

Comments

@kassane
Copy link

kassane commented Oct 27, 2023

Source to translate:
https://github.com/tigerbeetle/tigerbeetle/blob/main/src/clients/c/tb_client.h

typedef __uint128_t tb_uint128_t; -> alias tb_uint128_t = <unimplemented>;

The translation gave an undefined type.

tuple("__s8", CXTypeKind.sChar): "byte",
tuple("__s16", CXTypeKind.short_): "short",
tuple("__s32", CXTypeKind.int_): "int",
tuple("__s64", CXTypeKind.longLong): "long",
tuple("__u8", CXTypeKind.uChar): "ubyte",
tuple("__u16", CXTypeKind.uShort): "ushort",
tuple("__u32", CXTypeKind.uInt): "uint",
tuple("__u64", CXTypeKind.uLongLong): "ulong",

@kassane kassane changed the title Missing __int128 support Missing __u/int128 support Oct 27, 2023
@jacob-carlborg
Copy link
Owner

D doesn't support 128bit integers. What do you suggest the result would be?

@kassane
Copy link
Author

kassane commented Oct 28, 2023

D doesn't support 128bit integers

https://dlang.org/phobos/core_int128.html ?


Edit:

Not yet how supported it is by other D compilers... At first it would be enough to just translate to 64bit integers. (Like Pascal)

@kassane
Copy link
Author

kassane commented Oct 29, 2023

In my test core.int128 not working in DMD2:
https://d.godbolt.org/z/n3bG75d3K

LDC and GDC works!

<source>(9): Error: module `int128` is in file 'core/int128.d' which cannot be read
import path[0] = /opt/compiler-explorer/dmd2-nightly/dmd2/linux/bin64/../../src/phobos
import path[1] = /opt/compiler-explorer/dmd2-nightly/dmd2/linux/bin64/../../src/druntime/import
Compiler returned: 1

@jacob-carlborg
Copy link
Owner

Strange, it's available in the repository. BTW, have you checked if it's ABI compatible with __uint128_t?

@kassane
Copy link
Author

kassane commented Oct 30, 2023

Strange, it's available in the repository. BTW, have you checked if it's ABI compatible with __uint128_t?

More recent information is below:

cc: @ibuclaw

@jacob-carlborg
Copy link
Owner

BTW, should it be core.int128 or std.int128?

@kassane
Copy link
Author

kassane commented Nov 1, 2023

BTW, should it be core.int128 or std.int128?

Please, use core.int128! Added the Cent to my wrapper and it's fine during the test.

@jacob-carlborg
Copy link
Owner

I'm not that familiar with 128 bit integers, but it seems there's no unsigned version in core.int128?

@kassane
Copy link
Author

kassane commented Nov 4, 2023

I'm not that familiar with 128 bit integers, but it seems there's no unsigned version in core.int128?

I know. Not ideal, but for some simulated operations so far haven't had any problems.

I tried using uint64 with high values ​​during concurrent transactions and in some cases I applied the use of integer casts.

Then I will publish the D client to compare with the C Client as a reference.
I need to better integrate Zig's event-loop (libtbClient) with D concurrency (appClient).

References

Why not 64-bit?

A: https://tigerbeetle.com/blog/2023-09-19-64-bit-bank-balances-ought-to-be-enough-for-anybody/

Clients FFI
https://tigerbeetle.com/blog/2023-02-21-writing-high-performance-clients-for-tigerbeetle/

@jacob-carlborg
Copy link
Owner

Do you suggest using the signed Cent for both signed and unsigned?

@kassane
Copy link
Author

kassane commented Nov 4, 2023

Do you suggest using the signed Cent for both signed and unsigned?

It's not ideal, but yeah. Using Cent in signed and unsigned.

jacob-carlborg added a commit that referenced this issue Nov 10, 2023
@jacob-carlborg
Copy link
Owner

@kassane
Copy link
Author

kassane commented Nov 10, 2023

Exactly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants