Ruby 2.7.0p0(2019-12-25revision647ee6f091eafcce70ffb75ddf7e121e192ab217)

Macros | Functions
ffi.c File Reference
`#include <ffi.h>`
`#include <ffi_common.h>`
`#include <stdlib.h>`

Go to the source code of this file.

## Macros
#define | FFI_INIT_TRAMPOLINE_WIN64(TRAMP, FUN, CTX, MASK)
#define | FFI_INIT_TRAMPOLINE(TRAMP, FUN, CTX)
#define | FFI_INIT_TRAMPOLINE_RAW_THISCALL(TRAMP, FUN, CTX, SIZE)
#define | FFI_INIT_TRAMPOLINE_WIN32(TRAMP, FUN, CTX)

## Functions
unsigned int | ffi_prep_args (char *stack, extended_cif *ecif)
ffi_status | ffi_prep_cif_machdep (ffi_cif *cif)
void | ffi_call_win32 (unsigned int(*)(char *, extended_cif *), extended_cif *, unsigned, unsigned, unsigned, unsigned *, void(*fn)(void))
void | ffi_call_SYSV (void(*)(char *, extended_cif *), extended_cif *, unsigned, unsigned, unsigned *, void(*fn)(void))
void | ffi_call (ffi_cif *cif, void(*fn)(void), void *rvalue, void **avalue)
void FFI_HIDDEN | ffi_closure_SYSV (ffi_closure *)
unsigned int FFI_HIDDEN | __attribute__ ((regparm(1)))
ffi_status | ffi_prep_closure_loc (ffi_closure *closure, ffi_cif *cif, void(*fun)(ffi_cif *, void *, void **, void *), void *user_data, void *codeloc)
ffi_status | ffi_prep_raw_closure_loc (ffi_raw_closure *closure, ffi_cif *cif, void(*fun)(ffi_cif *, void *, ffi_raw *, void *), void *user_data, void *codeloc)
void | ffi_raw_call (ffi_cif *cif, void(*fn)(void), void *rvalue, ffi_raw *fake_avalue)

## Macro Definition Documentation

## ◆ FFI_INIT_TRAMPOLINE

#define FFI_INIT_TRAMPOLINE | ( |  | TRAMP,
|  |  | FUN,
|  |  | CTX
| ) |  |

Value:
{ unsigned char *__tramp = (unsigned char*)(TRAMP); \
unsigned int __fun = (unsigned int)(FUN); \
unsigned int __ctx = (unsigned int)(CTX); \
unsigned int __dis = __fun - (__ctx + 10); \
*(unsigned char*) &__tramp[0] = 0xb8; \
*(unsigned int*) &__tramp[1] = __ctx; /* movl __ctx, %eax */ \
*(unsigned char*) &__tramp[5] = 0xe9; \
*(unsigned int*) &__tramp[6] = __dis; /* jmp __fun */ \
}

Definition at line 673 of file ffi.c.

## ◆ FFI_INIT_TRAMPOLINE_RAW_THISCALL

#define FFI_INIT_TRAMPOLINE_RAW_THISCALL | ( |  | TRAMP,
|  |  | FUN,
|  |  | CTX,
|  |  | SIZE
| ) |  |

