summaryrefslogtreecommitdiff
path: root/lib/BlocksRuntime/tests/byrefcopyint.c
diff options
context:
space:
mode:
authorAlexey Samsonov <samsonov@google.com>2014-02-14 08:38:30 +0000
committerAlexey Samsonov <samsonov@google.com>2014-02-14 08:38:30 +0000
commitdb75ada3a3169f4bc4b9f9f04b42a5075d264743 (patch)
tree93631b13cadee6e4a9ac6e452ed06534ee5102fc /lib/BlocksRuntime/tests/byrefcopyint.c
parent5c8699e6a78818c59ece2c60f77ad630b1b6eb86 (diff)
Move BlocksRuntime to lib/ directory
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@201390 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/BlocksRuntime/tests/byrefcopyint.c')
-rw-r--r--lib/BlocksRuntime/tests/byrefcopyint.c69
1 files changed, 69 insertions, 0 deletions
diff --git a/lib/BlocksRuntime/tests/byrefcopyint.c b/lib/BlocksRuntime/tests/byrefcopyint.c
new file mode 100644
index 000000000..d632f88a0
--- /dev/null
+++ b/lib/BlocksRuntime/tests/byrefcopyint.c
@@ -0,0 +1,69 @@
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+
+/*
+ * byrefcopyint.c
+ * testObjects
+ *
+ * Created by Blaine Garst on 12/1/08.
+ *
+ */
+
+//
+// byrefcopyid.m
+// testObjects
+//
+// Created by Blaine Garst on 5/13/08.
+//
+
+// Tests copying of blocks with byref ints
+// CONFIG rdar://6414583 -C99
+
+#include <stdio.h>
+#include <string.h>
+#include <Block.h>
+#include <Block_private.h>
+
+
+
+
+typedef void (^voidVoid)(void);
+
+voidVoid dummy;
+
+void callVoidVoid(voidVoid closure) {
+ closure();
+}
+
+
+voidVoid testRoutine(const char *whoami) {
+ __block int dumbo = strlen(whoami);
+ dummy = ^{
+ //printf("incring dumbo from %d\n", dumbo);
+ ++dumbo;
+ };
+
+
+ voidVoid copy = Block_copy(dummy);
+
+
+ return copy;
+}
+
+int main(int argc, char *argv[]) {
+ voidVoid array[100];
+ for (int i = 0; i < 100; ++i) {
+ array[i] = testRoutine(argv[0]);
+ array[i]();
+ }
+ for (int i = 0; i < 100; ++i) {
+ Block_release(array[i]);
+ }
+
+
+ printf("%s: success\n", argv[0]);
+ return 0;
+}