Page MenuHomeFreeBSD

sys/libkern.h: Add type conversion helpers

Authored by on Nov 29 2021, 12:29 PM.
Referenced Files
Unknown Object (File)
Tue, Jul 16, 12:25 PM
Unknown Object (File)
Sat, Jun 29, 5:30 AM
Unknown Object (File)
Thu, Jun 27, 4:52 AM
Unknown Object (File)
Mon, Jun 24, 8:18 PM
Unknown Object (File)
Mon, Jun 24, 8:14 PM
Unknown Object (File)
Mon, Jun 24, 7:24 PM
Unknown Object (File)
Mon, Jun 24, 2:57 AM
Unknown Object (File)
May 25 2024, 8:12 PM



Add helper functions for 32 and 64 bit unsigned to signed integers

Diff Detail

rG FreeBSD src repository
Lint Skipped
Tests Skipped

Event Timeline

I would prefer shorter names. signed_extend32 is really unwieldy. Also, the name does not really explain that the operation is really about extracting from bitfields.

How about mirroring the ARM instructions these are based on? I.e. sbfx32 and sbfx64.

Change function's names to more self-descriptive, reflecting followed ARM instructions behavior.

sbfx32 means nothing to me, signed_extend32 was way more clear to what it does.

How about extract_s32/extract_s64?

I like the idea but would reduce it to sextract32 and sextract64. Or just leave the underscore out. Alternative: extractl and extractll (with corresponding unsigned functions extractul and extractull).

This revision was not accepted when it landed; it landed in state Needs Review.Dec 2 2021, 9:00 AM
This revision was automatically updated to reflect the committed changes.

I agree with @manu These functions are going to be used extremely rarely and imo the more meaningful name the better.