oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
74.12k stars 2.77k forks source link

Support `int128` and `uint128` in `bun:ffi` #8191

Open Didas-git opened 9 months ago

Didas-git commented 9 months ago

What is the problem this feature would solve?

Currently there is no good way to bind functions that return 128 bit integers, adding a way to do so would solve this.

What is the feature you are proposing to solve the problem?

Add FFIType.i128 and FFIType.u128

What alternatives have you considered?

No response

paperdave commented 9 months ago

c technically doesnt have a u128 type, but it technically does; i see __int128 within tinycc.

one note is it would have to almost always become a bigint cell, which is unfortunate for performance on large integers.

it shouldnt be that hard to implement this.

Didas-git commented 9 months ago

GCC also has __int128 and related types.

Regarding return type, could be nice to have an option to return int128 as a string (let the user choose) just for the speed bonus

paperdave commented 9 months ago

i'm skeptical of string <-> int128 conversion being a speed bonus, but it may be an interesting option.