Value:
{ unsigned char *__tramp = (unsigned char*)(TRAMP); \
unsigned int __fun = (unsigned int)(FUN); \
unsigned int __ctx = (unsigned int)(CTX); \
unsigned int __dis = __fun - (__ctx + 49); \
unsigned short __size = (unsigned short)(SIZE); \
*(unsigned int *) &__tramp[0] = 0x8324048b; /* mov (%esp), %eax */ \
*(unsigned int *) &__tramp[4] = 0x4c890cec; /* sub $12, %esp */ \
*(unsigned int *) &__tramp[8] = 0x04890424; /* mov %ecx, 4(%esp) */ \
*(unsigned char*) &__tramp[12] = 0x24; /* mov %eax, (%esp) */ \
*(unsigned char*) &__tramp[13] = 0xb8; \
*(unsigned int *) &__tramp[14] = __size; /* mov __size, %eax */ \
*(unsigned int *) &__tramp[18] = 0x08244c8d; /* lea 8(%esp), %ecx */ \
*(unsigned int *) &__tramp[22] = 0x4802e8c1; /* shr $2, %eax ; dec %eax */ \
*(unsigned short*) &__tramp[26] = 0x0b74; /* jz 1f */ \
*(unsigned int *) &__tramp[28] = 0x8908518b; /* 2b: mov 8(%ecx), %edx */ \
*(unsigned int *) &__tramp[32] = 0x04c18311; /* mov %edx, (%ecx) ; add $4, %ecx */ \
*(unsigned char*) &__tramp[36] = 0x48; /* dec %eax */ \
*(unsigned short*) &__tramp[37] = 0xf575; /* jnz 2b ; 1f: */ \
*(unsigned char*) &__tramp[39] = 0xb8; \
*(unsigned int*) &__tramp[40] = __ctx; /* movl __ctx, %eax */ \
*(unsigned char *) &__tramp[44] = 0xe8; \
*(unsigned int*) &__tramp[45] = __dis; /* call __fun */ \
*(unsigned char*) &__tramp[49] = 0xc2; /* ret */ \
*(unsigned short*) &__tramp[50] = (__size + 8); /* ret (__size + 8) */ \
}

Definition at line 684 of file ffi.c.

## ◆ FFI_INIT_TRAMPOLINE_WIN32

#define FFI_INIT_TRAMPOLINE_WIN32 | ( |  | TRAMP,
|  |  | FUN,
|  |  | CTX
| ) |  |

Value:
{ unsigned char *__tramp = (unsigned char*)(TRAMP); \
unsigned int __fun = (unsigned int)(FUN); \
unsigned int __ctx = (unsigned int)(CTX); \
unsigned int __dis = __fun - (__ctx + 10); \
*(unsigned char*) &__tramp[0] = 0x68; \
*(unsigned int*) &__tramp[1] = __ctx; /* push __ctx */ \
*(unsigned char*) &__tramp[5] = 0xe9; \
*(unsigned int*) &__tramp[6] = __dis; /* jmp __fun */ \
}

Definition at line 711 of file ffi.c.

## ◆ FFI_INIT_TRAMPOLINE_WIN64

#define FFI_INIT_TRAMPOLINE_WIN64 | ( |  | TRAMP,
|  |  | FUN,
|  |  | CTX,
|  |  | MASK
| ) |  |

Value:
{ unsigned char *__tramp = (unsigned char*)(TRAMP); \
void* __fun = (void*)(FUN); \
void* __ctx = (void*)(CTX); \
*(unsigned char*) &__tramp[0] = 0x41; \
*(unsigned char*) &__tramp[1] = 0xbb; \
*(unsigned int*) &__tramp[2] = MASK; /* mov $mask, %r11 */ \
*(unsigned char*) &__tramp[6] = 0x48; \
*(unsigned char*) &__tramp[7] = 0xb8; \
*(void**) &__tramp[8] = __ctx; /* mov __ctx, %rax */ \
*(unsigned char *) &__tramp[16] = 0x49; \
*(unsigned char *) &__tramp[17] = 0xba; \
*(void**) &__tramp[18] = __fun; /* mov __fun, %r10 */ \
*(unsigned char *) &__tramp[26] = 0x41; \
*(unsigned char *) &__tramp[27] = 0xff; \
*(unsigned char *) &__tramp[28] = 0xe2; /* jmp %r10 */ \
}

Definition at line 653 of file ffi.c.

## Function Documentation

## ◆ __attribute__()

unsigned int FFI_HIDDEN __attribute__ | ( | (regparm(1)) |  | ) |

Definition at line 496 of file ffi.c.

References alloca.

## ◆ ffi_call()

void ffi_call | ( | ffi_cif * | cif,
|  | void(*)(void) | fn,
|  | void * | rvalue,
|  | void ** | avalue
| ) |  |

Definition at line 352 of file ffi.c.

References alloca, extended_cif::avalue, extended_cif::cif, FFI_ASSERT, ffi_call_SYSV(), ffi_call_win32(), FFI_FASTCALL, FFI_PASCAL, ffi_prep_args(), FFI_REGISTER, FFI_STDCALL, FFI_SYSV, FFI_THISCALL, FFI_TYPE_MS_STRUCT, NULL, and extended_cif::rvalue.

