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
5
6// -*- mode:C; c-basic-offset:4; tab-width:4; intent-tabs-mode:nil; -*-
7// CONFIG
8
9#import <stdio.h>
10#import <stdlib.h>
11#import <string.h>
12
13typedef struct {
14 unsigned long ps[30];
15 int qs[30];
16} BobTheStruct;
17
18int main (int argc, const char * argv[]) {
19 BobTheStruct inny;
20 BobTheStruct outty;
21 BobTheStruct (^copyStruct)(BobTheStruct);
22 int i;
23
24 memset(s: &inny, c: 0xA5, n: sizeof(inny));
25 memset(s: &outty, c: 0x2A, n: sizeof(outty));
26
27 for(i=0; i<30; i++) {
28 inny.ps[i] = i * i * i;
29 inny.qs[i] = -i * i * i;
30 }
31
32 copyStruct = ^(BobTheStruct aBigStruct){ return aBigStruct; }; // pass-by-value intrinsically copies the argument
33
34 outty = copyStruct(inny);
35
36 if ( &inny == &outty ) {
37 printf(format: "%s: struct wasn't copied.", argv[0]);
38 exit(status: 1);
39 }
40 for(i=0; i<30; i++) {
41 if ( (inny.ps[i] != outty.ps[i]) || (inny.qs[i] != outty.qs[i]) ) {
42 printf(format: "%s: struct contents did not match.", argv[0]);
43 exit(status: 1);
44 }
45 }
46
47 printf(format: "%s: success\n", argv[0]);
48
49 return 0;
50}
51

source code of compiler-rt/test/BlocksRuntime/large-struct.c