view test/callback_suite/README.txt @ 27:523c45dfa8fb

- refactored arm calling conventions' callvm code, so that the code that keeps the caller from overwriting the return value on some platforms also works on OpenBSD (before we casted the function pointer to have long long as return type, to hint the caller that there is one, but that triggers an intentional SIGABRT on OpenBSD for security reasons; now the decl reflects this, directly)
author cslag
date Tue, 15 Sep 2015 12:48:52 +0200
parents 3e629dc19168
children 45ac093ca822
line wrap: on
line source

Callback Test Suite 2 
---------------------

REQUIREMENTS
- dyncall
- ANSI C compiler
- lua (tested with 5.1)

CONFIGURE SUITE

  edit config.lua and run "make config".

DESCRIPTION

Generates a set of callback invokers in C using lua as a preprocessor.
The invokers put up an argument vector using a global Value-Matrix which
holds a specific type-specific value pattern as a function of position.

The Value-Matrix

The value-matrix is a data structure consisting of n x m elements of
type DCValueSet which can store distinct numbers for each type.

It is used in the body of the auto-generated callback invokers (C code).

The Callback Invocation Body

Example:
The body for a signature of type  "dpdf)p" at case id 19 is:

void f19(void* addr) 
{ 
  Result.p = ((CONFIG_API p(*)(d,p,d,f))addr)(ValueMatrix[0].d,ValueMatrix[1].p,ValueMatrix[2].d,ValueMatrix[3].f);
}              ^^^^^^^^^^- calling convention
                          ^^^^^^^^^^^^^- signature
         ^- return type signature
                                                  ^- arg signature char 0 (later expected) value


Result (type DCValue)  and ValueMatrix (type DCValueSet[MAXARGS]) are globals. 
The ValueMatrix is initialized once from main.c for all cominations of types
and argument position.
See env.* files for details.


Reference argument and result value

The value is generated by a pure function GetReferenceValue and
GetReferenceResult (file env.c). They have formals position and type 
and are pure without any side-effects (means the function value does only
relay on the input arguments - if called with same arguments it will reveal
the same value.

It defined in env.c.

Tssting for exotic calling conventions on Windows:

Specify 'api' and 'ccprefix' accordingly:


"__stdcall"	"_s"
"__fastcall"	"_f" for gcc compiler
		"_F" for microsoft compiler