Changeset 1c507eb


Ignore:
Timestamp:
Sep 4, 2020, 2:00:53 PM (15 months ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
arm-eh, jacob/cs343-translation, master, new-ast-unique-expr
Children:
7a80113
Parents:
5a1c9ef (diff), 2801829 (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

Files:
5 added
17 edited

Legend:

Unmodified
Added
Removed
  • doc/LaTeXmacros/common.tex

    r5a1c9ef r1c507eb  
    1111%% Created On       : Sat Apr  9 10:06:17 2016
    1212%% Last Modified By : Peter A. Buhr
    13 %% Last Modified On : Mon Jul  9 08:28:05 2018
    14 %% Update Count     : 380
     13%% Last Modified On : Fri Sep  4 13:56:52 2020
     14%% Update Count     : 383
    1515%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    1616
     
    3636% Names used in the document.
    3737
     38\usepackage{xspace}
    3839\newcommand{\CFAIcon}{\textsf{C}\raisebox{\depth}{\rotatebox{180}{\textsf{A}}}\xspace} % Cforall symbolic name
    3940\newcommand{\CFA}{\protect\CFAIcon}             % safe for section/caption
     
    241242}%
    242243
     244\usepackage{listings}                                                                   % format program code
    243245\usepackage{lstlang}
    244246
  • doc/man/cfa.1

    r5a1c9ef r1c507eb  
    1111.\" Created On       : Wed Jul 26 22:34:47 2017
    1212.\" Last Modified By : Peter A. Buhr
    13 .\" Last Modified On : Thu Jul 27 10:29:29 2017
    14 .\" Update Count     : 44
     13.\" Last Modified On : Wed Sep  2 17:59:53 2020
     14.\" Update Count     : 78
    1515.\"
    1616.\" nroff -man cfa.1
     
    2323.ds Cf "Cforall
    2424.\"
    25 .TH cfa 1 2017-07-27 cfa-\*(Mg
     25.TH CFA 1 "2020-09-2" cfa-\*(Mg "\*(Cf Project"
    2626.SH NAME
    27 cfa \- \*(Cf Translator and Runtime Library
     27cfa \- \*(Cf project translator and runtime library to enhance C
    2828.SH SYNOPSIS
    29 cfa [gcc-options] [C/\*(Cf source-files] [assembler/loader files]
     29cfa [cfa/gcc-options]
     30    [cfa/c source-files]
     31    [assembler/loader files]
    3032.SH DESCRIPTION
     33\*(Cf (C-for-all) is an open-source project extending ISO C with modern safety and productivity features, while still ensuring backwards compatibility with C and its programmers.
     34
    3135The cfa command compiles C and \*(Cf source files and links C/\*(Cf object
    3236files named on the command line.
     
    3438The cfa command introduces a translator pass over the specified source files
    3539after the C preprocessor but before the C compilation.  The translator converts
    36 new \*(Cf constructs into C statements.  The cfa command also provides the
    37 runtime library, which is linked with each \*(Cf application.
     40new \*(Cf constructs into C statements.  The cfa command also provides a fully
     41concurrent (user-level threads) runtime library, which is linked with the
     42\*(Cf application.
    3843
    3944The command line options depend on the particular C compiler used (gcc/clang
    4045supported).  As with most C compilers, the output is sent to the file a.out(5)
    4146unless the -o option is present on the command line.  See the reference pages
    42 for gcc(1) for more information.
     47for gcc(1) for more information on command line options.
    4348.SH OPTIONS
    4449When multiple conflicting options appear on the command line, e.g.,
     
    5055All of the options available to the gcc compiler are available to the cfa
    5156translator.  The following gcc flags are implicitly turned on:
    52 .IP -std=gnu99 3
    53 The 1999 C standard plus GNU extensions.
    54 .IP -fgnu89-inline
    55 Use the traditional GNU semantics for inline routines in C99 mode, which allows inline routines in header files.
     57.IP "-std=gnu11" 3
     58The 2011 C standard plus GNU extensions.
     59.IP "-fgnu89-inline"
     60Use the traditional GNU semantics for inline routines in C11 mode, which allows inline routines in header files.
     61.IP "-imacros stdbool.h"
     62Include stdbool.h to get defines for bool/true/false.
     63.IP "-latomic -lm"
     64Provide access to double-wide CAS instruction and math library.
    5665.LP
    5766The following additional options are available:
    58 .IP -CFA 3
     67.IP "-CFA" 3
    5968Only the C preprocessor and the \*(Cf translator steps are performed and the transformed program is written to standard output, which makes it possible to examine the code generated by the \*(Cf translator.
    6069The generated code starts with the standard \*(Cf prelude.
    61 .IP -debug
     70.IP "-debug"
    6271The program is linked with the debugging version of the runtime system.
    6372The debug version performs runtime checks to help during the debugging phase of a \*(Cf program, but can substantially slow program execution.
    6473The runtime checks should only be removed after the program is completely debugged.
    6574.B This option is the default.
    66 .IP -nodebug
     75.IP "-nodebug"
    6776The program is linked with the non-debugging version of the runtime system, so the execution of the program is faster.
    6877.I However, no runtime checks or asserts are performed so errors usually result in abnormal program behaviour or termination.
    69 .IP -help
     78.IP "-help"
    7079Information about the set of \*(Cf compilation flags is printed.
    71 .IP -nohelp
     80.IP "-nohelp"
    7281Information about the set of \*(Cf compilation flags is not printed.
    7382.B This option is the default.
    74 .IP -quiet
     83.IP "-quiet"
    7584The \*(Cf compilation message is not printed at the beginning of a compilation.
    76 .IP -noquiet
     85.IP "-noquiet"
    7786The \*(Cf compilation message is printed at the beginning of a compilation.
    7887.B This option is the default.
     
    8190available.  These variables allow conditional compilation of programs that must
    8291work differently in these situations.
    83 .IP __CFA_MAJOR__ 3
     92.IP "__CFA_MAJOR__" 3
    8493is available during preprocessing and its value is the major version number of \*(Cf.
    85 .IP __CFA_MINOR__
     94.IP "__CFA_MINOR__"
    8695is available during preprocessing and its value is the minor version number of \*(Cf.
    87 .IP __CFA_PATCH__
     96.IP "__CFA_PATCH__"
    8897is available during preprocessing and its value is the patch level number of \*(Cf.
    8998.IP "__CFA__, __CFORALL__, and __cforall"
    9099are always available during preprocessing and have no value.
    91 .IP __CFA_DEBUG__
     100.IP "__CFA_DEBUG__"
    92101is available during preprocessing if the -debug compilation option is
    93102specified.
     
    116125.SH REFERENCES
    117126.HP 3
    118 \*(Cf Reference and Rational Manual
     127.I \*(Cf Home Page
    119128.br
    120 http://plg.uwaterloo.ca/~cforall/refrat.pdf
     129https://cforall.uwaterloo.ca
    121130.HP
    122131.I \*(Cf User Manual
    123132.br
    124 http://plg.uwaterloo.ca/~cforall/user.pdf
     133https://cforall.uwaterloo.ca/doc/user.pdf
     134.SH BUILDS
     135Nightly builds are available here https://cforall.uwaterloo.ca/jenkins
    125136.SH BUGS
    126 Bugs should be reported to trac@plg.cs.uwaterloo.ca.
     137Bugs reportss are available here https://cforall.uwaterloo.ca/trac
    127138.SH COPYRIGHT
    128139\*(Cf is covered under the licence agreement in the distribution.
    129140.SH AUTHORS
    130141Andrew Beach, Richard Bilson, Peter A. Buhr, Thierry Delisle, Glen Ditchfield,
    131 Rodolfo G. Esteves, Aaron Moss, Rob Schluntz
     142Rodolfo G. Esteves, Aaron Moss, Rob Schluntz, Mubeen Zulfiqar
  • driver/cfa.cc

    r5a1c9ef r1c507eb  
    1010// Created On       : Tue Aug 20 13:44:49 2002
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Aug 20 23:43:59 2020
    13 // Update Count     : 436
     12// Last Modified On : Wed Sep  2 17:59:20 2020
     13// Update Count     : 438
    1414//
    1515
     
    437437                #endif // __x86_64__
    438438                args[nargs++] = "-ldl";
    439                 args[nargs++] = "-lrt";
    440439                args[nargs++] = "-lm";
    441440        } // if
  • libcfa/src/bits/locks.hfa

    r5a1c9ef r1c507eb  
    218218        }
    219219
    220         // Semaphore which only supports a single thread and one post
    221         // Semaphore which only supports a single thread
     220        // Synchronozation primitive which only supports a single thread and one post
     221        // Similar to a binary semaphore with a 'one shot' semantic
     222        // is expected to be discarded after each party call their side
    222223        struct oneshot {
     224                // Internal state :
     225                //     0p     : is initial state (wait will block)
     226                //     1p     : fulfilled (wait won't block)
     227                // any thread : a thread is currently waiting
    223228                struct $thread * volatile ptr;
    224229        };
     
    231236                void ^?{}(oneshot & this) {}
    232237
     238                // Wait for the post, return immidiately if it already happened.
     239                // return true if the thread was parked
    233240                bool wait(oneshot & this) {
    234241                        for() {
     
    244251                }
    245252
     253                // Mark as fulfilled, wake thread if needed
     254                // return true if a thread was unparked
    246255                bool post(oneshot & this) {
    247256                        struct $thread * got = __atomic_exchange_n( &this.ptr, 1p, __ATOMIC_SEQ_CST);
     
    251260                }
    252261        }
     262
     263        // base types for future to build upon
     264        // It is based on the 'oneshot' type to allow multiple futures
     265        // to block on the same instance, permitting users to block a single
     266        // thread on "any of" [a given set of] futures.
     267        // does not support multiple threads waiting on the same future
     268        struct future_t {
     269                // Internal state :
     270                //     0p      : is initial state (wait will block)
     271                //     1p      : fulfilled (wait won't block)
     272                //     2p      : in progress ()
     273                //     3p      : abandoned, server should delete
     274                // any oneshot : a context has been setup to wait, a thread could wait on it
     275                struct oneshot * volatile ptr;
     276        };
     277
     278        static inline {
     279                void  ?{}(future_t & this) {
     280                        this.ptr = 0p;
     281                }
     282
     283                void ^?{}(future_t & this) {}
     284
     285                // check if the future is available
     286                bool available( future_t & this ) {
     287                        return this.ptr == 1p;
     288                }
     289
     290                // Prepare the future to be waited on
     291                // intented to be use by wait, wait_any, waitfor, etc. rather than used directly
     292                bool setup( future_t & this, oneshot & wait_ctx ) {
     293                        /* paranoid */ verify( wait_ctx.ptr == 0p );
     294                        // The future needs to set the wait context
     295                        for() {
     296                                struct oneshot * expected = this.ptr;
     297                                // Is the future already fulfilled?
     298                                if(expected == 1p) return false; // Yes, just return false (didn't block)
     299
     300                                // The future is not fulfilled, try to setup the wait context
     301                                /* paranoid */ verify( expected == 0p );
     302                                if(__atomic_compare_exchange_n(&this.ptr, &expected, &wait_ctx, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) {
     303                                        return true;
     304                                }
     305                        }
     306                }
     307
     308                // Stop waiting on a future
     309                // When multiple futures are waited for together in "any of" pattern
     310                // futures that weren't fulfilled before the thread woke up
     311                // should retract the wait ctx
     312                // intented to be use by wait, wait_any, waitfor, etc. rather than used directly
     313                void retract( future_t & this, oneshot & wait_ctx ) {
     314                        // Remove the wait context
     315                        struct oneshot * got = __atomic_exchange_n( &this.ptr, 0p, __ATOMIC_SEQ_CST);
     316
     317                        // got == 0p: future was never actually setup, just return
     318                        if( got == 0p ) return;
     319
     320                        // got == wait_ctx: since fulfil does an atomic_swap,
     321                        // if we got back the original then no one else saw context
     322                        // It is safe to delete (which could happen after the return)
     323                        if( got == &wait_ctx ) return;
     324
     325                        // got == 1p: the future is ready and the context was fully consumed
     326                        // the server won't use the pointer again
     327                        // It is safe to delete (which could happen after the return)
     328                        if( got == 1p ) return;
     329
     330                        // got == 2p: the future is ready but the context hasn't fully been consumed
     331                        // spin until it is safe to move on
     332                        if( got == 2p ) {
     333                                while( this.ptr != 1p ) Pause();
     334                                return;
     335                        }
     336
     337                        // got == any thing else, something wen't wrong here, abort
     338                        abort("Future in unexpected state");
     339                }
     340
     341                // Mark the future as abandoned, meaning it will be deleted by the server
     342                void abandon( future_t & this ) {
     343                        struct oneshot * got = __atomic_exchange_n( &this.ptr, 3p, __ATOMIC_SEQ_CST);
     344
     345                        // got == 2p: the future is ready but the context hasn't fully been consumed
     346                        // spin until it is safe to move on
     347                        if( got == 2p ) {
     348                                while( this.ptr != 1p ) Pause();
     349                        }
     350                        return;
     351                }
     352
     353                // from the server side, mark the future as fulfilled
     354                // delete it if needed
     355                bool fulfil( future_t & this ) {
     356                        for() {
     357                                struct oneshot * expected = this.ptr;
     358                                // was this abandoned?
     359                                if( expected == 3p ) { free( &this ); return false; }
     360
     361                                /* paranoid */ verify( expected != 1p ); // Future is already fulfilled, should not happen
     362                                /* paranoid */ verify( expected != 2p ); // Future is bein fulfilled by someone else, this is even less supported then the previous case.
     363
     364                                // If there is a wait context, we need to consume it and mark it as consumed after
     365                                // If there is no context then we can skip the in progress phase
     366                                struct oneshot * want = expected == 0p ? 1p : 2p;
     367                                if(__atomic_compare_exchange_n(&this.ptr, &expected, want, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) {
     368                                        if( expected == 0p ) { /* paranoid */ verify( this.ptr == 1p); return false; }
     369                                        bool ret = post( *expected );
     370                                        __atomic_store_n( &this.ptr, 1p, __ATOMIC_SEQ_CST);
     371                                        return ret;
     372                                }
     373                        }
     374
     375                }
     376
     377                // Wait for the future to be fulfilled
     378                bool wait( future_t & this ) {
     379                        oneshot temp;
     380                        if( !setup(this, temp) ) return false;
     381
     382                        // Wait context is setup, just wait on it
     383                        bool ret = wait( temp );
     384
     385                        // Wait for the future to tru
     386                        while( this.ptr == 2p ) Pause();
     387                        // Make sure the state makes sense
     388                        // Should be fulfilled, could be in progress but it's out of date if so
     389                        // since if that is the case, the oneshot was fulfilled (unparking this thread)
     390                        // and the oneshot should not be needed any more
     391                        __attribute__((unused)) struct oneshot * was = this.ptr;
     392                        /* paranoid */ verifyf( was == 1p, "Expected this.ptr to be 1p, was %p\n", was );
     393
     394                        // Mark the future as fulfilled, to be consistent
     395                        // with potential calls to avail
     396                        // this.ptr = 1p;
     397                        return ret;
     398                }
     399        }
    253400#endif
  • libcfa/src/heap.cfa

    r5a1c9ef r1c507eb  
    1010// Created On       : Tue Dec 19 21:58:35 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Aug 24 20:29:24 2020
    13 // Update Count     : 926
     12// Last Modified On : Thu Sep  3 16:22:54 2020
     13// Update Count     : 943
    1414//
    1515
     
    2929#include "math.hfa"                                                                             // ceiling
    3030#include "bitmanip.hfa"                                                                 // is_pow2, ceiling2
    31 
    32 #define MIN(x, y) (y > x ? x : y)
    3331
    3432static bool traceHeap = false;
     
    956954
    957955                headers( "realloc", naddr, header, freeElem, bsize, oalign );
    958                 memcpy( naddr, oaddr, MIN( osize, size ) );             // copy bytes
     956                memcpy( naddr, oaddr, min( osize, size ) );             // copy bytes
    959957                free( oaddr );
    960958
     
    12181216        #endif // __STATISTICS__
    12191217
    1220         // If size is equal to 0, either NULL or a pointer suitable to be passed to free() is returned.
    1221   if ( unlikely( size == 0 ) ) { free( oaddr ); return 0p; } // special cases
    1222   if ( unlikely( oaddr == 0p ) ) {
    1223                 #ifdef __STATISTICS__
    1224                 __atomic_add_fetch( &resize_storage, size, __ATOMIC_SEQ_CST );
    1225                 #endif // __STATISTICS__
    1226                 return memalignNoStats( nalign, size );
    1227         } // if
    1228 
    12291218        if ( unlikely( nalign < libAlign() ) ) nalign = libAlign(); // reset alignment to minimum
    12301219        #ifdef __CFA_DEBUG__
     
    12331222        #endif // __CFA_DEBUG__
    12341223
    1235         HeapManager.Storage.Header * header;
    1236         HeapManager.FreeHeader * freeElem;
    1237         size_t bsize, oalign;
    1238         headers( "resize", oaddr, header, freeElem, bsize, oalign );
    1239         size_t odsize = dataStorage( bsize, oaddr, header ); // data storage available in bucket
    1240 
    1241         if ( oalign <= nalign && (uintptr_t)oaddr % nalign == 0 ) { // <= alignment and new alignment happens to match
    1242                 if ( oalign > libAlign() ) {                                    // fake header ?
     1224        // If size is equal to 0, either NULL or a pointer suitable to be passed to free() is returned.
     1225  if ( unlikely( size == 0 ) ) { free( oaddr ); return 0p; } // special cases
     1226  if ( unlikely( oaddr == 0p ) ) {
     1227                #ifdef __STATISTICS__
     1228                __atomic_add_fetch( &resize_storage, size, __ATOMIC_SEQ_CST );
     1229                #endif // __STATISTICS__
     1230                return memalignNoStats( nalign, size );
     1231        } // if
     1232
     1233        // Attempt to reuse existing storage.
     1234        HeapManager.Storage.Header * header = headerAddr( oaddr );
     1235        if ( unlikely ( ( header->kind.fake.alignment & 1 == 1 &&       // old fake header ?
     1236                                 (uintptr_t)oaddr % nalign == 0 &&                              // lucky match ?
     1237                                 header->kind.fake.alignment <= nalign &&               // ok to leave LSB at 1
     1238                                 nalign <= 128 )                                                                // not too much alignment storage wasted ?
     1239                        ||   ( header->kind.fake.alignment & 1 != 1 &&          // old real header ( aligned on libAlign ) ?
     1240                                 nalign == libAlign() ) ) ) {                                   // new alignment also on libAlign
     1241
     1242                HeapManager.FreeHeader * freeElem;
     1243                size_t bsize, oalign;
     1244                headers( "resize", oaddr, header, freeElem, bsize, oalign );
     1245                size_t odsize = dataStorage( bsize, oaddr, header ); // data storage available in bucket
     1246
     1247                if ( size <= odsize && odsize <= size * 2 ) { // allow 50% wasted data storage
    12431248                        headerAddr( oaddr )->kind.fake.alignment = nalign | 1; // update alignment (could be the same)
    1244                 } // if
    1245                 if ( size <= odsize && odsize <= size * 2 ) {   // allow 50% wasted storage for smaller size
    1246                         header->kind.real.blockSize &= -2;                      // turn off 0 fill
    1247                         header->kind.real.size = size;                          // reset allocation size
     1249
     1250                        header->kind.real.blockSize &= -2;              // turn off 0 fill
     1251                        header->kind.real.size = size;                  // reset allocation size
    12481252                        return oaddr;
    12491253                } // if
     
    12671271        #endif // __CFA_DEBUG__
    12681272
     1273        // If size is equal to 0, either NULL or a pointer suitable to be passed to free() is returned.
     1274  if ( unlikely( size == 0 ) ) { free( oaddr ); return 0p; } // special cases
     1275  if ( unlikely( oaddr == 0p ) ) {
     1276                #ifdef __STATISTICS__
     1277                __atomic_add_fetch( &realloc_calls, 1, __ATOMIC_SEQ_CST );
     1278                __atomic_add_fetch( &realloc_storage, size, __ATOMIC_SEQ_CST );
     1279                #endif // __STATISTICS__
     1280                return memalignNoStats( nalign, size );
     1281        } // if
     1282
    12691283        HeapManager.Storage.Header * header;
    12701284        HeapManager.FreeHeader * freeElem;
     
    12721286        headers( "realloc", oaddr, header, freeElem, bsize, oalign );
    12731287
    1274         if ( oalign <= nalign && (uintptr_t)oaddr % nalign == 0 ) { // <= alignment and new alignment happens to match
    1275                 if ( oalign > libAlign() ) {                                    // fake header ?
    1276                         headerAddr( oaddr )->kind.fake.alignment = nalign | 1; // update alignment (could be the same)
    1277                 } // if
     1288        // Attempt to reuse existing storage.
     1289        if ( unlikely ( ( header->kind.fake.alignment & 1 == 1 &&       // old fake header ?
     1290                                 (uintptr_t)oaddr % nalign == 0 &&                              // lucky match ?
     1291                                 header->kind.fake.alignment <= nalign &&               // ok to leave LSB at 1
     1292                                 nalign <= 128 )                                                                // not too much alignment storage wasted ?
     1293                        ||   ( header->kind.fake.alignment & 1 != 1 &&          // old real header ( aligned on libAlign ) ?
     1294                                 nalign == libAlign() ) ) ) {                                   // new alignment also on libAlign
     1295
     1296                headerAddr( oaddr )->kind.fake.alignment = nalign | 1; // update alignment (could be the same)
    12781297                return realloc( oaddr, size );
     1298
    12791299        } // if
    12801300
     
    12861306        #endif // __STATISTICS__
    12871307
    1288         // If size is equal to 0, either NULL or a pointer suitable to be passed to free() is returned.
    1289   if ( unlikely( size == 0 ) ) { free( oaddr ); return 0p; } // special cases
    1290   if ( unlikely( oaddr == 0p ) ) return memalignNoStats( nalign, size );
    1291 
    12921308        size_t osize = header->kind.real.size;                          // old allocation size
    12931309        bool ozfill = (header->kind.real.blockSize & 2) != 0; // old allocation zero filled
     
    12961312
    12971313        headers( "realloc", naddr, header, freeElem, bsize, oalign );
    1298         memcpy( naddr, oaddr, MIN( osize, size ) );                     // copy bytes
     1314        memcpy( naddr, oaddr, min( osize, size ) );                     // copy bytes
    12991315        free( oaddr );
    13001316
  • libcfa/src/stdlib.hfa

    r5a1c9ef r1c507eb  
    1010// Created On       : Thu Jan 28 17:12:35 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Aug 14 23:38:50 2020
    13 // Update Count     : 504
     12// Last Modified On : Tue Sep  1 20:32:34 2020
     13// Update Count     : 505
    1414//
    1515
     
    4444
    4545// Macro because of returns
    46 #define $VAR_ALLOC( allocation, alignment ) \
    47         if ( _Alignof(T) <= libAlign() ) return (T *)(void *)allocation( (size_t)sizeof(T) ); /* C allocation */ \
    48         else return (T *)alignment( _Alignof(T), sizeof(T) )
    49 
    5046#define $ARRAY_ALLOC( allocation, alignment, dim ) \
    5147        if ( _Alignof(T) <= libAlign() ) return (T *)(void *)allocation( dim, (size_t)sizeof(T) ); /* C allocation */ \
    5248        else return (T *)alignment( _Alignof(T), dim, sizeof(T) )
    5349
    54 #define $RE_SPECIALS( ptr, size, allocation, alignment ) \
    55         if ( unlikely( size == 0 ) || unlikely( ptr == 0p ) ) { \
    56                 if ( unlikely( size == 0 ) ) free( ptr ); \
    57                 $VAR_ALLOC( malloc, memalign ); \
    58         } /* if */
    59 
    6050static inline forall( dtype T | sized(T) ) {
    6151        // Cforall safe equivalents, i.e., implicit size specification
    6252
    6353        T * malloc( void ) {
    64                 $VAR_ALLOC( malloc, memalign );
     54                if ( _Alignof(T) <= libAlign() ) return (T *)(void *)malloc( (size_t)sizeof(T) ); // C allocation
     55                else return (T *)memalign( _Alignof(T), sizeof(T) );
    6556        } // malloc
    6657
     
    7465
    7566        T * resize( T * ptr, size_t size ) {                            // CFA resize, eliminate return-type cast
    76                 $RE_SPECIALS( ptr, size, malloc, memalign );
    7767                if ( _Alignof(T) <= libAlign() ) return (T *)(void *)resize( (void *)ptr, size ); // CFA resize
    7868                else return (T *)(void *)resize( (void *)ptr, _Alignof(T), size ); // CFA resize
     
    8070
    8171        T * realloc( T * ptr, size_t size ) {                           // CFA realloc, eliminate return-type cast
    82                 $RE_SPECIALS( ptr, size, malloc, memalign );
    8372                if ( _Alignof(T) <= libAlign() ) return (T *)(void *)realloc( (void *)ptr, size ); // C realloc
    8473                else return (T *)(void *)realloc( (void *)ptr, _Alignof(T), size ); // CFA realloc
     
    189178                size_t copy_end = 0;
    190179
    191                 if(Resize) {
    192                         ptr = (T*) (void *) resize( (int *)Resize, Align, Dim * size );
    193                 } else if (Realloc) {
     180                if ( Resize ) {
     181                        ptr = (T*) (void *) resize( (void *)Resize, Align, Dim * size );
     182                } else if ( Realloc ) {
    194183                        if (Fill.tag != '0') copy_end = min(malloc_size( Realloc ), Dim * size);
    195                         ptr = (T*) (void *) realloc( (int *)Realloc, Align, Dim * size );
     184                        ptr = (T*) (void *) realloc( (void *)Realloc, Align, Dim * size );
    196185                } else {
    197186                        ptr = (T*) (void *) memalign( Align, Dim * size );
  • src/AST/Pass.hpp

    r5a1c9ef r1c507eb  
    4848//
    4949// Several additional features are available through inheritance
     50// | PureVisitor           - makes the visitor pure, it never modifies nodes in place and always
     51//                           clones nodes it needs to make changes to
    5052// | WithTypeSubstitution  - provides polymorphic const TypeSubstitution * env for the
    5153//                           current expression
     
    267269/// Keep track of the polymorphic const TypeSubstitution * env for the current expression
    268270
    269 /// marker to force shallow copies in pass visit
     271/// If used the visitor will always clone nodes.
    270272struct PureVisitor {};
    271273
  • src/AST/Pass.impl.hpp

    r5a1c9ef r1c507eb  
    2121
    2222#include "AST/TypeSubstitution.hpp"
    23 // #include "AST/Copy.hpp"
    2423
    2524#define VISIT_START( node ) \
     
    329328
    330329                if( __pass::differs(old_val, new_val) ) {
    331                         // auto new_parent = mutate(parent);
    332330                        auto new_parent = __pass::mutate<core_t>(parent);
    333331                        new_parent->*child = new_val;
  • src/AST/TypeSubstitution.hpp

    r5a1c9ef r1c507eb  
    4646        template< typename SynTreeClass >
    4747        struct ApplyResult {
    48                 // const SynTreeClass * node;
    4948                ast::ptr<SynTreeClass> node;
    5049                int count;
     
    187186        assert( input );
    188187        Pass<Substituter> sub( *this, false );
    189 //      input = strict_dynamic_cast< const SynTreeClass * >( deepCopy(input)->accept( sub ) );
    190188        input = strict_dynamic_cast< const SynTreeClass * >( input->accept( sub ) );
    191189        return { input, sub.core.subCount };
     
    196194        assert( input );
    197195        Pass<Substituter> sub( *this, true );
    198 //      input = strict_dynamic_cast< const SynTreeClass * >( deepCopy(input)->accept( sub ) );
    199196        input = strict_dynamic_cast< const SynTreeClass * >( input->accept( sub ) );
    200197        return { input, sub.core.subCount };
  • src/ResolvExpr/Unify.cc

    r5a1c9ef r1c507eb  
    11131113                        ast::Pass<TtypeExpander_new> expander{ tenv };
    11141114
    1115                         // ast::ptr<ast::TupleType> tuplec = tuple;
    1116                         // ast::ptr<ast::TupleType> tuple2c = tuple2;
    11171115                        const ast::Type * flat = tuple->accept( expander );
    11181116                        const ast::Type * flat2 = tuple2->accept( expander );
  • tests/.expect/alloc-ERROR.txt

    r5a1c9ef r1c507eb  
    1 alloc.cfa:362:1 error: No reasonable alternatives for expression Applying untyped:
     1alloc.cfa:361:1 error: No reasonable alternatives for expression Applying untyped:
    22  Name: ?=?
    33...to:
     
    1616          Name: stp
    1717
    18       with resolved type:
    19         unsigned long int
    2018
    2119
    2220
    23 alloc.cfa:363:1 error: No reasonable alternatives for expression Applying untyped:
     21alloc.cfa:362:1 error: No reasonable alternatives for expression Applying untyped:
    2422  Name: ?=?
    2523...to:
     
    3028    Name: stp
    3129    constant expression (10 10: signed int)
    32     with resolved type:
    33       signed int
    3430
    3531
    36 alloc.cfa:364:1 error: No reasonable alternatives for expression Applying untyped:
     32alloc.cfa:363:1 error: No reasonable alternatives for expression Applying untyped:
    3733  Name: ?=?
    3834...to:
  • tests/.expect/alloc.txt

    r5a1c9ef r1c507eb  
    14140xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede
    1515CFA array alloc, fill 0xef
    16 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef
     160xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef
    1717CFA array alloc, fill from array
    18 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 0xefefefef,
     180xdeadbeef 0xdeadbeef, 0xdeadbeef 0xdeadbeef, 0xdeadbeef 0xdeadbeef, 0xdeadbeef 0xdeadbeef, 0xdeadbeef 0xdeadbeef, 0xdeadbeef 0xdeadbeef, 0xdeadbeef 0xdeadbeef, 0xdeadbeef 0xdeadbeef, 0xdeadbeef 0xdeadbeef, 0xdeadbeef 0xdeadbeef, 0xdeadbeef 0xdeadbeef, 0xdeadbeef 0xdeadbeef, 0xdeadbeef 0xdeadbeef, 0xdeadbeef 0xdeadbeef, 0xdeadbeef 0xdeadbeef, 0xdeadbeef 0xdeadbeef, 0xdeadbeef 0xdeadbeef, 0xdeadbeef 0xdeadbeef, 0xdeadbeef 0xdeadbeef, 0xdeadbeef 0xdeadbeef,
    1919
    2020C realloc
    21 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef
     210xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef
    2222CFA realloc
    23 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101
     230xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101
    2424
    2525CFA realloc array alloc
  • tests/alloc2.cfa

    r5a1c9ef r1c507eb  
    1 /*
    2         some tests are commented-out because of resize/realloc bug from 0p. They should be uncommented after that bug is resolved.
    3 */
    4 
    51#include <malloc.h>                                                                             // malloc_usable_size
    62#include <stdint.h>                                                                             // uintptr_t
     
    2016        if (!passed) {
    2117                printf("failed test %3d: %4lu %4lu but got %4lu ( %3lu ) %4lu\n", tests_total, size, align, malloc_size(ip), malloc_usable_size(ip), malloc_alignment(ip));
    22 //              if (last_failed != tests_total) {
    23                         tests_failed += 1;
    24 //                      last_failed = tests_total;
    25 //              }
     18                tests_failed += 1;
    2619        }
    2720}
     
    3427        if (!passed) {
    3528                printf("failed test %3d: fill C\n", tests_total);
    36 //              if (last_failed != tests_total) {
    37                         tests_failed += 1;
    38 //                      last_failed = tests_total;
    39 //              }
     29                tests_failed += 1;
    4030        }
    4131}
     
    4838        if (!passed) {
    4939                printf("failed test %3d: fill int\n", tests_total);
    50 //              if (last_failed != tests_total) {
    51                         tests_failed += 1;
    52 //                      last_failed = tests_total;
    53 //              }
     40                tests_failed += 1;
    5441        }
    5542}
     
    6047        if (!passed) {
    6148                printf("failed test %3d: fill int A\n", tests_total);
    62 //              if (last_failed != tests_total) {
    63                         tests_failed += 1;
    64 //                      last_failed = tests_total;
    65 //              }
     49                tests_failed += 1;
    6650        }
    6751}
     
    7458        if (!passed) {
    7559                printf("failed test %3d: fill T1\n", tests_total);
    76 //              if (last_failed != tests_total) {
    77                         tests_failed += 1;
    78 //                      last_failed = tests_total;
    79 //              }
     60                tests_failed += 1;
    8061        }
    8162}
     
    8667        if (!passed) {
    8768                printf("failed test %3d: fill T1 A\n", tests_total);
    88 //              if (last_failed != tests_total) {
    89                         tests_failed += 1;
    90 //                      last_failed = tests_total;
    91 //              }
     69                tests_failed += 1;
    9270        }
    9371}
     
    10078        if (!passed) {
    10179                printf("failed test %3d: use int\n", tests_total);
    102 //              if (last_failed != tests_total) {
    103                         tests_failed += 1;
    104 //                      last_failed = tests_total;
    105 //              }
     80                tests_failed += 1;
    10681        }
    10782}
     
    11489        if (!passed) {
    11590                printf("failed test %3d: use T1\n", tests_total);
    116 //              if (last_failed != tests_total) {
    117                         tests_failed += 1;
    118 //                      last_failed = tests_total;
    119 //              }
     91                tests_failed += 1;
    12092        }
    12193}
     
    331303        free(ip);
    332304
    333 //      ip = alloc( 0, ((int*)0p)`realloc, FillT`fill );
    334 //      est_base(ip, 0, libAlign);
    335 //      free(ip);
     305        ip = alloc( 0, ((int*)0p)`realloc, FillT`fill );
     306        test_base(ip, 0, libAlign);
     307        free(ip);
    336308
    337309        ip = alloc( align`align );
     
    356328        free(ip);
    357329
    358 //      ip = alloc( ((int*)0p)`realloc, align`align );
    359 //      est_base(ip, elemSize, align);
    360 //      est_use(ip, elemSize / elemSize);
    361 //      free(ip);
     330        ip = alloc( ((int*)0p)`realloc, align`align );
     331        test_base(ip, elemSize, align);
     332        test_use(ip, elemSize / elemSize);
     333        free(ip);
    362334
    363335        dp = alloc( dim );
     
    367339        free(ip);
    368340
    369 //      ip = alloc( ((double*)0p)`resize, align`align );
    370 //      est_base(ip, elemSize, align);
    371 //      est_use(ip, elemSize / elemSize);
    372 //      free(ip);
     341        ip = alloc( ((double*)0p)`resize, align`align );
     342        test_base(ip, elemSize, align);
     343        test_use(ip, elemSize / elemSize);
     344        free(ip);
    373345
    374346        op = alloc( dim, ((int)0xdeadbeef)`fill);
     
    384356        free(ip);
    385357
    386 //      ip = alloc( dim, ((int*)0p)`realloc, align`align );
    387 //      est_base(ip, size, align);
    388 //      est_use(ip, size / elemSize);
    389 //      free(ip);
    390 
    391 //      ip = alloc( 0, ((int*)0p)`realloc, align`align );
    392 //      est_base(ip, 0, align);
    393 //      free(ip);
     358        ip = alloc( dim, ((int*)0p)`realloc, align`align );
     359        test_base(ip, size, align);
     360        test_use(ip, size / elemSize);
     361        free(ip);
     362
     363        ip = alloc( 0, ((int*)0p)`realloc, align`align );
     364        test_base(ip, 0, libAlign);
     365        free(ip);
    394366
    395367        ip = alloc( align`align, FillC`fill );
     
    462434        free(ip);
    463435
    464 //      ip = alloc( dim, ((int*)0p)`realloc, align`align, FillC`fill );
    465 //      est_base(ip, size, align);
    466 //      est_fill(ip, 0, size, FillC);
    467 //      est_use(ip, size / elemSize);
    468 //      free(ip);
    469 
    470 //      ip = alloc( 0, ((int*)0p)`realloc, align`align, FillC`fill );
    471 //      est_base(ip, 0, align);
    472 //      free(ip);
     436        ip = alloc( dim, ((int*)0p)`realloc, align`align, FillC`fill );
     437        test_base(ip, size, align);
     438        test_fill(ip, 0, size, FillC);
     439        test_use(ip, size / elemSize);
     440        free(ip);
     441
     442        ip = alloc( 0, ((int*)0p)`realloc, align`align, FillC`fill );
     443        test_base(ip, 0, libAlign);
     444        free(ip);
    473445
    474446        op = alloc( dim, ((int)0xdeadbeef)`fill );
     
    499471        free(ip);
    500472
    501 //      ip = alloc( dim, ((int*)0p)`realloc, align`align, FillT`fill );
    502 //      est_base(ip, size, align);
    503 //      est_fill(ip, 0, dim, FillT);
    504 //      est_use(ip, size / elemSize);
    505 //      free(ip);
    506 
    507 //      ip = alloc( 0, ((int*)0p)`realloc, align`align, FillT`fill );
    508 //      est_base(ip, 0, align);
    509 //      free(ip);
     473        ip = alloc( dim, ((int*)0p)`realloc, align`align, FillT`fill );
     474        test_base(ip, size, align);
     475        test_fill(ip, 0, dim, FillT);
     476        test_use(ip, size / elemSize);
     477        free(ip);
     478
     479        ip = alloc( 0, ((int*)0p)`realloc, align`align, FillT`fill );
     480        test_base(ip, 0, libAlign);
     481        free(ip);
    510482
    511483        if (tests_failed == 0) printf("PASSED alloc tests\n\n");
     
    704676        free(t1p);
    705677
    706 //      t1p = alloc( (T1*)0p, 0, FillT1 );
    707 //      est_base(t1p, 0, tAlign);
    708 //      free(t1p);
     678        t1p = alloc( 0, ((T1*)0p)`realloc, FillT1`fill );
     679        test_base(t1p, 0, libAlign);
     680        free(t1p);
    709681
    710682        t1p = alloc( align`align );
     
    729701        free(t1p);
    730702
    731 //      t1p = alloc( ((T1*)0p)`realloc, align`align );
    732 //      est_base(t1p, elemSize, align);
    733 //      est_use(t1p, elemSize / elemSize);
    734 //      free(t1p);
     703        t1p = alloc( ((T1*)0p)`realloc, align`align );
     704        test_base(t1p, elemSize, align);
     705        test_use(t1p, elemSize / elemSize);
     706        free(t1p);
    735707
    736708        dp = alloc( dim );
     
    740712        free(t1p);
    741713
    742 //      t1p = alloc( ((double*)0p)`resize, align`align );
    743 //      est_base(t1p, elemSize, align);
    744 //      est_use(t1p, elemSize / elemSize);
    745 //      free(t1p);
     714        t1p = alloc( ((double*)0p)`resize, align`align );
     715        test_base(t1p, elemSize, align);
     716        test_use(t1p, elemSize / elemSize);
     717        free(t1p);
    746718
    747719        t1op = alloc( dim, ((T1){0xdeadbeef})`fill );
     
    757729        free(t1p);
    758730
    759 //      t1p = alloc( dim, ((T1*)0p)`realloc, align`align );
    760 //      est_base(t1p, size, align);
    761 //      est_use(t1p, size / elemSize);
    762 //      free(t1p);
    763 
    764 //      t1p = alloc( 0, ((T1*)0p)`realloc, align`align );
    765 //      est_base(t1p, 0, align);
    766 //      free(t1p);
     731        t1p = alloc( dim, ((T1*)0p)`realloc, align`align );
     732        test_base(t1p, size, align);
     733        test_use(t1p, size / elemSize);
     734        free(t1p);
     735
     736        t1p = alloc( 0, ((T1*)0p)`realloc, align`align );
     737        test_base(t1p, 0, libAlign);
     738        free(t1p);
    767739
    768740        t1p = alloc( align`align, FillC`fill );
     
    835807        free(t1p);
    836808
    837 //      t1p = alloc( dim, ((T1*)0p)`realloc, align`align, FillC`fill );
    838 //      est_base(t1p, size, align);
    839 //      est_fill(t1p, 0, size, FillC);
    840 //      est_use(t1p, size / elemSize);
    841 //      free(t1p);
    842 
    843 //      t1p = alloc( 0, ((T1*)0p)`realloc, align`align, FillC`fill );
    844 //      est_base(t1p, 0, align);
    845 //      free(t1p);
     809        t1p = alloc( dim, ((T1*)0p)`realloc, align`align, FillC`fill );
     810        test_base(t1p, size, align);
     811        test_fill(t1p, 0, size, FillC);
     812        test_use(t1p, size / elemSize);
     813        free(t1p);
     814
     815        t1p = alloc( 0, ((T1*)0p)`realloc, align`align, FillC`fill );
     816        test_base(t1p, 0, libAlign);
     817        free(t1p);
    846818
    847819        t1op = alloc( dim, ((T1){0xdeadbeef})`fill);
     
    872844        free(t1p);
    873845
    874 //      t1p = alloc( dim, ((T1*)0p)`realloc, align`aling, FillT1`fill );
    875 //      est_base(t1p, size, align);
    876 //      est_fill(t1p, 0, dim, FillT1);
    877 //      est_use(t1p, size / elemSize);
    878 //      free(t1p);
    879 
    880 //      t1p = alloc( 0, ((T1*)0p)`realloc, align`align, FillT1`fill );
    881 //      est_base(t1p, 0, align);
    882 //      free(t1p);
     846        t1p = alloc( dim, ((T1*)0p)`realloc, align`align, FillT1`fill );
     847        test_base(t1p, size, align);
     848        test_fill(t1p, 0, dim, FillT1);
     849        test_use(t1p, size / elemSize);
     850        free(t1p);
     851
     852        t1p = alloc( 0, ((T1*)0p)`realloc, align`align, FillT1`fill );
     853        test_base(t1p, 0, libAlign);
     854        free(t1p);
    883855
    884856        if (tests_failed == 0) printf("PASSED alloc tests (aligned struct)\n\n");
  • tests/concurrent/examples/boundedBufferEXT.cfa

    r5a1c9ef r1c507eb  
    11//
    22// Cforall Version 1.0.0 Copyright (C) 2018 University of Waterloo
    3 // 
     3//
    44// The contents of this file are covered under the licence agreement in the
    55// file "LICENCE" distributed with Cforall.
     
    8787}
    8888
     89enum { Prods = 4, Cons = 5 };
     90Producer * prods[Prods];
     91Consumer * cons[Cons];
     92
    8993int main() {
    9094        Buffer(int) buffer;
    91         enum { Prods = 4, Cons = 5 };
    92         Producer * prods[Prods];
    93         Consumer * cons[Cons];
    9495        int sums[Cons];
    9596        int i;
  • tests/errors/.expect/completeType.x86.txt

    r5a1c9ef r1c507eb  
    66    Name: x
    77
    8 ... to: nothing
    9 with resolved type:
    10   void  Alternatives are:
     8... to: nothing Alternatives are:
    119Cost ( 0, 1, 2, 0, 1, -1, 0 ): Generated Cast of:
    1210      Application of
     
    2220
    2321
    24         with resolved type:
    25           pointer to forall
    26             _89_4_DT: data type
    27             function
    28           ... with parameters
    29             intrinsic pointer to instance of type _89_4_DT (not function type)
    30           ... returning
    31             _retval__operator_deref: reference to instance of type _89_4_DT (not function type)
    32             ... with attributes:
    33               Attribute with name: unused
    34 
    35 
    3622      ... to arguments
    3723        Variable Expression: x: pointer to instance of struct A with body 0
    38         with resolved type:
    39           pointer to instance of struct A with body 0
    4024
    41       with resolved type:
    42         reference to instance of struct A with body 0
    4325    ... to: nothing
    44     with resolved type:
    45       void
    4626  (types:
    4727    void
     
    6343
    6444
    65         with resolved type:
    66           pointer to forall
    67             _89_4_DT: data type
    68             function
    69           ... with parameters
    70             intrinsic pointer to instance of type _89_4_DT (not function type)
    71           ... returning
    72             _retval__operator_deref: reference to instance of type _89_4_DT (not function type)
    73             ... with attributes:
    74               Attribute with name: unused
    75 
    76 
    7745      ... to arguments
    7846        Variable Expression: x: pointer to instance of struct B with body 1
    79         with resolved type:
    80           pointer to instance of struct B with body 1
    8147
    82       with resolved type:
    83         reference to instance of struct B with body 1
    8448    ... to: nothing
    85     with resolved type:
    86       void
    8749  (types:
    8850    void
     
    159121            ... returning nothing
    160122
    161             with resolved type:
    162               pointer to forall
    163                 _108_0_T: sized data type
    164                 ... with assertions
    165                   ?=?: pointer to function
    166                   ... with parameters
    167                     reference to instance of type _108_0_T (not function type)
    168                     instance of type _108_0_T (not function type)
    169                   ... returning
    170                     _retval__operator_assign: instance of type _108_0_T (not function type)
    171                     ... with attributes:
    172                       Attribute with name: unused
    173 
    174 
    175                   ?{}: pointer to function
    176                   ... with parameters
    177                     reference to instance of type _108_0_T (not function type)
    178                   ... returning nothing
    179 
    180                   ?{}: pointer to function
    181                   ... with parameters
    182                     reference to instance of type _108_0_T (not function type)
    183                     instance of type _108_0_T (not function type)
    184                   ... returning nothing
    185 
    186                   ^?{}: pointer to function
    187                   ... with parameters
    188                     reference to instance of type _108_0_T (not function type)
    189                   ... returning nothing
    190 
    191 
    192                 function
    193               ... with parameters
    194                 pointer to instance of type _108_0_T (not function type)
    195               ... returning nothing
    196 
    197123          ... to arguments
    198124            Variable Expression: z: pointer to instance of type T (not function type)
    199             with resolved type:
    200               pointer to instance of type T (not function type)
    201125
    202           with resolved type:
    203             void
    204126        (types:
    205127          void
  • tests/malloc.cfa

    r5a1c9ef r1c507eb  
    252252
    253253        ip = (int *) (void *) malloc( size );
     254        ip = (int *) (void *) resize( (void *) ip, libAlign, size / 2 );
     255        test_base(ip, size / 2, libAlign);
     256        test_use(ip);
     257        free(ip);
     258
     259        ip = (int *) (void *) aligned_alloc( align, size );
     260        ip = (int *) (void *) resize( (void *) ip, align, size / 2 );
     261        test_base(ip, size / 2, align);
     262        test_use(ip);
     263        free(ip);
     264
     265        ip = (int *) (void *) malloc( size );
    254266        ip = (int *) (void *) resize( (void *) ip, align, size / 4 );
    255267        test_base(ip, size / 4, align);
     
    270282        ip = (int *) (void *) resize( 0p, align, size );
    271283        test_base(ip, size, align);
     284        test_use(ip);
     285        free(ip);
     286
     287        ip = (int *) (void *) calloc( dim, elemSize );
     288        ip = (int *) (void *) realloc( (void *) ip, libAlign, size / 2 );
     289        test_base(ip, size / 2, libAlign);
     290        test_fill(ip, 0, size / 2, '\0');
     291        test_use(ip);
     292        free(ip);
     293
     294        ip = (int *) (void *) cmemalign( align, dim, elemSize );
     295        ip = (int *) (void *) realloc( (void *) ip, align, size / 2 );
     296        test_base(ip, size / 2, align);
     297        test_fill(ip, 0, size / 2, '\0');
    272298        test_use(ip);
    273299        free(ip);
     
    348374        free(ip);
    349375
    350         ip = resize( NULL, size );
    351         test_base(ip, size, libAlign);
    352         test_use(ip);
    353         free(ip);
    354 
    355         ip = resize( 0p, size );
     376        ip = resize( (int*)0p, size );
     377        test_base(ip, size, libAlign);
     378        test_use(ip);
     379        free(ip);
     380
     381        ip = resize( (int*)0p, size );
    356382        test_base(ip, size, libAlign);
    357383        test_use(ip);
     
    378404        free(ip);
    379405
    380         ip = realloc( NULL, size );
     406        ip = realloc( (int*)0p, size );
    381407        test_base(ip, size , libAlign);
    382408        test_use(ip);
    383409        free(ip);
    384410
    385         ip = realloc( 0p, size );
     411        ip = realloc( (int*)0p, size );
    386412        test_base(ip, size, libAlign);
    387413        test_use(ip);
     
    437463        else printf("failed CFA malloc tests : %d/%d\n\n", tests_failed, tests_total);
    438464
    439         // testing CFA malloc
     465        // testing CFA malloc with aligned struct
    440466
    441467        elemSize = sizeof(T1);
     
    488514        free(tp);
    489515
    490         tp = resize( NULL, size );
     516        tp = resize( (T1*)0p, size );
    491517        test_base(tp, size, tAlign );
    492518        test_use(tp);
    493519        free(tp);
    494520
    495         tp = resize( 0p, size );
     521        tp = resize( (T1*)0p, size );
    496522        test_base(tp, size, tAlign );
    497523        test_use(tp);
     
    518544        free(tp);
    519545
    520         tp = realloc( NULL, size  );
     546        tp = realloc( (T1*)0p, size  );
    521547        test_base(tp, size , tAlign );
    522548        test_use(tp);
    523549        free(tp);
    524550
    525         tp = realloc( 0p, size );
     551        tp = realloc( (T1*)0p, size );
    526552        test_base(tp, size, tAlign );
    527553        test_use(tp);
     
    559585        free(tp);
    560586
    561         (int) posix_memalign( (int **) &tp, align );
     587        (int) posix_memalign( (T1 **) &tp, align );
    562588        test_base(tp, elemSize, align);
    563589        test_use(tp);
  • tests/test.py

    r5a1c9ef r1c507eb  
    116116        parser.add_argument('--arch', help='Test for specific architecture', type=comma_separated(str), default=None)
    117117        parser.add_argument('--continue', help='When multiple specifications are passed (debug/install/arch), sets whether or not to continue if the last specification failed', type=yes_no, default='yes', dest='continue_')
    118         parser.add_argument('--timeout', help='Maximum duration in seconds after a single test is considered to have timed out', type=int, default=60)
     118        parser.add_argument('--timeout', help='Maximum duration in seconds after a single test is considered to have timed out', type=int, default=120)
    119119        parser.add_argument('--global-timeout', help='Maximum cumulative duration in seconds after the ALL tests are considered to have timed out', type=int, default=7200)
    120120        parser.add_argument('--timeout-with-gdb', help='Instead of killing the command when it times out, orphan it and print process id to allow gdb to attach', type=yes_no, default="no")
Note: See TracChangeset for help on using the changeset viewer.