Mercurial > pub > dyncall > dyncall
diff test/callf/main.c @ 362:78dfa2f9783a
- added helper function dcGetModeFromCCSigChar() mapping callconv sig chars to respective mode
- added a signature-based syscall to callf testcode
- manual clarification about dcReset usage in combination with dcMode
author | Tassilo Philipp |
---|---|
date | Tue, 14 Apr 2020 16:56:57 +0200 |
parents | 30aae7371373 |
children | 3ff4a4ba7f0e |
line wrap: on
line diff
--- a/test/callf/main.c Mon Apr 13 21:40:28 2020 +0200 +++ b/test/callf/main.c Tue Apr 14 16:56:57 2020 +0200 @@ -32,6 +32,9 @@ #include "../common/platformInit.c" /* Impl. for functions only used in this translation unit */ #include <stdarg.h> +#if defined(DC_UNIX) +#include <sys/syscall.h> +#endif /* sample void function */ @@ -129,6 +132,14 @@ dcArgF(vm, "ffiffiffi", 1.f, 2.f, 3, 4.f, 5.f, 6, 7.f, 8.f, 9); r = r && dcCallInt(vm, (void*)&vf_ffiffiffi); +#if defined(DC_UNIX) + /* testing syscall using calling convention prefix - not available on all platforms */ + dcReset(vm); + printf("\ncallf _$ipi)i"); + fflush(NULL); /* needed before syscall write as it's immediate, or order might be incorrect */ + dcCallF(vm, &ret, (DCpointer)(ptrdiff_t)SYS_write, "_$ipi)i", 1/*stdout*/, " = syscall: 1", 13); + r = ret.i == 13 && r; +#endif /* free vm */ dcFree(vm);