Changeset b5e725a


Ignore:
Timestamp:
Aug 14, 2023, 9:28:00 PM (9 months ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
master
Children:
6264087
Parents:
7baff35
git-author:
Peter A. Buhr <pabuhr@…> (08/14/23 21:24:33)
git-committer:
Peter A. Buhr <pabuhr@…> (08/14/23 21:28:00)
Message:

move setting the default random-generator size from PRNG.cfa to stdlib.hfa, change to the exception macros

Files:
5 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/parseconfig.cfa

    r7baff35 rb5e725a  
    1616#pragma GCC visibility push(default)
    1717
     18
    1819// *********************************** exceptions ***********************************
    1920
    20 
    21 // TODO: Add names of missing config entries to exception (see further below)
    22 vtable(Missing_Config_Entries) Missing_Config_Entries_vt;
    2321
    2422[ void ] ?{}( & Missing_Config_Entries this, unsigned int num_missing ) {
     
    3331
    3432
    35 vtable(Parse_Failure) Parse_Failure_vt;
    36 
    3733[ void ] ?{}( & Parse_Failure this, [] char failed_key, [] char failed_value ) {
    3834        this.virtual_table = &Parse_Failure_vt;
     
    5450}
    5551
    56 
    57 vtable(Validation_Failure) Validation_Failure_vt;
    5852
    5953[ void ] ?{}( & Validation_Failure this, [] char failed_key, [] char failed_value ) {
  • libcfa/src/parseconfig.hfa

    r7baff35 rb5e725a  
    22
    33#include <math.trait.hfa>
     4#include <Exception.hfa>
    45
    56
     
    6263
    6364
    64 exception Missing_Config_Entries {
     65ExceptionDecl( Missing_Config_Entries,
    6566        unsigned int num_missing;
    66 };
     67);
    6768
    6869[ void ] msg( * Missing_Config_Entries ex );
    6970
    70 exception Parse_Failure {
     71ExceptionDecl( Parse_Failure,
    7172        * char failed_key;
    7273        * char failed_value;
    73 };
     74);
    7475
    7576[ void ] msg( * Parse_Failure ex );
    7677
    77 exception Validation_Failure {
     78ExceptionDecl( Validation_Failure,
    7879        * char failed_key;
    7980        * char failed_value;
    80 };
     81);
    8182
    8283[ void ] msg( * Validation_Failure ex );
  • libcfa/src/stdlib.cfa

    r7baff35 rb5e725a  
    1010// Created On       : Thu Jan 28 17:10:29 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Aug  5 11:53:43 2023
    13 // Update Count     : 637
     12// Last Modified On : Mon Aug 14 18:22:36 2023
     13// Update Count     : 642
    1414//
    1515
     
    6565//---------------------------------------
    6666
    67 static vtable(out_of_range) out_of_range_vt;
    68 static vtable(invalid_argument) invalid_argument_vt;
    69 
    7067forall( T | { T strto( const char sptr[], char * eptr[], int ); } )
    7168T convert( const char sptr[] ) {
     
    7370        errno = 0;                                                                                      // reset
    7471        T val = strto( sptr, &eptr, 10 );                                       // attempt conversion
    75         if ( errno == ERANGE ) Throw( out_of_range );
     72        if ( errno == ERANGE ) throw ExceptionInst( out_of_range );
    7673        if ( eptr == sptr ||                                                            // conversion failed, no characters generated
    77                  *eptr != '\0' ) Throw( invalid_argument );             // not at end of str ?
     74                 *eptr != '\0' ) throw ExceptionInst( invalid_argument ); // not at end of str ?
    7875        return val;
    7976} // convert
  • libcfa/src/stdlib.hfa

    r7baff35 rb5e725a  
    1010// Created On       : Thu Jan 28 17:12:35 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Aug  5 11:53:42 2023
    13 // Update Count     : 774
     12// Last Modified On : Mon Aug 14 18:19:12 2023
     13// Update Count     : 777
    1414//
    1515
     
    1919#include "bits/align.hfa"                                                               // libAlign
    2020#include "bits/random.hfa"                                                              // prng
     21#include <Exception.hfa>
     22#include <heap.hfa>
    2123
    2224#include <stdlib.h>                                                                             // *alloc, strto*, ato*
    23 #include <heap.hfa>
    2425#include <errno.h>
    2526
     
    310311long double _Complex strto( const char sptr[], char * eptr[] );
    311312
    312 exception out_of_range {};
    313 exception invalid_argument {};
     313ExceptionDecl( out_of_range );
     314ExceptionDecl( invalid_argument );
    314315
    315316forall( T | { T strto( const char sptr[], char * eptr[], int ); } )
     
    460461} // distribution
    461462
     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
    462470// Concurrent Pseudo Random-Number Generator : generate repeatable sequence of values that appear random.
    463471//
  • tests/PRNG.cfa

    r7baff35 rb5e725a  
    1010// Created On       : Wed Dec 29 09:38:12 2021
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jun 29 10:18:35 2023
    13 // Update Count     : 424
     12// Last Modified On : Mon Aug 14 08:49:53 2023
     13// Update Count     : 425
    1414//
    1515
     
    2727#define str(s) #s
    2828
    29 #if defined( __x86_64__ ) || defined( __aarch64__ )             // 64-bit architecture
    30 #define PRNG PRNG64
    31 #else                                                                                                   // 32-bit architecture
    32 #define PRNG PRNG32
    33 #endif // __x86_64__
    34 
    3529//#define TIME
    3630
Note: See TracChangeset for help on using the changeset viewer.