Changes in / [e1e8408:0dc954b]
- Location:
- src
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
src/driver/cfa.cc
re1e8408 r0dc954b 10 10 // Created On : Tue Aug 20 13:44:49 2002 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Sep 26 23:12:38201713 // Update Count : 1 5912 // Last Modified On : Tue Oct 31 11:40:44 2017 13 // Update Count : 160 14 14 // 15 15 … … 305 305 } // if 306 306 307 shuffle( args, sargs, nargs, 1 ); // make room at front of argument list 308 nargs += 1; 307 309 if ( CFA_flag ) { 310 args[sargs] = "-D__CFA_FLAG__=-N"; 308 311 args[nargs] = "-D__CFA_PREPROCESS_"; 309 312 nargs += 1; 310 } // if 313 } else { 314 args[sargs] = "-D__CFA_FLAG__=-L"; 315 } // if 316 sargs += 1; 311 317 312 318 if ( debug ) { -
src/libcfa/stdlib
re1e8408 r0dc954b 10 10 // Created On : Thu Jan 28 17:12:35 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Oct 30 17:30:09201713 // Update Count : 24 212 // Last Modified On : Tue Oct 31 13:47:24 2017 13 // Update Count : 245 14 14 // 15 15 … … 213 213 //--------------------------------------- 214 214 215 void rand 48seed( long int s );216 char rand 48( void );217 char rand 48( char lower_bound, char upper_bound);218 int rand 48( void );219 unsigned int rand 48( void );220 unsigned int rand 48( unsigned int upper_bound);221 unsigned int rand 48( unsigned int lower_bound, unsigned int upper_bound);222 long int rand48( void );223 unsigned long int rand 48( void );224 unsigned long int rand 48( unsigned long int upper_bound);225 unsigned long int rand 48( unsigned long int lower_bound, unsigned long int upper_bound);226 float rand 48( void );227 double rand 48( void );228 float _Complex rand 48( void );229 double _Complex rand 48( void );230 long double _Complex rand 48( void );215 void random_seed( long int s ); 216 char random( void ); 217 char random( char l, char u ); 218 int random( void ); 219 unsigned int random( void ); 220 unsigned int random( unsigned int u ); 221 unsigned int random( unsigned int l, unsigned int u ); 222 //long int random( void ); 223 unsigned long int random( void ); 224 unsigned long int random( unsigned long int u ); 225 unsigned long int random( unsigned long int l, unsigned long int u ); 226 float random( void ); 227 double random( void ); 228 float _Complex random( void ); 229 double _Complex random( void ); 230 long double _Complex random( void ); 231 231 232 232 //--------------------------------------- -
src/libcfa/stdlib.c
re1e8408 r0dc954b 10 10 // Created On : Thu Jan 28 17:10:29 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Oct 30 17:53:04201713 // Update Count : 29 512 // Last Modified On : Mon Oct 30 22:43:02 2017 13 // Update Count : 297 14 14 // 15 15 … … 275 275 //--------------------------------------- 276 276 277 void rand 48seed( long int s ) { srand48( s ); }278 char rand 48( void ) { return mrand48(); }279 char rand 48( char l, char u ) { return lrand48() % (u - l) + l; }280 int rand 48( void ) { return mrand48(); }281 unsigned int rand 48( void ) { return lrand48(); }282 unsigned int rand 48( unsigned int u ) { return lrand48() % u; }283 unsigned int rand 48( unsigned int l, unsigned int u ) { return lrand48() % (u - l) + l; }284 long int rand48( void ) { return mrand48(); }285 unsigned long int rand 48( void ) { return lrand48(); }286 unsigned long int rand 48( unsigned long int u ) { return lrand48() % u; }287 unsigned long int rand 48( unsigned long int l, unsigned long int u ) { return lrand48() % (u - l) + l; }288 float rand 48( void ) { return (float)drand48(); } // otherwise float uses lrand48289 double rand 48( void ) { return drand48(); }290 float _Complex rand 48( void ) { return (float)drand48() + (float _Complex)(drand48() * _Complex_I); }291 double _Complex rand 48( void ) { return drand48() + (double _Complex)(drand48() * _Complex_I); }292 long double _Complex rand 48( void) { return (long double)drand48() + (long double _Complex)(drand48() * _Complex_I); }277 void random_seed( long int s ) { srand48( s ); } 278 char random( void ) { return mrand48(); } 279 char random( char l, char u ) { return lrand48() % (u - l) + l; } 280 int random( void ) { return mrand48(); } 281 unsigned int random( void ) { return lrand48(); } 282 unsigned int random( unsigned int u ) { return lrand48() % u; } 283 unsigned int random( unsigned int l, unsigned int u ) { return lrand48() % (u - l) + l; } 284 //long int random( void ) { return mrand48(); } 285 unsigned long int random( void ) { return lrand48(); } 286 unsigned long int random( unsigned long int u ) { return lrand48() % u; } 287 unsigned long int random( unsigned long int l, unsigned long int u ) { return lrand48() % (u - l) + l; } 288 float random( void ) { return (float)drand48(); } // otherwise float uses lrand48 289 double random( void ) { return drand48(); } 290 float _Complex random( void ) { return (float)drand48() + (float _Complex)(drand48() * _Complex_I); } 291 double _Complex random( void ) { return drand48() + (double _Complex)(drand48() * _Complex_I); } 292 long double _Complex random( void) { return (long double)drand48() + (long double _Complex)(drand48() * _Complex_I); } 293 293 294 294 //--------------------------------------- -
src/main.cc
re1e8408 r0dc954b 10 10 // Author : Richard C. Bilson 11 11 // Created On : Fri May 15 23:12:02 2015 12 // Last Modified By : Andrew Beach13 // Last Modified On : Wed Jul 26 14:38:00 201714 // Update Count : 44 312 // Last Modified By : Peter A. Buhr 13 // Last Modified On : Tue Oct 31 12:22:40 2017 14 // Update Count : 445 15 15 // 16 16 … … 81 81 expraltp = false, 82 82 libcfap = false, 83 preludep = false, 83 84 nopreludep = false, 84 85 noprotop = false, … … 378 379 379 380 void parse_cmdline( int argc, char * argv[], const char *& filename ) { 380 enum { Ast, Bbox, Bresolver, CtorInitFix, DeclStats, Expr, ExprAlt, Grammar, LibCFA, Nopreamble, Parse, Prototypes, Resolver, Symbol, Tree, TupleExpansion, Validate, };381 enum { Ast, Bbox, Bresolver, CtorInitFix, DeclStats, Expr, ExprAlt, Grammar, LibCFA, Preamble, Nopreamble, Parse, Prototypes, Resolver, Symbol, Tree, TupleExpansion, Validate, }; 381 382 382 383 static struct option long_opts[] = { … … 390 391 { "grammar", no_argument, 0, Grammar }, 391 392 { "libcfa", no_argument, 0, LibCFA }, 393 { "preamble", no_argument, 0, Preamble }, 392 394 { "no-preamble", no_argument, 0, Nopreamble }, 393 395 { "parse", no_argument, 0, Parse }, … … 405 407 406 408 int c; 407 while ( (c = getopt_long( argc, argv, "abBcCdefglLmn pqrstTvyzZD:F:", long_opts, &long_index )) != -1 ) {409 while ( (c = getopt_long( argc, argv, "abBcCdefglLmnNpqrstTvyzZD:F:", long_opts, &long_index )) != -1 ) { 408 410 switch ( c ) { 409 411 case Ast: … … 451 453 case 'n': // do not read preamble 452 454 nopreludep = true; 455 break; 456 case Preamble: 457 case 'N': // read preamble 458 preludep = true; 453 459 break; 454 460 case Prototypes: -
src/tests/boundedBuffer.c
re1e8408 r0dc954b 8 8 // Created On : Mon Oct 30 12:45:13 2017 9 9 // Last Modified By : Peter A. Buhr 10 // Last Modified On : Mon Oct 30 18:00:10201711 // Update Count : 710 // Last Modified On : Mon Oct 30 23:02:46 2017 11 // Update Count : 9 12 12 // 13 13 14 14 #include <stdlib> 15 #include <fstream> 15 #include <fstream> // random 16 16 #include <kernel> 17 17 #include <thread> 18 #include <unistd.h> // getpid18 #include <unistd.h> // getpid 19 19 20 20 monitor Buffer { … … 52 52 void main( Producer & prod ) { 53 53 for ( int i = 1; i <= prod.N; i += 1 ) { 54 yield( rand 48( 5 ) );54 yield( random( 5 ) ); 55 55 insert( prod.buffer, 1 ); 56 56 } // for … … 69 69 cons.sum = 0; 70 70 for ( ;; ) { 71 yield( rand 48( 5 ) );71 yield( random( 5 ) ); 72 72 int item = remove( cons.buffer ); 73 73 if ( item == -1 ) break; // sentinel ? … … 90 90 processor p; 91 91 92 //rand 48seed( getpid() );93 rand 48seed( 1003 );92 //random_seed( getpid() ); 93 random_seed( 1003 ); 94 94 95 95 for ( i = 0; i < Cons; i += 1 ) { // create consumers -
src/tests/datingService.c
re1e8408 r0dc954b 9 9 // Created On : Mon Oct 30 12:56:20 2017 10 10 // Last Modified By : Peter A. Buhr 11 // Last Modified On : Mon Oct 30 17:58:41 201712 // Update Count : 1 411 // Last Modified On : Mon Oct 30 23:02:11 2017 12 // Update Count : 15 13 13 // 14 14 15 #include <stdlib> // rand 4815 #include <stdlib> // random 16 16 #include <fstream> 17 17 #include <kernel> … … 61 61 62 62 void main( Girl & g ) { 63 yield( rand 48( 100 ) ); // don't all start at the same time63 yield( random( 100 ) ); // don't all start at the same time 64 64 unsigned int partner = girl( g.TheExchange, g.id, g.ccode ); 65 65 //sout | "Girl:" | g.id | "is dating Boy at" | partner | "with ccode" | g.ccode | endl; … … 79 79 80 80 void main( Boy & b ) { 81 yield( rand 48( 100 ) ); // don't all start at the same time81 yield( random( 100 ) ); // don't all start at the same time 82 82 unsigned int partner = boy( b.TheExchange, b.id, b.ccode ); 83 83 //sout | " Boy:" | b.id | "is dating Girl" | partner | "with ccode" | b.ccode | endl; … … 96 96 Boy *boys[NoOfPairs]; 97 97 98 rand 48seed( getpid() );98 random_seed( getpid() ); 99 99 100 100 for ( unsigned int i = 0; i < NoOfPairs; i += 1 ) { -
src/tests/prodcons.c
re1e8408 r0dc954b 10 10 // Created On : Mon Sep 18 12:23:39 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Oct 30 18:01:19201713 // Update Count : 4 112 // Last Modified On : Mon Oct 30 23:06:05 2017 13 // Update Count : 42 14 14 // 15 15 16 16 #include <fstream> 17 17 #include <coroutine> 18 #include <stdlib> // rand 4818 #include <stdlib> // random 19 19 #include <unistd.h> // getpid 20 20 … … 30 30 // 1st resume starts here 31 31 for ( int i = 0; i < prod.N; i += 1 ) { 32 int p1 = rand 48( 100 );33 int p2 = rand 48( 100 );32 int p1 = random( 100 ); 33 int p2 = random( 100 ); 34 34 sout | p1 | " " | p2 | endl; 35 35 int status = delivery( *prod.c, p1, p2 ); … … 90 90 Prod prod; 91 91 Cons cons = { prod }; 92 rand 48seed( /* getpid() */ 103 ); // fixed seed for testing92 random_seed( /* getpid() */ 103 ); // fixed seed for testing 93 93 start( prod, 5, cons ); 94 94 sout | "main stops" | endl; -
src/tests/random.c
re1e8408 r0dc954b 10 10 // Created On : Tue Jul 5 21:29:30 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Jul 6 18:00:29 201613 // Update Count : 312 // Last Modified On : Mon Oct 30 23:06:49 2017 13 // Update Count : 6 14 14 // 15 15 … … 19 19 20 20 int main() { 21 // rand48seed( getpid() ); // set random seed22 rand 48seed( 1003 );// fixed seed for repeatable tests21 //srandom( getpid() ); // set random seed 22 random_seed( 1003 ); // fixed seed for repeatable tests 23 23 24 24 // test polymorphic calls to random and stream 25 char c = rand 48();25 char c = random(); 26 26 sout | c | endl; 27 int i = rand 48();27 int i = random(); 28 28 sout | i | endl; 29 unsigned int ui = rand 48();29 unsigned int ui = random(); 30 30 sout | ui | endl; 31 long int li = rand 48();31 long int li = random(); 32 32 sout | li | endl; 33 unsigned long int uli = rand 48();33 unsigned long int uli = random(); 34 34 sout | uli | endl; 35 float f = rand 48();35 float f = random(); 36 36 sout | f | endl; 37 double d = rand 48();37 double d = random(); 38 38 sout | d | endl; 39 float _Complex fc = rand 48();39 float _Complex fc = random(); 40 40 sout | fc | endl; 41 double _Complex dc = rand 48();41 double _Complex dc = random(); 42 42 sout | dc | endl; 43 long double _Complex ldc = rand 48();43 long double _Complex ldc = random(); 44 44 sout | ldc | endl; 45 45 } // main -
src/tests/rational.c
re1e8408 r0dc954b 10 10 // Created On : Mon Mar 28 08:43:12 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Aug 23 21:40:11201713 // Update Count : 6 612 // Last Modified On : Tue Oct 10 23:25:04 2017 13 // Update Count : 67 14 14 // 15 15 -
src/tests/sched-ext-barge.c
re1e8408 r0dc954b 42 42 void main( barger_t & this ) { 43 43 yield(); 44 while( barge( global ) ) { yield( rand48(10)); }44 while( barge( global ) ) { yield(random( 10 )); } 45 45 } 46 46 47 47 bool do_call( global_t & mutex this ) { 48 yield(rand 48(10));48 yield(random( 10 )); 49 49 if( this.state != WAITFOR && !this.done && this.started ) { 50 50 serr | "Barging before caller detected" | endl; … … 57 57 thread caller_t {}; 58 58 void main( caller_t & this ) { 59 while( do_call(global) ) { yield(rand 48(10)); }59 while( do_call(global) ) { yield(random( 10 )); } 60 60 } 61 61 … … 63 63 this.started = true; 64 64 for( int i = 0; i < N; i++) { 65 yield(rand 48(10));65 yield(random( 10 )); 66 66 this.state = WAITFOR; 67 67 waitfor(do_call, this) { -
src/tests/sched-ext-dtor.c
re1e8408 r0dc954b 45 45 46 46 void main( dummy_t & this ) { 47 yield(rand 48(10));47 yield(random( 10 )); 48 48 set_state( this, MAIN ); 49 49 waitfor( ^?{}, this ) { … … 58 58 for( int i = 0; i < N; i++ ){ 59 59 dummy_t dummy[4]; 60 yield( rand 48(100) );60 yield( random( 100 ) ); 61 61 } 62 62 sout | "Stopping" | endl; -
src/tests/sched-ext-recurse.c
re1e8408 r0dc954b 15 15 static const unsigned long N = 5_000ul; 16 16 17 static inline void rand_yield() { yield(rand 48(10)); }17 static inline void rand_yield() { yield(random( 10 )); } 18 18 19 19 enum state_t { FIRST, SECOND, THIRD, LAST, STOP }; … … 23 23 for (i = 0; i < 4; i++) 24 24 { 25 int j = rand 48(4);25 int j = random( 4 ); 26 26 enum state_t t = array[j]; 27 27 array[j] = array[i]; … … 131 131 132 132 int main() { 133 rand 48seed( time(NULL) );133 random_seed( time(NULL) ); 134 134 sout | "Starting" | endl; 135 135 { -
src/tests/sched-ext-when.c
re1e8408 r0dc954b 15 15 static const unsigned long N = 4_998ul; 16 16 17 static inline void rand_yield() { yield(rand 48(10)); }17 static inline void rand_yield() { yield(random( 10 )); } 18 18 19 19 monitor global_t { … … 77 77 78 78 int main() { 79 rand 48seed( time(NULL) );79 random_seed( time(NULL) ); 80 80 sout | "Starting" | endl; 81 81 { -
src/tests/sched-ext.c
re1e8408 r0dc954b 32 32 void do_wait( global_t * mutex a ) { 33 33 sout | "Waiting to accept" | endl; 34 yield( rand 48(10) );34 yield( random( 10 ) ); 35 35 36 36 sout | "Accepting" | endl; … … 44 44 45 45 sout | "Accepted" | endl; 46 yield( rand 10() );46 yield( random( 10 ) ); 47 47 } 48 48 … … 64 64 void main( Acceptee* this ) { 65 65 while( !done ) { 66 yield( rand 10() );66 yield( random( 10 ) ); 67 67 do_notify( &globalA ); 68 yield( rand 10() );68 yield( random( 10 ) ); 69 69 } 70 70 } … … 74 74 int main(int argc, char* argv[]) { 75 75 done = false; 76 rand 48seed( time( NULL ) );76 random_seed( time( NULL ) ); 77 77 printf("%p\n", &globalA); 78 78 sout | "Starting" | endl; -
src/tests/sched-int-barge.c
re1e8408 r0dc954b 64 64 65 65 if( action == 0 ) { 66 c.do_signal = max( rand 48(10), 1);67 c.do_wait1 = rand 48(c.do_signal);68 c.do_wait2 = rand 48(c.do_signal);66 c.do_signal = max( random( 10 ), 1); 67 c.do_wait1 = random( c.do_signal ); 68 c.do_wait2 = random( c.do_signal ); 69 69 70 70 if(c.do_wait1 == c.do_wait2) sout | "Same" | endl; … … 109 109 110 110 int main(int argc, char* argv[]) { 111 rand 48seed(0);111 random_seed(0); 112 112 processor p; 113 113 { -
src/tests/sched-int-block.c
re1e8408 r0dc954b 49 49 wait( &cond, (uintptr_t)this_thread ); 50 50 51 yield( rand 48(10) );51 yield( random( 10 ) ); 52 52 53 53 if(a.last_thread != a.last_signaller || b.last_thread != b.last_signaller ) { … … 58 58 a.last_thread = b.last_thread = this_thread; 59 59 60 yield( rand 48(10) );60 yield( random( 10 ) ); 61 61 } 62 62 … … 70 70 //------------------------------------------------------------------------------ 71 71 void signal_op( global_data_t & mutex a, global_data_t & mutex b ) { 72 yield( rand 48(10) );72 yield( random( 10 ) ); 73 73 74 74 [a.last_thread, b.last_thread, a.last_signaller, b.last_signaller] = this_thread; … … 83 83 } 84 84 85 yield( rand 48(10) );85 yield( random( 10 ) ); 86 86 87 87 if(a.last_thread != next || b.last_thread != next) { … … 118 118 119 119 int main(int argc, char* argv[]) { 120 rand 48seed( time( NULL ) );120 random_seed( time( NULL ) ); 121 121 done = false; 122 122 processor p; -
src/tests/sched-int-disjoint.c
re1e8408 r0dc954b 88 88 signal( &cond, a, data ); 89 89 90 yield( rand 48(10) );90 yield( random( 10 ) ); 91 91 92 92 //This is technically a mutual exclusion violation but the mutex monitor protects us … … 109 109 // Main loop 110 110 int main(int argc, char* argv[]) { 111 rand 48seed( time( NULL ) );111 random_seed( time( NULL ) ); 112 112 all_done = false; 113 113 processor p; -
src/tests/sched-int-wait.c
re1e8408 r0dc954b 62 62 63 63 while( waiter_left != 0 ) { 64 unsigned action = rand 48(4);64 unsigned action = random( 4 ); 65 65 switch( action ) { 66 66 case 0: … … 127 127 // Main 128 128 int main(int argc, char* argv[]) { 129 rand 48seed( time( NULL ) );129 random_seed( time( NULL ) ); 130 130 waiter_left = 4; 131 131 processor p[2];
Note: See TracChangeset
for help on using the changeset viewer.