2 // The LLVM Compiler Infrastructure
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
16 main(int argc
, char *argv
[])
19 void (^b
)(void) = ^{ var
++; };
23 printf("%s: success!\n", argv
[0]);
29 /* replicated internal data structures: BEWARE, MAY CHANGE!!! */
32 BLOCK_REFCOUNT_MASK
= (0xffff),
33 BLOCK_NEEDS_FREE
= (1 << 24),
34 BLOCK_HAS_COPY_DISPOSE
= (1 << 25),
35 BLOCK_NO_COPY
= (1 << 26), // interim byref: no copies allowed
36 BLOCK_IS_GC
= (1 << 27),
37 BLOCK_IS_GLOBAL
= (1 << 28),
41 struct byref_id
*forwarding
;
44 void (*byref_keep
)(struct byref_id
*dst
, struct byref_id
*src
);
45 void (*byref_destroy
)(struct byref_id
*);
50 int Block_flags
; // int32_t
51 int Block_size
; // XXX should be packed into Block_flags
52 void (*Block_invoke
)(void *);
53 void (*Block_copy
)(void *dst
, void *src
);
54 void (*Block_dispose
)(void *);
58 void sanity(void *arg
) {
59 struct Block_basic2
*bb
= (struct Block_basic2
*)arg
;
60 if ( ! (bb
->Block_flags
& BLOCK_HAS_COPY_DISPOSE
)) {
61 printf("missing copy/dispose helpers for byref data\n");
64 struct byref_id
*ref
= bb
->ref
;
65 if (ref
->forwarding
!= ref
) {
66 printf("forwarding pointer should be %p but is %p\n", ref
, ref
->forwarding
);