Bit Manipulation#

Bitwise operations.

Macros#

#define

Create bit mask with single, specified bit set.

#define
SL_SET_BIT (val, mask)

Set specified bit(s) in a value.

#define
SL_CLEAR_BIT (val, mask)

Clear specified bit(s) in a value.

#define
SL_IS_BIT_SET (val, mask)

Determine whether the specified bit(s) in a value are set.

#define
SL_IS_BIT_CLEAR (val, mask)

Determine whether the specified bit(s) in a value are clear.

#define
SL_IS_ANY_BIT_SET (val, mask)

Determine whether any specified bit(s) in a value are set.

#define

Determine whether any specified bit(s) in a value are clear.

#define

Determine if a value is a power of 2.

Macro Definition Documentation#

SL_DEF_BIT#

#define SL_DEF_BIT
Value:
(bit)

Create bit mask with single, specified bit set.

                                          SL_DEF_BIT()

Returns

  • Bit mask with single, specified bit set.

Note

  • (1) 'bit' SHOULD be a non-negative integer.

  • (2) 'bit' values that overflow the target CPU &/or compiler environment (e.g. negative or greater-than-CPU-data-size values) MAY generate compiler warnings &/or errors.


Definition at line 55 of file platform/common/inc/sl_bit.h

SL_SET_BIT#

#define SL_SET_BIT
Value:
(val, mask)

Set specified bit(s) in a value.

                                          SL_SET_BIT()

Returns

  • Modified value with specified bit(s) set.

Note

  • 'val' & 'mask' SHOULD be unsigned integers.


Definition at line 71 of file platform/common/inc/sl_bit.h

SL_CLEAR_BIT#

#define SL_CLEAR_BIT
Value:
(val, mask)

Clear specified bit(s) in a value.

                                          SL_CLEAR_BIT()

Returns

  • Modified value with specified bit(s) clear.

Note

  • 'val' & 'mask' SHOULD be unsigned integers.

  • 'mask' SHOULD be cast with the same data type than 'val'.


Definition at line 89 of file platform/common/inc/sl_bit.h

SL_IS_BIT_SET#

#define SL_IS_BIT_SET
Value:
(val, mask)

Determine whether the specified bit(s) in a value are set.

                                          SL_IS_BIT_SET()

Returns

  • true, if ALL specified bit(s) are set in value.

          false, if ALL specified bit(s) are NOT set in value.
    

Note

  • 'val' & 'mask' SHOULD be unsigned integers.

  • NULL 'mask' allowed; returns 'false' since NO mask bits specified.


Definition at line 109 of file platform/common/inc/sl_bit.h

SL_IS_BIT_CLEAR#

#define SL_IS_BIT_CLEAR
Value:
(val, mask)

Determine whether the specified bit(s) in a value are clear.

                                          SL_IS_BIT_CLEAR()

Returns

  • true, if ALL specified bit(s) are clear in value.

          false, if ALL specified bit(s) are NOT clear in value.
    

Note

  • val' & 'mask' SHOULD be unsigned integers.

  • NULL 'mask' allowed; returns 'false' since NO mask bits specified.


Definition at line 128 of file platform/common/inc/sl_bit.h

SL_IS_ANY_BIT_SET#

#define SL_IS_ANY_BIT_SET
Value:
(val, mask)

Determine whether any specified bit(s) in a value are set.

                                      SL_IS_ANY_BIT_SET()

Returns

  • true, if ANY specified bit(s) are set in value.

          false, if ALL specified bit(s) are NOT set in value.
    

Note

  • 'val' & 'mask' SHOULD be unsigned integers.

  • NULL 'mask' allowed; returns 'false' since NO mask bits specified.


Definition at line 148 of file platform/common/inc/sl_bit.h

SL_IS_ANY_BIT_CLEAR#

#define SL_IS_ANY_BIT_CLEAR
Value:
(val, mask)

Determine whether any specified bit(s) in a value are clear.

                                      SL_IS_ANY_BIT_CLEAR()

Returns

  • true, if ANY specified bit(s) are clear in value.

          false,  if ALL specified bit(s) are NOT clear in value.
    

Note

  • 'val' & 'mask' SHOULD be unsigned integers.

  • NULL 'mask' allowed; returns 'false' since NO mask bits specified.


Definition at line 168 of file platform/common/inc/sl_bit.h

SL_MATH_IS_PWR2#

#define SL_MATH_IS_PWR2
Value:
(val)

Determine if a value is a power of 2.

                                       SL_MATH_IS_PWR2()

Returns

  • true, 'val' is a power of 2. false, 'val' is not a power of 2.


Definition at line 181 of file platform/common/inc/sl_bit.h