[libc] Switch to using the generic `<gpuintrin.h>` implementations (#121810)
[llvm-project.git] / compiler-rt / test / BlocksRuntime / byrefcopycopy.c
blob1c03f6ca8a9271bdda96d2920980290a78f6a489
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-exception
6 // CONFIG rdar://6255170
8 #include <stdio.h>
9 #include <stdbool.h>
10 #include <stdlib.h>
11 #include <Block.h>
12 #include <Block_private.h>
13 #include <assert.h>
16 int
17 main(int argc, char *argv[])
19 __block int var = 0;
20 int shouldbe = 0;
21 void (^b)(void) = ^{ var++; /*printf("var is at %p with value %d\n", &var, var);*/ };
22 __typeof(b) _b;
23 //printf("before copy...\n");
24 b(); ++shouldbe;
25 size_t i;
27 for (i = 0; i < 10; i++) {
28 _b = Block_copy(b); // make a new copy each time
29 assert(_b);
30 ++shouldbe;
31 _b(); // should still update the stack
32 Block_release(_b);
35 //printf("after...\n");
36 b(); ++shouldbe;
38 if (var != shouldbe) {
39 printf("Hmm, var is %d but should be %d\n", var, shouldbe);
40 return 1;
42 printf("%s: Success!!\n", argv[0]);
44 return 0;