diff --git a/sys/sys/libkern.h b/sys/sys/libkern.h --- a/sys/sys/libkern.h +++ b/sys/sys/libkern.h @@ -226,6 +226,22 @@ return (strrchr(p, ch)); } +static __inline int64_t +signed_extend64(uint64_t bitmap, int lsb, int width) +{ + + return ((int64_t)(bitmap << (63 - lsb - (width - 1)))) >> + (63 - (width - 1)); +} + +static __inline int32_t +signed_extend32(uint32_t bitmap, int lsb, int width) +{ + + return ((int32_t)(bitmap << (31 - lsb - (width - 1)))) >> + (31 - (width - 1)); +} + /* fnmatch() return values. */ #define FNM_NOMATCH 1 /* Match failed. */