10#ifndef __WSUTIL_SIGN_EXT_H__
11#define __WSUTIL_SIGN_EXT_H__
22ws_sign_ext32(uint32_t val,
int no_of_bits)
24 ws_assert (no_of_bits >= 0 && no_of_bits <= 32);
26 if ((no_of_bits == 0) || (no_of_bits == 32))
35 if (val & (1U << (no_of_bits-1)))
36 val |= (0xFFFFFFFFU << no_of_bits);
42ws_sign_ext64(uint64_t val,
int no_of_bits)
44 ws_assert (no_of_bits >= 0 && no_of_bits <= 64);
46 if ((no_of_bits == 0) || (no_of_bits == 64))
55 if (val & (UINT64_C(1) << (no_of_bits-1)))
56 val |= (UINT64_C(0xFFFFFFFFFFFFFFFF) << no_of_bits);