Mono.Posix
1.0.5000.0
2.0.0.0
4.0.0.0
This type is safe for multithreaded operations.
System.Object
Permits calling a varargs (cdecl) function from a library.
This class represents a single unmanaged function with "cdecl" calling convention -- that is, it can accept a variable number of arguments which are passed on the runtime stack.
To use, create an instance, then call with the appropriate number of arguments:
CdeclFunction printf = new CdeclFunction (
"libc", // the libraary
"printf", // the function name
typeof (int) // optional; the function's return type
);
printf.Invoke (new object[]{"hello, %s\n", "world!"});
In the background a P/Invoke definition for the method with the requested argument types will be generated and invoked, invoking the unmanaged function. The generated methods are cached, so that subsequent calls with the same argument list do not generate new code, speeding up the call sequence.
Invoking Cdecl functions is not guaranteed to be portable across all platforms. For example, AMD64 requires that the caller set EAX to the number of floating point arguments passed in the SSE registers. This is only required for variable argument/cdecl functions; consequently, the overload technique used by this class wouldn't normally work. Mono's AMD64 JIT works around this by always setting EAX on P/Invoke invocations, allowing CdeclFunction to work properly, but it will not necessarily always work. See also: http://lwn.net/Articles/5201/?format=printable
Due to potential portability issues, cdecl functions should be avoided on most platforms.
Constructor
1.0.5000.0
2.0.0.0
4.0.0.0
The library the cdecl function resides in.
The export to invoke from library.
Create a stub object to invoke a cdecl function.
Constructor
1.0.5000.0
2.0.0.0
4.0.0.0
The library the cdecl function resides in.
The export to invoke from library.
The return type of the function to invoke. The default return type is .
Create a stub object to invoke a cdecl function.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.Object
The parameters to pass to the function.
Invoke the function specified in the constructor.
The return value of the invoked cdecl function.
Invokes the specified function.