📄 interface.texi
字号:
@c Copyright (C) 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,@c 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.@c This is part of the GCC manual.@c For copying conditions, see the file gcc.texi.@node Interface@chapter Interfacing to GCC Output@cindex interfacing to GCC output@cindex run-time conventions@cindex function call conventions@cindex conventions, run-timeGCC is normally configured to use the same function calling conventionnormally in use on the target system. This is done with themachine-description macros described (@pxref{Target Macros}).@cindex unions, returning@cindex structures, returning@cindex returning structures and unionsHowever, returning of structure and union values is done differently onsome target machines. As a result, functions compiled with PCCreturning such types cannot be called from code compiled with GCC,and vice versa. This does not cause trouble often because few Unixlibrary routines return structures or unions.GCC code returns structures and unions that are 1, 2, 4 or 8 byteslong in the same registers used for @code{int} or @code{double} returnvalues. (GCC typically allocates variables of such types inregisters also.) Structures and unions of other sizes are returned bystoring them into an address passed by the caller (usually in aregister). The target hook @code{TARGET_STRUCT_VALUE_RTX}tells GCC where to pass this address.By contrast, PCC on most target machines returns structures and unionsof any size by copying the data into an area of static storage, and thenreturning the address of that storage as if it were a pointer value.The caller must copy the data from that memory area to the place wherethe value is wanted. This is slower than the method used by GCC, andfails to be reentrant.On some target machines, such as RISC machines and the 80386, thestandard system convention is to pass to the subroutine the address ofwhere to return the value. On these machines, GCC has beenconfigured to be compatible with the standard compiler, when this methodis used. It may not be compatible for structures of 1, 2, 4 or 8 bytes.@cindex argument passing@cindex passing argumentsGCC uses the system's standard convention for passing arguments. Onsome machines, the first few arguments are passed in registers; inothers, all are passed on the stack. It would be possible to useregisters for argument passing on any machine, and this would probablyresult in a significant speedup. But the result would be completeincompatibility with code that follows the standard convention. So thischange is practical only if you are switching to GCC as the sole Ccompiler for the system. We may implement register argument passing oncertain machines once we have a complete GNU system so that we cancompile the libraries with GCC@.On some machines (particularly the SPARC), certain types of argumentsare passed ``by invisible reference''. This means that the value isstored in memory, and the address of the memory location is passed tothe subroutine.@cindex @code{longjmp} and automatic variablesIf you use @code{longjmp}, beware of automatic variables. ISO C says thatautomatic variables that are not declared @code{volatile} have undefinedvalues after a @code{longjmp}. And this is all GCC promises to do,because it is very difficult to restore register variables correctly, andone of GCC's features is that it can put variables in registers withoutyour asking it to.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -