blob: d632f88a0bc508871a0d5f9fb6ac2a778eb5842f [file] [log] [blame]
Blaine Garst86d0ba42010-08-04 23:34:21 +00001//
2// The LLVM Compiler Infrastructure
3//
4// This file is distributed under the University of Illinois Open Source
5// License. See LICENSE.TXT for details.
6
7/*
8 * byrefcopyint.c
9 * testObjects
10 *
11 * Created by Blaine Garst on 12/1/08.
12 *
13 */
14
15//
16// byrefcopyid.m
17// testObjects
18//
19// Created by Blaine Garst on 5/13/08.
20//
21
22// Tests copying of blocks with byref ints
23// CONFIG rdar://6414583 -C99
24
25#include <stdio.h>
26#include <string.h>
27#include <Block.h>
28#include <Block_private.h>
29
30
31
32
33typedef void (^voidVoid)(void);
34
35voidVoid dummy;
36
37void callVoidVoid(voidVoid closure) {
38 closure();
39}
40
41
42voidVoid testRoutine(const char *whoami) {
43 __block int dumbo = strlen(whoami);
44 dummy = ^{
45 //printf("incring dumbo from %d\n", dumbo);
46 ++dumbo;
47 };
48
49
50 voidVoid copy = Block_copy(dummy);
51
52
53 return copy;
54}
55
56int main(int argc, char *argv[]) {
57 voidVoid array[100];
58 for (int i = 0; i < 100; ++i) {
59 array[i] = testRoutine(argv[0]);
60 array[i]();
61 }
62 for (int i = 0; i < 100; ++i) {
63 Block_release(array[i]);
64 }
65
66
67 printf("%s: success\n", argv[0]);
68 return 0;
69}