iPXE
compiler.h
Go to the documentation of this file.
00001 #ifndef _BITS_COMPILER_H
00002 #define _BITS_COMPILER_H
00003 
00004 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
00005 
00006 /** Dummy relocation type */
00007 #define RELOC_TYPE_NONE R_386_NONE
00008 
00009 #ifndef ASSEMBLY
00010 
00011 /** Declare a function with standard calling conventions */
00012 #define __asmcall __attribute__ (( used, cdecl, regparm(0) ))
00013 
00014 /**
00015  * Declare a function with libgcc implicit linkage
00016  *
00017  * It seems as though gcc expects its implicit arithmetic functions to
00018  * be cdecl, even if -mrtd is specified.  This is somewhat
00019  * inconsistent; for example, if -mregparm=3 is used then the implicit
00020  * functions do become regparm(3).
00021  *
00022  * The implicit calls to memcpy() and memset() which gcc can generate
00023  * do not seem to have this inconsistency; -mregparm and -mrtd affect
00024  * them in the same way as any other function.
00025  *
00026  * Update (25/4/14): it appears that more recent gcc versions do allow
00027  * -mrtd to affect calls to the implicit arithmetic functions.  There
00028  * is nothing obvious in the gcc changelogs to indicate precisely when
00029  * this happened.  From experimentation with available gcc versions,
00030  * the change occurred sometime between v4.6.3 and v4.7.2.  We assume
00031  * that only versions up to v4.6.x require the special treatment.
00032  */
00033 #if ( __GNUC__ < 4 ) || ( ( __GNUC__ == 4 ) && ( __GNUC_MINOR__ <= 6 ) )
00034 #define __libgcc __attribute__ (( cdecl ))
00035 #else
00036 #define __libgcc
00037 #endif
00038 
00039 #endif /* ASSEMBLY */
00040 
00041 #endif /* _BITS_COMPILER_H */