Alias.h.xx-xxx-gcc File Reference
Defines a set of macros used to create function aliases for the GCC compiler.
More...
|
Defines |
#define | ALIAS_BEG(_container) |
| Introduces a group of aliases.
|
#define | ALIAS_FNC(_return_type, _name, _alias) |
| Defines an alias for a function.
|
#define | ALIAS_END(_container) |
| Closes a group of aliases.
|
Detailed Description
Defines a set of macros used to create function aliases for the GCC compiler.
- Author:
- JJRussell - russell@slac.stanford.edu
Define Documentation
#define ALIAS_BEG |
( |
_container |
|
) |
|
Introduces a group of aliases.
- Parameters:
-
| _container | A completely arbitrary, but unique name |
The container name is completely arbitrary. On some compilers (scc on SOLARIS) aliases can only be defined within the context of a routine. The parameter
_container is the name of the encapsulating routine. This is one of those interesting features that seemingly has no real reason, but...
#define ALIAS_END |
( |
_container |
|
) |
|
Closes a group of aliases.
- Parameters:
-
| _container | A completely arbitrary, but unique name. |
The container name is completely arbitrary. As explained in
ALIAS_BEG, on some compilers (scc on SOLARIS) aliases can only be defined within the context of a routine. The parameter
_container is the name of the encapsulating routine. The name is not actually used by this macro for any real purpose, but it cleanly highlights the declaration of a block of aliases.
#define ALIAS_FNC |
( |
_return_type, |
|
|
_name, |
|
|
_alias |
|
) |
|
Value:
asm (".globl " # _alias "\n" \
".type " # _alias ",@function \n" \
".set " # _alias "," # _name);
Defines an alias for a function.
- Parameters:
-
| _return_type | The return type of function call |
| _name | The original name of the symbol |
| _alias | The aliased name for the symbol |
- This macro is self-explanatory. For those curious about the calling convention (i.e. why isn't it ALIAS_FNC(_alias, _name)), the thought was that if one introduced a macro that defined multiple aliases for a single symbol the natural extension would be ALIAS_FNC2(_name, alias1, alias2). Just want to make sure you know there is a method to my madness.
- The return type argument was added 09.27.05 for the new GCC (>3.4) compiler. This compiler now removes all references to the static functions that are not referenced. This means no symbol appears in for this function in the assembler. Because of this, the aliased symbol is set equal to a symbol that, as far as the assembler is concerned, no longer exists. The solution is to use the __attribute__ specifier to declare the alias. This is certainly a better than trying to fake the compiler out with hidden assembler. However, the downside is that this syntax demands that the return type be specified. Unfortunately, this information is not available in the current macro, so a new argument must be added.