iPXE
Macros | Functions
compiler.h File Reference

Global compiler definitions. More...

#include <bits/compiler.h>

Go to the source code of this file.

Macros

#define __attribute__(x)
 
#define _C1(x, y)   x ## y
 Concatenate non-expanded arguments. More...
 
#define _C2(x, y)   _C1 ( x, y )
 Concatenate expanded arguments. More...
 
#define _S1(x)   #x
 Stringify non-expanded argument. More...
 
#define _S2(x)   _S1 ( x )
 Stringify expanded argument. More...
 
#define PROGBITS_OPS   _S2 ( ASM_TCHAR_OPS ) "progbits"
 
#define PROGBITS   _S2 ( ASM_TCHAR ) "progbits"
 
#define NOBITS_OPS   _S2 ( ASM_TCHAR_OPS ) "nobits"
 
#define NOBITS   _S2 ( ASM_TCHAR ) "nobits"
 
#define PROVIDE_SYMBOL(symbol)
 Provide a symbol within this object file. More...
 
#define REQUEST_SYMBOL(symbol)   __asm__ ( ".equ __request_" #symbol ", " #symbol )
 Request a symbol. More...
 
#define REQUIRE_SYMBOL(symbol)
 Require a symbol. More...
 
#define REQUIRING_SYMBOL(symbol)   __asm__ ( ".equ __requiring_symbol__, " #symbol )
 Specify the file's requiring symbol. More...
 
#define PROVIDE_REQUIRING_SYMBOL()
 Provide a file's requiring symbol. More...
 
#define PREFIX_OBJECT(_prefix)   _C2 ( _prefix, OBJECT )
 
#define OBJECT_SYMBOL   PREFIX_OBJECT ( obj_ )
 
#define REQUEST_OBJECT(object)   REQUEST_SYMBOL ( obj_ ## object )
 Request an object. More...
 
#define REQUIRE_OBJECT(object)   REQUIRE_SYMBOL ( obj_ ## object )
 Require an object. More...
 
#define ERRFILE   PREFIX_OBJECT ( ERRFILE_ )
 Select file identifier for errno.h (if used) More...
 
#define __weak   __attribute__ (( weak, noinline ))
 Declare a function as weak (use before the definition) More...
 
#define NDEBUG
 
#define DBGLVL_MAX   0
 
#define DBGLVL_DFLT   DBGLVL_MAX
 
#define __debug_disable(object)   _C2 ( __debug_disable_, object )
 
#define DBG_DISABLE_OBJECT(object, level)
 
#define DBG_ENABLE_OBJECT(object, level)
 
#define DBGLVL   0
 
#define DBG_DISABLE(level)   do { } while ( 0 )
 
#define DBG_ENABLE(level)   do { } while ( 0 )
 
#define DBGLVL_LOG   1
 
#define DBG_LOG   ( DBGLVL & DBGLVL_LOG )
 
#define DBGLVL_EXTRA   2
 
#define DBG_EXTRA   ( DBGLVL & DBGLVL_EXTRA )
 
#define DBGLVL_PROFILE   4
 
#define DBG_PROFILE   ( DBGLVL & DBGLVL_PROFILE )
 
#define DBGLVL_IO   8
 
#define DBG_IO   ( DBGLVL & DBGLVL_IO )
 
#define DBG_IF(level, ...)
 Print debugging message if we are at a certain debug level. More...
 
#define DBG_HDA_IF(level, dispaddr, data, len)
 Print a hex dump if we are at a certain debug level. More...
 
#define DBG_HD_IF(level, data, len)
 Print a hex dump if we are at a certain debug level. More...
 
#define DBG_MD5A_IF(level, dispaddr, data, len)
 Print an MD5 checksum if we are at a certain debug level. More...
 
#define DBG_MD5_IF(level, data, len)
 Print an MD5 checksum if we are at a certain debug level. More...
 
#define DBG_PAUSE_IF(level, ...)
 Prompt for key press if we are at a certain debug level. More...
 
#define DBG_MORE_IF(level, ...)
 Prompt for more output data if we are at a certain debug level. More...
 
#define DBG_AC_IF(level, id)
 Select colour for debug messages if we are at a certain debug level. More...
 
#define DBG_DC_IF(level)
 Revert colour for debug messages if we are at a certain debug level. More...
 
#define DBGC_IF(level, id, ...)
 
#define DBGC_HDA_IF(level, id, ...)
 
#define DBGC_HD_IF(level, id, ...)
 
#define DBGC_MD5A_IF(level, id, ...)
 
#define DBGC_MD5_IF(level, id, ...)
 
#define DBGC_PAUSE_IF(level, id)
 
#define DBGC_MORE_IF(level, id)
 
#define DBG(...)   DBG_IF ( LOG, ##__VA_ARGS__ )
 Print a debugging message. More...
 
#define DBG_HDA(...)   DBG_HDA_IF ( LOG, ##__VA_ARGS__ )
 
#define DBG_HD(...)   DBG_HD_IF ( LOG, ##__VA_ARGS__ )
 
#define DBG_MD5A(...)   DBG_MD5A_IF ( LOG, ##__VA_ARGS__ )
 
#define DBG_MD5(...)   DBG_MD5_IF ( LOG, ##__VA_ARGS__ )
 
#define DBG_PAUSE(...)   DBG_PAUSE_IF ( LOG, ##__VA_ARGS__ )
 
#define DBG_MORE(...)   DBG_MORE_IF ( LOG, ##__VA_ARGS__ )
 
#define DBGC(...)   DBGC_IF ( LOG, ##__VA_ARGS__ )
 
#define DBGC_HDA(...)   DBGC_HDA_IF ( LOG, ##__VA_ARGS__ )
 
#define DBGC_HD(...)   DBGC_HD_IF ( LOG, ##__VA_ARGS__ )
 
#define DBGC_MD5A(...)   DBGC_MD5A_IF ( LOG, ##__VA_ARGS__ )
 
#define DBGC_MD5(...)   DBGC_MD5_IF ( LOG, ##__VA_ARGS__ )
 
#define DBGC_PAUSE(...)   DBGC_PAUSE_IF ( LOG, ##__VA_ARGS__ )
 
#define DBGC_MORE(...)   DBGC_MORE_IF ( LOG, ##__VA_ARGS__ )
 
#define DBG2(...)   DBG_IF ( EXTRA, ##__VA_ARGS__ )
 
#define DBG2_HDA(...)   DBG_HDA_IF ( EXTRA, ##__VA_ARGS__ )
 
#define DBG2_HD(...)   DBG_HD_IF ( EXTRA, ##__VA_ARGS__ )
 
#define DBG2_MD5A(...)   DBG_MD5A_IF ( EXTRA, ##__VA_ARGS__ )
 
#define DBG2_MD5(...)   DBG_MD5_IF ( EXTRA, ##__VA_ARGS__ )
 
#define DBG2_PAUSE(...)   DBG_PAUSE_IF ( EXTRA, ##__VA_ARGS__ )
 
#define DBG2_MORE(...)   DBG_MORE_IF ( EXTRA, ##__VA_ARGS__ )
 
#define DBGC2(...)   DBGC_IF ( EXTRA, ##__VA_ARGS__ )
 
#define DBGC2_HDA(...)   DBGC_HDA_IF ( EXTRA, ##__VA_ARGS__ )
 
#define DBGC2_HD(...)   DBGC_HD_IF ( EXTRA, ##__VA_ARGS__ )
 
#define DBGC2_MD5A(...)   DBGC_MD5A_IF ( EXTRA, ##__VA_ARGS__ )
 
#define DBGC2_MD5(...)   DBGC_MD5_IF ( EXTRA, ##__VA_ARGS__ )
 
#define DBGC2_PAUSE(...)   DBGC_PAUSE_IF ( EXTRA, ##__VA_ARGS__ )
 
#define DBGC2_MORE(...)   DBGC_MORE_IF ( EXTRA, ##__VA_ARGS__ )
 
#define DBGP(...)   DBG_IF ( PROFILE, ##__VA_ARGS__ )
 
#define DBGP_HDA(...)   DBG_HDA_IF ( PROFILE, ##__VA_ARGS__ )
 
#define DBGP_HD(...)   DBG_HD_IF ( PROFILE, ##__VA_ARGS__ )
 
#define DBGP_MD5A(...)   DBG_MD5A_IF ( PROFILE, ##__VA_ARGS__ )
 
#define DBGP_MD5(...)   DBG_MD5_IF ( PROFILE, ##__VA_ARGS__ )
 
#define DBGP_PAUSE(...)   DBG_PAUSE_IF ( PROFILE, ##__VA_ARGS__ )
 
#define DBGP_MORE(...)   DBG_MORE_IF ( PROFILE, ##__VA_ARGS__ )
 
#define DBGCP(...)   DBGC_IF ( PROFILE, ##__VA_ARGS__ )
 
#define DBGCP_HDA(...)   DBGC_HDA_IF ( PROFILE, ##__VA_ARGS__ )
 
#define DBGCP_HD(...)   DBGC_HD_IF ( PROFILE, ##__VA_ARGS__ )
 
#define DBGCP_MD5A(...)   DBGC_MD5A_IF ( PROFILE, ##__VA_ARGS__ )
 
#define DBGCP_MD5(...)   DBGC_MD5_IF ( PROFILE, ##__VA_ARGS__ )
 
#define DBGCP_PAUSE(...)   DBGC_PAUSE_IF ( PROFILE, ##__VA_ARGS__ )
 
#define DBGCP_MORE(...)   DBGC_MORE_IF ( PROFILE, ##__VA_ARGS__ )
 
#define DBGIO(...)   DBG_IF ( IO, ##__VA_ARGS__ )
 
#define DBGIO_HDA(...)   DBG_HDA_IF ( IO, ##__VA_ARGS__ )
 
#define DBGIO_HD(...)   DBG_HD_IF ( IO, ##__VA_ARGS__ )
 
#define DBGIO_MD5A(...)   DBG_MD5A_IF ( IO, ##__VA_ARGS__ )
 
#define DBGIO_MD5(...)   DBG_MD5_IF ( IO, ##__VA_ARGS__ )
 
#define DBGIO_PAUSE(...)   DBG_PAUSE_IF ( IO, ##__VA_ARGS__ )
 
#define DBGIO_MORE(...)   DBG_MORE_IF ( IO, ##__VA_ARGS__ )
 
#define DBGCIO(...)   DBGC_IF ( IO, ##__VA_ARGS__ )
 
#define DBGCIO_HDA(...)   DBGC_HDA_IF ( IO, ##__VA_ARGS__ )
 
#define DBGCIO_HD(...)   DBGC_HD_IF ( IO, ##__VA_ARGS__ )
 
#define DBGCIO_MD5A(...)   DBGC_MD5A_IF ( IO, ##__VA_ARGS__ )
 
#define DBGCIO_MD5(...)   DBGC_MD5_IF ( IO, ##__VA_ARGS__ )
 
#define DBGCIO_PAUSE(...)   DBGC_PAUSE_IF ( IO, ##__VA_ARGS__ )
 
#define DBGCIO_MORE(...)   DBGC_MORE_IF ( IO, ##__VA_ARGS__ )
 
#define __unused   __attribute__ (( unused ))
 Declare a variable or data structure as unused. More...
 
#define __pure   __attribute__ (( pure ))
 Declare a function as pure - i.e. More...
 
#define __const   __attribute__ (( const ))
 Declare a function as const - i.e. More...
 
#define __nonnull   __attribute__ (( nonnull ))
 Declare a function's pointer parameters as non-null - i.e. More...
 
#define __malloc   __attribute__ (( malloc ))
 Declare a pointer returned by a function as a unique memory address as returned by malloc-type functions. More...
 
#define __used   __attribute__ (( used ))
 Declare a function as used. More...
 
#define __aligned   __attribute__ (( aligned ( 16 ) ))
 Declare a data structure to be aligned with 16-byte alignment. More...
 
#define __always_inline   __attribute__ (( always_inline ))
 Declare a function to be always inline. More...
 
#define inline   inline __attribute__ (( no_instrument_function ))
 
#define __shared   __asm__ ( "_shared_bss" ) __aligned
 Shared data. More...
 
#define barrier()   __asm__ __volatile__ ( "" : : : "memory" )
 Optimisation barrier. More...
 
#define ARRAY_SIZE(array)   ( sizeof (array) / sizeof ( (array)[0] ) )
 Array size. More...
 
#define FILE_LICENCE_PUBLIC_DOMAIN   PROVIDE_SYMBOL ( PREFIX_OBJECT ( __licence__public_domain__ ) )
 Declare a file as being in the public domain. More...
 
#define FILE_LICENCE_GPL2_OR_LATER   PROVIDE_SYMBOL ( PREFIX_OBJECT ( __licence__gpl2_or_later__ ) )
 Declare a file as being under version 2 (or later) of the GNU GPL. More...
 
#define FILE_LICENCE_GPL2_ONLY   PROVIDE_SYMBOL ( PREFIX_OBJECT ( __licence__gpl2_only__ ) )
 Declare a file as being under version 2 of the GNU GPL. More...
 
#define FILE_LICENCE_GPL_ANY   PROVIDE_SYMBOL ( PREFIX_OBJECT ( __licence__gpl_any__ ) )
 Declare a file as being under any version of the GNU GPL. More...
 
#define FILE_LICENCE_BSD3   PROVIDE_SYMBOL ( PREFIX_OBJECT ( __licence__bsd3__ ) )
 Declare a file as being under the three-clause BSD licence. More...
 
