mbgtools-lx  4.2.8
words.h File Reference
#include <mbg_tgt.h>

Go to the source code of this file.

Data Structures

struct  MBG_CODE_NAME_TABLE_ENTRY
 A table entry which can be used to map codes to names. More...
 
struct  NANO_TIME
 A timestamp with nanosecond resolution. More...
 
struct  NANO_TIME_64
 A timestamp with nanosecond resolution, but 64 bit size. More...
 

Macros

#define _IS_MBG_FIRMWARE   0
 
#define _ext   extern
 
#define MBG_TGT_HAS_64BIT_TYPES   1
 
#define _abs64(_i)   ( (int64_t) ( ( (_i) < 0 ) ? -(_i) : (_i) ) )
 
#define uchar   uchar
 
#define ushort   ushort
 
#define uint   uint
 
#define ulong   ulong
 
#define udouble   udouble
 
#define byte   byte
 
#define word   word
 
#define longword   longword
 
#define bool   bool
 
#define true   1
 
#define false   0
 
#define bit   bit
 
#define _BIT_REDEFINED   1
 
#define BYTE_0(_x)   ( (uint8_t ) ( (_x) & 0xFF ) )
 
#define BYTE_1(_x)   ( (uint8_t ) ( ( ( (uint16_t) (_x) ) >> 8 ) & 0xFF ) )
 
#define BYTE_2(_x)   ( (uint8_t ) ( ( ( (uint32_t) (_x) ) >> 16 ) & 0xFF ) )
 
#define BYTE_3(_x)   ( (uint8_t ) ( ( ( (uint32_t) (_x) ) >> 24 ) & 0xFF ) )
 
#define HI_BYTE(_x)   ( (uint8_t ) ( (_x) >> 8 ) )
 
#define LO_BYTE(_x)   ( (uint8_t ) ( (_x) & 0xFF ) )
 
#define HI_WORD(_x)   ( (uint16_t ) ( (_x) >> 16 ) )
 
#define LO_WORD(_x)   ( (uint16_t ) ( (_x) & 0xFFFF ) )
 
#define BYTE_OF(_v, _n)   *( ( (uint8_t *) &(_v) ) + (_n) )
 
#define WORD_OF(_v, _n)   *( ( (uint16_t *) &(_v) ) + (_n) )
 
#define FBYTE_OF(_v, _n)   *( ( (uint8_t far *) &(_v) ) + (_n) )
 
#define FWORD_OF(_v, _n)   *( ( (uint16_t far *) &(_v) ) + (_n) )
 
#define BYTE_OF_P(_p, _n)   *( ( (uint8_t *) (_p) ) + (_n) )
 
#define WORD_OF_P(_p, _n)   *( ( (uint16_t *) (_p) ) + (_n) )
 
#define _bswap16(_x)
 
#define _bswap32(_x)
 
#define _wswap32(_x)
 
#define _var_bswap16(_v)   (_v) = _bswap16( _v )
 
#define _var_bswap32(_v)   (_v) = _bswap32( _v )
 
#define _hilo_16(_x)   (_x)
 
#define _hilo_32(_x)   (_x)
 
#define _set_array_bit(_n, _byte_array, _max_bytes)
 
#define _clear_array_bit(_n, _byte_array, _max_bytes)
 
#define _isdigit(_c)   ( (_c) >= '0' && (_c) <= '9' )
 
#define _nop_macro_fnc()   do {} while (0)
 
#define _mbg_cn_table_entry(_n)   { _n, #_n }
 A macro defining a MBG_CODE_NAME_TABLE_ENTRY. More...
 
#define _mbg_cn_table_end()   { 0, NULL }
 A macro defining an empty MBG_CODE_NAME_TABLE_ENTRY. More...
 
#define _mbg_swab_nano_time(_p)
 
#define _nano_time_negative(_nt)   ( ( (_nt)->secs < 0 ) || ( (_nt)->nano_secs < 0 ) )
 
#define _nano_time_zero(_nt)   ( ( (_nt)->secs == 0 ) && ( (_nt)->nano_secs == 0 ) )
 
#define _mbg_swab_nano_time_64(_p)
 
#define _nano_time_64_negative(_nt)   ( ( (_nt)->secs < 0 ) || ( (_nt)->nano_secs < 0 ) )
 
