Changeset 8a930c03 for libcfa/src


Ignore:
Timestamp:
Jun 12, 2023, 12:05:58 PM (12 months ago)
Author:
JiadaL <j82liang@…>
Branches:
master
Children:
fec8bd1
Parents:
2b78949 (diff), 38e266c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

Location:
libcfa/src
Files:
1 added
18 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/Makefile.am

    r2b78949 r8a930c03  
    1111## Created On       : Sun May 31 08:54:01 2015
    1212## Last Modified By : Peter A. Buhr
    13 ## Last Modified On : Fri Jul 16 16:00:40 2021
    14 ## Update Count     : 255
     13## Last Modified On : Thu May 25 15:20:04 2023
     14## Update Count     : 259
    1515###############################################################################
    1616
     
    5959        bits/queue.hfa \
    6060        bits/sequence.hfa \
     61        concurrency/atomic.hfa \
    6162        concurrency/iofwd.hfa \
    6263        concurrency/barrier.hfa \
     
    115116        concurrency/kernel/fwd.hfa \
    116117        concurrency/mutex_stmt.hfa \
    117     concurrency/channel.hfa \
    118     concurrency/actor.hfa
     118        concurrency/channel.hfa \
     119        concurrency/actor.hfa
    119120
    120121inst_thread_headers_src = \
     
    127128        concurrency/monitor.hfa \
    128129        concurrency/mutex.hfa \
    129     concurrency/select.hfa \
     130        concurrency/select.hfa \
    130131        concurrency/thread.hfa
    131132
  • libcfa/src/bits/weakso_locks.cfa

    r2b78949 r8a930c03  
    3030bool register_select( blocking_lock & this, select_node & node ) { return false; }
    3131bool unregister_select( blocking_lock & this, select_node & node ) { return false; }
    32 bool on_selected( blocking_lock & this, select_node & node ) { return true; }
     32void on_selected( blocking_lock & this, select_node & node ) {}
    3333
  • libcfa/src/bits/weakso_locks.hfa

    r2b78949 r8a930c03  
    6262bool register_select( blocking_lock & this, select_node & node ) OPTIONAL_THREAD;
    6363bool unregister_select( blocking_lock & this, select_node & node ) OPTIONAL_THREAD;
    64 bool on_selected( blocking_lock & this, select_node & node ) OPTIONAL_THREAD;
     64void on_selected( blocking_lock & this, select_node & node ) OPTIONAL_THREAD;
    6565
    6666//----------
     
    8080static inline bool   register_select( multiple_acquisition_lock & this, select_node & node ) { return register_select( (blocking_lock &)this, node ); }
    8181static inline bool   unregister_select( multiple_acquisition_lock & this, select_node & node ) { return unregister_select( (blocking_lock &)this, node ); }
    82 static inline bool   on_selected( multiple_acquisition_lock & this, select_node & node ) { return on_selected( (blocking_lock &)this, node ); }
     82static inline void   on_selected( multiple_acquisition_lock & this, select_node & node ) { on_selected( (blocking_lock &)this, node ); }
  • libcfa/src/concurrency/actor.hfa

    r2b78949 r8a930c03  
    1313#endif // CFA_DEBUG
    1414
     15#define DEBUG_ABORT( cond, string ) CFA_DEBUG( if ( cond ) abort( string ) )
     16
    1517// Define the default number of processors created in the executor. Must be greater than 0.
    1618#define __DEFAULT_EXECUTOR_PROCESSORS__ 2
     
    4244struct executor;
    4345
    44 enum Allocation { Nodelete, Delete, Destroy, Finished }; // allocation status
    45 
    46 typedef Allocation (*__receive_fn)(actor &, message &);
     46enum allocation { Nodelete, Delete, Destroy, Finished }; // allocation status
     47
     48typedef allocation (*__receive_fn)(actor &, message &);
    4749struct request {
    4850    actor * receiver;
     
    393395struct actor {
    394396    size_t ticket;                                          // executor-queue handle
    395     Allocation allocation_;                                         // allocation action
     397    allocation allocation_;                                         // allocation action
    396398    inline virtual_dtor;
    397399};
     
    400402    // Once an actor is allocated it must be sent a message or the actor system cannot stop. Hence, its receive
    401403    // member must be called to end it
    402     verifyf( __actor_executor_, "Creating actor before calling start_actor_system() can cause undefined behaviour.\n" );
     404    DEBUG_ABORT( __actor_executor_ == 0p, "Creating actor before calling start_actor_system() can cause undefined behaviour.\n" );
    403405    allocation_ = Nodelete;
    404406    ticket = __get_next_ticket( *__actor_executor_ );
     
    430432
    431433struct message {
    432     Allocation allocation_;                     // allocation action
     434    allocation allocation_;                     // allocation action
    433435    inline virtual_dtor;
    434436};
     
    437439    this.allocation_ = Nodelete;
    438440}
    439 static inline void ?{}( message & this, Allocation allocation ) {
    440     memcpy( &this.allocation_, &allocation, sizeof(allocation) ); // optimization to elide ctor
    441     verifyf( this.allocation_ != Finished, "The Finished Allocation status is not supported for message types.\n");
     441static inline void ?{}( message & this, allocation alloc ) {
     442    memcpy( &this.allocation_, &alloc, sizeof(allocation) ); // optimization to elide ctor
     443    DEBUG_ABORT( this.allocation_ == Finished, "The Finished allocation status is not supported for message types.\n" );
    442444}
    443445static inline void ^?{}( message & this ) with(this) {
     
    453455    } // switch
    454456}
    455 static inline void set_allocation( message & this, Allocation state ) {
     457static inline void set_allocation( message & this, allocation state ) {
    456458    this.allocation_ = state;
    457459}
    458460
    459461static inline void deliver_request( request & this ) {
     462    DEBUG_ABORT( this.receiver->ticket == (unsigned long int)MAX, "Attempted to send message to deleted/dead actor\n" );
    460463    this.receiver->allocation_ = this.fn( *this.receiver, *this.msg );
    461464    check_message( *this.msg );
     
    631634
    632635static inline void send( actor & this, request & req ) {
    633     verifyf( this.ticket != (unsigned long int)MAX, "Attempted to send message to deleted/dead actor\n" );
     636    DEBUG_ABORT( this.ticket == (unsigned long int)MAX, "Attempted to send message to deleted/dead actor\n" );
    634637    send( *__actor_executor_, req, this.ticket );
    635638}
     
    680683// assigned at creation to __base_msg_finished to avoid unused message warning
    681684message __base_msg_finished @= { .allocation_ : Finished };
    682 struct __DeleteMsg { inline message; } DeleteMsg = __base_msg_finished;
    683 struct __DestroyMsg { inline message; } DestroyMsg = __base_msg_finished;
    684 struct __FinishedMsg { inline message; } FinishedMsg = __base_msg_finished;
    685 
    686 Allocation receive( actor & this, __DeleteMsg & msg ) { return Delete; }
    687 Allocation receive( actor & this, __DestroyMsg & msg ) { return Destroy; }
    688 Allocation receive( actor & this, __FinishedMsg & msg ) { return Finished; }
    689 
     685struct __delete_msg_t { inline message; } delete_msg = __base_msg_finished;
     686struct __destroy_msg_t { inline message; } destroy_msg = __base_msg_finished;
     687struct __finished_msg_t { inline message; } finished_msg = __base_msg_finished;
     688
     689allocation receive( actor & this, __delete_msg_t & msg ) { return Delete; }
     690allocation receive( actor & this, __destroy_msg_t & msg ) { return Destroy; }
     691allocation receive( actor & this, __finished_msg_t & msg ) { return Finished; }
     692
  • libcfa/src/concurrency/channel.hfa

    r2b78949 r8a930c03  
    5151vtable(channel_closed) channel_closed_vt;
    5252
     53static inline bool is_insert( channel_closed & e ) { return e.elem != 0p; }
     54static inline bool is_remove( channel_closed & e ) { return e.elem == 0p; }
     55
    5356// #define CHAN_STATS // define this to get channel stats printed in dtor
    5457
     
    341344}
    342345
     346// special case of __handle_waituntil_OR, that does some work to avoid starvation/deadlock case
     347static inline bool __handle_pending( dlist( select_node ) & queue, select_node & mine ) {
     348    while ( !queue`isEmpty ) {
     349        // if node not a special OR case or if we win the special OR case race break
     350        if ( !queue`first.clause_status || queue`first.park_counter || __pending_set_other( queue`first, mine, ((unsigned long int)(&(queue`first))) ) )
     351            return true;
     352       
     353        // our node lost the race when toggling in __pending_set_other
     354        if ( *mine.clause_status != __SELECT_PENDING )
     355            return false;
     356
     357        // otherwise we lost the special OR race so discard node
     358        try_pop_front( queue );
     359    }
     360    return false;
     361}
     362
    343363// type used by select statement to capture a chan read as the selected operation
    344364struct chan_read {
     
    374394                return false;
    375395            }
    376            
    377             if ( __handle_waituntil_OR( prods ) ) {
     396
     397            if ( __handle_pending( prods, node ) ) {
    378398                __prods_handoff( chan, ret );
    379399                __make_select_node_sat( node ); // need to to mark SAT now that we know operation is done or else threads could get stuck in __mark_select_node
     
    381401                return true;
    382402            }
    383             __make_select_node_unsat( node );
     403            if ( *node.clause_status == __SELECT_PENDING )
     404                __make_select_node_unsat( node );
    384405        }
    385406        // check if we can complete operation. If so race to establish winner in special OR case
     
    423444}
    424445static inline bool unregister_select( chan_read(T) & this, select_node & node ) { return unregister_chan( this.chan, node ); }
    425 static inline bool on_selected( chan_read(T) & this, select_node & node ) with(this) {
     446static inline void on_selected( chan_read(T) & this, select_node & node ) with(this) {
    426447    if ( node.extra == 0p ) // check if woken up due to closed channel
    427448        __closed_remove( chan, ret );
    428449    // This is only reachable if not closed or closed exception was handled
    429     return true;
    430450}
    431451
     
    464484                return false;
    465485            }
    466            
    467             if ( __handle_waituntil_OR( cons ) ) {
     486
     487            if ( __handle_pending( cons, node ) ) {
    468488                __cons_handoff( chan, elem );
    469489                __make_select_node_sat( node ); // need to to mark SAT now that we know operation is done or else threads could get stuck in __mark_select_node
     
    471491                return true;
    472492            }
    473             __make_select_node_unsat( node );
     493            if ( *node.clause_status == __SELECT_PENDING )
     494                __make_select_node_unsat( node );
    474495        }
    475496        // check if we can complete operation. If so race to establish winner in special OR case
     
    515536static inline bool unregister_select( chan_write(T) & this, select_node & node ) { return unregister_chan( this.chan, node ); }
    516537
    517 static inline bool on_selected( chan_write(T) & this, select_node & node ) with(this) {
     538static inline void on_selected( chan_write(T) & this, select_node & node ) with(this) {
    518539    if ( node.extra == 0p ) // check if woken up due to closed channel
    519540        __closed_insert( chan, elem );
    520541
    521542    // This is only reachable if not closed or closed exception was handled
    522     return true;
    523543}
    524544
  • libcfa/src/concurrency/future.hfa

    r2b78949 r8a930c03  
    7070                // check if the future is available
    7171        // currently no mutual exclusion because I can't see when you need this call to be synchronous or protected
    72                 bool available( future(T) & this ) { return this.state; }
     72                bool available( future(T) & this ) { return __atomic_load_n( &this.state, __ATOMIC_RELAXED ); }
    7373
    7474
     
    180180        }
    181181               
    182         bool on_selected( future(T) & this, select_node & node ) { return true; }
     182        void on_selected( future(T) & this, select_node & node ) {}
    183183        }
    184184}
    185185
    186186//--------------------------------------------------------------------------------------------------------
    187 // These futures below do not support select statements so they may not be as useful as 'future'
     187// These futures below do not support select statements so they may not have as many features as 'future'
    188188//  however the 'single_future' is cheap and cheerful and is most likely more performant than 'future'
    189189//  since it uses raw atomics and no locks
  • libcfa/src/concurrency/locks.cfa

    r2b78949 r8a930c03  
    239239}
    240240
    241 bool on_selected( blocking_lock & this, select_node & node ) { return true; }
     241void on_selected( blocking_lock & this, select_node & node ) {}
    242242
    243243//-----------------------------------------------------------------------------
  • libcfa/src/concurrency/locks.hfa

    r2b78949 r8a930c03  
    3232#include "select.hfa"
    3333
    34 #include <fstream.hfa>
    35 
    3634// futex headers
    3735#include <linux/futex.h>      /* Definition of FUTEX_* constants */
     
    114112static inline bool   register_select( single_acquisition_lock & this, select_node & node ) { return register_select( (blocking_lock &)this, node ); }
    115113static inline bool   unregister_select( single_acquisition_lock & this, select_node & node ) { return unregister_select( (blocking_lock &)this, node ); }
    116 static inline bool   on_selected( single_acquisition_lock & this, select_node & node ) { return on_selected( (blocking_lock &)this, node ); }
     114static inline void   on_selected( single_acquisition_lock & this, select_node & node ) { on_selected( (blocking_lock &)this, node ); }
    117115
    118116//----------
     
    131129static inline bool   register_select( owner_lock & this, select_node & node ) { return register_select( (blocking_lock &)this, node ); }
    132130static inline bool   unregister_select( owner_lock & this, select_node & node ) { return unregister_select( (blocking_lock &)this, node ); }
    133 static inline bool   on_selected( owner_lock & this, select_node & node ) { return on_selected( (blocking_lock &)this, node ); }
     131static inline void   on_selected( owner_lock & this, select_node & node ) { on_selected( (blocking_lock &)this, node ); }
    134132
    135133//-----------------------------------------------------------------------------
     
    621619}
    622620
    623 static inline bool on_selected( simple_owner_lock & this, select_node & node ) { return true; }
     621static inline void on_selected( simple_owner_lock & this, select_node & node ) {}
    624622
    625623
  • libcfa/src/concurrency/select.cfa

    r2b78949 r8a930c03  
    4949    return false;
    5050}
    51 bool on_selected( select_timeout_node & this, select_node & node ) { return true; }
     51void on_selected( select_timeout_node & this, select_node & node ) {}
    5252
    5353// Gateway routine to wait on duration
  • libcfa/src/concurrency/select.hfa

    r2b78949 r8a930c03  
    9191    // For unregistering a select stmt on a selectable concurrency primitive
    9292    // If true is returned then the corresponding code block is run (only in non-special OR case and only if node status is not RUN)
    93     bool unregister_select( T &, select_node &  );
     93    bool unregister_select( T &, select_node & );
    9494
    9595    // This routine is run on the selecting thread prior to executing the statement corresponding to the select_node
    9696    //    passed as an arg to this routine
    9797    // If on_selected returns false, the statement is not run, if it returns true it is run.
    98     bool on_selected( T &, select_node & );
     98    void on_selected( T &, select_node & );
    9999};
    100100
     
    102102// Waituntil Helpers
    103103//=============================================================================================
     104
     105static inline void __make_select_node_unsat( select_node & this ) with( this ) {
     106    __atomic_store_n( clause_status, __SELECT_UNSAT, __ATOMIC_SEQ_CST );
     107}
     108static inline void __make_select_node_sat( select_node & this ) with( this ) {
     109    __atomic_store_n( clause_status, __SELECT_SAT, __ATOMIC_SEQ_CST );
     110}
    104111
    105112// used for the 2-stage avail needed by the special OR case
     
    116123}
    117124
    118 static inline void __make_select_node_unsat( select_node & this ) with( this ) {
    119     __atomic_store_n( clause_status, __SELECT_UNSAT, __ATOMIC_SEQ_CST );
    120 }
    121 static inline void __make_select_node_sat( select_node & this ) with( this ) {
    122     __atomic_store_n( clause_status, __SELECT_SAT, __ATOMIC_SEQ_CST );
     125// used for the 2-stage avail by the thread who owns a pending node
     126static inline bool __pending_set_other( select_node & other, select_node & mine, unsigned long int val ) with( other ) {
     127    /* paranoid */ verify( park_counter == 0p );
     128    /* paranoid */ verify( clause_status != 0p );
     129
     130    unsigned long int cmp_status = __SELECT_UNSAT;
     131    while( !__atomic_compare_exchange_n( clause_status, &cmp_status, val, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST ) ) {
     132        if ( cmp_status != __SELECT_PENDING )
     133            return false;
     134
     135        // toggle current status flag to avoid starvation/deadlock
     136        __make_select_node_unsat( mine );
     137        cmp_status = __SELECT_UNSAT;
     138        if ( !__atomic_compare_exchange_n( mine.clause_status, &cmp_status, __SELECT_PENDING, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST ) )
     139            return false;
     140        cmp_status = __SELECT_UNSAT;
     141    }
     142    return true;
    123143}
    124144
     
    188208bool register_select( select_timeout_node & this, select_node & node );
    189209bool unregister_select( select_timeout_node & this, select_node & node );
    190 bool on_selected( select_timeout_node & this, select_node & node );
     210void on_selected( select_timeout_node & this, select_node & node );
    191211
    192212// Gateway routines to waituntil on duration
  • libcfa/src/containers/lockfree.hfa

    r2b78949 r8a930c03  
    199199
    200200forall( T & )
     201struct LinkData {
     202        T * volatile top;                                                               // pointer to stack top
     203        uintptr_t count;                                                                // count each push
     204};
     205
     206forall( T & )
    201207union Link {
    202         struct {                                                                                        // 32/64-bit x 2
    203                 T * volatile top;                                                               // pointer to stack top
    204                 uintptr_t count;                                                                // count each push
    205         };
     208        LinkData(T) data;
    206209        #if __SIZEOF_INT128__ == 16
    207210        __int128                                                                                        // gcc, 128-bit integer
     
    220223                void ?{}( StackLF(T) & this ) with(this) { stack.atom = 0; }
    221224
    222                 T * top( StackLF(T) & this ) with(this) { return stack.top; }
     225                T * top( StackLF(T) & this ) with(this) { return stack.data.top; }
    223226
    224227                void push( StackLF(T) & this, T & n ) with(this) {
    225228                        *( &n )`next = stack;                                           // atomic assignment unnecessary, or use CAA
    226229                        for () {                                                                        // busy wait
    227                           if ( __atomic_compare_exchange_n( &stack.atom, &( &n )`next->atom, (Link(T))@{ {&n, ( &n )`next->count + 1} }.atom, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST ) ) break; // attempt to update top node
     230                                if ( __atomic_compare_exchange_n( &stack.atom, &( &n )`next->atom, (Link(T))@{ (LinkData(T))@{ &n, ( &n )`next->data.count + 1} }.atom, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST ) ) break; // attempt to update top node
    228231                        } // for
    229232                } // push
     
    232235                        Link(T) t @= stack;                                                     // atomic assignment unnecessary, or use CAA
    233236                        for () {                                                                        // busy wait
    234                           if ( t.top == 0p ) return 0p;                         // empty stack ?
    235                           if ( __atomic_compare_exchange_n( &stack.atom, &t.atom, (Link(T))@{ {( t.top )`next->top, t.count} }.atom, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST ) ) return t.top; // attempt to update top node
     237                                if ( t.data.top == 0p ) return 0p;                              // empty stack ?
     238                                Link(T) * next = ( t.data.top )`next;
     239                                if ( __atomic_compare_exchange_n( &stack.atom, &t.atom, (Link(T))@{ (LinkData(T))@{ next->data.top, t.data.count } }.atom, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST ) ) return t.data.top; // attempt to update top node
    236240                        } // for
    237241                } // pop
     
    239243                bool unsafe_remove( StackLF(T) & this, T * node ) with(this) {
    240244                        Link(T) * link = &stack;
    241                         for() {
    242                                 T * next = link->top;
    243                                 if( next == node ) {
    244                                         link->top = ( node )`next->top;
     245                        for () {
     246                                // TODO: Avoiding some problems with double fields access.
     247                                LinkData(T) * data = &link->data;
     248                                T * next = (T *)&(*data).top;
     249                                if ( next == node ) {
     250                                        data->top = ( node )`next->data.top;
    245251                                        return true;
    246252                                }
    247                                 if( next == 0p ) return false;
     253                                if ( next == 0p ) return false;
    248254                                link = ( next )`next;
    249255                        }
  • libcfa/src/fstream.cfa

    r2b78949 r8a930c03  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Apr  9 14:55:54 2022
    13 // Update Count     : 515
     12// Last Modified On : Mon Jun  5 22:00:23 2023
     13// Update Count     : 518
    1414//
    1515
     
    117117    } // for
    118118        if ( file == 0p ) {
    119                 throw (Open_Failure){ os };
     119                throw (open_failure){ os };
    120120                // abort | IO_MSG "open output file \"" | name | "\"" | nl | strerror( errno );
    121121        } // if
     
    137137    } // for
    138138        if ( ret == EOF ) {
    139                 throw (Close_Failure){ os };
     139                throw (close_failure){ os };
    140140                // abort | IO_MSG "close output" | nl | strerror( errno );
    141141        } // if
     
    145145ofstream & write( ofstream & os, const char data[], size_t size ) {
    146146        if ( fail( os ) ) {
    147                 throw (Write_Failure){ os };
     147                throw (write_failure){ os };
    148148                // abort | IO_MSG "attempt write I/O on failed stream";
    149149        } // if
    150150
    151151        if ( fwrite( data, 1, size, (FILE *)(os.file$) ) != size ) {
    152                 throw (Write_Failure){ os };
     152                throw (write_failure){ os };
    153153                // abort | IO_MSG "write" | nl | strerror( errno );
    154154        } // if
     
    240240    } // for
    241241        if ( file == 0p ) {
    242                 throw (Open_Failure){ is };
     242                throw (open_failure){ is };
    243243                // abort | IO_MSG "open input file \"" | name | "\"" | nl | strerror( errno );
    244244        } // if
     
    260260    } // for
    261261        if ( ret == EOF ) {
    262                 throw (Close_Failure){ is };
     262                throw (close_failure){ is };
    263263                // abort | IO_MSG "close input" | nl | strerror( errno );
    264264        } // if
     
    268268ifstream & read( ifstream & is, char data[], size_t size ) {
    269269        if ( fail( is ) ) {
    270                 throw (Read_Failure){ is };
     270                throw (read_failure){ is };
    271271                // abort | IO_MSG "attempt read I/O on failed stream";
    272272        } // if
    273273
    274274        if ( fread( data, size, 1, (FILE *)(is.file$) ) == 0 ) {
    275                 throw (Read_Failure){ is };
     275                throw (read_failure){ is };
    276276                // abort | IO_MSG "read" | nl | strerror( errno );
    277277        } // if
     
    318318
    319319
    320 static vtable(Open_Failure) Open_Failure_vt;
     320static vtable(open_failure) open_failure_vt;
    321321
    322322// exception I/O constructors
    323 void ?{}( Open_Failure & ex, ofstream & ostream ) with(ex) {
    324         virtual_table = &Open_Failure_vt;
     323void ?{}( open_failure & ex, ofstream & ostream ) with(ex) {
     324        virtual_table = &open_failure_vt;
    325325        ostream = &ostream;
    326326        tag = 1;
    327327} // ?{}
    328328
    329 void ?{}( Open_Failure & ex, ifstream & istream ) with(ex) {
    330         virtual_table = &Open_Failure_vt;
     329void ?{}( open_failure & ex, ifstream & istream ) with(ex) {
     330        virtual_table = &open_failure_vt;
    331331        istream = &istream;
    332332        tag = 0;
     
    334334
    335335
    336 static vtable(Close_Failure) Close_Failure_vt;
     336static vtable(close_failure) close_failure_vt;
    337337
    338338// exception I/O constructors
    339 void ?{}( Close_Failure & ex, ofstream & ostream ) with(ex) {
    340         virtual_table = &Close_Failure_vt;
     339void ?{}( close_failure & ex, ofstream & ostream ) with(ex) {
     340        virtual_table = &close_failure_vt;
    341341        ostream = &ostream;
    342342        tag = 1;
    343343} // ?{}
    344344
    345 void ?{}( Close_Failure & ex, ifstream & istream ) with(ex) {
    346         virtual_table = &Close_Failure_vt;
     345void ?{}( close_failure & ex, ifstream & istream ) with(ex) {
     346        virtual_table = &close_failure_vt;
    347347        istream = &istream;
    348348        tag = 0;
     
    350350
    351351
    352 static vtable(Write_Failure) Write_Failure_vt;
     352static vtable(write_failure) write_failure_vt;
    353353
    354354// exception I/O constructors
    355 void ?{}( Write_Failure & ex, ofstream & ostream ) with(ex) {
    356         virtual_table = &Write_Failure_vt;
     355void ?{}( write_failure & ex, ofstream & ostream ) with(ex) {
     356        virtual_table = &write_failure_vt;
    357357        ostream = &ostream;
    358358        tag = 1;
    359359} // ?{}
    360360
    361 void ?{}( Write_Failure & ex, ifstream & istream ) with(ex) {
    362         virtual_table = &Write_Failure_vt;
     361void ?{}( write_failure & ex, ifstream & istream ) with(ex) {
     362        virtual_table = &write_failure_vt;
    363363        istream = &istream;
    364364        tag = 0;
     
    366366
    367367
    368 static vtable(Read_Failure) Read_Failure_vt;
     368static vtable(read_failure) read_failure_vt;
    369369
    370370// exception I/O constructors
    371 void ?{}( Read_Failure & ex, ofstream & ostream ) with(ex) {
    372         virtual_table = &Read_Failure_vt;
     371void ?{}( read_failure & ex, ofstream & ostream ) with(ex) {
     372        virtual_table = &read_failure_vt;
    373373        ostream = &ostream;
    374374        tag = 1;
    375375} // ?{}
    376376
    377 void ?{}( Read_Failure & ex, ifstream & istream ) with(ex) {
    378         virtual_table = &Read_Failure_vt;
     377void ?{}( read_failure & ex, ifstream & istream ) with(ex) {
     378        virtual_table = &read_failure_vt;
    379379        istream = &istream;
    380380        tag = 0;
    381381} // ?{}
    382382
    383 // void throwOpen_Failure( ofstream & ostream ) {
    384 //      Open_Failure exc = { ostream };
     383// void throwopen_failure( ofstream & ostream ) {
     384//      open_failure exc = { ostream };
    385385// }
    386386
    387 // void throwOpen_Failure( ifstream & istream ) {
    388 //      Open_Failure exc = { istream };
     387// void throwopen_failure( ifstream & istream ) {
     388//      open_failure exc = { istream };
    389389// }
    390390
  • libcfa/src/fstream.hfa

    r2b78949 r8a930c03  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Oct 10 09:37:32 2021
    13 // Update Count     : 243
     12// Last Modified On : Mon Jun  5 22:00:20 2023
     13// Update Count     : 246
    1414//
    1515
     
    137137
    138138
    139 exception Open_Failure {
     139exception open_failure {
    140140        union {
    141141                ofstream * ostream;
     
    146146};
    147147
    148 void ?{}( Open_Failure & this, ofstream & );
    149 void ?{}( Open_Failure & this, ifstream & );
     148void ?{}( open_failure & this, ofstream & );
     149void ?{}( open_failure & this, ifstream & );
    150150
    151 exception Close_Failure {
     151exception close_failure {
    152152        union {
    153153                ofstream * ostream;
     
    158158};
    159159
    160 void ?{}( Close_Failure & this, ofstream & );
    161 void ?{}( Close_Failure & this, ifstream & );
     160void ?{}( close_failure & this, ofstream & );
     161void ?{}( close_failure & this, ifstream & );
    162162
    163 exception Write_Failure {
     163exception write_failure {
    164164        union {
    165165                ofstream * ostream;
     
    170170};
    171171
    172 void ?{}( Write_Failure & this, ofstream & );
    173 void ?{}( Write_Failure & this, ifstream & );
     172void ?{}( write_failure & this, ofstream & );
     173void ?{}( write_failure & this, ifstream & );
    174174
    175 exception Read_Failure {
     175exception read_failure {
    176176        union {
    177177                ofstream * ostream;
     
    182182};
    183183
    184 void ?{}( Read_Failure & this, ofstream & );
    185 void ?{}( Read_Failure & this, ifstream & );
     184void ?{}( read_failure & this, ofstream & );
     185void ?{}( read_failure & this, ifstream & );
    186186
    187187// Local Variables: //
  • libcfa/src/math.trait.hfa

    r2b78949 r8a930c03  
    1010// Created On       : Fri Jul 16 15:40:52 2021
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Feb  2 11:36:56 2023
    13 // Update Count     : 20
     12// Last Modified On : Tue Jun  6 07:59:17 2023
     13// Update Count     : 24
    1414//
    1515
     
    1717
    1818forall( U )
    19 trait Not {
     19trait not {
    2020        void ?{}( U &, zero_t );
    2121        int !?( U );
    22 }; // Not
     22}; // not
    2323
    24 forall( T | Not( T ) )
    25 trait Equality {
     24forall( T | not( T ) )
     25trait equality {
    2626        int ?==?( T, T );
    2727        int ?!=?( T, T );
    28 }; // Equality
     28}; // equality
    2929
    30 forall( U | Equality( U ) )
    31 trait Relational {
     30forall( U | equality( U ) )
     31trait relational {
    3232        int ?<?( U, U );
    3333        int ?<=?( U, U );
    3434        int ?>?( U, U );
    3535        int ?>=?( U, U );
    36 }; // Relational
     36}; // relational
    3737
    3838forall ( T )
    39 trait Signed {
     39trait Signed {  // must be capitalized, conflict with keyword signed
    4040        T +?( T );
    4141        T -?( T );
     
    4444
    4545forall( U | Signed( U ) )
    46 trait Additive {
     46trait additive {
    4747        U ?+?( U, U );
    4848        U ?-?( U, U );
    4949        U ?+=?( U &, U );
    5050        U ?-=?( U &, U );
    51 }; // Additive
     51}; // additive
    5252
    53 forall( T | Additive( T ) )
    54 trait Incdec {
     53forall( T | additive( T ) )
     54trait inc_dec {
    5555        void ?{}( T &, one_t );
    5656        // T ?++( T & );
     
    5858        // T ?--( T & );
    5959        // T --?( T & );
    60 }; // Incdec
     60}; // inc_dec
    6161
    62 forall( U | Incdec( U ) )
    63 trait Multiplicative {
     62forall( U | inc_dec( U ) )
     63trait multiplicative {
    6464        U ?*?( U, U );
    6565        U ?/?( U, U );
    6666        U ?%?( U, U );
    6767        U ?/=?( U &, U );
    68 }; // Multiplicative
     68}; // multiplicative
    6969
    70 forall( T | Relational( T ) | Multiplicative( T ) )
    71 trait Arithmetic {
    72 }; // Arithmetic
     70forall( T | relational( T ) | multiplicative( T ) )
     71trait arithmetic {
     72}; // arithmetic
    7373
    7474// Local Variables: //
  • libcfa/src/parseconfig.cfa

    r2b78949 r8a930c03  
    144144                        in | nl;                                                                // ignore remainder of line
    145145                } // for
    146         } catch( Open_Failure * ex; ex->istream == &in ) {
     146        } catch( open_failure * ex; ex->istream == &in ) {
    147147                delete( kv_pairs );
    148148                throw *ex;
     
    203203
    204204
    205 forall(T | Relational( T ))
     205forall(T | relational( T ))
    206206[ bool ] is_nonnegative( & T value ) {
    207207        T zero_val = 0;
     
    209209}
    210210
    211 forall(T | Relational( T ))
     211forall(T | relational( T ))
    212212[ bool ] is_positive( & T value ) {
    213213        T zero_val = 0;
     
    215215}
    216216
    217 forall(T | Relational( T ))
     217forall(T | relational( T ))
    218218[ bool ] is_nonpositive( & T value ) {
    219219        T zero_val = 0;
     
    221221}
    222222
    223 forall(T | Relational( T ))
     223forall(T | relational( T ))
    224224[ bool ] is_negative( & T value ) {
    225225        T zero_val = 0;
  • libcfa/src/parseconfig.hfa

    r2b78949 r8a930c03  
    107107
    108108
    109 forall(T | Relational( T ))
     109forall(T | relational( T ))
    110110[ bool ] is_nonnegative( & T );
    111111
    112 forall(T | Relational( T ))
     112forall(T | relational( T ))
    113113[ bool ] is_positive( & T );
    114114
    115 forall(T | Relational( T ))
     115forall(T | relational( T ))
    116116[ bool ] is_nonpositive( & T );
    117117
    118 forall(T | Relational( T ))
     118forall(T | relational( T ))
    119119[ bool ] is_negative( & T );
    120120
  • libcfa/src/rational.cfa

    r2b78949 r8a930c03  
    1010// Created On       : Wed Apr  6 17:54:28 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Aug 25 18:09:58 2022
    13 // Update Count     : 194
     12// Last Modified On : Mon Jun  5 22:49:06 2023
     13// Update Count     : 196
    1414//
    1515
     
    2020#pragma GCC visibility push(default)
    2121
    22 forall( T | Arithmetic( T ) ) {
     22forall( T | arithmetic( T ) ) {
    2323        // helper routines
    2424
     
    3939                        abort | "Invalid rational number construction: denominator cannot be equal to 0.";
    4040                } // exit
    41                 if ( d < (T){0} ) { d = -d; n = -n; } // move sign to numerator
     41                if ( d < (T){0} ) { d = -d; n = -n; }                   // move sign to numerator
    4242                return gcd( abs( n ), d );                                              // simplify
    43         } // Rationalnumber::simplify
     43        } // simplify
    4444
    4545        // constructors
    4646
    47         void ?{}( Rational(T) & r, zero_t ) {
     47        void ?{}( rational(T) & r, zero_t ) {
    4848                r{ (T){0}, (T){1} };
    4949        } // rational
    5050
    51         void ?{}( Rational(T) & r, one_t ) {
     51        void ?{}( rational(T) & r, one_t ) {
    5252                r{ (T){1}, (T){1} };
    5353        } // rational
    5454
    55         void ?{}( Rational(T) & r ) {
     55        void ?{}( rational(T) & r ) {
    5656                r{ (T){0}, (T){1} };
    5757        } // rational
    5858
    59         void ?{}( Rational(T) & r, T n ) {
     59        void ?{}( rational(T) & r, T n ) {
    6060                r{ n, (T){1} };
    6161        } // rational
    6262
    63         void ?{}( Rational(T) & r, T n, T d ) {
    64                 T t = simplify( n, d );                         // simplify
     63        void ?{}( rational(T) & r, T n, T d ) {
     64                T t = simplify( n, d );                                                 // simplify
    6565                r.[numerator, denominator] = [n / t, d / t];
    6666        } // rational
     
    6868        // getter for numerator/denominator
    6969
    70         T numerator( Rational(T) r ) {
     70        T numerator( rational(T) r ) {
    7171                return r.numerator;
    7272        } // numerator
    7373
    74         T denominator( Rational(T) r ) {
     74        T denominator( rational(T) r ) {
    7575                return r.denominator;
    7676        } // denominator
    7777
    78         [ T, T ] ?=?( & [ T, T ] dest, Rational(T) src ) {
     78        [ T, T ] ?=?( & [ T, T ] dest, rational(T) src ) {
    7979                return dest = src.[ numerator, denominator ];
    8080        } // ?=?
     
    8282        // setter for numerator/denominator
    8383
    84         T numerator( Rational(T) r, T n ) {
     84        T numerator( rational(T) r, T n ) {
    8585                T prev = r.numerator;
    86                 T t = gcd( abs( n ), r.denominator ); // simplify
     86                T t = gcd( abs( n ), r.denominator );                   // simplify
    8787                r.[numerator, denominator] = [n / t, r.denominator / t];
    8888                return prev;
    8989        } // numerator
    9090
    91         T denominator( Rational(T) r, T d ) {
     91        T denominator( rational(T) r, T d ) {
    9292                T prev = r.denominator;
    93                 T t = simplify( r.numerator, d );       // simplify
     93                T t = simplify( r.numerator, d );                               // simplify
    9494                r.[numerator, denominator] = [r.numerator / t, d / t];
    9595                return prev;
     
    9898        // comparison
    9999
    100         int ?==?( Rational(T) l, Rational(T) r ) {
     100        int ?==?( rational(T) l, rational(T) r ) {
    101101                return l.numerator * r.denominator == l.denominator * r.numerator;
    102102        } // ?==?
    103103
    104         int ?!=?( Rational(T) l, Rational(T) r ) {
     104        int ?!=?( rational(T) l, rational(T) r ) {
    105105                return ! ( l == r );
    106106        } // ?!=?
    107107
    108         int ?!=?( Rational(T) l, zero_t ) {
    109                 return ! ( l == (Rational(T)){ 0 } );
     108        int ?!=?( rational(T) l, zero_t ) {
     109                return ! ( l == (rational(T)){ 0 } );
    110110        } // ?!=?
    111111
    112         int ?<?( Rational(T) l, Rational(T) r ) {
     112        int ?<?( rational(T) l, rational(T) r ) {
    113113                return l.numerator * r.denominator < l.denominator * r.numerator;
    114114        } // ?<?
    115115
    116         int ?<=?( Rational(T) l, Rational(T) r ) {
     116        int ?<=?( rational(T) l, rational(T) r ) {
    117117                return l.numerator * r.denominator <= l.denominator * r.numerator;
    118118        } // ?<=?
    119119
    120         int ?>?( Rational(T) l, Rational(T) r ) {
     120        int ?>?( rational(T) l, rational(T) r ) {
    121121                return ! ( l <= r );
    122122        } // ?>?
    123123
    124         int ?>=?( Rational(T) l, Rational(T) r ) {
     124        int ?>=?( rational(T) l, rational(T) r ) {
    125125                return ! ( l < r );
    126126        } // ?>=?
     
    128128        // arithmetic
    129129
    130         Rational(T) +?( Rational(T) r ) {
    131                 return (Rational(T)){ r.numerator, r.denominator };
     130        rational(T) +?( rational(T) r ) {
     131                return (rational(T)){ r.numerator, r.denominator };
    132132        } // +?
    133133
    134         Rational(T) -?( Rational(T) r ) {
    135                 return (Rational(T)){ -r.numerator, r.denominator };
     134        rational(T) -?( rational(T) r ) {
     135                return (rational(T)){ -r.numerator, r.denominator };
    136136        } // -?
    137137
    138         Rational(T) ?+?( Rational(T) l, Rational(T) r ) {
     138        rational(T) ?+?( rational(T) l, rational(T) r ) {
    139139                if ( l.denominator == r.denominator ) {                 // special case
    140                         return (Rational(T)){ l.numerator + r.numerator, l.denominator };
     140                        return (rational(T)){ l.numerator + r.numerator, l.denominator };
    141141                } else {
    142                         return (Rational(T)){ l.numerator * r.denominator + l.denominator * r.numerator, l.denominator * r.denominator };
     142                        return (rational(T)){ l.numerator * r.denominator + l.denominator * r.numerator, l.denominator * r.denominator };
    143143                } // if
    144144        } // ?+?
    145145
    146         Rational(T) ?+=?( Rational(T) & l, Rational(T) r ) {
     146        rational(T) ?+=?( rational(T) & l, rational(T) r ) {
    147147                l = l + r;
    148148                return l;
    149149        } // ?+?
    150150
    151         Rational(T) ?+=?( Rational(T) & l, one_t ) {
    152                 l = l + (Rational(T)){ 1 };
     151        rational(T) ?+=?( rational(T) & l, one_t ) {
     152                l = l + (rational(T)){ 1 };
    153153                return l;
    154154        } // ?+?
    155155
    156         Rational(T) ?-?( Rational(T) l, Rational(T) r ) {
     156        rational(T) ?-?( rational(T) l, rational(T) r ) {
    157157                if ( l.denominator == r.denominator ) {                 // special case
    158                         return (Rational(T)){ l.numerator - r.numerator, l.denominator };
     158                        return (rational(T)){ l.numerator - r.numerator, l.denominator };
    159159                } else {
    160                         return (Rational(T)){ l.numerator * r.denominator - l.denominator * r.numerator, l.denominator * r.denominator };
     160                        return (rational(T)){ l.numerator * r.denominator - l.denominator * r.numerator, l.denominator * r.denominator };
    161161                } // if
    162162        } // ?-?
    163163
    164         Rational(T) ?-=?( Rational(T) & l, Rational(T) r ) {
     164        rational(T) ?-=?( rational(T) & l, rational(T) r ) {
    165165                l = l - r;
    166166                return l;
    167167        } // ?-?
    168168
    169         Rational(T) ?-=?( Rational(T) & l, one_t ) {
    170                 l = l - (Rational(T)){ 1 };
     169        rational(T) ?-=?( rational(T) & l, one_t ) {
     170                l = l - (rational(T)){ 1 };
    171171                return l;
    172172        } // ?-?
    173173
    174         Rational(T) ?*?( Rational(T) l, Rational(T) r ) {
    175                 return (Rational(T)){ l.numerator * r.numerator, l.denominator * r.denominator };
     174        rational(T) ?*?( rational(T) l, rational(T) r ) {
     175                return (rational(T)){ l.numerator * r.numerator, l.denominator * r.denominator };
    176176        } // ?*?
    177177
    178         Rational(T) ?*=?( Rational(T) & l, Rational(T) r ) {
     178        rational(T) ?*=?( rational(T) & l, rational(T) r ) {
    179179                return l = l * r;
    180180        } // ?*?
    181181
    182         Rational(T) ?/?( Rational(T) l, Rational(T) r ) {
     182        rational(T) ?/?( rational(T) l, rational(T) r ) {
    183183                if ( r.numerator < (T){0} ) {
    184184                        r.[numerator, denominator] = [-r.numerator, -r.denominator];
    185185                } // if
    186                 return (Rational(T)){ l.numerator * r.denominator, l.denominator * r.numerator };
     186                return (rational(T)){ l.numerator * r.denominator, l.denominator * r.numerator };
    187187        } // ?/?
    188188
    189         Rational(T) ?/=?( Rational(T) & l, Rational(T) r ) {
     189        rational(T) ?/=?( rational(T) & l, rational(T) r ) {
    190190                return l = l / r;
    191191        } // ?/?
     
    194194
    195195        forall( istype & | istream( istype ) | { istype & ?|?( istype &, T & ); } )
    196         istype & ?|?( istype & is, Rational(T) & r ) {
     196        istype & ?|?( istype & is, rational(T) & r ) {
    197197                is | r.numerator | r.denominator;
    198198                T t = simplify( r.numerator, r.denominator );
     
    203203
    204204        forall( ostype & | ostream( ostype ) | { ostype & ?|?( ostype &, T ); } ) {
    205                 ostype & ?|?( ostype & os, Rational(T) r ) {
     205                ostype & ?|?( ostype & os, rational(T) r ) {
    206206                        return os | r.numerator | '/' | r.denominator;
    207207                } // ?|?
    208208
    209                 void ?|?( ostype & os, Rational(T) r ) {
     209                void ?|?( ostype & os, rational(T) r ) {
    210210                        (ostype &)(os | r); ends( os );
    211211                } // ?|?
     
    213213} // distribution
    214214
    215 forall( T | Arithmetic( T ) | { T ?\?( T, unsigned long ); } ) {
    216         Rational(T) ?\?( Rational(T) x, long int y ) {
     215forall( T | arithmetic( T ) | { T ?\?( T, unsigned long ); } ) {
     216        rational(T) ?\?( rational(T) x, long int y ) {
    217217                if ( y < 0 ) {
    218                         return (Rational(T)){ x.denominator \ -y, x.numerator \ -y };
     218                        return (rational(T)){ x.denominator \ -y, x.numerator \ -y };
    219219                } else {
    220                         return (Rational(T)){ x.numerator \ y, x.denominator \ y };
     220                        return (rational(T)){ x.numerator \ y, x.denominator \ y };
    221221                } // if
    222222        } // ?\?
    223223
    224         Rational(T) ?\=?( Rational(T) & x, long int y ) {
     224        rational(T) ?\=?( rational(T) & x, long int y ) {
    225225                return x = x \ y;
    226226        } // ?\?
     
    229229// conversion
    230230
    231 forall( T | Arithmetic( T ) | { double convert( T ); } )
    232 double widen( Rational(T) r ) {
     231forall( T | arithmetic( T ) | { double convert( T ); } )
     232double widen( rational(T) r ) {
    233233        return convert( r.numerator ) / convert( r.denominator );
    234234} // widen
    235235
    236 forall( T | Arithmetic( T ) | { double convert( T ); T convert( double ); } )
    237 Rational(T) narrow( double f, T md ) {
     236forall( T | arithmetic( T ) | { double convert( T ); T convert( double ); } )
     237rational(T) narrow( double f, T md ) {
    238238        // http://www.ics.uci.edu/~eppstein/numth/frap.c
    239         if ( md <= (T){1} ) {                                   // maximum fractional digits too small?
    240                 return (Rational(T)){ convert( f ), (T){1}}; // truncate fraction
     239        if ( md <= (T){1} ) {                                                           // maximum fractional digits too small?
     240                return (rational(T)){ convert( f ), (T){1}};    // truncate fraction
    241241        } // if
    242242
     
    260260          if ( f > (double)0x7FFFFFFF ) break;                          // representation failure
    261261        } // for
    262         return (Rational(T)){ m00, m10 };
     262        return (rational(T)){ m00, m10 };
    263263} // narrow
    264264
  • libcfa/src/rational.hfa

    r2b78949 r8a930c03  
    1212// Created On       : Wed Apr  6 17:56:25 2016
    1313// Last Modified By : Peter A. Buhr
    14 // Last Modified On : Tue Jul 20 17:45:29 2021
    15 // Update Count     : 118
     14// Last Modified On : Mon Jun  5 22:49:05 2023
     15// Update Count     : 119
    1616//
    1717
     
    1919
    2020#include "iostream.hfa"
    21 #include "math.trait.hfa"                                                               // Arithmetic
     21#include "math.trait.hfa"                                                               // arithmetic
    2222
    2323// implementation
    2424
    25 forall( T | Arithmetic( T ) ) {
    26         struct Rational {
     25forall( T | arithmetic( T ) ) {
     26        struct rational {
    2727                T numerator, denominator;                                               // invariant: denominator > 0
    28         }; // Rational
     28        }; // rational
    2929
    3030        // constructors
    3131
    32         void ?{}( Rational(T) & r );
    33         void ?{}( Rational(T) & r, zero_t );
    34         void ?{}( Rational(T) & r, one_t );
    35         void ?{}( Rational(T) & r, T n );
    36         void ?{}( Rational(T) & r, T n, T d );
     32        void ?{}( rational(T) & r );
     33        void ?{}( rational(T) & r, zero_t );
     34        void ?{}( rational(T) & r, one_t );
     35        void ?{}( rational(T) & r, T n );
     36        void ?{}( rational(T) & r, T n, T d );
    3737
    3838        // numerator/denominator getter
    3939
    40         T numerator( Rational(T) r );
    41         T denominator( Rational(T) r );
    42         [ T, T ] ?=?( & [ T, T ] dest, Rational(T) src );
     40        T numerator( rational(T) r );
     41        T denominator( rational(T) r );
     42        [ T, T ] ?=?( & [ T, T ] dest, rational(T) src );
    4343
    4444        // numerator/denominator setter
    4545
    46         T numerator( Rational(T) r, T n );
    47         T denominator( Rational(T) r, T d );
     46        T numerator( rational(T) r, T n );
     47        T denominator( rational(T) r, T d );
    4848
    4949        // comparison
    5050
    51         int ?==?( Rational(T) l, Rational(T) r );
    52         int ?!=?( Rational(T) l, Rational(T) r );
    53         int ?!=?( Rational(T) l, zero_t );                                      // => !
    54         int ?<?( Rational(T) l, Rational(T) r );
    55         int ?<=?( Rational(T) l, Rational(T) r );
    56         int ?>?( Rational(T) l, Rational(T) r );
    57         int ?>=?( Rational(T) l, Rational(T) r );
     51        int ?==?( rational(T) l, rational(T) r );
     52        int ?!=?( rational(T) l, rational(T) r );
     53        int ?!=?( rational(T) l, zero_t );                                      // => !
     54        int ?<?( rational(T) l, rational(T) r );
     55        int ?<=?( rational(T) l, rational(T) r );
     56        int ?>?( rational(T) l, rational(T) r );
     57        int ?>=?( rational(T) l, rational(T) r );
    5858
    5959        // arithmetic
    6060
    61         Rational(T) +?( Rational(T) r );
    62         Rational(T) -?( Rational(T) r );
    63         Rational(T) ?+?( Rational(T) l, Rational(T) r );
    64         Rational(T) ?+=?( Rational(T) & l, Rational(T) r );
    65         Rational(T) ?+=?( Rational(T) & l, one_t );                     // => ++?, ?++
    66         Rational(T) ?-?( Rational(T) l, Rational(T) r );
    67         Rational(T) ?-=?( Rational(T) & l, Rational(T) r );
    68         Rational(T) ?-=?( Rational(T) & l, one_t );                     // => --?, ?--
    69         Rational(T) ?*?( Rational(T) l, Rational(T) r );
    70         Rational(T) ?*=?( Rational(T) & l, Rational(T) r );
    71         Rational(T) ?/?( Rational(T) l, Rational(T) r );
    72         Rational(T) ?/=?( Rational(T) & l, Rational(T) r );
     61        rational(T) +?( rational(T) r );
     62        rational(T) -?( rational(T) r );
     63        rational(T) ?+?( rational(T) l, rational(T) r );
     64        rational(T) ?+=?( rational(T) & l, rational(T) r );
     65        rational(T) ?+=?( rational(T) & l, one_t );                     // => ++?, ?++
     66        rational(T) ?-?( rational(T) l, rational(T) r );
     67        rational(T) ?-=?( rational(T) & l, rational(T) r );
     68        rational(T) ?-=?( rational(T) & l, one_t );                     // => --?, ?--
     69        rational(T) ?*?( rational(T) l, rational(T) r );
     70        rational(T) ?*=?( rational(T) & l, rational(T) r );
     71        rational(T) ?/?( rational(T) l, rational(T) r );
     72        rational(T) ?/=?( rational(T) & l, rational(T) r );
    7373
    7474        // I/O
    7575        forall( istype & | istream( istype ) | { istype & ?|?( istype &, T & ); } )
    76         istype & ?|?( istype &, Rational(T) & );
     76        istype & ?|?( istype &, rational(T) & );
    7777
    7878        forall( ostype & | ostream( ostype ) | { ostype & ?|?( ostype &, T ); } ) {
    79                 ostype & ?|?( ostype &, Rational(T) );
    80                 void ?|?( ostype &, Rational(T) );
     79                ostype & ?|?( ostype &, rational(T) );
     80                void ?|?( ostype &, rational(T) );
    8181        } // distribution
    8282} // distribution
    8383
    84 forall( T | Arithmetic( T ) | { T ?\?( T, unsigned long ); } ) {
    85         Rational(T) ?\?( Rational(T) x, long int y );
    86         Rational(T) ?\=?( Rational(T) & x, long int y );
     84forall( T | arithmetic( T ) | { T ?\?( T, unsigned long ); } ) {
     85        rational(T) ?\?( rational(T) x, long int y );
     86        rational(T) ?\=?( rational(T) & x, long int y );
    8787} // distribution
    8888
    8989// conversion
    90 forall( T | Arithmetic( T ) | { double convert( T ); } )
    91 double widen( Rational(T) r );
    92 forall( T | Arithmetic( T ) | { double convert( T );  T convert( double );} )
    93 Rational(T) narrow( double f, T md );
     90forall( T | arithmetic( T ) | { double convert( T ); } )
     91double widen( rational(T) r );
     92forall( T | arithmetic( T ) | { double convert( T );  T convert( double );} )
     93rational(T) narrow( double f, T md );
    9494
    9595// Local Variables: //
Note: See TracChangeset for help on using the changeset viewer.