muteki
Loading...
Searching...
No Matches
abi.h File Reference

ABI compatibility helpers. More...

Go to the source code of this file.

Macros

#define NO_EXPECTED_WARNINGS_BEGIN
 
#define NO_EXPECTED_WARNINGS_END
 
#define __APCS_WRAPPER_BASE(NAME, VA_LIST_NAME, STATIC, RETTYPE, ...)
 
#define APCS_WRAPPER(NAME, VA_LIST_NAME, RETTYPE, ...)    __APCS_WRAPPER_BASE(NAME, VA_LIST_NAME, , RETTYPE, __VA_ARGS__)
 Create thunk for an APCS caller.
 
#define APCS_WRAPPER_STATIC(NAME, VA_LIST_NAME, RETTYPE, ...)    __APCS_WRAPPER_BASE(NAME, VA_LIST_NAME, static, RETTYPE, __VA_ARGS__)
 Same as APCS_WRAPPER(), but marks the outer thunk as static.
 

Detailed Description

ABI compatibility helpers.

Macro Definition Documentation

◆ APCS_WRAPPER

#define APCS_WRAPPER (   NAME,
  VA_LIST_NAME,
  RETTYPE,
  ... 
)     __APCS_WRAPPER_BASE(NAME, VA_LIST_NAME, , RETTYPE, __VA_ARGS__)

Create thunk for an APCS caller.

This macro generates a set of thunks that adapts a function using AAPCS calling convention for use with an APCS caller. The syntax is as follows:

#include <stdarg.h>
extern int test_eabi(int arg0, char *arg1);
// Use void in place of the last 2 parameters is also acceptable if test() will not be passed as a callback
// with specific requirement on its function signature.
APCS_WRAPPER(test, args, int, int arg0, char *arg1) {
int arg0 = va_arg(args, int);
char *arg1 = va_arg(args, char *);
return test_eabi(arg0, arg1);
}
#define APCS_WRAPPER(NAME, VA_LIST_NAME, RETTYPE,...)
Create thunk for an APCS caller.
Definition abi.h:111
Note
It is recommended to use the scope block of this macro solely for defining a thunk to some other EABI functions. In other words, any other program logic should generally be defined elsewhere and not inside the scope block of this macro. One should also avoid calling the thunk generated by this macro directly from the EABI land for performance and type safety reasons.
Warning
This wrapper does not align the variadic reader to 8-bytes, therefore if you want to read 64-bit values, you need to do it with 2 separate 32-bit reads. This is the same for double values. For those, it's better to read them as 2 integers, then concatenate them, and finally cast the result back to double.
Parameters
NAMEName of the thunk that will be called from APCS functions.
VA_LIST_NAMEThe name of the variadic list object.
RETTYPEReturn type of the thunk. Used to match the signature of the outer thunk to those of a kernel callback pointer.
...Parameter signature of the outer thunk. Used to match the signature of the outer thunk to those of a kernel callback pointer.

◆ APCS_WRAPPER_STATIC

#define APCS_WRAPPER_STATIC (   NAME,
  VA_LIST_NAME,
  RETTYPE,
  ... 
)     __APCS_WRAPPER_BASE(NAME, VA_LIST_NAME, static, RETTYPE, __VA_ARGS__)

Same as APCS_WRAPPER(), but marks the outer thunk as static.

Parameters
NAMEName of the thunk that will be called from APCS functions.
VA_LIST_NAMEThe name of the variadic list object.
RETTYPEReturn type of the thunk. Used to match the signature of the outer thunk to those of a kernel callback pointer.
...Parameter signature of the outer thunk. Used to match the signature of the outer thunk to those of a kernel callback pointer.