Garmin Fleet Management Controller
2.19.0
|
Basic utility macros for low-level functions. More...
Go to the source code of this file.
Macros | |
#define | _compiler_assert(_e, _m) struct tokcat( __, tokcat( _m, __LINE__ ) ) { int _ : ( (_e) ? 1 : 0 ); } |
Compile time assert. More... | |
#define | _tokcat(_x, _y) _x ## _y |
Concatenate two tokens. Do not use directly. More... | |
#define | allbitset(_val, _mask) ( ( (_val) & (_mask) ) == (_mask) ) |
True if all mask bits are set in the specified value. More... | |
#define | anybitset(_val, _mask) ( ( (_val) & (_mask) ) != 0 ) |
True if any mask bits are set in the specified value. More... | |
#define | clrbit(_b) ( ~setbit( _b ) ) |
A bit mask with one bit cleared and the rest set. More... | |
#define | clrbits(_b, _len) ( ~setbits( (_b), (_len) ) ) |
A bit mask with several bits cleared and the rest set. More... | |
#define | cnt_of_array(_a) ( sizeof( (_a) ) / sizeof( (_a)[0] ) ) |
The number of elements in _a. More... | |
#define | compiler_assert(_e) _compiler_assert( _e, _UTIL_H_ ) |
Compile time assert. More... | |
#define | max_sint_val(_t) ( setbits( 0, ( sizeof( _t ) * 8 ) - 1 ) ) |
The maximum signed integer that can be stored in a type. More... | |
#define | max_uint_val(_t) ( setbits( 0, ( sizeof( _t ) * 8 ) ) ) |
The maximum unsigned integer that can be stored in a type. More... | |
#define | maxval(_x, _y) ( (_x) > (_y) ? (_x) : (_y) ) |
The larger of _x and _y. More... | |
#define | min_sint_val(_t) ( ~max_sint_val( _t ) ) |
The minimum signed integer that can be stored in a type. More... | |
#define | minval(_x, _y) ( (_x) < (_y) ? (_x) : (_y) ) |
The smaller of _x and _y. More... | |
#define | offset_of(_s, _m) ( (unsigned char *)&( ( (_s *)0 )->_m ) - (unsigned char *)0 ) |
The offset of _m from the beginning of _s. More... | |
#define | returnif(_check) |
Return if a condition is true. More... | |
#define | returnif_v(_check, _value) |
Return a value if a condition is true. More... | |
#define | setbit(_b) ( (unsigned)1 << (_b) ) |
A bit mask with one bit set and the rest cleared. More... | |
#define | setbits(_b, _len) ( ( ( 1U << ( (_len) - 1 ) ) - 1U + ( 1U << ( (_len) - 1 ) ) ) << (_b) ) |
A bit mask with several bits set and the rest cleared. More... | |
#define | tokcat(_x, _y) _tokcat( _x, _y ) |
Concatenate two tokens. More... | |
Basic utility macros for low-level functions.
Definition in file util_macros.h.
#define _compiler_assert | ( | _e, | |
_m | |||
) | struct tokcat( __, tokcat( _m, __LINE__ ) ) { int _ : ( (_e) ? 1 : 0 ); } |
Compile time assert.
Generate compiler error if _e is 0/false
_e | The value to assert. This must evaluate to a compile-time constant. |
_m | A valid C identifier that represents the module name. |
Definition at line 155 of file util_macros.h.
#define _tokcat | ( | _x, | |
_y | |||
) | _x ## _y |
#define allbitset | ( | _val, | |
_mask | |||
) | ( ( (_val) & (_mask) ) == (_mask) ) |
True if all mask bits are set in the specified value.
_val | The value to test |
_mask | The mask bits to check |
Definition at line 52 of file util_macros.h.
#define anybitset | ( | _val, | |
_mask | |||
) | ( ( (_val) & (_mask) ) != 0 ) |
True if any mask bits are set in the specified value.
_val | The value to test |
_mask | The mask bits to check |
Definition at line 59 of file util_macros.h.
#define clrbit | ( | _b | ) | ( ~setbit( _b ) ) |
A bit mask with one bit cleared and the rest set.
_b | The bit number that is cleared, counting from 0 as the LSB. |
Definition at line 45 of file util_macros.h.
#define clrbits | ( | _b, | |
_len | |||
) | ( ~setbits( (_b), (_len) ) ) |
A bit mask with several bits cleared and the rest set.
_b | The lowest bit number that is cleared, counting from 0 as the LSB. |
_len | The number of bits that are cleared. |
Definition at line 38 of file util_macros.h.
#define cnt_of_array | ( | _a | ) | ( sizeof( (_a) ) / sizeof( (_a)[0] ) ) |
The number of elements in _a.
_a | the name of the array |
Definition at line 90 of file util_macros.h.
Referenced by AobrdEventLogConverter::convertAnnotation(), FmiLogParser::formatFmiPacket(), modifyStatusChangeRecord(), CEtaModeDlg::OnInitDialog(), CFileTransferDlg::OnInitDialog(), CFileConverterDlg::OnInitDialog(), LogParser::readLog(), FmiApplicationLayer::rx(), FmiApplicationLayer::sendA607DriverIdUpdate(), FmiApplicationLayer::sendCannedResponseTextMessage(), FmiApplicationLayer::sendDriverIdUpdate(), FmiApplicationLayer::sendFile(), FmiApplicationLayer::sendNextAOBRDAnnotation(), and FmiApplicationLayer::sendNextAOBRDShipment().
#define compiler_assert | ( | _e | ) | _compiler_assert( _e, _UTIL_H_ ) |
Compile time assert.
Generate compiler error if _e is 0/false
_e | The value to assert. This must evaluate to a compile-time constant. |
Definition at line 164 of file util_macros.h.
#define max_sint_val | ( | _t | ) | ( setbits( 0, ( sizeof( _t ) * 8 ) - 1 ) ) |
The maximum signed integer that can be stored in a type.
_t | The data type to test. |
Definition at line 65 of file util_macros.h.
#define max_uint_val | ( | _t | ) | ( setbits( 0, ( sizeof( _t ) * 8 ) ) ) |
The maximum unsigned integer that can be stored in a type.
_t | The data type to test. |
Definition at line 77 of file util_macros.h.
Referenced by Logger::logRawData(), and UTIL_data_is_uint32().
#define maxval | ( | _x, | |
_y | |||
) | ( (_x) > (_y) ? (_x) : (_y) ) |
The larger of _x and _y.
Definition at line 100 of file util_macros.h.
Referenced by FmiApplicationLayer::rx().
#define min_sint_val | ( | _t | ) | ( ~max_sint_val( _t ) ) |
The minimum signed integer that can be stored in a type.
_t | The data type to test. |
Definition at line 71 of file util_macros.h.
#define minval | ( | _x, | |
_y | |||
) | ( (_x) < (_y) ? (_x) : (_y) ) |
The smaller of _x and _y.
Definition at line 95 of file util_macros.h.
Referenced by FmiLogParser::formatFmiPacket(), FmiLogParser::formatHosartPacket(), FmiLogParser::formatMessageId(), FmiLogParser::getPacketDetail(), MessageId::MessageId(), CStopNewDlg::OnBnClickedOk(), CFileTransferDlg::OnBnClickedOk(), CGpiQueryDlg::OnGpiInfoReceived(), MessageId::operator=(), SerialPort::pumpRx(), FmiApplicationLayer::rx(), FmiApplicationLayer::sendA603Stop(), FmiApplicationLayer::sendCannedResponseTextMessage(), FmiApplicationLayer::sendEnablePvtCommand(), FmiApplicationLayer::sendFile(), CMapViewerDlg::sendRouteToDevice(), CCustomFormsDlg::sendToDevice(), and FmiApplicationLayer::sendUserInterfaceText().
#define offset_of | ( | _s, | |
_m | |||
) | ( (unsigned char *)&( ( (_s *)0 )->_m ) - (unsigned char *)0 ) |
The offset of _m from the beginning of _s.
_s | the name of the struct |
_m | the name of the member |
Definition at line 84 of file util_macros.h.
Referenced by FmiApplicationLayer::beginA611LongTextMessage(), FmiLogParser::formatFmiPacket(), FmiApplicationLayer::sendA602Stop(), FmiApplicationLayer::sendA602TextMessage(), FmiApplicationLayer::sendA603Stop(), FmiApplicationLayer::sendA604TextMessage(), FmiApplicationLayer::sendA607DriverIdUpdate(), FmiApplicationLayer::sendCannedMessage(), FmiApplicationLayer::sendCannedResponse(), FmiApplicationLayer::sendCannedResponseTextMessage(), FmiApplicationLayer::sendDriverIdUpdate(), FmiApplicationLayer::sendDriverStatusListItem(), FmiApplicationLayer::sendEnable(), FmiApplicationLayer::sendEnablePvtCommand(), and FmiApplicationLayer::sendUserInterfaceText().
#define returnif | ( | _check | ) |
Return if a condition is true.
_check | The boolean expression to check |
Definition at line 106 of file util_macros.h.
#define returnif_v | ( | _check, | |
_value | |||
) |
Return a value if a condition is true.
_check | The boolean expression to check |
_value | The value to return |
Definition at line 119 of file util_macros.h.
Referenced by UTIL_convert_date_time_to_seconds().
#define setbit | ( | _b | ) | ( (unsigned)1 << (_b) ) |
A bit mask with one bit set and the rest cleared.
_b | The bit number that is set, counting from 0 as the LSB. |
Definition at line 30 of file util_macros.h.
Referenced by CWaypointDlg::getCatIds(), and FmiApplicationLayer::rx().
#define setbits | ( | _b, | |
_len | |||
) | ( ( ( 1U << ( (_len) - 1 ) ) - 1U + ( 1U << ( (_len) - 1 ) ) ) << (_b) ) |
A bit mask with several bits set and the rest cleared.
_b | The lowest bit number that is set, counting from 0 as the LSB. |
_len | The number of bits that are set. |
Definition at line 24 of file util_macros.h.
#define tokcat | ( | _x, | |
_y | |||
) | _tokcat( _x, _y ) |
Concatenate two tokens.
tokcat() returns a single C token that is the result of concatenating two tokens. For example, if "tokcat( _, __LINE__)" appears at line 123, it will be replaced with "_123" by the preprocessor. tokcat() is analogous to strcat().
_x | The first token |
_y | The second token |
Definition at line 146 of file util_macros.h.