#define _nano_time_64_zero(_nt)   ( ( (_nt)->secs == 0 ) && ( (_nt)->nano_secs == 0 ) )
 
#define _int_from_size_t(_n)   (_n)
 
#define XSTRINGIFY(x)   #x
 A helper macro to implement STRINGIFY correctly. More...
 
#define STRINGIFY(x)   XSTRINGIFY(x)
 Make a string from a constant definition. More...
 

Typedefs

typedef char int8_t
 
typedef unsigned char uint8_t
 
typedef short int16_t
 
typedef unsigned short uint16_t
 
typedef __int64 int64_t
 
typedef unsigned __int64 uint64_t
 
typedef unsigned char uchar
 
typedef unsigned short ushort
 
typedef unsigned int uint
 
typedef unsigned long ulong
 
typedef double udouble
 
typedef unsigned char byte
 
typedef unsigned short word
 
typedef unsigned long longword
 
typedef int bool
 
typedef bool bit
 

Macro Definition Documentation

◆ _abs64

#define _abs64 (   _i)    ( (int64_t) ( ( (_i) < 0 ) ? -(_i) : (_i) ) )

Definition at line 267 of file words.h.

Referenced by snprint_nano_time_64().

◆ _BIT_REDEFINED

#define _BIT_REDEFINED   1

Definition at line 417 of file words.h.

◆ _bswap16

#define _bswap16 (   _x)
Value:
( \
( ( ( (uint16_t) (_x) ) & 0x00FF ) << 8 ) | \
( ( ( (uint16_t) (_x) ) & 0xFF00 ) >> 8 ) \
)
unsigned short uint16_t
Definition: words.h:213

Definition at line 452 of file words.h.

◆ _bswap32

#define _bswap32 (   _x)
Value:
( \
( ( ( (uint32_t) (_x) ) & 0x000000FFUL ) << 24 ) | \
( ( ( (uint32_t) (_x) ) & 0x0000FF00UL ) << 8 ) | \
( ( ( (uint32_t) (_x) ) & 0x00FF0000UL ) >> 8 ) | \
( ( ( (uint32_t) (_x) ) & 0xFF000000UL ) >> 24 ) \
)
Definition: myutil.h:117

Definition at line 459 of file words.h.

◆ _clear_array_bit

#define _clear_array_bit (   _n,
  _byte_array,
  _max_bytes 
)
Value:
do \
{ \
int byte_idx = (_n) >> 3; \
\
if ( byte_idx < _max_bytes ) \
_byte_array[byte_idx] &= ~( 1 << ( (_n) & 0x07 ) ); \
\
} while ( 0 )

Definition at line 505 of file words.h.

◆ _ext

#define _ext   extern

Definition at line 176 of file words.h.

◆ _hilo_16

#define _hilo_16 (   _x)    (_x)

Definition at line 488 of file words.h.

◆ _hilo_32

#define _hilo_32 (   _x)    (_x)

Definition at line 489 of file words.h.

◆ _int_from_size_t

◆ _IS_MBG_FIRMWARE

#define _IS_MBG_FIRMWARE   0

Definition at line 147 of file words.h.

◆ _isdigit

#define _isdigit (   _c)    ( (_c) >= '0' && (_c) <= '9' )

Definition at line 517 of file words.h.

◆ _mbg_cn_table_end

#define _mbg_cn_table_end ( )    { 0, NULL }

A macro defining an empty MBG_CODE_NAME_TABLE_ENTRY.

This is used to terminate a table.

Definition at line 553 of file words.h.

◆ _mbg_cn_table_entry

#define _mbg_cn_table_entry (   _n)    { _n, #_n }

A macro defining a MBG_CODE_NAME_TABLE_ENTRY.

The stringified parameter is used for the name.

Parameters
_nThe symbolic name of the numeric code

Definition at line 546 of file words.h.

◆ _mbg_swab_nano_time

#define _mbg_swab_nano_time (   _p)
Value:
do \
{ \
_mbg_swab32( &(_p)->nano_secs ); \
_mbg_swab32( &(_p)->secs ); \
} while ( 0 )

Definition at line 586 of file words.h.

◆ _mbg_swab_nano_time_64

#define _mbg_swab_nano_time_64 (   _p)
Value:
do \
{ \
_mbg_swab64( &(_p)->secs ); \
_mbg_swab64( &(_p)->nano_secs ); \
} while ( 0 )

Definition at line 632 of file words.h.

Referenced by mbgextio_set_fdm_tdev().

◆ _nano_time_64_negative

#define _nano_time_64_negative (   _nt)    ( ( (_nt)->secs < 0 ) || ( (_nt)->nano_secs < 0 ) )

Check if the value of the NANO_TIME_64 structure _nt is negative

Definition at line 642 of file words.h.

◆ _nano_time_64_zero

#define _nano_time_64_zero (   _nt)    ( ( (_nt)->secs == 0 ) && ( (_nt)->nano_secs == 0 ) )

Check if the value of the NANO_TIME_64 structure _nt is 0

Definition at line 648 of file words.h.

◆ _nano_time_negative

#define _nano_time_negative (   _nt)    ( ( (_nt)->secs < 0 ) || ( (_nt)->nano_secs < 0 ) )

Check if the value of the NANO_TIME structure _nt is negative

Definition at line 596 of file words.h.

Referenced by snprint_nano_time(), and snprint_nano_time_64().

◆ _nano_time_zero

#define _nano_time_zero (   _nt)    ( ( (_nt)->secs == 0 ) && ( (_nt)->nano_secs == 0 ) )

Check if the value of the NANO_TIME structure _nt is 0

Definition at line 602 of file words.h.

◆ _nop_macro_fnc

#define _nop_macro_fnc ( )    do {} while (0)

Definition at line 525 of file words.h.

◆ _set_array_bit

#define _set_array_bit (   _n,
  _byte_array,
  _max_bytes 
)
Value:
do \
{ \
int byte_idx = (_n) >> 3; \
\
if ( byte_idx < _max_bytes ) \
_byte_array[byte_idx] |= ( 1 << ( (_n) & 0x07 ) ); \
\
} while ( 0 )

Definition at line 494 of file words.h.

◆ _var_bswap16

#define _var_bswap16 (   _v)    (_v) = _bswap16( _v )

Definition at line 474 of file words.h.

◆ _var_bswap32

#define _var_bswap32 (   _v)    (_v) = _bswap32( _v )

Definition at line 475 of file words.h.

◆ _wswap32

#define _wswap32 (   _x)
Value:
( \
( ( ( (uint32_t) (_x) ) & 0x0000FFFFUL ) << 16 ) | \
( ( ( (uint32_t) (_x) ) >> 16 ) & 0x0000FFFFUL ) \
)

Definition at line 468 of file words.h.

◆ bit

#define bit   bit

Definition at line 415 of file words.h.

◆ bool

#define bool   bool

Definition at line 375 of file words.h.

◆ byte

#define byte   byte

Definition at line 303 of file words.h.

◆ BYTE_0

#define BYTE_0 (   _x)    ( (uint8_t ) ( (_x) & 0xFF ) )

Definition at line 426 of file words.h.

Referenced by snprint_ip4_addr().

◆ BYTE_1

#define BYTE_1 (   _x)    ( (uint8_t ) ( ( ( (uint16_t) (_x) ) >> 8 ) & 0xFF ) )

Definition at line 427 of file words.h.

Referenced by snprint_ip4_addr().

◆ BYTE_2

#define BYTE_2 (   _x)    ( (uint8_t ) ( ( ( (uint32_t) (_x) ) >> 16 ) & 0xFF ) )

Definition at line 428 of file words.h.

Referenced by snprint_ip4_addr().

◆ BYTE_3

#define BYTE_3 (   _x)    ( (uint8_t ) ( ( ( (uint32_t) (_x) ) >> 24 ) & 0xFF ) )

Definition at line 429 of file words.h.

Referenced by snprint_ip4_addr().

◆ BYTE_OF

#define BYTE_OF (   _v,
  _n 
)    *( ( (uint8_t *) &(_v) ) + (_n) )

Definition at line 440 of file words.h.

Referenced by mbg_swab_double(), nl_read(), and pcps_read_amcc_s5920().

◆ BYTE_OF_P

#define BYTE_OF_P (   _p,
  _n 
)    *( ( (uint8_t *) (_p) ) + (_n) )

Definition at line 447 of file words.h.

◆ false

#define false   0

Definition at line 377 of file words.h.

◆ FBYTE_OF

