10 #define __attribute__(x) 36 #pragma GCC visibility push(hidden) 46 #define _C1( x, y ) x ## y 48 #define _C2( x, y ) _C1 ( x, y ) 53 #define _S2( x ) _S1 ( x ) 57 #define PROGBITS _C2 ( ASM_TCHAR, progbits ) 58 #define NOBITS _C2 ( ASM_TCHAR, nobits ) 60 #define PROGBITS_OPS _S2 ( ASM_TCHAR_OPS ) "progbits" 61 #define PROGBITS _S2 ( ASM_TCHAR ) "progbits" 62 #define NOBITS_OPS _S2 ( ASM_TCHAR_OPS ) "nobits" 63 #define NOBITS _S2 ( ASM_TCHAR ) "nobits" 77 #define PROVIDE_SYMBOL( symbol ) \ 78 .section ".provided", "a", NOBITS ; \ 84 #define PROVIDE_SYMBOL( symbol ) \ 86 __attribute__ (( section ( ".provided" ) )) 98 #define REQUEST_SYMBOL( symbol ) \ 99 .equ __request_ ## symbol, symbol 101 #define REQUEST_SYMBOL( symbol ) \ 102 __asm__ ( ".equ __request_" #symbol ", " #symbol ) 118 #define REQUIRE_SYMBOL( symbol ) \ 119 .reloc __requiring_symbol__, RELOC_TYPE_NONE, symbol 121 #define REQUIRE_SYMBOL( symbol ) \ 122 __asm__ ( ".reloc __requiring_symbol__, " \ 123 _S2 ( RELOC_TYPE_NONE ) ", " #symbol ) 137 #define REQUIRING_SYMBOL( symbol ) \ 138 .equ __requiring_symbol__, symbol 140 #define REQUIRING_SYMBOL( symbol ) \ 141 __asm__ ( ".equ __requiring_symbol__, " #symbol ) 152 #define PROVIDE_REQUIRING_SYMBOL() \ 153 .section ".tbl.requiring_symbols", "a", PROGBITS ; \ 154 __requiring_symbol__: .byte 0 ; \ 155 .size __requiring_symbol__, . - __requiring_symbol__ ; \ 158 #define PROVIDE_REQUIRING_SYMBOL() \ 159 __asm__ ( ".section \".tbl.requiring_symbols\", " \ 160 " \"a\", " PROGBITS "\n" \ 161 "__requiring_symbol__:\t.byte 0\n" \ 162 ".size __requiring_symbol__, " \ 163 " . - __requiring_symbol__\n" \ 174 #define PREFIX_OBJECT( _prefix ) _C2 ( _prefix, OBJECT ) 175 #define OBJECT_SYMBOL PREFIX_OBJECT ( obj_ ) 188 #define REQUEST_OBJECT( object ) REQUEST_SYMBOL ( obj_ ## object ) 202 #define REQUIRE_OBJECT( object ) REQUIRE_SYMBOL ( obj_ ## object ) 207 #define ERRFILE PREFIX_OBJECT ( ERRFILE_ ) 219 #define __weak __attribute__ (( weak, noinline )) 274 #define DBGLVL_DFLT DBGLVL_MAX 285 const
void *
data,
unsigned long len );
286 extern
void dbg_md5_da (
unsigned long dispaddr,
287 const
void *
data,
unsigned long len );
292 #define __debug_disable( object ) _C2 ( __debug_disable_, object ) 294 #define DBG_DISABLE_OBJECT( object, level ) do { \ 295 extern char __debug_disable(object); \ 296 __debug_disable(object) |= (level); \ 298 #define DBG_ENABLE_OBJECT( object, level ) do { \ 299 extern char __debug_disable(object); \ 300 __debug_disable(object) &= ~(level); \ 303 #define DBGLVL ( DBGLVL_MAX & ~__debug_disable(OBJECT) ) 304 #define DBG_DISABLE( level ) do { \ 305 __debug_disable(OBJECT) |= ( (level) & DBGLVL_MAX ); \ 307 #define DBG_ENABLE( level ) do { \ 308 __debug_disable(OBJECT) &= ~( (level) & DBGLVL_MAX ); \ 312 #define DBG_DISABLE( level ) do { } while ( 0 ) 313 #define DBG_ENABLE( level ) do { } while ( 0 ) 317 #define DBG_LOG ( DBGLVL & DBGLVL_LOG ) 318 #define DBGLVL_EXTRA 2 319 #define DBG_EXTRA ( DBGLVL & DBGLVL_EXTRA ) 320 #define DBGLVL_PROFILE 4 321 #define DBG_PROFILE ( DBGLVL & DBGLVL_PROFILE ) 323 #define DBG_IO ( DBGLVL & DBGLVL_IO ) 331 #define DBG_IF( level, ... ) do { \ 332 if ( DBG_ ## level ) { \ 333 dbg_printf ( __VA_ARGS__ ); \ 345 #define DBG_HDA_IF( level, dispaddr, data, len ) do { \ 346 if ( DBG_ ## level ) { \ 349 typeof ( dispaddr ) raw; \ 353 dbg_hex_dump_da ( da.ul, data, len ); \ 364 #define DBG_HD_IF( level, data, len ) do { \ 365 const void *_data = data; \ 366 DBG_HDA_IF ( level, _data, _data, len ); \ 377 #define DBG_MD5A_IF( level, dispaddr, data, len ) do { \ 378 if ( DBG_ ## level ) { \ 381 typeof ( dispaddr ) raw; \ 385 dbg_md5_da ( da.ul, data, len ); \ 396 #define DBG_MD5_IF( level, data, len ) do { \ 397 const void *_data = data; \ 398 DBG_MD5A_IF ( level, _data, _data, len ); \ 406 #define DBG_PAUSE_IF( level, ... ) do { \ 407 if ( DBG_ ## level ) { \ 417 #define DBG_MORE_IF( level, ... ) do { \ 418 if ( DBG_ ## level ) { \ 429 #define DBG_AC_IF( level, id ) do { \ 430 if ( DBG_ ## level ) { \ 436 dbg_stream.raw = id; \ 437 dbg_autocolourise ( dbg_stream.ul ); \ 446 #define DBG_DC_IF( level ) do { \ 447 if ( DBG_ ## level ) { \ 454 #define DBGC_IF( level, id, ... ) do { \ 455 DBG_AC_IF ( level, id ); \ 456 DBG_IF ( level, __VA_ARGS__ ); \ 457 DBG_DC_IF ( level ); \ 460 #define DBGC_HDA_IF( level, id, ... ) do { \ 461 DBG_AC_IF ( level, id ); \ 462 DBG_HDA_IF ( level, __VA_ARGS__ ); \ 463 DBG_DC_IF ( level ); \ 466 #define DBGC_HD_IF( level, id, ... ) do { \ 467 DBG_AC_IF ( level, id ); \ 468 DBG_HD_IF ( level, __VA_ARGS__ ); \ 469 DBG_DC_IF ( level ); \ 472 #define DBGC_MD5A_IF( level, id, ... ) do { \ 473 DBG_AC_IF ( level, id ); \ 474 DBG_MD5A_IF ( level, __VA_ARGS__ ); \ 475 DBG_DC_IF ( level ); \ 478 #define DBGC_MD5_IF( level, id, ... ) do { \ 479 DBG_AC_IF ( level, id ); \ 480 DBG_MD5_IF ( level, __VA_ARGS__ ); \ 481 DBG_DC_IF ( level ); \ 484 #define DBGC_PAUSE_IF( level, id ) do { \ 485 DBG_AC_IF ( level, id ); \ 486 DBG_PAUSE_IF ( level ); \ 487 DBG_DC_IF ( level ); \ 490 #define DBGC_MORE_IF( level, id ) do { \ 491 DBG_AC_IF ( level, id ); \ 492 DBG_MORE_IF ( level ); \ 493 DBG_DC_IF ( level ); \ 498 #define DBG( ... ) DBG_IF ( LOG, ##__VA_ARGS__ ) 499 #define DBG_HDA( ... ) DBG_HDA_IF ( LOG, ##__VA_ARGS__ ) 500 #define DBG_HD( ... ) DBG_HD_IF ( LOG, ##__VA_ARGS__ ) 501 #define DBG_MD5A( ... ) DBG_MD5A_IF ( LOG, ##__VA_ARGS__ ) 502 #define DBG_MD5( ... ) DBG_MD5_IF ( LOG, ##__VA_ARGS__ ) 503 #define DBG_PAUSE( ... ) DBG_PAUSE_IF ( LOG, ##__VA_ARGS__ ) 504 #define DBG_MORE( ... ) DBG_MORE_IF ( LOG, ##__VA_ARGS__ ) 505 #define DBGC( ... ) DBGC_IF ( LOG, ##__VA_ARGS__ ) 506 #define DBGC_HDA( ... ) DBGC_HDA_IF ( LOG, ##__VA_ARGS__ ) 507 #define DBGC_HD( ... ) DBGC_HD_IF ( LOG, ##__VA_ARGS__ ) 508 #define DBGC_MD5A( ... ) DBGC_MD5A_IF ( LOG, ##__VA_ARGS__ ) 509 #define DBGC_MD5( ... ) DBGC_MD5_IF ( LOG, ##__VA_ARGS__ ) 510 #define DBGC_PAUSE( ... ) DBGC_PAUSE_IF ( LOG, ##__VA_ARGS__ ) 511 #define DBGC_MORE( ... ) DBGC_MORE_IF ( LOG, ##__VA_ARGS__ ) 515 #define DBG2( ... ) DBG_IF ( EXTRA, ##__VA_ARGS__ ) 516 #define DBG2_HDA( ... ) DBG_HDA_IF ( EXTRA, ##__VA_ARGS__ ) 517 #define DBG2_HD( ... ) DBG_HD_IF ( EXTRA, ##__VA_ARGS__ ) 518 #define DBG2_MD5A( ... ) DBG_MD5A_IF ( EXTRA, ##__VA_ARGS__ ) 519 #define DBG2_MD5( ... ) DBG_MD5_IF ( EXTRA, ##__VA_ARGS__ ) 520 #define DBG2_PAUSE( ... ) DBG_PAUSE_IF ( EXTRA, ##__VA_ARGS__ ) 521 #define DBG2_MORE( ... ) DBG_MORE_IF ( EXTRA, ##__VA_ARGS__ ) 522 #define DBGC2( ... ) DBGC_IF ( EXTRA, ##__VA_ARGS__ ) 523 #define DBGC2_HDA( ... ) DBGC_HDA_IF ( EXTRA, ##__VA_ARGS__ ) 524 #define DBGC2_HD( ... ) DBGC_HD_IF ( EXTRA, ##__VA_ARGS__ ) 525 #define DBGC2_MD5A( ... ) DBGC_MD5A_IF ( EXTRA, ##__VA_ARGS__ ) 526 #define DBGC2_MD5( ... ) DBGC_MD5_IF ( EXTRA, ##__VA_ARGS__ ) 527 #define DBGC2_PAUSE( ... ) DBGC_PAUSE_IF ( EXTRA, ##__VA_ARGS__ ) 528 #define DBGC2_MORE( ... ) DBGC_MORE_IF ( EXTRA, ##__VA_ARGS__ ) 532 #define DBGP( ... ) DBG_IF ( PROFILE, ##__VA_ARGS__ ) 533 #define DBGP_HDA( ... ) DBG_HDA_IF ( PROFILE, ##__VA_ARGS__ ) 534 #define DBGP_HD( ... ) DBG_HD_IF ( PROFILE, ##__VA_ARGS__ ) 535 #define DBGP_MD5A( ... ) DBG_MD5A_IF ( PROFILE, ##__VA_ARGS__ ) 536 #define DBGP_MD5( ... ) DBG_MD5_IF ( PROFILE, ##__VA_ARGS__ ) 537 #define DBGP_PAUSE( ... ) DBG_PAUSE_IF ( PROFILE, ##__VA_ARGS__ ) 538 #define DBGP_MORE( ... ) DBG_MORE_IF ( PROFILE, ##__VA_ARGS__ ) 539 #define DBGCP( ... ) DBGC_IF ( PROFILE, ##__VA_ARGS__ ) 540 #define DBGCP_HDA( ... ) DBGC_HDA_IF ( PROFILE, ##__VA_ARGS__ ) 541 #define DBGCP_HD( ... ) DBGC_HD_IF ( PROFILE, ##__VA_ARGS__ ) 542 #define DBGCP_MD5A( ... ) DBGC_MD5A_IF ( PROFILE, ##__VA_ARGS__ ) 543 #define DBGCP_MD5( ... ) DBGC_MD5_IF ( PROFILE, ##__VA_ARGS__ ) 544 #define DBGCP_PAUSE( ... ) DBGC_PAUSE_IF ( PROFILE, ##__VA_ARGS__ ) 545 #define DBGCP_MORE( ... ) DBGC_MORE_IF ( PROFILE, ##__VA_ARGS__ ) 549 #define DBGIO( ... ) DBG_IF ( IO, ##__VA_ARGS__ ) 550 #define DBGIO_HDA( ... ) DBG_HDA_IF ( IO, ##__VA_ARGS__ ) 551 #define DBGIO_HD( ... ) DBG_HD_IF ( IO, ##__VA_ARGS__ ) 552 #define DBGIO_MD5A( ... ) DBG_MD5A_IF ( IO, ##__VA_ARGS__ ) 553 #define DBGIO_MD5( ... ) DBG_MD5_IF ( IO, ##__VA_ARGS__ ) 554 #define DBGIO_PAUSE( ... ) DBG_PAUSE_IF ( IO, ##__VA_ARGS__ ) 555 #define DBGIO_MORE( ... ) DBG_MORE_IF ( IO, ##__VA_ARGS__ ) 556 #define DBGCIO( ... ) DBGC_IF ( IO, ##__VA_ARGS__ ) 557 #define DBGCIO_HDA( ... ) DBGC_HDA_IF ( IO, ##__VA_ARGS__ ) 558 #define DBGCIO_HD( ... ) DBGC_HD_IF ( IO, ##__VA_ARGS__ ) 559 #define DBGCIO_MD5A( ... ) DBGC_MD5A_IF ( IO, ##__VA_ARGS__ ) 560 #define DBGCIO_MD5( ... ) DBGC_MD5_IF ( IO, ##__VA_ARGS__ ) 561 #define DBGCIO_PAUSE( ... ) DBGC_PAUSE_IF ( IO, ##__VA_ARGS__ ) 562 #define DBGCIO_MORE( ... ) DBGC_MORE_IF ( IO, ##__VA_ARGS__ ) 573 #define __unused __attribute__ (( unused )) 578 #define __pure __attribute__ (( pure )) 585 #define __const __attribute__ (( const )) 592 #define __nonnull __attribute__ (( nonnull )) 598 #define __malloc __attribute__ (( malloc )) 605 #define __used __attribute__ (( used )) 608 #define __aligned __attribute__ (( aligned ( 16 ) )) 611 #define __always_inline __attribute__ (( always_inline )) 624 #define inline inline __attribute__ (( no_instrument_function )) 646 #define __shared __asm__ ( "_shared_bss" ) __aligned 655 #define barrier() __asm__ __volatile__ ( "" : : : "memory" ) 662 #define ARRAY_SIZE(array) ( sizeof (array) / sizeof ( (array)[0] ) ) 679 #define FILE_LICENCE_PUBLIC_DOMAIN \ 680 PROVIDE_SYMBOL ( PREFIX_OBJECT ( __licence__public_domain__ ) ) 688 #define FILE_LICENCE_GPL2_OR_LATER \ 689 PROVIDE_SYMBOL ( PREFIX_OBJECT ( __licence__gpl2_or_later__ ) ) 697 #define FILE_LICENCE_GPL2_ONLY \ 698 PROVIDE_SYMBOL ( PREFIX_OBJECT ( __licence__gpl2_only__ ) ) 709 #define FILE_LICENCE_GPL_ANY \ 710 PROVIDE_SYMBOL ( PREFIX_OBJECT ( __licence__gpl_any__ ) ) 734 #define FILE_LICENCE_BSD3 \ 735 PROVIDE_SYMBOL ( PREFIX_OBJECT ( __licence__bsd3__ ) ) 755 #define FILE_LICENCE_BSD2 \ 756 PROVIDE_SYMBOL ( PREFIX_OBJECT ( __licence__bsd2__ ) ) 802 #define FILE_LICENCE_BSD2_PATENT \ 803 PROVIDE_SYMBOL ( PREFIX_OBJECT ( __licence__bsd2_patent__ ) ) 812 #define FILE_LICENCE_MIT \ 813 PROVIDE_SYMBOL ( PREFIX_OBJECT ( __licence__mit__ ) ) 823 #define FILE_LICENCE_GPL2_OR_LATER_OR_UBDL \ 824 PROVIDE_SYMBOL ( PREFIX_OBJECT ( __licence__gpl2_or_later_or_ubdl__ ) ) 827 #define FILE_LICENCE( _licence ) FILE_LICENCE_ ## _licence
int printf(const char *fmt,...)
Write a formatted string to the console.
void dbg_autocolourise(unsigned long id)
Select automatic colour for debug messages.
void dbg_more(void)
Indicate more data to follow and pause until a key is pressed.
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
#define __debug_disable(object)
void dbg_md5_da(unsigned long dispaddr, const void *data, unsigned long len)
Print an MD5 checksum with specified display address.
void dbg_pause(void)
Pause until a key is pressed.
void dbg_decolourise(void)
Revert to normal colour.
uint8_t data[48]
Additional event data.
int ssize_t const char * fmt
void dbg_hex_dump_da(unsigned long dispaddr, const void *data, unsigned long len)
Print hex dump with specified display address.
#define PROVIDE_SYMBOL(symbol)
Provide a symbol within this object file.
void dbg_printf(const char *fmt,...)
printf() for debugging