1 | //
|
---|
2 | // Cforall Version 1.0.0 Copyright (C) 2023 University of Waterloo
|
---|
3 | //
|
---|
4 | // The contents of this file are covered under the licence agreement in the
|
---|
5 | // file "LICENCE" distributed with Cforall.
|
---|
6 | //
|
---|
7 | // boxed.bookend.cfa -- stack address recording and acceptance for the "array boxed" test
|
---|
8 | //
|
---|
9 | // Author : Mike Brooks
|
---|
10 | // Created On : Thu Jul 25 17:00:00 2024
|
---|
11 | // Last Modified By :
|
---|
12 | // Last Modified On :
|
---|
13 | // Update Count :
|
---|
14 | //
|
---|
15 |
|
---|
16 | // See general test documentation in boxed.main.cfa.
|
---|
17 | // See abbreviation definitions in boxed.cases.hfa.
|
---|
18 |
|
---|
19 |
|
---|
20 |
|
---|
21 |
|
---|
22 | #include "boxed.hfa"
|
---|
23 |
|
---|
24 | char * ar_lo = (char *) -1;
|
---|
25 | char * ar_hi = 0p;
|
---|
26 | static char * bookend_lo = (char *) -1;
|
---|
27 | static char * bookend_hi = 0p;
|
---|
28 |
|
---|
29 | void bookendInner( void ) {
|
---|
30 | char var = 'x';
|
---|
31 | (void) var;
|
---|
32 | bookend_lo = & var;
|
---|
33 | }
|
---|
34 |
|
---|
35 | #define TC(...)
|
---|
36 | #define TR( TRID, SZS, SZV, ETG, ACCS, SPS, OVLD ) \
|
---|
37 | F_SIG( bookendOuter, TRID, SZS, SZV, ACCS, SPS, OVLD ) { \
|
---|
38 | char var = 'x'; \
|
---|
39 | (void) var; \
|
---|
40 | bookend_hi = & var; \
|
---|
41 | return CALL( allocAndAccess, TRID, SZS, n, expectedElmSz, tcid, vart ); \
|
---|
42 | }
|
---|
43 | #include "boxed.cases.hfa"
|
---|
44 | #undef TC
|
---|
45 | #undef TR
|
---|
46 |
|
---|
47 | void resetBookends( void ) {
|
---|
48 | bookend_lo = (char *) -1;
|
---|
49 | bookend_hi = 0p;
|
---|
50 | ar_lo = (char *) -1;
|
---|
51 | ar_hi = 0p;
|
---|
52 | }
|
---|
53 |
|
---|
54 | void reportBookends( void ) {
|
---|
55 | ptrdiff_t ar_lo_fwd_offs = ar_lo - bookend_lo;
|
---|
56 | ptrdiff_t ar_hi_rev_offs = bookend_hi - ar_hi;
|
---|
57 |
|
---|
58 | VPRT( "Bookends are %p and %p\n", bookend_lo, bookend_hi );
|
---|
59 | VPRT( "Array ends are %p and %p\n", ar_lo, ar_hi );
|
---|
60 | VPRT( "Bookend lo fwd offset %zd\n", bookend_lo - bookend_lo );
|
---|
61 | VPRT( "Array lo fwd offset %zd\n", ar_lo_fwd_offs );
|
---|
62 | VPRT( "Array hi fwd offset %zd\n", ar_hi - bookend_lo );
|
---|
63 | VPRT( "Bookend hi fwd offset %zd\n", bookend_hi - bookend_lo );
|
---|
64 | VPRT( "Bookend lo rev offset %zd\n", bookend_hi - bookend_lo );
|
---|
65 | VPRT( "Array lo rev offset %zd\n", bookend_hi - ar_lo );
|
---|
66 | VPRT( "Array hi rev offset %zd\n", ar_hi_rev_offs );
|
---|
67 | VPRT( "Bookend hi rev offset %zd\n", bookend_hi - bookend_hi );
|
---|
68 |
|
---|
69 | if (bookend_lo >= bookend_hi) {
|
---|
70 | printf("bookends were not set\n");
|
---|
71 | return;
|
---|
72 | }
|
---|
73 | if (ar_lo >= ar_hi) {
|
---|
74 | printf("array bounds were not set\n");
|
---|
75 | return;
|
---|
76 | }
|
---|
77 |
|
---|
78 | printf("array starts after lo bookend: %s\n", ar_lo_fwd_offs > 0 ? "yes" : "no" );
|
---|
79 | printf("array ends before hi bookend: %s\n", ar_hi_rev_offs > 0 ? "yes" : "no" );
|
---|
80 | }
|
---|