Changes between Version 4 and Version 5 of Commentary/Compiler/Backends/PprC


Ignore:
Timestamp:
May 8, 2008 11:24:42 AM (6 years ago)
Author:
simonmar
Comment:

update prototype info

Legend:

Unmodified
Added
Removed
Modified
  • Commentary/Compiler/Backends/PprC

    v4 v5  
    4242know whether to declare the label first, and if so, at what type. 
    4343 
     44C only lets us declare an external label at one 
     45type in any given source file, even if the scopes of the 
     46declarations don't overlap.  So we either have to scan the whole code to figure out what the type of each label should be, or we opt for declaring all labels at the same type and then casting later.  Currently we do the latter. 
     47 
    4448 * all labels referenced as a result of an FFI declaration 
    4549   are declared as `extern StgWord[]`, including funciton labels. 
     
    4852   referred to both as a function and an untyped data label in 
    4953   the same module (e.g. Foreign.Marsal.Alloc refers to "free" 
    50    this way). 
     54   this way).   
     55 
     56 * An exception is made to the above for functions declared with 
     57   the `stdcall` calling convention on Windows.  These functions must 
     58   be declared with the `stdcall` attribute and a function type, 
     59   otherwise the C compiler won't add the `@n` suffix to the symbol. 
     60   We can't add the `@n` suffix ourselves, because it is illegal 
     61   syntax in C.  However, we always declare these labels with the 
     62   type `void (*)(void)`, to avoid conflicts if the same function 
     63   is called at different types in one module (see `Graphics.Win32.GDI.HDC.SelectObject`). 
     64 
     65 * Another exception is made for functions that are marked `never returns`.  We 
     66   have to put an `__attribute__((noreturn))` on the declaration for these functions, 
     67   and it only works if the function is declared with a proper function type and 
     68   called without casting it to/from a pointer.  So only the correct prototype 
     69   will do here. 
    5170 
    5271 * all RTS symbols already have declarations (mostly with the correct