summaryrefslogtreecommitdiff
path: root/libtest/VariadicTest.c
diff options
context:
space:
mode:
authorLars Kanis <kanis@comcard.de>2015-08-05 18:13:13 +0200
committerLars Kanis <kanis@comcard.de>2015-08-05 18:13:13 +0200
commit8703becf83c816db5e48519ceebb11ef87fd3344 (patch)
tree9e54edd3c7624c68082fa9e72390286c26399921 /libtest/VariadicTest.c
parent9e01dc31f9b940d560cf75528615720ca9cf33e7 (diff)
downloadffi-larskanis-appveyor.tar.gz
Synchronize changes between libtest and spec/ffi/fixtures directories.larskanis-appveyor
Diffstat (limited to 'libtest/VariadicTest.c')
-rw-r--r--libtest/VariadicTest.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/libtest/VariadicTest.c b/libtest/VariadicTest.c
index fea6c3b..2f3d801 100644
--- a/libtest/VariadicTest.c
+++ b/libtest/VariadicTest.c
@@ -60,3 +60,40 @@ void pack_varargs(s64* buf, const char* fmt, ...)
va_end(ap);
}
+int pack_varargs2(s64* buf, int retval, const char* fmt, ...)
+{
+ va_list ap;
+ int c;
+ double d;
+ va_start(ap, fmt);
+ while ((c = *fmt++)) {
+ switch (c) {
+ case 'c':
+ case 's':
+ case 'i':
+ *buf++ = va_arg(ap, s32);
+ break;
+ case 'l':
+ *buf++ = va_arg(ap, long);
+ break;
+ case 'j':
+ *buf++ = va_arg(ap, s64);
+ break;
+ case 'f':
+ case 'd':
+ d = va_arg(ap, double);
+ memcpy(buf++, &d, sizeof(d));
+ break;
+ case 'C':
+ case 'S':
+ case 'I':
+ *buf++ = va_arg(ap, u32);
+ break;
+ case 'L':
+ *buf++ = va_arg(ap, unsigned long);
+ break;
+ }
+ }
+ va_end(ap);
+ return retval + 1;
+}