xref: /aosp_15_r20/external/compiler-rt/test/BlocksRuntime/blockimport.c (revision 7c3d14c8b49c529e04be81a3ce6f5cc23712e4c6)
1*7c3d14c8STreehugger Robot //
2*7c3d14c8STreehugger Robot //                     The LLVM Compiler Infrastructure
3*7c3d14c8STreehugger Robot //
4*7c3d14c8STreehugger Robot // This file is distributed under the University of Illinois Open Source
5*7c3d14c8STreehugger Robot // License. See LICENSE.TXT for details.
6*7c3d14c8STreehugger Robot 
7*7c3d14c8STreehugger Robot /*
8*7c3d14c8STreehugger Robot  *  blockimport.c
9*7c3d14c8STreehugger Robot  *  testObjects
10*7c3d14c8STreehugger Robot  *
11*7c3d14c8STreehugger Robot  *  Created by Blaine Garst on 10/13/08.
12*7c3d14c8STreehugger Robot  *
13*7c3d14c8STreehugger Robot  */
14*7c3d14c8STreehugger Robot 
15*7c3d14c8STreehugger Robot 
16*7c3d14c8STreehugger Robot //
17*7c3d14c8STreehugger Robot // pure C nothing more needed
18*7c3d14c8STreehugger Robot // CONFIG  rdar://6289344
19*7c3d14c8STreehugger Robot 
20*7c3d14c8STreehugger Robot #include <stdio.h>
21*7c3d14c8STreehugger Robot #include <Block.h>
22*7c3d14c8STreehugger Robot #include <Block_private.h>
23*7c3d14c8STreehugger Robot 
24*7c3d14c8STreehugger Robot 
25*7c3d14c8STreehugger Robot 
26*7c3d14c8STreehugger Robot 
main(int argc,char * argv[])27*7c3d14c8STreehugger Robot int main(int argc, char *argv[]) {
28*7c3d14c8STreehugger Robot     int i = 1;
29*7c3d14c8STreehugger Robot     int (^intblock)(void) = ^{ return i*10; };
30*7c3d14c8STreehugger Robot 
31*7c3d14c8STreehugger Robot     void (^vv)(void) = ^{
32*7c3d14c8STreehugger Robot         if (argc > 0) {
33*7c3d14c8STreehugger Robot             printf("intblock returns %d\n", intblock());
34*7c3d14c8STreehugger Robot         }
35*7c3d14c8STreehugger Robot     };
36*7c3d14c8STreehugger Robot 
37*7c3d14c8STreehugger Robot #if 0
38*7c3d14c8STreehugger Robot     //printf("Block dump %s\n", _Block_dump(vv));
39*7c3d14c8STreehugger Robot     {
40*7c3d14c8STreehugger Robot         struct Block_layout *layout = (struct Block_layout *)(void *)vv;
41*7c3d14c8STreehugger Robot         printf("isa %p\n", layout->isa);
42*7c3d14c8STreehugger Robot         printf("flags %x\n", layout->flags);
43*7c3d14c8STreehugger Robot         printf("descriptor %p\n", layout->descriptor);
44*7c3d14c8STreehugger Robot         printf("descriptor->size %d\n", layout->descriptor->size);
45*7c3d14c8STreehugger Robot     }
46*7c3d14c8STreehugger Robot #endif
47*7c3d14c8STreehugger Robot     void (^vvcopy)(void) = Block_copy(vv);
48*7c3d14c8STreehugger Robot     Block_release(vvcopy);
49*7c3d14c8STreehugger Robot     printf("%s: success\n", argv[0]);
50*7c3d14c8STreehugger Robot     return 0;
51*7c3d14c8STreehugger Robot }
52