aboutsummaryrefslogtreecommitdiff
path: root/tests/threads/regression/ffi_o3.zc
diff options
context:
space:
mode:
Diffstat (limited to 'tests/threads/regression/ffi_o3.zc')
-rw-r--r--tests/threads/regression/ffi_o3.zc16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/threads/regression/ffi_o3.zc b/tests/threads/regression/ffi_o3.zc
new file mode 100644
index 0000000..ecf8c0c
--- /dev/null
+++ b/tests/threads/regression/ffi_o3.zc
@@ -0,0 +1,16 @@
+namespace;
+include rt;
+extern void qsort(word* base, long length, long size, void* compare);
+int calls;
+int compare(int* a, int* b) { calls++; return *a - *b; }
+o3 int sum(int n) { int total = 0; for (int i = 0; i <= n; i++) total += i; return total; }
+unchecked fn main() {
+ word comparator = cfunc(compare); int fd = 0;
+ let context = rt.syscall(51, fn() {
+ int values[3]; values[0] = 3; values[1] = 1; values[2] = 2; qsort(values, 3, 8, comparator);
+ int result[3]; result[0] = values[0] == 1 && values[2] == 3 && calls > 0; result[1] = sum(100); result[2] = calls;
+ rt.syscall(44, fd, result, 3); return 0;
+ } as word, &fd, 0);
+ int result[3]; rt.syscall(45, fd, result, 3); rt.syscall(52, context, 0, 0);
+ rt.put_n(result[0]); rt.put_c(' '); rt.put_n(result[1]); rt.put_c(' '); rt.put_n(calls); rt.put_c(10); return 0;
+}