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