Changeset 8b58bae for libcfa


Ignore:
Timestamp:
Jun 24, 2020, 5:00:59 PM (5 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
c953163
Parents:
9791ab5 (diff), 7f9968ad (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' into relaxed_ready

Location:
libcfa/src
Files:
1 added
12 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/bits/debug.cfa

    r9791ab5 r8b58bae  
    1010// Created On       : Thu Mar 30 12:30:01 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Feb  4 13:03:16 2020
    13 // Update Count     : 11
     12// Last Modified On : Wed Jun 17 11:07:13 2020
     13// Update Count     : 12
    1414//
    1515
    16 extern "C" {
    1716#include <stdio.h>
    1817#include <stdlib.h>
     
    2120#include <stdarg.h>
    2221#include <unistd.h>
    23 }
    2422
    2523enum { buffer_size = 4096 };
  • libcfa/src/bits/signal.hfa

    r9791ab5 r8b58bae  
    1919#include "bits/defs.hfa"
    2020
    21 extern "C" {
    2221#include <errno.h>
    2322#define __USE_GNU
     
    2625#include <stdlib.h>
    2726#include <string.h>
    28 }
    2927
    3028// Short hands for signal context information
  • libcfa/src/concurrency/alarm.cfa

    r9791ab5 r8b58bae  
    1010// Created On       : Fri Jun 2 11:31:25 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Jan  5 08:41:36 2020
    13 // Update Count     : 69
     12// Last Modified On : Wed Jun 17 16:11:35 2020
     13// Update Count     : 75
    1414//
    1515
    1616#define __cforall_thread__
    1717
    18 extern "C" {
    1918#include <errno.h>
    2019#include <stdio.h>
     20#include <unistd.h>
    2121#include <string.h>
    22 #include <unistd.h>
    2322#include <sys/time.h>
    24 }
    2523
    2624#include "alarm.hfa"
     
    5553}
    5654
    57 void ?{}( alarm_node_t & this, processor   * proc, Time alarm, Duration period ) with( this ) {
     55void ?{}( alarm_node_t & this, processor * proc, Time alarm, Duration period ) with( this ) {
    5856        this.proc = proc;
    5957        this.alarm = alarm;
  • libcfa/src/concurrency/preemption.cfa

    r9791ab5 r8b58bae  
    1010// Created On       : Mon Jun 5 14:20:42 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Dec  5 16:34:05 2019
    13 // Update Count     : 43
     12// Last Modified On : Wed Jun 17 11:36:25 2020
     13// Update Count     : 46
    1414//
    1515
     
    1919#include <assert.h>
    2020
    21 extern "C" {
    2221#include <errno.h>
    2322#include <stdio.h>
     
    2524#include <unistd.h>
    2625#include <limits.h>                                                                             // PTHREAD_STACK_MIN
    27 }
    2826
    2927#include "bits/signal.hfa"
  • libcfa/src/containers/stackLockFree.hfa

    r9791ab5 r8b58bae  
    99// Created On       : Wed May 13 20:58:58 2020
    1010// Last Modified By : Peter A. Buhr
    11 // Last Modified On : Mon May 18 13:30:08 2020
    12 // Update Count     : 55
     11// Last Modified On : Sun Jun 14 13:25:09 2020
     12// Update Count     : 64
    1313//
    1414
     
    1919forall( dtype T )
    2020union Link {
    21         struct {                                                                        // 32/64-bit x 2
     21        struct {                                                                                        // 32/64-bit x 2
    2222                T * volatile top;                                                               // pointer to stack top
    23                 uintptr_t count;                                                // count each push
     23                uintptr_t count;                                                                // count each push
    2424        };
    2525        #if __SIZEOF_INT128__ == 16
    26         __int128                                                                        // gcc, 128-bit integer
     26        __int128                                                                                        // gcc, 128-bit integer
    2727        #else
    28         uint64_t                                                                        // 64-bit integer
     28        uint64_t                                                                                        // 64-bit integer
    2929        #endif // __SIZEOF_INT128__ == 16
    3030        atom;
    3131}; // Link
    3232
    33 forall( otype T | { Link(T) * ?`next( T * ); } ) {
     33forall( otype T | sized(T) | { Link(T) * ?`next( T * ); } ) {
    3434        struct StackLF {
    3535                Link(T) stack;
     
    4242
    4343                void push( StackLF(T) & this, T & n ) with(this) {
     44                        *( &n )`next = stack;                                   // atomic assignment unnecessary, or use CAA
    4445                        for () {                                                                        // busy wait
    45                                 *( &n )`next = stack;                                   // atomic assignment unnecessary, or use CAA
    4646                          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
    4747                        } // for
     
    4949
    5050                T * pop( StackLF(T) & this ) with(this) {
    51                         Link(T) t @= {};
     51                        Link(T) t @= stack;                                                     // atomic assignment unnecessary, or use CAA
    5252                        for () {                                                                        // busy wait
    53                                 t = stack;                                                              // atomic assignment unnecessary, or use CAA
    5453                          if ( t.top == 0p ) return 0p;                         // empty stack ?
    5554                          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
  • libcfa/src/containers/vector.hfa

    r9791ab5 r8b58bae  
    1010// Created On       : Tue Jul  5 18:00:07 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 10:01:18 2017
    13 // Update Count     : 3
     12// Last Modified On : Wed Jun 17 11:02:46 2020
     13// Update Count     : 4
    1414//
    1515
    1616#pragma once
    1717
    18 extern "C" {
    1918#include <stdbool.h>
    20 }
    2119
    2220//------------------------------------------------------------------------------
  • libcfa/src/fstream.cfa

    r9791ab5 r8b58bae  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Feb  7 19:01:01 2020
    13 // Update Count     : 363
     12// Last Modified On : Fri Jun 19 16:24:54 2020
     13// Update Count     : 384
    1414//
    1515
     
    2626
    2727
    28 //*********************************** ofstream ***********************************
     28// *********************************** ofstream ***********************************
    2929
    3030
     
    123123        #ifdef __CFA_DEBUG__
    124124        if ( file == 0p ) {
    125                 abort | IO_MSG "open output file \"" | name | "\"" | nl | strerror( errno );
     125                throw (Open_Failure){ os };
     126                // abort | IO_MSG "open output file \"" | name | "\"" | nl | strerror( errno );
    126127        } // if
    127128        #endif // __CFA_DEBUG__
     
    134135
    135136void close( ofstream & os ) {
    136         if ( (FILE *)(os.$file) == stdout || (FILE *)(os.$file) == stderr ) return;
     137  if ( (FILE *)(os.$file) == 0p ) return;
     138  if ( (FILE *)(os.$file) == (FILE *)stdout || (FILE *)(os.$file) == (FILE *)stderr ) return;
    137139
    138140        if ( fclose( (FILE *)(os.$file) ) == EOF ) {
    139141                abort | IO_MSG "close output" | nl | strerror( errno );
    140142        } // if
     143        os.$file = 0p;
    141144} // close
    142145
     
    179182
    180183
    181 //*********************************** ifstream ***********************************
     184// *********************************** ifstream ***********************************
    182185
    183186
     
    219222        #ifdef __CFA_DEBUG__
    220223        if ( file == 0p ) {
    221                 abort | IO_MSG "open input file \"" | name | "\"" | nl | strerror( errno );
     224                throw (Open_Failure){ is };
     225                // abort | IO_MSG "open input file \"" | name | "\"" | nl | strerror( errno );
    222226        } // if
    223227        #endif // __CFA_DEBUG__
     
    230234
    231235void close( ifstream & is ) {
    232         if ( (FILE *)(is.$file) == stdin ) return;
     236  if ( (FILE *)(is.$file) == 0p ) return;
     237  if ( (FILE *)(is.$file) == (FILE *)stdin ) return;
    233238
    234239        if ( fclose( (FILE *)(is.$file) ) == EOF ) {
    235240                abort | IO_MSG "close input" | nl | strerror( errno );
    236241        } // if
     242        is.$file = 0p;
    237243} // close
    238244
     
    276282ifstream & sin = sinFile, & stdin = sinFile;
    277283
     284
     285// *********************************** exceptions ***********************************
     286
     287
     288void ?{}( Open_Failure & this, ofstream & ostream ) {
     289        VTABLE_INIT(this, Open_Failure);
     290        this.ostream = &ostream;
     291        this.tag = 1;
     292}
     293void ?{}( Open_Failure & this, ifstream & istream ) {
     294        VTABLE_INIT(this, Open_Failure);
     295        this.istream = &istream;
     296        this.tag = 0;
     297}
     298const char * Open_Failure_msg(Open_Failure * this) {
     299        return "Open_Failure";
     300}
     301VTABLE_INSTANCE(Open_Failure)(Open_Failure_msg);
     302void throwOpen_Failure( ofstream & ostream ) {
     303        Open_Failure exc = { ostream };
     304}
     305void throwOpen_Failure( ifstream & istream ) {
     306        Open_Failure exc = { istream };
     307}
     308
    278309// Local Variables: //
    279310// tab-width: 4 //
  • libcfa/src/fstream.hfa

    r9791ab5 r8b58bae  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Feb 17 08:29:23 2020
    13 // Update Count     : 175
     12// Last Modified On : Fri Jun 19 16:29:17 2020
     13// Update Count     : 189
    1414//
    1515
     
    1717
    1818#include "iostream.hfa"
     19#include <exception.hfa>
    1920
    2021
    21 //*********************************** ofstream ***********************************
     22// *********************************** ofstream ***********************************
    2223
    2324
     
    7879
    7980
    80 //*********************************** ifstream ***********************************
     81// *********************************** ifstream ***********************************
    8182
    8283
     
    106107extern ifstream & sin, & stdin;                                                 // aliases
    107108
     109
     110// *********************************** exceptions ***********************************
     111
     112
     113DATA_EXCEPTION(Open_Failure)(
     114        union {
     115                ofstream * ostream;
     116                ifstream * istream;
     117        };
     118        // TEMPORARY: need polymorphic exceptions
     119        int tag;                                                                                        // 1 => ostream; 0 => istream
     120);
     121
     122void ?{}( Open_Failure & this, ofstream & ostream );
     123void ?{}( Open_Failure & this, ifstream & istream );
     124
    108125// Local Variables: //
    109126// mode: c //
  • libcfa/src/heap.cfa

    r9791ab5 r8b58bae  
    1010// Created On       : Tue Dec 19 21:58:35 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed May 27 15:08:49 2020
    13 // Update Count     : 770
     12// Last Modified On : Sat Jun 13 22:42:15 2020
     13// Update Count     : 805
    1414//
    1515
     
    208208
    209209#if BUCKETLOCK == LOCKFREE
    210 static inline Link(HeapManager.Storage) * ?`next( HeapManager.Storage * this ) { return &this->header.kind.real.next; }
    211 static inline void ?{}( HeapManager.FreeHeader & ) {}
    212 static inline void ^?{}( HeapManager.FreeHeader & ) {}
     210static inline {
     211        Link(HeapManager.Storage) * ?`next( HeapManager.Storage * this ) { return &this->header.kind.real.next; }
     212        void ?{}( HeapManager.FreeHeader & ) {}
     213        void ^?{}( HeapManager.FreeHeader & ) {}
     214} // distribution
    213215#endif // LOCKFREE
    214216
  • libcfa/src/iostream.cfa

    r9791ab5 r8b58bae  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat May  2 18:30:25 2020
    13 // Update Count     : 1017
     12// Last Modified On : Fri Jun 19 16:15:34 2020
     13// Update Count     : 1019
    1414//
    1515
    1616#include "iostream.hfa"
    1717
    18 extern "C" {
    1918#include <stdio.h>
    2019#include <stdbool.h>                                                                    // true/false
    2120#include <stdint.h>                                                                             // UINT64_MAX
     21#include <float.h>                                                                              // DBL_DIG, LDBL_DIG
     22#include <math.h>                                                                               // isfinite
     23#include <complex.h>                                                                    // creal, cimag
    2224//#include <string.h>                                                                   // strlen, strcmp
     25extern "C" {
    2326extern size_t strlen (const char *__s) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
    2427extern int strcmp (const char *__s1, const char *__s2) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
    2528extern char *strcpy (char *__restrict __dest, const char *__restrict __src) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
    2629extern void *memcpy (void *__restrict __dest, const void *__restrict __src, size_t __n) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
    27 #include <float.h>                                                                              // DBL_DIG, LDBL_DIG
    28 #include <math.h>                                                                               // isfinite
    29 #include <complex.h>                                                                    // creal, cimag
    3030} // extern "C"
    3131
     
    3333
    3434
    35 //*********************************** ostream ***********************************
     35// *********************************** ostream ***********************************
    3636
    3737
     
    447447} // distribution
    448448
    449 //*********************************** manipulators ***********************************
    450 
    451 //*********************************** integral ***********************************
     449// *********************************** manipulators ***********************************
     450
     451// *********************************** integral ***********************************
    452452
    453453static const char * shortbin[] = { "0", "1", "10", "11", "100", "101", "110", "111", "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111" };
     
    664664#endif // __SIZEOF_INT128__
    665665
    666 //*********************************** floating point ***********************************
     666// *********************************** floating point ***********************************
    667667
    668668#define PrintWithDP2( os, format, val, ... ) \
     
    720720FloatingPointFMTImpl( long double, "%    *L ", "%    *.*L " )
    721721
    722 //*********************************** character ***********************************
     722// *********************************** character ***********************************
    723723
    724724forall( dtype ostype | ostream( ostype ) ) {
     
    753753} // distribution
    754754
    755 //*********************************** C string ***********************************
     755// *********************************** C string ***********************************
    756756
    757757forall( dtype ostype | ostream( ostype ) ) {
     
    800800
    801801
    802 //*********************************** istream ***********************************
     802// *********************************** istream ***********************************
    803803
    804804
     
    946946} // distribution
    947947
    948 //*********************************** manipulators ***********************************
     948// *********************************** manipulators ***********************************
    949949
    950950forall( dtype istype | istream( istype ) )
  • libcfa/src/iostream.hfa

    r9791ab5 r8b58bae  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Feb 20 15:30:56 2020
    13 // Update Count     : 337
     12// Last Modified On : Fri Jun 19 16:15:56 2020
     13// Update Count     : 338
    1414//
    1515
     
    1919
    2020
    21 //*********************************** ostream ***********************************
     21// *********************************** ostream ***********************************
    2222
    2323
     
    156156} // distribution
    157157
    158 //*********************************** manipulators ***********************************
     158// *********************************** manipulators ***********************************
    159159
    160160forall( otype T )
     
    175175}; // _Ostream_Manip
    176176
    177 //*********************************** integral ***********************************
     177// *********************************** integral ***********************************
    178178
    179179// See 6.7.9. 19) The initialization shall occur in initializer list order, each initializer provided for a particular
     
    217217#endif
    218218
    219 //*********************************** floating point ***********************************
     219// *********************************** floating point ***********************************
    220220
    221221// Default suffix for values with no fraction is "."
     
    246246FloatingPointFMTDecl( long double )
    247247
    248 //*********************************** character ***********************************
     248// *********************************** character ***********************************
    249249
    250250static inline {
     
    263263} // ?|?
    264264
    265 //*********************************** C string ***********************************
     265// *********************************** C string ***********************************
    266266
    267267static inline {
     
    282282
    283283
    284 //*********************************** istream ***********************************
     284// *********************************** istream ***********************************
    285285
    286286
     
    336336} // distribution
    337337
    338 //*********************************** manipulators ***********************************
     338// *********************************** manipulators ***********************************
    339339
    340340struct _Istream_Cstr {
     
    413413
    414414
    415 //*********************************** time ***********************************
     415// *********************************** time ***********************************
    416416
    417417
  • libcfa/src/time.hfa

    r9791ab5 r8b58bae  
    1010// Created On       : Wed Mar 14 23:18:57 2018
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Feb  4 08:24:32 2020
    13 // Update Count     : 654
     12// Last Modified On : Wed Jun 17 16:13:00 2020
     13// Update Count     : 663
    1414//
    1515
     
    2020
    2121#include <time.h>                                                                               // timespec
    22 extern "C" {
    2322#include <sys/time.h>                                                                   // timeval
    24 }
    2523#include <time_t.hfa>                                                                   // Duration/Time types
    2624
     
    9189        int64_t ?`w( Duration dur ) { return dur.tn / (7LL * 24LL * 60LL * 60LL * TIMEGRAN); }
    9290
     91        double ?`dns( Duration dur ) { return dur.tn; }
     92        double ?`dus( Duration dur ) { return dur.tn / ((double)TIMEGRAN / 1_000_000.); }
     93        double ?`dms( Duration dur ) { return dur.tn / ((double)TIMEGRAN / 1_000.); }
     94        double ?`ds( Duration dur ) { return dur.tn / (double)TIMEGRAN; }
     95        double ?`dm( Duration dur ) { return dur.tn / (60. * TIMEGRAN); }
     96        double ?`dh( Duration dur ) { return dur.tn / (60. * 60. * (double)TIMEGRAN); }
     97        double ?`dd( Duration dur ) { return dur.tn / (24. * 60. * 60. * (double)TIMEGRAN); }
     98        double ?`dw( Duration dur ) { return dur.tn / (7. * 24. * 60. * 60. * (double)TIMEGRAN); }
     99
    93100        Duration max( Duration lhs, Duration rhs ) { return  (lhs.tn < rhs.tn) ? rhs : lhs;}
    94101        Duration min( Duration lhs, Duration rhs ) { return !(rhs.tn < lhs.tn) ? lhs : rhs;}
Note: See TracChangeset for help on using the changeset viewer.