source: tests/nested_function.cfa @ b035046

ADTast-experimentalpthread-emulationqualifiedEnum
Last change on this file since b035046 was 666f8a3, checked in by Peter A. Buhr <pabuhr@…>, 22 months ago

fix test and expected output for nested functions run on user-thread stacks

  • Property mode set to 100644
File size: 1.2 KB
Line 
1//
2// Cforall Version 1.0.0 Copyright (C) 2016 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// nested_function.cfa -- Test nested functions run on user-thread stacks.
8//
9// Author           : Peter A. Buhr
10// Created On       : Mon May 23 22:21:30 2022
11// Last Modified By : Peter A. Buhr
12// Last Modified On : Mon May 23 23:11:25 2022
13// Update Count     : 4
14//
15
16#include <thread.hfa>
17#include <fstream.hfa>
18#include <stdlib.hfa>
19
20thread T {};
21
22enum { VALUES = 10_000 };
23int values[VALUES];
24
25void main( T & ) {
26        void f() {
27                int i = 0;
28                void h( void ) {                                                                // nest routine
29                        int j = i;                                                                      // non-local reference
30                        void g( void ) {                                                        // nest routine
31                                i += 1;                                                                 // non-local reference
32                                j += 1;                                                                 // non-local reference
33                                if ( i < 3 ) h();
34                        } // g
35                        if ( prng( 6 ) == 0 ) g();                                      // prevent compiler inlining
36                        else h();
37                        i += 1;
38                        sout | "j" | j | bsearchl( j, values, VALUES ); // has internal nested compare routine
39                } // h
40                h();
41                sout | "i" | i | bsearchl( i, values, VALUES ); // has internal nested compare routine
42        } // f
43        f();
44}
45int main() {
46        set_seed( 1003 );
47        for ( i; VALUES ) values[i] = i;
48        T t[5];
49}
Note: See TracBrowser for help on using the repository browser.