Commit efa5d383 authored by Hubert Mazur's avatar Hubert Mazur Committed by Wojciech Macek
Browse files

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
parent c3f345ae
......@@ -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. */
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment