summaryrefslogtreecommitdiffstats
path: root/src/include/compiler.h
Commit message (Collapse)AuthorAgeFilesLines
* [build] Avoid confusing sparse in single-argument DBG() macrosMichael Brown2017-03-221-2/+2
| | | | | | | | | | | | | For visual consistency with surrounding lines, the definitions of DBG_MORE(), DBG_PAUSE(), etc include an unnecessary ##__VA_ARGS__ argument which is always elided. This confuses sparse, which complains about DBG_MORE_IF() being called with more than one argument. Work around this problem by adding an unused variable argument list to the single-argument macros DBG_MORE_IF() and DBG_PAUSE_IF(). Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [build] Provide common ARRAY_SIZE() definitionMichael Brown2017-03-101-0/+7
| | | | | | | Several files define the ARRAY_SIZE() macro as used in Linux. Provide a common definition for this in include/compiler.h. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [debug] Allow debug messages to be initially disabled at runtimeMichael Brown2016-07-051-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Extend the DEBUG=... syntax to allow debug messages to be compiled in but disabled by default. For example: make bin/undionly.kpxe DEBUG=netdevice:3:1 would compile in the messages as for DEBUG=netdevice:3, but would set the debug level mask so that only the DEBUG=netdevice:1 messages would be displayed. This allows for external code to selectively enable the additional debug messages at runtime, without being overwhelmed by unwanted initial noise. For example, a developer of a new protocol may want to temporarily enable tracing of all packets received: this can be done by building with DEBUG=netdevice:3:1 and using // temporarily enable per-packet messages DBG_ENABLE_OBJECT ( netdevice, DBGLVL_EXTRA ); ... // disable per-packet messages DBG_DISABLE_OBJECT ( netdevice, DBGLVL_EXTRA ); Note that unlike the usual DBG_ENABLE() and DBG_DISABLE() macros, DBG_ENABLE_OBJECT() and DBG_DISABLE_OBJECT() will not be removed via dead code elimination if debugging is disabled in the specified object. In particular, this means that using either of these macros will always result in a symbol reference to the specified object. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [debug] Allow per-object runtime enabling/disabling of debug messagesMichael Brown2016-07-051-4/+13
| | | | | | | | | | | | | | | | | | | | | | | | | The DBG_ENABLE() and DBG_DISABLE() macros currently affect the debug level of all objects that were built with debugging enabled. This is undesirable, since it is common to use different debug levels in each object. Make the debug level mask a per-object variable. DBG_ENABLE() and DBG_DISABLE() now control only the debug level for the containing object (which is consistent with the intended usage across the existing codebase). DBG_ENABLE_OBJECT() and DBG_DISABLE_OBJECT() may be used to control the debug level for a specified object. For example: // Enable DBG() messages from tcpip.c DBG_ENABLE_OBJECT ( tcpip, DBGLVL_LOG ); Note that the existence of debug messages continues to be gated by the DEBUG=... list specified on the build command line. If an object was built without the relevant debug level, then DBG_ENABLE_OBJECT() will have no effect on that object at runtime (other than to explicitly drag in the object via a symbol reference). Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [build] Allow assembler section type character to vary by architectureMichael Brown2016-03-131-3/+14
| | | | | | | | | | | | | | | On some architectures (such as ARM) the "@" character is used as a comment delimiter. A section type argument such as "@progbits" therefore becomes "%progbits". This is further complicated by the fact that the "%" character has special meaning for inline assembly when input or output operands are used, in which cases "@progbits" becomes "%%progbits". Allow the section type character(s) to be defined via Makefile variables. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [build] Fix the REQUIRE_SYMBOL mechanismMichael Brown2015-03-051-42/+107
| | | | | | | | | | | | | | | | | | | | | | | | | | At some point in the past few years, binutils became more aggressive at removing unused symbols. To function as a symbol requirement, a relocation record must now be in a section marked with @progbits and must not be in a section which gets discarded during the link (either via --gc-sections or via /DISCARD/). Update REQUIRE_SYMBOL() to generate relocation records meeting these criteria. To minimise the impact upon the final binary size, we use existing symbols (specified via the REQUIRING_SYMBOL() macro) as the relocation targets where possible. We use R_386_NONE or R_X86_64_NONE relocation types to prevent any actual unwanted relocation taking place. Where no suitable symbol exists for REQUIRING_SYMBOL() (such as in config.c), the macro PROVIDE_REQUIRING_SYMBOL() can be used to generate a one-byte-long symbol to act as the relocation target. If there are versions of binutils for which this approach fails, then the fallback will probably involve killing off REQUEST_SYMBOL(), redefining REQUIRE_SYMBOL() to use the current definition of REQUEST_SYMBOL(), and postprocessing the linked ELF file with something along the lines of "nm -u | wc -l" to check that there are no undefined symbols remaining. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [build] Use REQUIRE_OBJECT() to drag in per-object configurationMichael Brown2015-03-051-5/+0Star
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [build] Remove unused __keepme macroMichael Brown2015-03-031-8/+0Star
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [build] Remove unused IMPORT_SYMBOL() and EXPORT_SYMBOL() macrosMichael Brown2015-03-031-48/+0Star
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [legal] Add support for the Unmodified Binary Distribution LicenceMichael Brown2015-03-021-0/+11
| | | | | | | | | | | | | | | Add the text for the Unmodified Binary Distribution Licence. This Licence allows for the distribution of unmodified binaries built from publicly available source code, without imposing the obligations of the GNU General Public License upon anyone who chooses to distribute only the unmodified binaries built from that source code. See the licence text for the precise terms and conditions. Add the licence GPL2_OR_LATER_OR_UBDL to the set of licences which can be declared using FILE_LICENCE(), and add the corresponding support to licence.pl. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [build] Allow for a debug level of zeroMichael Brown2014-04-281-15/+2Star
| | | | | | | | Allow for an explicit debug level of zero, which will enable assertions and profiling (i.e. anything controlled by NDEBUG) without generating any debug messages. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [build] Fix %.licence build targetMichael Brown2013-07-161-10/+13
| | | | | | | | | | | | | | | | | | | | | | | | Our use of --gc-sections causes the linker to discard the symbols defined by FILE_LICENCE(), meaning that the resulting licence determination is incomplete. We must use the KEEP() directive in the linker script to force the linker to not discard the licence symbols. Using KEEP(*(COMMON)) would be undesirable, since there are some symbols in COMMON which we may wish to discard. Fix by placing symbols defined by PROVIDE_SYMBOL() (which is used by FILE_LICENCE()) into a special ".provided" section, which we then mark with KEEP(). All such symbols are zero-length, so there is no cost in terms of the final binary size. Since the symbols are no longer in COMMON, the linker will reject symbols with the same name coming from multiple objects. We therefore append the object name to the licence symbol, to ensure that it is unique. Reported-by: Marin Hannache <git@mareo.fr> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [build] Avoid sparse undeclared symbol warning for PROVIDE_SYMBOL()Michael Brown2013-04-251-0/+1
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [console] Allow usage to be defined independently for each consoleMichael Brown2012-03-261-13/+3Star
| | | | | | | | | | | | | | | | | | | | | Add the concept of a "console usage", such as "standard output" or "debug messages". Allow usages to be associated with each console independently. For example, to send debugging output via the serial port, while preventing it from appearing on the local console: #define CONSOLE_SERIAL CONSOLE_USAGE_ALL #define CONSOLE_PCBIOS ( CONSOLE_USAGE_ALL & ~CONSOLE_USAGE_DEBUG ) If no usages are explicitly specified, then a default set of usages will be applied. For example: #define CONSOLE_SERIAL will have the same affect as #define CONSOLE_SERIAL CONSOLE_USAGE_ALL Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [debug] Ensure debug address and colourisation fields are fully initialisedMichael Brown2012-03-061-0/+3
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [build] Allow DEBUG=... to affect builds of assembler source filesMichael Brown2011-03-011-6/+6
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [debug] Add DBG_MD5() and related macrosMichael Brown2010-12-091-0/+61
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [fnrec] Enhance function recordingMichael Brown2010-12-091-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | Enhance the information collected by the function recorder to include the call site and entry/exit counts. This allows fnrec.pl to produce a call tree such as: step (from core/getkey.c:46 = 0x17e90) { ref_increment (from core/process.c:93 = 0x73ec) { } net_step (from core/process.c:96 = 0x73f1) { net_poll (from net/netdevice.c:741 = 0xbce6) { netdev_poll (from net/netdevice.c:700 = 0xbc58) { } netdev_rx_dequeue (from net/netdevice.c:709 = 0xbc65) { } } } ref_decrement (from core/process.c:96 = 0x73f9) { } } Note that inlined functions are reported, confusingly, as extra calls to the *containing* function. Minimise this confusion by adding the attribute "no_instrument_function" to all functions declared as inline. (Static functions that have been inlined autonomously by gcc will still be problematic, but these are far fewer in number.) Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [build] Remove unnecessary constraint on DBG_ENABLE()/DBG_DISABLE()Michael Brown2010-09-121-2/+2
| | | | | | | | | | | | | | DBG_ENABLE() and DBG_DISABLE() are currently constrained to enabling and disabling only debug levels that are compiled in for the current object. For example, a DBG_ENABLE(DBGLVL_EXTRA) in foo.c will not be able to affect output from other objects at DBGLVL_EXTRA unless foo.c is itself compiled with DBGLVL_EXTRA enabled. Partially fix by removing this unnecessary constraint. (Note that it is still necessary for at least one debug level to be compiled in for the object invoking DBG_ENABLE()/DBG_DISABLE().) Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [compiler] Prevent empty weak function stubs from being removedJoshua Oreman2010-08-191-0/+8
| | | | | | | | | | | | | | | | | Even with the noinline specifier added by commit 1a260f8, gcc may skip calls to non-inlinable functions that it knows have no side effects. This caused the get_cached_dhcpack() call in start_dhcp(), the weak stub of which has no code in its body, to be removed, preventing cached DHCP from working. Fix by adding a __keepme macro to compiler.h expanding to asm(""), as recommended by gcc's info page, and using it in the weak stub for get_cached_dhcpack(). Reported-by: Aaron Brooks <aaron@brooks1.net> Tested-by: Aaron Brooks <aaron@brooks1.net> Signed-off-by: Joshua Oreman <oremanj@rwcr.net> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [build] Mark weak functions noinlineStefan Hajnoczi2010-07-141-2/+9
| | | | | | | | | | | | | | | | | | | | | Weak functions whose visibility is hidden may be inlined due to a bug in GCC. Explicitly mark weak functions noinline to work around the problem. This makes the PXE_MENU config option work again, the PXE boot menu was never being called because the compiler inlined a weak stub function. The GCC bug was identified and fixed by Richard Sandiford <rdsandiford@googlemail.com> but in the meantime iPXE needs to implement a workaround. Reported-by: Steve Jones <steve@squaregoldfish.co.uk> Reported-by: Shao Miller <shao.miller@yrdsb.edu.on.ca> Suggested-by: Joshua Oreman <oremanj@rwcr.net> Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com> Modified-by: Michael Brown <mcb30@ipxe.org> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [debug] Expose pause() and more() debugging functionsMichael Brown2010-07-141-24/+76
| | | | | | | | Include the pause() and more() debugging functions within the general iPXE debugging framework, by introducing DBGxxx_PAUSE() and DBGxxx_MORE() macros. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [build] Remove PACKED macroMichael Brown2010-05-301-3/+0Star
| | | | | | | Most of iPXE uses __attribute__((packed)) anyway, and PACKED conflicts with an identically-named macro in the upstream EFI header files. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [build] Use weak definitions instead of weak declarationsJoshua Oreman2010-05-271-31/+2Star
| | | | | | | | | | | | | | | This removes the need for inline safety wrappers, marginally reducing the size penalty of weak functions, and works around an apparent binutils bug that causes undefined weak symbols to not actually be NULL when compiling with -fPIE (as EFI builds do). A bug in versions of binutils prior to 2.16 (released in 2005) will cause same-file weak definitions to not work with those toolchains. Update the README to reflect our new dependency on binutils >= 2.16. Signed-off-by: Joshua Oreman <oremanj@rwcr.net> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [build] Rename gPXE to iPXEMichael Brown2010-04-201-1/+1
| | | | | | | | | | | Access to the gpxe.org and etherboot.org domains and associated resources has been revoked by the registrant of the domain. Work around this problem by renaming project from gPXE to iPXE, and updating URLs to match. Also update README, LOG and COPYRIGHTS to remove obsolete information. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [linker] Add safe weak symbol macrosJoshua Oreman2010-01-201-0/+36
| | | | | | | | | | | Weak symbols are a useful tool in eliminating unnecessary dependencies between object files, but they are somewhat dangerous because one must remember to test the weak symbol against NULL before using it. To rectify that, add macros for declaring weak functions that will return a default value inline if the file defining them is not available at link time. Signed-off-by: Marty Connor <mdc@etherboot.org>
* [linker] Add mechanism for subsystem-dependent configuration optionsJoshua Oreman2009-11-211-0/+5
| | | | | | | | | | | | | | | | | | | | It is often the case that some module of gPXE is only relevant if the subsystem it depends on is already being included. For instance, commands to manage wireless interfaces are quite useless if no compiled-in driver has pulled in the wireless networking stack. There may be a user-modifiable configuration options for these dependent modules, but even if enabled, they should not be included when they would be useless. Solve this by allowing the creation of config_subsystem.c, for configuration directives like those in the global config.c that should only be considered when subsystem.c is included in the final gPXE build. For consistency, move core/config.c to the config/ directory, where the other config_subsystem.c files will eventually reside. Signed-off-by: Marty Connor <mdc@etherboot.org>
* [linker] Expand and correct symbol requirement macrosJoshua Oreman2009-11-211-10/+95
| | | | | | | | | | | | | | | REQUIRE_SYMBOL() formerly used a formulation of symbol requirement that would allow a link to succeed despite lacking a required symbol, because it did not introduce any relocations. Fix by renaming it to REQUEST_SYMBOL() (since the soft-requirement behavior can be useful) and add a REQUIRE_SYMBOL() that truly requires. Add EXPORT_SYMBOL() and IMPORT_SYMBOL() for REQUEST_SYMBOL()-like behavior that allows one to make use of the symbol, by combining a weak external on the symbol itself with a REQUEST_SYMBOL() of a second symbol. Signed-off-by: Marty Connor <mdc@etherboot.org>
* [legal] Add MIT licence declarationJoshua Oreman2009-08-091-0/+10
| | | | Signed-off-by: Michael Brown <mcb30@etherboot.org>
* [legal] Add mechanism for explicit per-file licence declarationsMichael Brown2009-05-181-0/+101
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For partly historical reasons, various files in the gPXE source tree are licensed under different, though compatible, terms. Most of the code is licensed under GPLv2 with the "or later" clause, but there are exceptions such as: The string.h file, which derives from Linux and is licensed as Public Domain. The EFI header files, which are taken from the EDK2 source tree and are licensed under BSD. The 3c90x driver, which has a custom GPL-like licence text. Introduce a FILE_LICENCE() macro to make licensing more explicit. This macro should be applied exactly once to each source (.c, .S or .h) file. It will cause a corresponding zero-sized common symbol to be added to any .o files generated from that source file (and hence to any final gPXE binaries generated from that source file). Determining the applicable licences to generated files can then be done using e.g. $ objdump -t bin/process.o | grep __licence 00000000 O *COM* 00000001 .hidden __licence_gpl2_or_later indicating that bin/process.o is covered entirely by the GPLv2 with the "or later" clause, or $ objdump -t bin/rtl8139.dsk.tmp | grep __licence 00033e8c g O .bss.textdata 00000000 .hidden __licence_gpl2_only 00033e8c g O .bss.textdata 00000000 .hidden __licence_gpl2_or_later 00033e8c g O .bss.textdata 00000000 .hidden __licence_public_domain indicating that bin/rtl8139.dsk includes both code licensed under GPLv2 (both with and without the "or later" clause) and code licensed as Public Domain. Determining the result of licence combinations is currently left as an exercise for the reader.
* [build] Add {PROVIDE,REQUIRE}_SYMBOL macros and tidy up compiler.hMichael Brown2009-04-271-41/+68
|
* [build] Enable building with the Intel C compiler (icc)Michael Brown2009-03-261-1/+2
|
* [build] Fix building on gcc 3Michael Brown2009-02-161-0/+2
| | | | GCC did not support #pragma GCC visibility until version 4.0.
* [x86_64] Add support for compilation as an x86_64 binaryMichael Brown2008-12-051-0/+9
| | | | | | | | | | | | Currently the only supported platform for x86_64 is EFI. Building an EFI64 gPXE requires a version of gcc that supports __attribute__((ms_abi)). This currently means a development build of gcc; the feature should be present when gcc 4.4 is released. In the meantime; you can grab a suitable gcc tree from git://git.etherboot.org/scm/people/mcb30/gcc/.git
* [i386] Rename __cdecl to __asmcallMichael Brown2008-11-191-3/+2Star
| | | | | __cdecl is a misleading name, since it currently encapsulates both cdecl and regparm(0) attributes. Rename to __asmcall.
* [compiler] Allow for selective disabling of debug levels at runtimeMichael Brown2008-10-011-2/+17
| | | | | | | | | | | | | The usefulness of DBGLVL_IO is limited by the fact that many cards require large numbers of uninteresting I/O reads/writes at device probe time, typically when driving a bit-bashing I2C/SPI bus to read the MAC address. This patch adds the DBG_DISABLE() and DBG_ENABLE() macros, which can be used to temporarily disable and re-enable selected debug levels. Note that debug levels must still be enabled in the build in order to function at all: you can't use DBG_ENABLE(DBGLVL_IO) in an object built with DEBUG=object:1 and expect it to do anything.
* [compiler] Add __always_inline macroMichael Brown2008-10-011-0/+3
|
* [legacy] Align legacy drivers' __shared data to the maximum possibleMichael Brown2008-06-141-1/+1
| | | | | | | | | | | | | | Some drivers that still use the legacy-driver wrapper (tg3 in particular) apparently do not specify their alignment constraints properly. This hack forces any __shared data to be maximally aligned. Note that this provides only 16-byte alignment; it is not possible to request alignment to any greater than 16 bytes using __attribute__((aligned)), since the relocation code will preserve only 16 byte alignment (and operation under -DKEEP_IT_REAL cannot preserve more that 16 byte alignment). Idea proposed by Tim Hockin <thockin@google.com>
* Add DBGLVL_IO to trace all memory-mapped I/O.Michael Brown2008-02-211-0/+11
|
* Merge commit 'holger/strings'Michael Brown2007-08-231-0/+25
|\
| * define malloc attributeHolger Lubitz2007-08-201-0/+6
| |
| * define __nonnullHolger Lubitz2007-08-021-0/+7
| |
| * define __pure and __constHolger Lubitz2007-08-021-0/+12
| |
* | Add barrier() primitive (was present in Eb5.4), used by some currentlyMichael Brown2007-08-181-0/+5
|/ | | | out-of-tree driver code.
* Applied a modified version of holger's regparm patches.Michael Brown2007-07-291-0/+3
|
* Add per-file error identifiersMichael Brown2007-07-241-0/+3
|
* Use "dbg_stream" rather than "stream" as a variable name inMichael Brown2007-01-301-3/+3
| | | | DBG_AC_IF(), to avoid namespace collisions.
* console.h is no longer needed for debuggingMichael Brown2007-01-181-1/+0Star
|
* Add DBGLVL_PROFILEMichael Brown2007-01-181-14/+28
|
* Hex dumps are now integrated into the DBG() framework.Michael Brown2007-01-131-5/+93
|