#define FILE_LICENCE_BSD2   PROVIDE_SYMBOL ( PREFIX_OBJECT ( __licence__bsd2__ ) )
 Declare a file as being under the two-clause BSD licence. More...
 
#define FILE_LICENCE_BSD2_PATENT   PROVIDE_SYMBOL ( PREFIX_OBJECT ( __licence__bsd2_patent__ ) )
 Declare a file as being under the two-clause BSD plus patent licence. More...
 
#define FILE_LICENCE_MIT   PROVIDE_SYMBOL ( PREFIX_OBJECT ( __licence__mit__ ) )
 Declare a file as being under the one-clause MIT-style licence. More...
 
#define FILE_LICENCE_GPL2_OR_LATER_OR_UBDL   PROVIDE_SYMBOL ( PREFIX_OBJECT ( __licence__gpl2_or_later_or_ubdl__ ) )
 Declare a file as being under GPLv2+ or UBDL. More...
 
#define FILE_LICENCE(_licence)   FILE_LICENCE_ ## _licence
 Declare a particular licence as applying to a file. More...
 

Functions

 PROVIDE_SYMBOL (OBJECT_SYMBOL)
 Always provide the symbol for the current object (defined by -DOBJECT) More...
 
void dbg_printf (const char *fmt,...)
 printf() for debugging More...
 
void dbg_autocolourise (unsigned long id)
 Select automatic colour for debug messages. More...
 
void dbg_decolourise (void)
 Revert to normal colour. More...
 
void dbg_hex_dump_da (unsigned long dispaddr, const void *data, unsigned long len)
 Print hex dump with specified display address. More...
 
void dbg_md5_da (unsigned long dispaddr, const void *data, unsigned long len)
 Print an MD5 checksum with specified display address. More...
 
void dbg_pause (void)
 Pause until a key is pressed. More...
 
void dbg_more (void)
 Indicate more data to follow and pause until a key is pressed. More...
 
char __debug_disable (OBJECT)
 
 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 

Detailed Description

Global compiler definitions.

This file is implicitly included by every .c file in Etherboot. It defines global macros such as DBG().

We arrange for each object to export the symbol obj_OBJECT (where OBJECT is the object name, e.g. rtl8139) as a global symbol, so that the linker can drag in selected object files from the library using -u obj_OBJECT .

Definition in file compiler.h.

Macro Definition Documentation

◆ __attribute__

#define __attribute__ (   x)

Definition at line 10 of file compiler.h.

◆ _C1

#define _C1 (   x,
 
)    x ## y

Concatenate non-expanded arguments.

Definition at line 46 of file compiler.h.

◆ _C2

#define _C2 (   x,
 
)    _C1 ( x, y )

Concatenate expanded arguments.

Definition at line 48 of file compiler.h.

◆ _S1

#define _S1 (   x)    #x

Stringify non-expanded argument.

Definition at line 51 of file compiler.h.

◆ _S2

#define _S2 (   x)    _S1 ( x )

Stringify expanded argument.

Definition at line 53 of file compiler.h.

◆ PROGBITS_OPS

#define PROGBITS_OPS   _S2 ( ASM_TCHAR_OPS ) "progbits"

Definition at line 60 of file compiler.h.

◆ PROGBITS

#define PROGBITS   _S2 ( ASM_TCHAR ) "progbits"

Definition at line 61 of file compiler.h.

◆ NOBITS_OPS

#define NOBITS_OPS   _S2 ( ASM_TCHAR_OPS ) "nobits"

Definition at line 62 of file compiler.h.

◆ NOBITS

#define NOBITS   _S2 ( ASM_TCHAR ) "nobits"

Definition at line 63 of file compiler.h.

◆ ERRFILE

#define ERRFILE   PREFIX_OBJECT ( ERRFILE_ )

Select file identifier for errno.h (if used)

Definition at line 207 of file compiler.h.

◆ __weak

#define __weak   __attribute__ (( weak, noinline ))

Declare a function as weak (use before the definition)

Due to a bug in at least GCC 4.4.4 and earlier, weak symbols may be inlined if they have hidden visibility (see above for why hidden visibility is used). This results in the non-weak symbol never being used, so explicitly mark the function as noinline to prevent inlining.

Definition at line 219 of file compiler.h.

◆ barrier

#define barrier ( )    __asm__ __volatile__ ( "" : : : "memory" )

Optimisation barrier.

Definition at line 655 of file compiler.h.

◆ ARRAY_SIZE

#define ARRAY_SIZE (   array)    ( sizeof (array) / sizeof ( (array)[0] ) )

Array size.

Definition at line 662 of file compiler.h.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )