brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.2 KiB · b9148cb Raw
69 lines · c
1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5 6/*7 *  byrefcopyint.c8 *  testObjects9 *10 *  Created by Blaine Garst on 12/1/08.11 *12 */13 14//15//  byrefcopyid.m16//  testObjects17//18//  Created by Blaine Garst on 5/13/08.19//20 21// Tests copying of blocks with byref ints22// CONFIG rdar://6414583 -C9923 24#include <stdio.h>25#include <string.h>26#include <Block.h>27#include <Block_private.h>28 29 30 31 32typedef void (^voidVoid)(void);33 34voidVoid dummy;35 36void callVoidVoid(voidVoid closure) {37    closure();38}39 40 41voidVoid testRoutine(const char *whoami) {42    __block int  dumbo = strlen(whoami);43    dummy = ^{44        //printf("incring dumbo from %d\n", dumbo);45        ++dumbo;46    };47    48    49    voidVoid copy = Block_copy(dummy);50    51 52    return copy;53}54 55int main(int argc, char *argv[]) {56    voidVoid array[100];57    for (int i = 0; i <  100; ++i) {58        array[i] = testRoutine(argv[0]);59        array[i]();60    }61    for (int i = 0; i <  100; ++i) {62        Block_release(array[i]);63    }64    65    66    printf("%s: success\n", argv[0]);67    return 0;68}69