Changeset 1fcc2f3


Ignore:
Timestamp:
Nov 7, 2019, 2:49:24 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:
f2d1335
Parents:
396b830 (diff), d056d0d (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 new-ast

Files:
10 added
1 deleted
26 edited

Legend:

Unmodified
Added
Removed
  • Jenkins/FullBuild

    r396b830 r1fcc2f3  
    1717
    1818                                parallel (
     19                                        clang_x86: { trigger_build( 'gcc-8',   'x86' ) },
     20                                        gcc_5_x86: { trigger_build( 'gcc-7',   'x86' ) },
     21                                        gcc_6_x86: { trigger_build( 'gcc-6',   'x86' ) },
     22                                        gcc_6_x64: { trigger_build( 'gcc-9',   'x64' ) },
     23                                        gcc_6_x64: { trigger_build( 'gcc-8',   'x64' ) },
     24                                        gcc_6_x64: { trigger_build( 'gcc-7',   'x64' ) },
    1925                                        gcc_6_x64: { trigger_build( 'gcc-6',   'x64' ) },
    20                                         gcc_6_x86: { trigger_build( 'gcc-6',   'x86' ) },
    2126                                        gcc_5_x64: { trigger_build( 'gcc-5',   'x64' ) },
    22                                         gcc_5_x86: { trigger_build( 'gcc-5',   'x86' ) },
    2327                                        clang_x64: { trigger_build( 'clang',   'x64' ) },
    24                                         clang_x86: { trigger_build( 'clang',   'x86' ) },
    2528                                )
    2629                        }
  • Jenkinsfile_disabled

    r396b830 r1fcc2f3  
    224224//Routine responsible of sending the email notification once the build is completed
    225225//===========================================================================================================
     226@NonCPS
     227def SplitLines(String text) {
     228        def list = []
     229
     230        text.eachLine {
     231                list += it
     232        }
     233
     234        return list
     235}
     236
    226237def GitLogMessage() {
    227238        if (!Settings || !Settings.GitOldRef || !Settings.GitNewRef) return "\nERROR retrieveing git information!\n"
    228239
    229         sh "${SrcDir}/tools/PrettyGitLogs.sh ${SrcDir} ${BuildDir} ${Settings.GitOldRef} ${Settings.GitNewRef}"
    230 
    231         def gitUpdate = readFile("${BuildDir}/GIT_UPDATE")
    232         def gitLog    = readFile("${BuildDir}/GIT_LOG")
    233         def gitDiff   = readFile("${BuildDir}/GIT_DIFF")
     240        def oldRef = Settings.GitOldRef
     241        def newRef = Settings.GitNewRef
     242
     243        def revText = sh(returnStdout: true, script: "git rev-list ${oldRef}..${newRef}").trim()
     244        def revList = SplitLines( revText )
     245
     246        def gitUpdate = ""
     247        revList.each { rev ->
     248                def type = sh(returnStdout: true, script: "git cat-file -t ${rev}").trim()
     249                gitUpdate = gitUpdate + "       via  ${rev} (${type})"
     250        }
     251
     252        def rev = oldRef
     253        def type = sh(returnStdout: true, script: "git cat-file -t ${rev}").trim()
     254        gitUpdate = gitUpdate + "      from  ${rev} (${type})"
     255
     256        def gitLog    = sh(returnStdout: true, script: "git rev-list --format=short ${oldRef}...${newRef}").trim()
     257
     258        def gitDiff   = sh(returnStdout: true, script: "git diff --stat --color ${newRef} ${oldRef}").trim()
     259        gitDiff = gitDiff.replace('[32m', '<span style="color: #00AA00;">')
     260        gitDiff = gitDiff.replace('[31m', '<span style="color: #AA0000;">')
     261        gitDiff = gitDiff.replace('[m', '</span>')
    234262
    235263        return """
     
    330358        BuildSettings(java.util.Collections$UnmodifiableMap param, String branch) {
    331359                switch( param.Compiler ) {
     360                        case 'gcc-9':
     361                                this.Compiler = new CC_Desc('gcc-9', 'g++-9', 'gcc-9')
     362                        break
     363                        case 'gcc-8':
     364                                this.Compiler = new CC_Desc('gcc-8', 'g++-8', 'gcc-8')
     365                        break
     366                        case 'gcc-7':
     367                                this.Compiler = new CC_Desc('gcc-7', 'g++-7', 'gcc-7')
     368                        break
    332369                        case 'gcc-6':
    333370                                this.Compiler = new CC_Desc('gcc-6', 'g++-6', 'gcc-6')
     
    340377                        break
    341378                        case 'clang':
    342                                 this.Compiler = new CC_Desc('clang', 'clang++', 'gcc-6')
     379                                this.Compiler = new CC_Desc('clang', 'clang++-6.0', 'gcc-6')
    343380                        break
    344381                        default :
     
    402439                                        description: 'Which compiler to use',                                   \
    403440                                        name: 'Compiler',                                                                       \
    404                                         choices: 'gcc-6\ngcc-5\ngcc-4.9\nclang',                                        \
    405                                         defaultValue: 'gcc-6',                                                          \
     441                                        choices: 'gcc-9\ngcc-8\ngcc-7\ngcc-6\ngcc-5\ngcc-4.9\nclang',                                   \
     442                                        defaultValue: 'gcc-8',                                                          \
    406443                                ],                                                                                              \
    407444                                [$class: 'ChoiceParameterDefinition',                                           \
  • automake/missing

    • Property mode changed from 120000 to 100644
    r396b830 r1fcc2f3  
    1 /usr/share/automake-1.15/missing
     1#! /bin/sh
     2# Tdelisle : having the Makefiles.in automatically regenerated causes problems
     3#            when using multiple versions of automake, even if only on end user machines
     4#            therefore I am disabling that feature by commenting this script
     5exit 0
  • doc/papers/concurrency/Paper.tex

    r396b830 r1fcc2f3  
    253253\lstMakeShortInline@%
    254254
     255\newcommand{\commenttd}[1]{{\color{red}{Thierry : #1}}}
     256
    255257\let\OLDthebibliography\thebibliography
    256258\renewcommand\thebibliography[1]{
     
    970972% }
    971973% int main() {
    972 % 
     974%
    973975%       for ( int i = 0; i < 10; i += 1 ) {
    974976%               printf( "%d\n", fib() );
     
    17071709                if ( random() % 3 ) transfer( b1, b2, 7 );
    17081710        }
    1709 }   
     1711}
    17101712int main() {
    17111713        `Person p1 = { b1, b2 }, p2 = { b2, b1 };`
     
    17371739                if ( random() % 3 ) transfer( b1, b2, 7 );
    17381740        }
    1739 }   
     1741}
    17401742int main() {
    17411743        `thread p1(person, ref(b1), ref(b2)), p2(person, ref(b2), ref(b1));`
     
    19151917% forall( otype T ) { // distribute forall
    19161918%       monitor Buffer {
    1917 % 
     1919%
    19181920%               int front, back, count;
    19191921%               T elements[10];
     
    19271929%               if ( count == 10 ) `waitfor( remove, buffer )`;
    19281930%               // insert elem into buffer
    1929 % 
     1931%
    19301932%       }
    19311933%       T remove( Buffer(T) & mutex buffer ) with(buffer) {
    19321934%               if ( count == 0 ) `waitfor( insert, buffer )`;
    19331935%               // remove elem from buffer
    1934 % 
     1936%
    19351937%               return elem;
    19361938%       }
     
    25402542% \section{Parallelism}
    25412543% \label{s:Parallelism}
    2542 % 
     2544%
    25432545% Historically, computer performance was about processor speeds.
    25442546% However, with heat dissipation being a direct consequence of speed increase, parallelism is the new source for increased performance~\cite{Sutter05, Sutter05b}.
     
    25472549% However, kernel threads are better as an implementation tool because of complexity and higher cost.
    25482550% Therefore, different abstractions are often layered onto kernel threads to simplify them, \eg pthreads.
    2549 % 
    2550 % 
     2551%
     2552%
    25512553% \subsection{User Threads}
    2552 % 
     2554%
    25532555% A direct improvement on kernel threads is user threads, \eg Erlang~\cite{Erlang} and \uC~\cite{uC++book}.
    25542556% This approach provides an interface that matches the language paradigms, gives more control over concurrency by the language runtime, and an abstract (and portable) interface to the underlying kernel threads across operating systems.
     
    25562558% Like kernel threads, user threads support preemption, which maximizes nondeterminism, but increases the potential for concurrency errors: race, livelock, starvation, and deadlock.
    25572559% \CFA adopts user-threads to provide more flexibility and a low-cost mechanism to build any other concurrency approach, \eg thread pools and actors~\cite{Actors}.
    2558 % 
     2560%
    25592561% A variant of user thread is \newterm{fibres}, which removes preemption, \eg Go~\cite{Go} @goroutine@s.
    25602562% Like functional programming, which removes mutation and its associated problems, removing preemption from concurrency reduces nondeterminism, making race and deadlock errors more difficult to generate.
  • driver/cc1.cc

    r396b830 r1fcc2f3  
    1010// Created On       : Fri Aug 26 14:23:51 2005
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Sep  9 17:50:53 2019
    13 // Update Count     : 384
     12// Last Modified On : Sun Oct 20 08:14:33 2019
     13// Update Count     : 385
    1414//
    1515
     
    503503                execvp( args[0], (char * const *)args );                // should not return
    504504                perror( "CC1 Translator error: stage 2 cc1, execvp" );
    505                 cerr << " invoked " << cargs[0] << endl;
     505                cerr << " invoked " << args[0] << endl;
    506506                exit( EXIT_FAILURE );                                                   // tell gcc not to go any further
    507507        } // if
  • libcfa/automake/missing

    • Property mode changed from 120000 to 100644
    r396b830 r1fcc2f3  
    1 /usr/share/automake-1.15/missing
     1#! /bin/sh
     2# Tdelisle : having the Makefiles.in automatically regenerated causes problems
     3#            when using multiple versions of automake, even if only on end user machines
     4#            therefore I am disabling that feature by commenting this script
     5exit 0
  • libcfa/src/concurrency/kernel_private.hfa

    r396b830 r1fcc2f3  
    3434static inline void WakeThread( thread_desc * thrd ) {
    3535        if( !thrd ) return;
     36
     37        verify(thrd->state == Inactive);
    3638
    3739        disable_interrupts();
  • libcfa/src/heap.cfa

    r396b830 r1fcc2f3  
    1010// Created On       : Tue Dec 19 21:58:35 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Jul 24 13:12:45 2019
    13 // Update Count     : 550
     12// Last Modified On : Fri Oct 18 07:42:09 2019
     13// Update Count     : 556
    1414//
    1515
     
    541541        // along with the block and is a multiple of the alignment size.
    542542
     543  if ( unlikely( size > ~0ul - sizeof(HeapManager.Storage) ) ) return 0;
    543544        size_t tsize = size + sizeof(HeapManager.Storage);
    544545        if ( likely( tsize < mmapStart ) ) {                            // small size => sbrk
     
    592593                block->header.kind.real.home = freeElem;                // pointer back to free list of apropriate size
    593594        } else {                                                                                        // large size => mmap
     595  if ( unlikely( size > ~0ul - pageSize ) ) return 0;
    594596                tsize = libCeiling( tsize, pageSize );                  // must be multiple of page size
    595597                #ifdef __STATISTICS__
     
    888890        } // realloc
    889891
    890 
    891892        // The obsolete function memalign() allocates size bytes and returns a pointer to the allocated memory. The memory
    892893        // address will be a multiple of alignment, which must be a power of two.
     
    992993        size_t malloc_alignment( void * addr ) {
    993994          if ( unlikely( addr == 0 ) ) return libAlign();       // minimum alignment
    994                 HeapManager.Storage.Header * header = (HeapManager.Storage.Header *)( (char *)addr - sizeof(HeapManager.Storage) );
     995                HeapManager.Storage.Header * header = headerAddr( addr );
    995996                if ( (header->kind.fake.alignment & 1) == 1 ) { // fake header ?
    996997                        return header->kind.fake.alignment & -2;        // remove flag from value
     
    10041005        bool malloc_zero_fill( void * addr ) {
    10051006          if ( unlikely( addr == 0 ) ) return false;            // null allocation is not zero fill
    1006 
    1007                 HeapManager.Storage.Header * header = (HeapManager.Storage.Header *)( (char *)addr - sizeof(HeapManager.Storage) );
     1007                HeapManager.Storage.Header * header = headerAddr( addr );
    10081008                if ( (header->kind.fake.alignment & 1) == 1 ) { // fake header ?
    10091009                        header = (HeapManager.Storage.Header *)((char *)header - header->kind.fake.offset);
  • libcfa/src/stdlib.cfa

    r396b830 r1fcc2f3  
    1010// Created On       : Thu Jan 28 17:10:29 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Jun 24 17:34:44 2019
    13 // Update Count     : 462
     12// Last Modified On : Tue Oct 22 08:57:52 2019
     13// Update Count     : 478
    1414//
    1515
     
    2121#include <string.h>                                                                             // memcpy, memset
    2222#include <malloc.h>                                                                             // malloc_usable_size
    23 #include <math.h>                                                                               // fabsf, fabs, fabsl
     23//#include <math.h>                                                                             // fabsf, fabs, fabsl
    2424#include <complex.h>                                                                    // _Complex_I
    2525#include <assert.h>
     
    2727//---------------------------------------
    2828
    29 // resize, non-array types
    30 forall( dtype T | sized(T) ) T * alloc( T ptr[], size_t dim, char fill ) {
    31         size_t olen = malloc_usable_size( ptr );                        // current allocation
    32     char * nptr = (void *)realloc( (void *)ptr, dim * (size_t)sizeof(T) ); // C realloc
    33         size_t nlen = malloc_usable_size( nptr );                       // new allocation
    34         if ( nlen > olen ) {                                                            // larger ?
    35                 memset( nptr + olen, (int)fill, nlen - olen );  // initialize added storage
    36         } //
    37     return (T *)nptr;
    38 } // alloc
     29forall( dtype T | sized(T) ) {
     30        T * alloc_set( T ptr[], size_t dim, char fill ) {       // realloc array with fill
     31                size_t olen = malloc_usable_size( ptr );                // current allocation
     32                char * nptr = (char *)realloc( (void *)ptr, dim * sizeof(T) ); // C realloc
     33                size_t nlen = malloc_usable_size( nptr );               // new allocation
     34                if ( nlen > olen ) {                                                    // larger ?
     35                        memset( nptr + olen, (int)fill, nlen - olen ); // initialize added storage
     36                } // if
     37                return (T *)nptr;
     38        } // alloc_set
     39
     40        T * alloc_align( T ptr[], size_t align ) {                      // aligned realloc array
     41                char * nptr;
     42                size_t alignment = malloc_alignment( ptr );
     43                if ( align != alignment && (uintptr_t)ptr % align != 0 ) {
     44                        size_t olen = malloc_usable_size( ptr );        // current allocation
     45                        nptr = (char *)memalign( align, olen );
     46                        size_t nlen = malloc_usable_size( nptr );       // new allocation
     47                        size_t lnth = olen < nlen ? olen : nlen;        // min
     48                        memcpy( nptr, ptr, lnth );                                      // initialize storage
     49                        free( ptr );
     50                } else {
     51                        nptr = (char *)ptr;
     52                } // if
     53                return (T *)nptr;
     54        } // alloc_align
     55
     56        T * alloc_align( T ptr[], size_t align, size_t dim ) { // aligned realloc array
     57                char * nptr;
     58                size_t alignment = malloc_alignment( ptr );
     59                if ( align != alignment ) {
     60                        size_t olen = malloc_usable_size( ptr );        // current allocation
     61                        nptr = (char *)memalign( align, dim * sizeof(T) );
     62                        size_t nlen = malloc_usable_size( nptr );       // new allocation
     63                        size_t lnth = olen < nlen ? olen : nlen;        // min
     64                        memcpy( nptr, ptr, lnth );                                      // initialize storage
     65                        free( ptr );
     66                } else {
     67                        nptr = (char *)realloc( (void *)ptr, dim * sizeof(T) ); // C realloc
     68                } // if
     69                return (T *)nptr;
     70        } // alloc_align
     71
     72        T * alloc_align_set( T ptr[], size_t align, char fill ) { // aligned realloc with fill
     73                size_t olen = malloc_usable_size( ptr );                // current allocation
     74                char * nptr = alloc_align( ptr, align );
     75                size_t nlen = malloc_usable_size( nptr );               // new allocation
     76                if ( nlen > olen ) {                                                    // larger ?
     77                        memset( nptr + olen, (int)fill, nlen - olen ); // initialize added storage
     78                } // if
     79                return (T *)nptr;
     80        } // alloc_align_set
     81} // distribution
    3982
    4083// allocation/deallocation and constructor/destructor, non-array types
    4184forall( dtype T | sized(T), ttype Params | { void ?{}( T &, Params ); } )
    4285T * new( Params p ) {
    43         return &(*malloc()){ p };                                                               // run constructor
     86        return &(*malloc()){ p };                                                       // run constructor
    4487} // new
    4588
     
    4790void delete( T * ptr ) {
    4891        if ( ptr ) {                                                                            // ignore null
    49                 ^(*ptr){};                                                                                      // run destructor
     92                ^(*ptr){};                                                                              // run destructor
    5093                free( ptr );
    5194        } // if
     
    5598void delete( T * ptr, Params rest ) {
    5699        if ( ptr ) {                                                                            // ignore null
    57                 ^(*ptr){};                                                                                      // run destructor
     100                ^(*ptr){};                                                                              // run destructor
    58101                free( ptr );
    59102        } // if
  • libcfa/src/stdlib.hfa

    r396b830 r1fcc2f3  
    1010// Created On       : Thu Jan 28 17:12:35 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Jul 23 14:14:59 2019
    13 // Update Count     : 373
     12// Last Modified On : Sun Oct 20 22:57:33 2019
     13// Update Count     : 390
    1414//
    1515
     
    2525        void * memset( void * dest, int fill, size_t size ); // string.h
    2626        void * memcpy( void * dest, const void * src, size_t size ); // string.h
    27     void * cmemalign( size_t alignment, size_t noOfElems, size_t elemSize ); // CFA
     27    void * cmemalign( size_t alignment, size_t noOfElems, size_t elemSize ); // CFA heap
    2828} // extern "C"
    2929
     
    5252        T * realloc( T * ptr, size_t size ) {
    5353                if ( unlikely( ptr == 0 ) ) return malloc();
    54                 return (T *)(void *)realloc( (void *)ptr, size );
     54                return (T *)(void *)realloc( (void *)ptr, size ); // C realloc
    5555        } // realloc
    5656
    5757        T * memalign( size_t align ) {
    58                 return (T *)memalign( align, sizeof(T) );
     58                return (T *)memalign( align, sizeof(T) );               // C memalign
    5959        } // memalign
    6060
    6161        T * aligned_alloc( size_t align ) {
    62                 return (T *)aligned_alloc( align, sizeof(T) );
     62                return (T *)aligned_alloc( align, sizeof(T) );  // C aligned_alloc
    6363        } // aligned_alloc
    6464
     
    6767        } // posix_memalign
    6868
    69 
    7069        // Cforall dynamic allocation
    7170
     
    7473        } // alloc
    7574
    76         T * alloc( char fill ) {
    77                 T * ptr;
    78                 if ( _Alignof(T) <= libAlign() ) ptr = (T *)(void *)malloc( (size_t)sizeof(T) ); // C malloc
    79                 else ptr = (T *)memalign( _Alignof(T), sizeof(T) );
    80                 return (T *)memset( ptr, (int)fill, sizeof(T) ); // initialize with fill value
    81         } // alloc
    82 
    8375        T * alloc( size_t dim ) {
    84                 if ( _Alignof(T) <= libAlign() ) return (T *)(void *)malloc( dim * (size_t)sizeof(T) ); // C malloc
     76                if ( _Alignof(T) <= libAlign() ) return (T *)(void *)malloc( dim * (size_t)sizeof(T) );
    8577                else return (T *)memalign( _Alignof(T), dim * sizeof(T) );
    8678        } // alloc
    8779
    88         T * alloc( size_t dim, char fill ) {
     80        T * alloc( T ptr[], size_t dim ) {                                      // realloc
     81                return realloc( ptr, dim * sizeof(T) );
     82        } // alloc
     83
     84        T * alloc_set( char fill ) {
     85                return (T *)memset( (T *)alloc(), (int)fill, sizeof(T) ); // initialize with fill value
     86        } // alloc
     87
     88        T * alloc_set( T fill ) {
     89                return (T *)memcpy( (T *)alloc(), &fill, sizeof(T) ); // initialize with fill value
     90        } // alloc
     91
     92        T * alloc_set( size_t dim, char fill ) {
    8993                return (T *)memset( (T *)alloc( dim ), (int)fill, dim * sizeof(T) ); // initialize with fill value
    9094        } // alloc
    9195
    92         T * alloc( T ptr[], size_t dim ) {
    93                 return realloc( ptr, dim * sizeof(T) );
    94         } // alloc
    95 } // distribution
    96 
    97 
    98 static inline forall( dtype T | sized(T) ) {
    99         T * align_alloc( size_t align ) {
     96        T * alloc_set( size_t dim, T fill ) {
     97                T * r = (T *)alloc( dim );
     98                for ( i; dim ) { memcpy( &r[i], &fill, sizeof(T) ); } // initialize with fill value
     99                return r;
     100        } // alloc
     101
     102        T * alloc_set( size_t dim, const T fill[] ) {
     103                return (T *)memcpy( (T *)alloc( dim ), fill, dim * sizeof(T) ); // initialize with fill value
     104        } // alloc
     105} // distribution
     106
     107forall( dtype T | sized(T) ) {
     108        T * alloc_set( T ptr[], size_t dim, char fill );        // realloc array with fill
     109} // distribution
     110
     111static inline forall( dtype T | sized(T) ) {
     112        T * alloc_align( size_t align ) {
    100113                return (T *)memalign( align, sizeof(T) );
    101         } // align_alloc
    102 
    103         T * align_alloc( size_t align, char fill ) {
    104                 T * ptr = (T *)memalign( align, sizeof(T) );
    105                 return (T *)memset( ptr, (int)fill, sizeof(T) );
    106         } // align_alloc
    107 
    108         T * align_alloc( size_t align, size_t dim ) {
     114        } // alloc_align
     115
     116        T * alloc_align( size_t align, size_t dim ) {
    109117                return (T *)memalign( align, dim * sizeof(T) );
    110         } // align_alloc
    111 
    112         T * align_alloc( size_t align, size_t dim, char fill ) {
    113                 if ( fill == '\0' ) {
    114                         return (T *)cmemalign( align, dim, sizeof(T) );
    115                 } else {
    116                         return (T *)memset( (T *)memalign( align, dim * sizeof(T) ), (int)fill, dim * sizeof(T) );
    117                 } // if
    118         } // align_alloc
    119 } // distribution
    120 
    121 forall( dtype T | sized(T) ) T * alloc( T ptr[], size_t dim, char fill );
    122 
     118        } // alloc_align
     119
     120        T * alloc_align_set( size_t align, char fill ) {
     121                return (T *)memset( (T *)alloc_align( align ), (int)fill, sizeof(T) ); // initialize with fill value
     122        } // alloc_align
     123
     124        T * alloc_align_set( size_t align, T fill ) {
     125                return (T *)memcpy( (T *)alloc_align( align ), &fill, sizeof(T) ); // initialize with fill value
     126        } // alloc_align
     127
     128        T * alloc_align_set( size_t align, size_t dim, char fill ) {
     129                return (T *)memset( (T *)alloc_align( align, dim ), (int)fill, dim * sizeof(T) ); // initialize with fill value
     130        } // alloc_align
     131
     132        T * alloc_align_set( size_t align, size_t dim, T fill ) {
     133                T * r = (T *)alloc_align( align, dim );
     134                for ( i; dim ) { memcpy( &r[i], &fill, sizeof(T) ); } // initialize with fill value
     135                return r;
     136        } // alloc_align
     137
     138        T * alloc_align_set( size_t align, size_t dim, const T fill[] ) {
     139                return (T *)memcpy( (T *)alloc_align( align, dim ), fill, dim * sizeof(T) );
     140        } // alloc_align
     141} // distribution
     142
     143forall( dtype T | sized(T) ) {
     144        T * alloc_align( T ptr[], size_t align );                       // realign
     145        T * alloc_align( T ptr[], size_t align, size_t dim ); // aligned realloc array
     146        T * alloc_align_set( T ptr[], size_t align, size_t dim, char fill ); // aligned realloc array with fill
     147} // distribution
    123148
    124149static inline forall( dtype T | sized(T) ) {
    125150        // data, non-array types
    126 
    127151        T * memset( T * dest, char fill ) {
    128152                return (T *)memset( dest, fill, sizeof(T) );
     
    136160static inline forall( dtype T | sized(T) ) {
    137161        // data, array types
    138 
    139162        T * amemset( T dest[], char fill, size_t dim ) {
    140163                return (T *)(void *)memset( dest, fill, dim * sizeof(T) ); // C memset
  • longrun_tests/Makefile.am

    r396b830 r1fcc2f3  
    4242        -I$(abs_top_srcdir)/tests \
    4343        -I$(srcdir) \
    44         -DTEST_$(shell cat .type | tr a-z A-Z) \
     44        -DTEST_$(shell cat .type | tr a-z A-Z)
    4545
    4646TESTS = block coroutine create disjoint enter enter3 processor stack wait yield
  • longrun_tests/Makefile.in

    r396b830 r1fcc2f3  
    526526        -I$(abs_top_srcdir)/tests \
    527527        -I$(srcdir) \
    528         -DTEST_$(shell cat .type | tr a-z A-Z) \
    529         -in-tree
     528        -DTEST_$(shell cat .type | tr a-z A-Z)
    530529
    531530TESTS = block coroutine create disjoint enter enter3 processor stack wait yield
  • src/CodeGen/CodeGenerator.cc

    r396b830 r1fcc2f3  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Thr May  2 10:47:00 2019
    13 // Update Count     : 497
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Sat Oct 19 19:30:38 2019
     13// Update Count     : 506
    1414//
    1515#include "CodeGenerator.h"
     
    198198                // deleted decls should never be used, so don't print them
    199199                if ( objectDecl->isDeleted && options.genC ) return;
    200                 if (objectDecl->get_name().empty() && options.genC ) {
     200
     201                // gcc allows an empty declarator (no name) for bit-fields and C states: 6.7.2.1 Structure and union specifiers,
     202                // point 4, page 113: If the (bit field) value is zero, the declaration shall have no declarator.  For anything
     203                // else, the anonymous name refers to the anonymous object for plan9 inheritance.
     204                if ( objectDecl->get_name().empty() && options.genC && ! objectDecl->get_bitfieldWidth() ) {
    201205                        // only generate an anonymous name when generating C code, otherwise it clutters the output too much
    202206                        static UniqueName name = { "__anonymous_object" };
    203207                        objectDecl->set_name( name.newName() );
    204             // Stops unused parameter warnings.
    205             if ( options.anonymousUnused ) {
    206                 objectDecl->attributes.push_back( new Attribute( "unused" ) );
    207             }
     208                        // Stops unused parameter warnings.
     209                        if ( options.anonymousUnused ) {
     210                                objectDecl->attributes.push_back( new Attribute( "unused" ) );
     211                        }
    208212                }
    209213
  • src/ControlStruct/MLEMutator.cc

    r396b830 r1fcc2f3  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Mar  8 17:08:25 2018
    13 // Update Count     : 219
     12// Last Modified On : Tue Oct 22 17:22:44 2019
     13// Update Count     : 220
    1414//
    1515
     
    313313        }
    314314
     315        void MLEMutator::premutate( TryStmt * tryStmt ) {
     316                // generate a label for breaking out of a labeled if
     317                bool labeledBlock = !(tryStmt->get_labels().empty());
     318                if ( labeledBlock ) {
     319                        Label brkLabel = generator->newLabel("blockBreak", tryStmt);
     320                        enclosingControlStructures.push_back( Entry( tryStmt, brkLabel ) );
     321                        GuardAction( [this]() { enclosingControlStructures.pop_back(); } );
     322                } // if
     323        }
     324
     325        Statement * MLEMutator::postmutate( TryStmt * tryStmt ) {
     326                bool labeledBlock = !(tryStmt->get_labels().empty());
     327                if ( labeledBlock ) {
     328                        if ( ! enclosingControlStructures.back().useBreakExit().empty() ) {
     329                                set_breakLabel( enclosingControlStructures.back().useBreakExit() );
     330                        } // if
     331                } // if
     332                return tryStmt;
     333        }
     334
    315335        void MLEMutator::premutate( CaseStmt *caseStmt ) {
    316336                visit_children = false;
  • src/ControlStruct/MLEMutator.h

    r396b830 r1fcc2f3  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Mar  8 16:42:32 2018
    13 // Update Count     : 41
     12// Last Modified On : Tue Oct 22 17:22:47 2019
     13// Update Count     : 45
    1414//
    1515
     
    4747                void premutate( SwitchStmt *switchStmt );
    4848                Statement * postmutate( SwitchStmt *switchStmt );
     49                void premutate( TryStmt *tryStmt );
     50                Statement * postmutate( TryStmt *tryStmt );
    4951
    5052                Statement *mutateLoop( Statement *bodyLoop, Entry &e );
     
    7375                        explicit Entry( SwitchStmt *stmt, Label breakExit, Label fallDefaultExit ) :
    7476                                stmt( stmt ), breakExit( breakExit ), fallDefaultExit( fallDefaultExit ) {}
     77
     78                        explicit Entry( TryStmt *stmt, Label breakExit ) :
     79                                stmt( stmt ), breakExit( breakExit ) {}
    7580
    7681                        bool operator==( const Statement *other ) { return stmt == other; }
  • tests/.expect/alloc-ERROR.txt

    r396b830 r1fcc2f3  
    1 alloc.cfa:265:1 error: No reasonable alternatives for expression Applying untyped:
     1alloc.cfa:311:1 error: No reasonable alternatives for expression Applying untyped:
    22  Name: ?=?
    33...to:
     
    1919
    2020
    21 alloc.cfa:266:1 error: No reasonable alternatives for expression Applying untyped:
     21alloc.cfa:312:1 error: No reasonable alternatives for expression Applying untyped:
    2222  Name: ?=?
    2323...to:
     
    3939
    4040
    41 alloc.cfa:267:1 error: No reasonable alternatives for expression Applying untyped:
     41alloc.cfa:313:1 error: No reasonable alternatives for expression Applying untyped:
    4242  Name: ?=?
    4343...to:
     
    5050
    5151
    52 alloc.cfa:268:1 error: No reasonable alternatives for expression Applying untyped:
     52alloc.cfa:314:1 error: No reasonable alternatives for expression Applying untyped:
    5353  Name: ?=?
    5454...to:
  • tests/.expect/alloc.txt

    r396b830 r1fcc2f3  
    22CFA malloc 0xdeadbeef
    33CFA alloc 0xdeadbeef
    4 CFA alloc, fill ffffffff
     4CFA array alloc, fill 0xde
     5CFA alloc, fill dededede
     6CFA alloc, fill 3
    57
    68C   array calloc, fill 0
     
    1012CFA array alloc, no fill
    11130xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef
    12 CFA array alloc, fill 0xff
    13 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff
     14CFA array alloc, fill 0xde
     150xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede
     16CFA array alloc, fill 0xef
     170xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef
     18CFA array alloc, fill from array
     190xefefefef 0xefefefef, 0xefefefef 0xefefefef, 0xefefefef 0xefefefef, 0xefefefef 0xefefefef, 0xefefefef 0xefefefef, 0xefefefef 0xefefefef, 0xefefefef 0xefefefef, 0xefefefef 0xefefefef, 0xefefefef 0xefefefef, 0xefefefef 0xefefefef, 0xefefefef 0xefefefef, 0xefefefef 0xefefefef, 0xefefefef 0xefefefef, 0xefefefef 0xefefefef, 0xefefefef 0xefefefef, 0xefefefef 0xefefefef, 0xefefefef 0xefefefef, 0xefefefef 0xefefefef, 0xefefefef 0xefefefef, 0xefefefef 0xefefefef,
    1420
    15 C   realloc
    16 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef
     21C realloc
     220xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef
    1723CFA realloc
    18 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101
     240xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101
    1925
    20 CFA resize alloc
     26CFA resize array alloc
    21270xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef
    2228CFA resize array alloc
     
    25310xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef
    2632CFA resize array alloc, fill
    27 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff
     330xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede
    2834CFA resize array alloc, fill
    29 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff
     350xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef
    3036CFA resize array alloc, fill
    31 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff
     370xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede
    3238
    3339C   memalign 42 42.5
     
    3541CFA posix_memalign 42 42.5
    3642CFA posix_memalign 42 42.5
    37 CFA aligned_alloc 42 42.5
    38 CFA align_alloc 42 42.5
    39 CFA align_alloc fill 0xffffffff -nan
     43CFA alloc_align 42 42.5
     44CFA alloc_align 42 42.5
     45CFA alloc_align fill 0xdededede -0x1.ededededededep+494
     46CFA alloc_align fill 42 42.5
     47CFA alloc_align 42 42.5
    4048
    41 CFA array align_alloc
     49CFA array alloc_align
    425042 42.5, 42 42.5, 42 42.5, 42 42.5, 42 42.5, 42 42.5, 42 42.5, 42 42.5, 42 42.5, 42 42.5,
    43 CFA array align_alloc, fill
    44 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan,
     51CFA array alloc_align, fill
     520xdededede -0x1.ededededededep+494, 0xdededede -0x1.ededededededep+494, 0xdededede -0x1.ededededededep+494, 0xdededede -0x1.ededededededep+494, 0xdededede -0x1.ededededededep+494, 0xdededede -0x1.ededededededep+494, 0xdededede -0x1.ededededededep+494, 0xdededede -0x1.ededededededep+494, 0xdededede -0x1.ededededededep+494, 0xdededede -0x1.ededededededep+494,
     53CFA array alloc_align, fill
     5442 42.5, 42 42.5, 42 42.5, 42 42.5, 42 42.5, 42 42.5, 42 42.5, 42 42.5, 42 42.5, 42 42.5,
     55CFA array alloc_align, fill array
     5642 42.5, 42 42.5, 42 42.5, 42 42.5, 42 42.5, 42 42.5, 42 42.5, 42 42.5, 42 42.5, 42 42.5,
     57CFA realloc array alloc_align
     5842 42.5, 42 42.5, 42 42.5, 42 42.5, 42 42.5, 42 42.5, 42 42.5, 42 42.5, 42 42.5, 42 42.5,
    4559
    46 CFA memset 0xffffffff -nan
    47 CFA memcpy 0xffffffff -nan
     60CFA memset 0xdededede -0x1.ededededededep+494
     61CFA memcpy 0xdededede -0x1.ededededededep+494
    4862
    4963CFA array memset
    50 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan,
     640xdededede -0x1.ededededededep+494, 0xdededede -0x1.ededededededep+494, 0xdededede -0x1.ededededededep+494, 0xdededede -0x1.ededededededep+494, 0xdededede -0x1.ededededededep+494, 0xdededede -0x1.ededededededep+494, 0xdededede -0x1.ededededededep+494, 0xdededede -0x1.ededededededep+494, 0xdededede -0x1.ededededededep+494, 0xdededede -0x1.ededededededep+494,
    5165CFA array memcpy
    52 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan,
     660xdededede -0x1.ededededededep+494, 0xdededede -0x1.ededededededep+494, 0xdededede -0x1.ededededededep+494, 0xdededede -0x1.ededededededep+494, 0xdededede -0x1.ededededededep+494, 0xdededede -0x1.ededededededep+494, 0xdededede -0x1.ededededededep+494, 0xdededede -0x1.ededededededep+494, 0xdededede -0x1.ededededededep+494, 0xdededede -0x1.ededededededep+494,
    5367
    5468CFA new initialize
  • tests/.expect/attributes.x64.txt

    r396b830 r1fcc2f3  
    784784signed int _X4apd7Fi_Fi_i_Fi_i___1(__attribute__ ((unused,unused,unused)) signed int (*__anonymous_object23)(__attribute__ ((unused)) signed int __anonymous_object24), __attribute__ ((unused,unused,unused)) signed int (*__anonymous_object25)(__attribute__ ((unused)) signed int __anonymous_object26));
    785785struct Vad {
    786     __attribute__ ((unused)) signed int __anonymous_object27:4;
    787     __attribute__ ((unused)) signed int __anonymous_object28:4;
    788     __attribute__ ((unused,unused)) signed int __anonymous_object29:6;
     786    __attribute__ ((unused)) signed int :4;
     787    __attribute__ ((unused)) signed int :4;
     788    __attribute__ ((unused,unused)) signed int :6;
    789789};
    790790static inline void _X12_constructorFv_S3Vad_autogen___1(struct Vad *_X4_dstS3Vad_1);
  • tests/.expect/attributes.x86.txt

    r396b830 r1fcc2f3  
    784784signed int _X4apd7Fi_Fi_i_Fi_i___1(__attribute__ ((unused,unused,unused)) signed int (*__anonymous_object23)(__attribute__ ((unused)) signed int __anonymous_object24), __attribute__ ((unused,unused,unused)) signed int (*__anonymous_object25)(__attribute__ ((unused)) signed int __anonymous_object26));
    785785struct Vad {
    786     __attribute__ ((unused)) signed int __anonymous_object27:4;
    787     __attribute__ ((unused)) signed int __anonymous_object28:4;
    788     __attribute__ ((unused,unused)) signed int __anonymous_object29:6;
     786    __attribute__ ((unused)) signed int :4;
     787    __attribute__ ((unused)) signed int :4;
     788    __attribute__ ((unused,unused)) signed int :6;
    789789};
    790790static inline void _X12_constructorFv_S3Vad_autogen___1(struct Vad *_X4_dstS3Vad_1);
  • tests/Makefile.am

    r396b830 r1fcc2f3  
    4646
    4747# adjust CC to current flags
    48 CC = $(if $(ifeq $(DISTCC_CFA_PATH),yes),distcc $(DISTCC_CFA_PATH),$(TARGET_CFA) ${DEBUG_FLAGS} ${ARCH_FLAGS})
     48CC = $(if $(DISTCC_CFA_PATH),distcc $(DISTCC_CFA_PATH),$(TARGET_CFA) ${DEBUG_FLAGS} ${ARCH_FLAGS})
    4949CFACC = $(CC)
    5050
  • tests/Makefile.in

    r396b830 r1fcc2f3  
    214214
    215215# adjust CC to current flags
    216 CC = $(if $(ifeq $(DISTCC_CFA_PATH),yes),distcc $(DISTCC_CFA_PATH),$(TARGET_CFA) ${DEBUG_FLAGS} ${ARCH_FLAGS})
     216CC = $(if $(DISTCC_CFA_PATH),distcc $(DISTCC_CFA_PATH),$(TARGET_CFA) ${DEBUG_FLAGS} ${ARCH_FLAGS})
    217217CCAS = @CCAS@
    218218CCASDEPMODE = @CCASDEPMODE@
  • tests/alloc.cfa

    r396b830 r1fcc2f3  
    1010// Created On       : Wed Feb  3 07:56:22 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Nov  6 17:50:52 2018
    13 // Update Count     : 339
     12// Last Modified On : Sun Oct 20 21:45:21 2019
     13// Update Count     : 391
    1414//
    1515
     
    1919#include <stdlib.h>                                                                             // posix_memalign
    2020#include <fstream.hfa>
    21 #include <stdlib.hfa>                                                                           // access C malloc, realloc
     21#include <stdlib.hfa>                                                                   // access C malloc, realloc
    2222
    2323int * foo( int * p, int c ) { return p; }
     
    2727int main( void ) {
    2828        size_t dim = 10;
    29         char fill = '\xff';
    30         int * p;
     29        char fill = '\xde';
     30        int * p, * p1;
    3131
    3232        // allocation, non-array types
    33 
    34         // int & r = malloc();
    35         // r = 0xdeadbeef;
    36         // printf( "C   malloc %#x\n", r );
    37         // free( &r );
    3833
    3934        p = (int *)malloc( sizeof(*p) );                                        // C malloc, type unsafe
     
    5247        free( p );
    5348
    54         p = alloc( fill );                                  // CFA alloc, fill
     49        p = alloc_set( fill );                                                          // CFA alloc, fill
     50        printf( "CFA array alloc, fill %#hhx\n", fill );
    5551        printf( "CFA alloc, fill %08x\n", *p );
     52        free( p );
     53
     54        p = alloc_set( 3 );                                                                     // CFA alloc, fill
     55        printf( "CFA alloc, fill %d\n", *p );
    5656        free( p );
    5757
     
    7979        free( p );
    8080
    81         p = alloc( 2 * dim, fill );                         // CFA array alloc, fill
     81        p = alloc_set( 2 * dim, fill );                                         // CFA array alloc, fill
    8282        printf( "CFA array alloc, fill %#hhx\n", fill );
    8383        for ( i; 2 * dim ) { printf( "%#x ", p[i] ); }
    8484        printf( "\n" );
    85         // do not free
     85        free( p );
     86
     87        p = alloc_set( 2 * dim, 0xdeadbeef );                           // CFA array alloc, fill
     88        printf( "CFA array alloc, fill %#hhx\n", 0xdeadbeef );
     89        for ( i; 2 * dim ) { printf( "%#x ", p[i] ); }
     90        printf( "\n" );
     91        // do not free
     92
     93        p1 = alloc_set( 2 * dim, p );                                           // CFA array alloc, fill
     94        printf( "CFA array alloc, fill from array\n" );
     95        for ( i; 2 * dim ) { printf( "%#x %#x, ", p[i], p1[i] ); }
     96        free( p1 );
     97        printf( "\n" );
    8698
    8799
     
    90102
    91103        p = (int *)realloc( p, dim * sizeof(*p) );                      // C realloc
    92         for ( i; dim ) { p[i] = 0xdeadbeef; }
    93         printf( "C   realloc\n" );
    94         for ( i; dim ) { printf( "%#x ", p[i] ); }
    95         printf( "\n" );
     104        printf( "C realloc\n" );
     105        for ( i; dim ) { printf( "%#x ", p[i] ); }
     106        printf( "\n" );
     107        // do not free
    96108
    97109        p = realloc( p, 2 * dim * sizeof(*p) );             // CFA realloc
     
    108120        p = alloc( p, dim );                                // CFA resize array alloc
    109121        for ( i; dim ) { p[i] = 0xdeadbeef; }
    110         printf( "CFA resize alloc\n" );
    111         for ( i; dim ) { printf( "%#x ", p[i] ); }
    112         printf( "\n" );
     122        printf( "CFA resize array alloc\n" );
     123        for ( i; dim ) { printf( "%#x ", p[i] ); }
     124        printf( "\n" );
     125        // do not free
    113126
    114127        p = alloc( p, 2 * dim );                            // CFA resize array alloc
     
    117130        for ( i; 2 * dim ) { printf( "%#x ", p[i] ); }
    118131        printf( "\n" );
    119 
    120         p = alloc( p, dim );                                // CFA array alloc
     132        // do not free
     133
     134        p = alloc( p, dim );                                // CFA resize array alloc
    121135        printf( "CFA resize array alloc\n" );
    122136        for ( i; dim ) { printf( "%#x ", p[i] ); }
    123137        printf( "\n" );
    124 
    125         free( p );
    126         p = 0;
    127 
    128         p = alloc( p, dim, fill );                          // CFA array alloc, fill
     138        // do not free
     139
     140        p = alloc_set( p, 3 * dim, fill );                                      // CFA resize array alloc, fill
    129141        printf( "CFA resize array alloc, fill\n" );
    130         for ( i; dim ) { printf( "%#x ", p[i] ); }
    131         printf( "\n" );
    132 
    133         p = alloc( p, 2 * dim, fill );                      // CFA array alloc, fill
     142        for ( i; 3 * dim ) { printf( "%#x ", p[i] ); }
     143        printf( "\n" );
     144        // do not free
     145
     146        p = alloc_set( p, dim, fill );                                          // CFA resize array alloc, fill
    134147        printf( "CFA resize array alloc, fill\n" );
    135         for ( i; 2 * dim ) { printf( "%#x ", p[i] ); }
    136         printf( "\n" );
    137 
    138         p = alloc( p, dim, fill );                          // CFA array alloc, fill
     148        for ( i; dim ) { printf( "%#x ", p[i] ); }
     149        printf( "\n" );
     150        // do not free
     151
     152        p = alloc_set( p, 3 * dim, fill );                                      // CFA resize array alloc, fill
    139153        printf( "CFA resize array alloc, fill\n" );
    140         for ( i; dim ) { printf( "%#x ", p[i] );; }
     154        for ( i; 3 * dim ) { printf( "%#x ", p[i] );; }
    141155        printf( "\n" );
    142156        free( p );
     
    172186        free( stp );
    173187
    174         stp = &(*aligned_alloc( Alignment )){ 42, 42.5 };     // CFA aligned_alloc
    175         assert( (uintptr_t)stp % Alignment == 0 );
    176         printf( "CFA aligned_alloc %d %g\n", stp->x, stp->y );
    177         free( stp );
    178 
    179         stp = &(*align_alloc( Alignment )){ 42, 42.5 };       // CFA align_alloc
    180         assert( (uintptr_t)stp % Alignment == 0 );
    181         printf( "CFA align_alloc %d %g\n", stp->x, stp->y );
    182         free( stp );
    183 
    184         stp = align_alloc( Alignment, fill );               // CFA memalign, fill
    185         assert( (uintptr_t)stp % Alignment == 0 );
    186         printf( "CFA align_alloc fill %#x %a\n", stp->x, stp->y );
     188        stp = &(*alloc_align( Alignment)){ 42, 42.5 };          // CFA alloc_align
     189        assert( (uintptr_t)stp % Alignment == 0 );
     190        printf( "CFA alloc_align %d %g\n", stp->x, stp->y );
     191        free( stp );
     192
     193        stp = &(*alloc_align( Alignment )){ 42, 42.5 };         // CFA alloc_align
     194        assert( (uintptr_t)stp % Alignment == 0 );
     195        printf( "CFA alloc_align %d %g\n", stp->x, stp->y );
     196        free( stp );
     197
     198        stp = alloc_align_set( Alignment, fill );                       // CFA memalign, fill
     199        assert( (uintptr_t)stp % Alignment == 0 );
     200        printf( "CFA alloc_align fill %#x %a\n", stp->x, stp->y );
     201        free( stp );
     202
     203        stp = alloc_align_set( Alignment, (Struct){ 42, 42.5 } ); // CFA memalign, fill
     204        assert( (uintptr_t)stp % Alignment == 0 );
     205        printf( "CFA alloc_align fill %d %g\n", stp->x, stp->y );
     206        // do not free
     207
     208        stp = &(*alloc_align( stp, 4096 )){ 42, 42.5 };         // CFA realign
     209        assert( (uintptr_t)stp % 4096 == 0 );
     210        printf( "CFA alloc_align %d %g\n", stp->x, stp->y );
    187211        free( stp );
    188212
     
    191215        printf( "\n" );
    192216
    193         stp = align_alloc( Alignment, dim );                // CFA array memalign
     217        stp = alloc_align( Alignment, dim );                // CFA array memalign
    194218        assert( (uintptr_t)stp % Alignment == 0 );
    195219        for ( i; dim ) { stp[i] = (Struct){ 42, 42.5 }; }
    196         printf( "CFA array align_alloc\n" );
     220        printf( "CFA array alloc_align\n" );
    197221        for ( i; dim ) { printf( "%d %g, ", stp[i].x, stp[i].y ); }
    198222        printf( "\n" );
    199223        free( stp );
    200224
    201         stp = align_alloc( Alignment, dim, fill );          // CFA array memalign, fill
    202         assert( (uintptr_t)stp % Alignment == 0 );
    203         printf( "CFA array align_alloc, fill\n" );
     225        stp = alloc_align_set( Alignment, dim, fill );          // CFA array memalign, fill
     226        assert( (uintptr_t)stp % Alignment == 0 );
     227        printf( "CFA array alloc_align, fill\n" );
    204228        for ( i; dim ) { printf( "%#x %a, ", stp[i].x, stp[i].y ); }
     229        printf( "\n" );
     230        free( stp );
     231
     232        stp = alloc_align_set( Alignment, dim, (Struct){ 42, 42.5 } ); // CFA array memalign, fill
     233        assert( (uintptr_t)stp % Alignment == 0 );
     234        printf( "CFA array alloc_align, fill\n" );
     235        for ( i; dim ) { printf( "%d %g, ", stp[i].x, stp[i].y ); }
     236        printf( "\n" );
     237        // do not free
     238
     239        stp1 = alloc_align_set( Alignment, dim, stp );          // CFA array memalign, fill
     240        assert( (uintptr_t)stp % Alignment == 0 );
     241        printf( "CFA array alloc_align, fill array\n" );
     242        for ( i; dim ) { printf( "%d %g, ", stp1[i].x, stp1[i].y ); }
     243        printf( "\n" );
     244        free( stp1 );
     245
     246        stp = alloc_align( stp, 4096, dim );                            // CFA aligned realloc array
     247        assert( (uintptr_t)stp % 4096 == 0 );
     248        for ( i; dim ) { stp[i] = (Struct){ 42, 42.5 }; }
     249        printf( "CFA realloc array alloc_align\n" );
     250        for ( i; dim ) { printf( "%d %g, ", stp[i].x, stp[i].y ); }
    205251        printf( "\n" );
    206252        free( stp );
  • tests/concurrent/examples/quickSort.cfa

    r396b830 r1fcc2f3  
    1111// Created On       : Wed Dec  6 12:15:52 2017
    1212// Last Modified By : Peter A. Buhr
    13 // Last Modified On : Fri Jun 21 08:27:45 2019
    14 // Update Count     : 172
     13// Last Modified On : Thu Oct 10 13:58:18 2019
     14// Update Count     : 176
    1515//
    1616
     
    6666                        if ( depth > 0 ) {
    6767                                depth -= 1;
    68                                 Quicksort rqs = { values, low, right, depth }; // concurrently sort upper half
    69                                 //Quicksort lqs( values, left, high, depth ); // concurrently sort lower half
    70                                 sort( values, left, high, depth );              // concurrently sort lower half
     68                                Quicksort lqs = { values, low, right, depth }; // concurrently sort lower half
     69                                Quicksort rqs = { values, left, high, depth }; // concurrently sort upper half
     70                                // Quicksort lqs = { values, low, right, depth }; // concurrently sort lower half
     71                                // sort( values, left, high, depth );           // concurrently sort upper half
    7172                        } else {
    7273                                sort( values, low, right, 0 );                  // sequentially sort lower half
     
    162163                processor processors[ (1 << depth) - 1 ] __attribute__(( unused )); // create 2^depth-1 kernel threads
    163164
    164                 int * values = alloc( size );                           // values to be sorted, too large to put on stack
    165                 for ( counter; size ) {                                         // generate unsorted numbers
     165                int * values = alloc( size );                                   // values to be sorted, too large to put on stack
     166                for ( counter; size ) {                                                 // generate unsorted numbers
    166167                        values[counter] = size - counter;                       // descending values
     168                } // for
     169                for ( int i = 0; i < 200; i +=1 ) {                             // random shuffle a few values
     170                        swap( values[rand() % size], values[rand() % size] );
    167171                } // for
    168172                {
     
    178182} // main
    179183
     184// for depth in 0 1 2 3 4 5 ; do echo "sort 500000000 values with ${depth} depth" ; time -f "%Uu %Ss %E %Mkb" a.out -t 500000000 ${depth} ; done
     185
    180186// Local Variables: //
    181187// tab-width: 4 //
  • tests/labelledExit.cfa

    r396b830 r1fcc2f3  
    1010// Created On       : Wed Aug 10 07:29:39 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Nov  6 17:57:42 2018
    13 // Update Count     : 4
     12// Last Modified On : Fri Oct 25 17:41:51 2019
     13// Update Count     : 7
    1414//
    1515
     
    136136        }
    137137
     138        // all nested control options, labelled exits
     139
     140  Comp: {
     141          Try: try {
     142                  For: for ( ;; ) {
     143                          While: while ( true ) {
     144                                  Do: do {
     145                                          If: if ( true ) {
     146                                                  Switch2: switch ( 3 ) {
     147                                                          case 3:
     148                                                                break Try;
     149                                                                break Comp;
     150                                                                break For;              continue For;
     151                                                                break While;    continue While;
     152                                                                break Do;               continue Do;
     153                                                                break If;
     154                                                                break Switch2;
     155                                                        } // switch
     156                                                } // if
     157                                        } while ( true );
     158                                } // while
     159                        } // for
     160                } finally {} // always executed
     161        } // compound
     162
    138163        // computed goto
    139164        // {
  • tests/pybin/tools.py

    r396b830 r1fcc2f3  
    2424# helper functions to run terminal commands
    2525def sh(*cmd, timeout = False, output_file = None, input_file = None, input_text = None, error = subprocess.STDOUT, ignore_dry_run = False):
    26         cmd = list(cmd)
    27 
    28         if input_file and input_text:
    29                 return 401, "Cannot use both text and file inputs"
    30 
    31         # if this is a dry_run, only print the commands that would be ran
    32         if settings.dry_run and not ignore_dry_run:
    33                 cmd = "{} cmd: {}".format(os.getcwd(), ' '.join(cmd))
    34                 if output_file and not isinstance(output_file, int):
    35                         cmd += " > "
    36                         cmd += output_file
    37 
    38                 if error and not isinstance(error, int):
    39                         cmd += " 2> "
    40                         cmd += error
    41 
    42                 if input_file and not isinstance(input_file, int) and os.path.isfile(input_file):
    43                         cmd += " < "
    44                         cmd += input_file
    45 
    46                 print(cmd)
    47                 return 0, None
    48 
    49         with contextlib.ExitStack() as onexit:
    50                 # add input redirection if needed
    51                 input_file = openfd(input_file, 'r', onexit, True)
    52 
    53                 # add output redirection if needed
    54                 output_file = openfd(output_file, 'w', onexit, False)
    55 
    56                 # add error redirection if needed
    57                 error = openfd(error, 'w', onexit, False)
    58 
    59                 # run the desired command
    60                 try:
    61                         proc = subprocess.run(
     26        try:
     27                cmd = list(cmd)
     28
     29                if input_file and input_text:
     30                        return 401, "Cannot use both text and file inputs"
     31
     32                # if this is a dry_run, only print the commands that would be ran
     33                if settings.dry_run and not ignore_dry_run:
     34                        cmd = "{} cmd: {}".format(os.getcwd(), ' '.join(cmd))
     35                        if output_file and not isinstance(output_file, int):
     36                                cmd += " > "
     37                                cmd += output_file
     38
     39                        if error and not isinstance(error, int):
     40                                cmd += " 2> "
     41                                cmd += error
     42
     43                        if input_file and not isinstance(input_file, int) and os.path.isfile(input_file):
     44                                cmd += " < "
     45                                cmd += input_file
     46
     47                        print(cmd)
     48                        return 0, None
     49
     50                with contextlib.ExitStack() as onexit:
     51                        # add input redirection if needed
     52                        input_file = openfd(input_file, 'r', onexit, True)
     53
     54                        # add output redirection if needed
     55                        output_file = openfd(output_file, 'w', onexit, False)
     56
     57                        # add error redirection if needed
     58                        error = openfd(error, 'w', onexit, False)
     59
     60                        # run the desired command
     61                        # use with statement to make sure proc is cleaned
     62                        # don't use subprocess.run because we want to send SIGABRT on exit
     63                        with subprocess.Popen(
    6264                                cmd,
    6365                                **({'input' : bytes(input_text, encoding='utf-8')} if input_text else {'stdin' : input_file}),
    6466                                stdout  = output_file,
    65                                 stderr  = error,
    66                                 timeout = settings.timeout.single if timeout else None
    67                         )
    68 
    69                         return proc.returncode, proc.stdout.decode("utf-8") if proc.stdout else None
    70                 except subprocess.TimeoutExpired:
    71                         return 124, str(None)
     67                                stderr  = error
     68                        ) as proc:
     69
     70                                try:
     71                                        out, _ = proc.communicate(
     72                                                timeout = settings.timeout.single if timeout else None
     73                                        )
     74
     75                                        return proc.returncode, out.decode("utf-8") if out else None
     76                                except subprocess.TimeoutExpired:
     77                                        proc.send_signal(signal.SIGABRT)
     78                                        proc.communicate()
     79                                        return 124, str(None)
     80
     81        except Exception as ex:
     82                print ("Unexpected error: %s" % ex)
     83                raise
    7284
    7385def is_ascii(fname):
     
    343355        # make a directory for this test
    344356        # mkdir makes the parent directory only so add a dummy
    345         mkdir(os.path.join(dst, "dir"))
     357        mkdir(os.path.join(dst, name ))
    346358
    347359        # moves the files
  • tests/test.py

    r396b830 r1fcc2f3  
    210210        except KeyboardInterrupt:
    211211                return False, ""
    212         except:
    213                 print("Unexpected error in worker thread", file=sys.stderr)
     212        except Exception as ex:
     213                print("Unexpected error in worker thread: %s" % ex, file=sys.stderr)
    214214                sys.stderr.flush()
    215215                return False, ""
Note: See TracChangeset for help on using the changeset viewer.