sys/libkern.h: Add type conversion helpers
Add helper functions for 32 and 64 bit unsigned to signed integers conversions. Reviewed by: Sponsored by: Alstom Obtained from: Semihalf Differential revision: https://reviews.freebsd.org/D33162
This commit is contained in:
parent
c3f345ae3c
commit
efa5d3831b
@ -226,6 +226,22 @@ rindex(const char *p, int ch)
|
||||
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. */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user