## ◆ ffi_call_SYSV()

void ffi_call_SYSV | ( | void(*)(char *, extended_cif *) | ,
|  | extended_cif * | ,
|  | unsigned | ,
|  | unsigned | ,
|  | unsigned * | ,
|  | void(*)(void) | fn
| ) |  |

## ◆ ffi_call_win32()

void ffi_call_win32 | ( | unsigned | int*)(char *, extended_cif *,
|  | extended_cif * | ,
|  | unsigned | ,
|  | unsigned | ,
|  | unsigned | ,
|  | unsigned * | ,
|  | void(*)(void) | fn
| ) |  |

Referenced by ffi_call().

## ◆ ffi_closure_SYSV()

void FFI_HIDDEN ffi_closure_SYSV | ( | ffi_closure * |  | ) |

Definition at line 420 of file ffi.c.

Referenced by ffi_prep_closure_loc(), and ffi_prep_closure_loc_sysv().

## ◆ ffi_prep_args()

unsigned int ffi_prep_args | ( | char * | stack,
|  | extended_cif * | ecif
| ) |  |

Definition at line 47 of file ffi.c.

References ALIGN, extended_cif::avalue, extended_cif::cif, FFI_ASSERT, FFI_FASTCALL, FFI_PASCAL, FFI_REGISTER, FFI_SIZEOF_ARG, FFI_THISCALL, FFI_TYPE_LONGDOUBLE, FFI_TYPE_MS_STRUCT, i, memcpy(), memmove, and extended_cif::rvalue.

## ◆ ffi_prep_cif_machdep()

ffi_status ffi_prep_cif_machdep | ( | ffi_cif * | cif | ) |

Definition at line 235 of file ffi.c.

References ALIGN, FFI_SIZEOF_ARG, FFI_SYSV, FFI_TYPE_LONGDOUBLE, FFI_TYPE_MS_STRUCT, FFI_TYPE_SMALL_STRUCT_1B, FFI_TYPE_SMALL_STRUCT_2B, FFI_TYPE_SMALL_STRUCT_4B, FFI_UNIX64, i, if(), ptr, and unsigned.

## ◆ ffi_prep_closure_loc()

ffi_status ffi_prep_closure_loc | ( | ffi_closure * | closure,
|  | ffi_cif * | cif,
|  | void(*)(ffi_cif *, void *, void **, void *) | fun,
|  | void * | user_data,
|  | void * | codeloc
| ) |  |

Definition at line 725 of file ffi.c.

References ffi_closure_SYSV(), FFI_FASTCALL, FFI_INIT_TRAMPOLINE, FFI_INIT_TRAMPOLINE_WIN32, FFI_INIT_TRAMPOLINE_WIN64, FFI_PASCAL, FFI_REGISTER, FFI_STDCALL, FFI_SYSV, FFI_THISCALL, and mask.

## ◆ ffi_prep_raw_closure_loc()

ffi_status ffi_prep_raw_closure_loc | ( | ffi_raw_closure * | closure,
|  | ffi_cif * | cif,
|  | void(*)(ffi_cif *, void *, ffi_raw *, void *) | fun,
|  | void * | user_data,
|  | void * | codeloc
| ) |  |

Definition at line 799 of file ffi.c.

References FFI_ASSERT, FFI_INIT_TRAMPOLINE, FFI_INIT_TRAMPOLINE_RAW_THISCALL, FFI_SYSV, FFI_THISCALL, FFI_TYPE_LONGDOUBLE, and i.

## ◆ ffi_raw_call()

void ffi_raw_call | ( | ffi_cif * | cif,
|  | void(*)(void) | fn,
|  | void * | rvalue,
|  | ffi_raw * | fake_avalue
| ) |  |

Definition at line 886 of file ffi.c.

References alloca, extended_cif::avalue, extended_cif::cif, ffi_call_SYSV(), FFI_SYSV, FFI_TYPE_MS_STRUCT, NULL, and extended_cif::rvalue.

short
#define short
Definition: rb_mjit_min_header-2.7.0.h:2877
int
__inline__ int
Definition: rb_mjit_min_header-2.7.0.h:2839
__size
__inline__ size_t __size
Definition: rb_mjit_min_header-2.7.0.h:1903