#define FBYTE_OF (   _v,
  _n 
)    *( ( (uint8_t far *) &(_v) ) + (_n) )

Definition at line 443 of file words.h.

◆ FWORD_OF

#define FWORD_OF (   _v,
  _n 
)    *( ( (uint16_t far *) &(_v) ) + (_n) )

Definition at line 444 of file words.h.

◆ HI_BYTE

#define HI_BYTE (   _x)    ( (uint8_t ) ( (_x) >> 8 ) )

Definition at line 432 of file words.h.

◆ HI_WORD

#define HI_WORD (   _x)    ( (uint16_t ) ( (_x) >> 16 ) )

Definition at line 435 of file words.h.

◆ LO_BYTE

#define LO_BYTE (   _x)    ( (uint8_t ) ( (_x) & 0xFF ) )

Definition at line 433 of file words.h.

◆ LO_WORD

#define LO_WORD (   _x)    ( (uint16_t ) ( (_x) & 0xFFFF ) )

Definition at line 436 of file words.h.

◆ longword

#define longword   longword

Definition at line 313 of file words.h.

◆ MBG_TGT_HAS_64BIT_TYPES

#define MBG_TGT_HAS_64BIT_TYPES   1

Definition at line 264 of file words.h.

◆ STRINGIFY

#define STRINGIFY (   x)    XSTRINGIFY(x)

Make a string from a constant definition.

This macro can be used e.g. to define a constant string on the compiler's command line, e.g. like -DVERSION_STRING="v1.0 BETA". Source code like

const char version_string[] = VERSION_STRING;

may not work for every compiler since the double quotes in VERSION_STRING may be removed when the definition is evaluated. A proper solution is to use the STRINGIFY() macro defined here:

const char version_string[] = STRINGIFY( VERSION_STRING );

Definition at line 695 of file words.h.

◆ true

#define true   1

Definition at line 376 of file words.h.

◆ uchar

#define uchar   uchar

Definition at line 278 of file words.h.

◆ udouble

#define udouble   udouble

Definition at line 298 of file words.h.

◆ uint

#define uint   uint

Definition at line 288 of file words.h.

◆ ulong

#define ulong   ulong

Definition at line 293 of file words.h.

◆ ushort

#define ushort   ushort

Definition at line 283 of file words.h.

◆ word

#define word   word

Definition at line 308 of file words.h.

◆ WORD_OF

#define WORD_OF (   _v,
  _n 
)    *( ( (uint16_t *) &(_v) ) + (_n) )

Definition at line 441 of file words.h.

◆ WORD_OF_P

#define WORD_OF_P (   _p,
  _n 
)    *( ( (uint16_t *) (_p) ) + (_n) )

Definition at line 448 of file words.h.

◆ XSTRINGIFY

#define XSTRINGIFY (   x)    #x

A helper macro to implement STRINGIFY correctly.

This just a helper macro which must be defined before STRINGIFY to work correctly, and should not be used alone.

See also
STRINGIFY

Definition at line 675 of file words.h.

Typedef Documentation

◆ bit

typedef bool bit

Definition at line 411 of file words.h.

◆ bool

typedef int bool

Definition at line 370 of file words.h.

◆ byte

typedef unsigned char byte

Definition at line 302 of file words.h.

◆ int16_t

typedef short int16_t

Definition at line 212 of file words.h.

◆ int64_t

typedef __int64 int64_t

Definition at line 249 of file words.h.

◆ int8_t

typedef char int8_t

Definition at line 209 of file words.h.

◆ longword

typedef unsigned long longword

Definition at line 312 of file words.h.

◆ uchar

typedef unsigned char uchar

Definition at line 277 of file words.h.

◆ udouble

typedef double udouble

Definition at line 297 of file words.h.

◆ uint

typedef unsigned int uint

Definition at line 287 of file words.h.

◆ uint16_t

typedef unsigned short uint16_t

Definition at line 213 of file words.h.

◆ uint64_t

typedef unsigned __int64 uint64_t

Definition at line 250 of file words.h.

◆ uint8_t

typedef unsigned char uint8_t

Definition at line 210 of file words.h.

◆ ulong

typedef unsigned long ulong

Definition at line 292 of file words.h.

◆ ushort

typedef unsigned short ushort

Definition at line 282 of file words.h.

◆ word

typedef unsigned short word

Definition at line 307 of file words.h.