Changeset 54aba8d


Ignore:
Timestamp:
Jan 2, 2018, 1:53:13 PM (4 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, resolv-new, with_gc
Children:
b3048d4
Parents:
490d9972
Message:

change name of random_seed to srandom, and make all random calls through rand48

Location:
src
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/stdlib

    r490d9972 r54aba8d  
    1010// Created On       : Thu Jan 28 17:12:35 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Jan  1 17:35:43 2018
    13 // Update Count     : 291
     12// Last Modified On : Tue Jan  2 12:21:04 2018
     13// Update Count     : 292
    1414//
    1515
     
    265265//---------------------------------------
    266266
    267 void random_seed( long int s );
     267extern "C" { void srandom( unsigned int seed ); }               // override C version
    268268char random( void );
    269269char random( char u );
     
    275275unsigned int random( unsigned int u );
    276276unsigned int random( unsigned int l, unsigned int u );
    277 extern "C" { long int random( void ); }
     277extern "C" { long int random( void ); }                                 // override C version
    278278long int random( long int u );
    279279long int random( long int l, long int u );
  • src/libcfa/stdlib.c

    r490d9972 r54aba8d  
    1010// Created On       : Thu Jan 28 17:10:29 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Jan  1 19:03:16 2018
    13 // Update Count     : 437
     12// Last Modified On : Tue Jan  2 12:20:32 2018
     13// Update Count     : 441
    1414//
    1515
     
    257257//---------------------------------------
    258258
    259 void random_seed( long int s ) { srand48( s ); srandom( s ); } // call srandom to harmonize with C-lib random
     259extern "C" { void srandom( unsigned int seed ) { srand48( seed ); } } // override C version
    260260char random( void ) { return (unsigned long int)random(); }
    261261char random( char u ) { return random( (unsigned long int)u ); }
     
    267267unsigned int random( unsigned int u ) { return random( (unsigned long int)u ); }
    268268unsigned int random( unsigned int l, unsigned int u ) { return random( (unsigned long int)l, (unsigned long int)u ); }
    269 //extern "C" { long int random() { return mrand48(); } }
     269extern "C" { long int random( void ) { return mrand48(); } } // override C version
    270270long int random( long int u ) { if ( u < 0 ) return random( u, 0 ); else return random( 0, u ); }
    271271long int random( long int l, long int u ) { assert( l < u ); return lrand48() % (u - l) + l; }
  • src/tests/.expect/random.txt

    r490d9972 r54aba8d  
    22=
    33V
    4 2005783408
    5 2
     4-911259971
    656
    7 861904956
    8 7
    9 10
    10 630915564
    11 8
    12 5
    13 697339851
    14 5
    15 19
    16 0.61653
    17 0.623932379138292
    18 0.677254+0.678107i
    19 0.298107334760999+0.951550630916653i
    20 0.724141628787954517+0.188154303303139869i
     6-4
     71232105397
     80
     918
     10-914096085
     111
     1215
     132077092859
     141
     1511
     160.677254
     170.678106775246139
     180.298107+0.951551i
     190.724141628787955+0.18815430330314i
     200.358747528448063235+0.27913860468074958i
  • src/tests/concurrent/examples/boundedBuffer.c

    r490d9972 r54aba8d  
    88// Created On       : Mon Oct 30 12:45:13 2017
    99// Last Modified By : Peter A. Buhr
    10 // Last Modified On : Thu Dec 14 21:28:52 2017
    11 // Update Count     : 32
     10// Last Modified On : Tue Jan  2 12:18:18 2018
     11// Update Count     : 33
    1212//
    1313
     
    9191        processor p;
    9292
    93         //random_seed( getpid() );
    94         random_seed( 1003 );
     93        //srandom( getpid() );
     94        srandom( 1003 );
    9595
    9696        for ( i = 0; i < Cons; i += 1 ) {                       // create consumers
  • src/tests/concurrent/examples/datingService.c

    r490d9972 r54aba8d  
    88// Created On       : Mon Oct 30 12:56:20 2017
    99// Last Modified By : Peter A. Buhr
    10 // Last Modified On : Wed Dec  6 12:19:19 2017
    11 // Update Count     : 21
     10// Last Modified On : Tue Jan  2 12:19:01 2018
     11// Update Count     : 22
    1212//
    1313
     
    9191        Boy  *boys[NoOfPairs];
    9292
    93         random_seed( /*getpid()*/ 103 );
     93        srandom( /*getpid()*/ 103 );
    9494
    9595        for ( unsigned int i = 0; i < NoOfPairs; i += 1 ) {
  • src/tests/concurrent/signal/barge.c

    r490d9972 r54aba8d  
    109109
    110110int main(int argc, char* argv[]) {
    111         random_seed(0);
     111        srandom(0);
    112112        processor p;
    113113        {
  • src/tests/concurrent/signal/block.c

    r490d9972 r54aba8d  
    118118
    119119int main(int argc, char* argv[]) {
    120         random_seed( time( NULL ) );
     120        srandom( time( NULL ) );
    121121        done = false;
    122122        processor p;
  • src/tests/concurrent/signal/disjoint.c

    r490d9972 r54aba8d  
    109109// Main loop
    110110int main(int argc, char* argv[]) {
    111         random_seed( time( NULL ) );
     111        srandom( time( NULL ) );
    112112        all_done = false;
    113113        processor p;
  • src/tests/concurrent/signal/wait.c

    r490d9972 r54aba8d  
    127127// Main
    128128int main(int argc, char* argv[]) {
    129         random_seed( time( NULL ) );
     129        srandom( time( NULL ) );
    130130        waiter_left = 4;
    131131        processor p[2];
  • src/tests/concurrent/waitfor/recurse.c

    r490d9972 r54aba8d  
    131131
    132132int main() {
    133         random_seed( time(NULL) );
     133        srandom( time(NULL) );
    134134        sout | "Starting" | endl;
    135135        {
  • src/tests/concurrent/waitfor/simple.c

    r490d9972 r54aba8d  
    7474int main(int argc, char* argv[]) {
    7575        done = false;
    76         random_seed( time( NULL ) );
     76        srandom( time( NULL ) );
    7777        printf("%p\n", &globalA);
    7878        sout | "Starting" | endl;
  • src/tests/concurrent/waitfor/when.c

    r490d9972 r54aba8d  
    7777
    7878int main() {
    79         random_seed( time(NULL) );
     79        srandom( time(NULL) );
    8080        sout | "Starting" | endl;
    8181        {
  • src/tests/coroutine/prodcons.c

    r490d9972 r54aba8d  
    1010// Created On       : Mon Sep 18 12:23:39 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Dec  5 22:40:55 2017
    13 // Update Count     : 46
     12// Last Modified On : Tue Jan  2 12:17:01 2018
     13// Update Count     : 47
    1414//
    1515
     
    9090        Prod prod;
    9191        Cons cons = { prod };
    92         random_seed( /* getpid() */ 103 );                                      // fixed seed for testing
     92        srandom( /* getpid() */ 103 );                                          // fixed seed for testing
    9393        start( prod, 5, cons );
    9494        sout | "main stops" | endl;
  • src/tests/random.c

    r490d9972 r54aba8d  
    1010// Created On       : Tue Jul  5 21:29:30 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Dec 24 07:48:23 2017
    13 // Update Count     : 18
     12// Last Modified On : Tue Jan  2 12:19:34 2018
     13// Update Count     : 19
    1414//
    1515
     
    1919
    2020int main() {
    21         // random_seed( getpid() );                                                             // set random seed
    22         random_seed( 1003 );                                                            // fixed seed for repeatable tests
     21        // srandom( getpid() );                                                         // set random seed
     22        srandom( 1003 );                                                                        // fixed seed for repeatable tests
    2323
    2424        // test polymorphic calls to random and stream
Note: See TracChangeset for help on using the changeset viewer.