[AA] Rename CaptureInfo -> CaptureAnalysis (NFC) (#116842)
[llvm-project.git] / compiler-rt / test / BlocksRuntime / byrefstruct.c
blobd30207e2d631d6a4978e806682e16d0a92652f3e
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 // -*- mode:C; c-basic-offset:4; tab-width:4; intent-tabs-mode:nil; -*-
7 // CONFIG
9 #import <stdio.h>
10 #import <stdlib.h>
11 #import <string.h>
13 typedef struct {
14 unsigned long ps[30];
15 int qs[30];
16 } BobTheStruct;
18 int main (int argc, const char * argv[]) {
19 __block BobTheStruct fiddly;
20 BobTheStruct copy;
22 void (^incrementFiddly)() = ^{
23 int i;
24 for(i=0; i<30; i++) {
25 fiddly.ps[i]++;
26 fiddly.qs[i]++;
30 memset(&fiddly, 0xA5, sizeof(fiddly));
31 memset(&copy, 0x2A, sizeof(copy));
33 int i;
34 for(i=0; i<30; i++) {
35 fiddly.ps[i] = i * i * i;
36 fiddly.qs[i] = -i * i * i;
39 copy = fiddly;
40 incrementFiddly();
42 if ( &copy == &fiddly ) {
43 printf("%s: struct wasn't copied.", argv[0]);
44 exit(1);
46 for(i=0; i<30; i++) {
47 //printf("[%d]: fiddly.ps: %lu, copy.ps: %lu, fiddly.qs: %d, copy.qs: %d\n", i, fiddly.ps[i], copy.ps[i], fiddly.qs[i], copy.qs[i]);
48 if ( (fiddly.ps[i] != copy.ps[i] + 1) || (fiddly.qs[i] != copy.qs[i] + 1) ) {
49 printf("%s: struct contents were not incremented.", argv[0]);
50 exit(1);
54 printf("%s: success\n", argv[0]);
55 return 0;