Page MenuHomeFreeBSD

sys/libkern.h: Add type conversion helpers
ClosedPublic

Authored by hum_semihalf.com on Nov 29 2021, 12:29 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Apr 17, 7:52 AM
Unknown Object (File)
Wed, Apr 17, 7:52 AM
Unknown Object (File)
Wed, Apr 17, 7:48 AM
Unknown Object (File)
Feb 11 2024, 8:55 PM
Unknown Object (File)
Dec 23 2023, 9:43 AM
Unknown Object (File)
Dec 21 2023, 6:03 PM
Unknown Object (File)
Dec 12 2023, 9:15 PM
Unknown Object (File)
Nov 29 2023, 2:04 AM

Details

Summary

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

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
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.