ADTast-experimentalpthread-emulationqualifiedEnum
Last change
on this file since 03656d1 was
03656d1,
checked in by Peter A. Buhr <pabuhr@…>, 2 years ago
|
add test for nested functions run on user-thread stacks
|
-
Property mode set to
100644
|
File size:
1.2 KB
|
Rev | Line | |
---|
[03656d1] | 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 22:24:28 2022 |
---|
| 13 | // Update Count : 2 |
---|
| 14 | // |
---|
| 15 | |
---|
| 16 | #include <thread.hfa> |
---|
| 17 | #include <fstream.hfa> |
---|
| 18 | #include <stdlib.hfa> |
---|
| 19 | |
---|
| 20 | thread T {}; |
---|
| 21 | |
---|
| 22 | enum { VALUES = 10_000 }; |
---|
| 23 | int values[VALUES]; |
---|
| 24 | |
---|
| 25 | void main( T & t ) { |
---|
| 26 | int 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 | } |
---|
| 45 | int 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.