Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/stdlib.hfa

    rb5e725a r8a97248  
    1010// Created On       : Thu Jan 28 17:12:35 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Aug 14 18:19:12 2023
    13 // Update Count     : 777
     12// Last Modified On : Thu Feb  2 11:30:04 2023
     13// Update Count     : 766
    1414//
    1515
     
    1919#include "bits/align.hfa"                                                               // libAlign
    2020#include "bits/random.hfa"                                                              // prng
    21 #include <Exception.hfa>
     21
     22#include <stdlib.h>                                                                             // *alloc, strto*, ato*
    2223#include <heap.hfa>
    2324
    24 #include <stdlib.h>                                                                             // *alloc, strto*, ato*
    25 #include <errno.h>
    2625
    2726// Reduce includes by explicitly defining these routines.
     
    295294
    296295static inline {
    297         int strto( const char sptr[], char * eptr[], int base ) { return (int)strtol( sptr, eptr, base ); }
    298         unsigned int strto( const char sptr[], char * eptr[], int base ) { return (unsigned int)strtoul( sptr, eptr, base ); }
    299         long int strto( const char sptr[], char * eptr[], int base ) { return strtol( sptr, eptr, base ); }
    300         unsigned long int strto( const char sptr[], char * eptr[], int base ) { return strtoul( sptr, eptr, base ); }
    301         long long int strto( const char sptr[], char * eptr[], int base ) { return strtoll( sptr, eptr, base ); }
    302         unsigned long long int strto( const char sptr[], char * eptr[], int base ) { return strtoull( sptr, eptr, base ); }
    303 
    304         float strto( const char sptr[], char * eptr[] ) { return strtof( sptr, eptr ); }
    305         double strto( const char sptr[], char * eptr[] ) { return strtod( sptr, eptr ); }
    306         long double strto( const char sptr[], char * eptr[] ) { return strtold( sptr, eptr ); }
    307 } // distribution
    308 
    309 float _Complex strto( const char sptr[], char * eptr[] );
    310 double _Complex strto( const char sptr[], char * eptr[] );
    311 long double _Complex strto( const char sptr[], char * eptr[] );
    312 
    313 ExceptionDecl( out_of_range );
    314 ExceptionDecl( invalid_argument );
    315 
    316 forall( T | { T strto( const char sptr[], char * eptr[], int ); } )
    317 T convert( const char sptr[] );
     296        int strto( const char sptr[], char ** eptr, int base ) { return (int)strtol( sptr, eptr, base ); }
     297        unsigned int strto( const char sptr[], char ** eptr, int base ) { return (unsigned int)strtoul( sptr, eptr, base ); }
     298        long int strto( const char sptr[], char ** eptr, int base ) { return strtol( sptr, eptr, base ); }
     299        unsigned long int strto( const char sptr[], char ** eptr, int base ) { return strtoul( sptr, eptr, base ); }
     300        long long int strto( const char sptr[], char ** eptr, int base ) { return strtoll( sptr, eptr, base ); }
     301        unsigned long long int strto( const char sptr[], char ** eptr, int base ) { return strtoull( sptr, eptr, base ); }
     302
     303        float strto( const char sptr[], char ** eptr ) { return strtof( sptr, eptr ); }
     304        double strto( const char sptr[], char ** eptr ) { return strtod( sptr, eptr ); }
     305        long double strto( const char sptr[], char ** eptr ) { return strtold( sptr, eptr ); }
     306} // distribution
     307
     308float _Complex strto( const char sptr[], char ** eptr );
     309double _Complex strto( const char sptr[], char ** eptr );
     310long double _Complex strto( const char sptr[], char ** eptr );
    318311
    319312static inline {
     
    374367
    375368        char random( void ) { return (unsigned long int)random(); }
    376         char random( char u ) { return (unsigned long int)random( (unsigned long int)u ); } // [0,u)
     369        char random( char u ) { return random( (unsigned long int)u ); } // [0,u)
    377370        char random( char l, char u ) { return random( (unsigned long int)l, (unsigned long int)u ); } // [l,u)
    378371        int random( void ) { return (long int)random(); }
    379         int random( int u ) { return (long int)random( (long int)u ); } // [0,u]
     372        int random( int u ) { return random( (long int)u ); } // [0,u]
    380373        int random( int l, int u ) { return random( (long int)l, (long int)u ); } // [l,u)
    381374        unsigned int random( void ) { return (unsigned long int)random(); }
    382         unsigned int random( unsigned int u ) { return (unsigned long int)random( (unsigned long int)u ); } // [0,u]
     375        unsigned int random( unsigned int u ) { return random( (unsigned long int)u ); } // [0,u]
    383376        unsigned int random( unsigned int l, unsigned int u ) { return random( (unsigned long int)l, (unsigned long int)u ); } // [l,u)
    384377} // distribution
     
    461454} // distribution
    462455
    463 // Set default random-generator size.
    464 #if defined( __x86_64__ ) || defined( __aarch64__ )             // 64-bit architecture
    465 #define PRNG PRNG64
    466 #else                                                                                                   // 32-bit architecture
    467 #define PRNG PRNG32
    468 #endif // __x86_64__
    469 
    470456// Concurrent Pseudo Random-Number Generator : generate repeatable sequence of values that appear random.
    471457//
Note: See TracChangeset for help on using the changeset viewer.