Changeset 6c12fd28 for libcfa


Ignore:
Timestamp:
May 8, 2020, 2:42:45 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:
5c581cc
Parents:
dd4e2d7 (diff), 0dedf027 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

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

Location:
libcfa
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • libcfa/configure

    rdd4e2d7 r6c12fd28  
    790790enable_distcc
    791791with_cfa_name
     792enable_static
    792793enable_shared
    793 enable_static
    794794with_pic
    795795enable_fast_install
     
    14521452  --disable-silent-rules  verbose build output (undo: "make V=0")
    14531453  --enable-distcc     whether or not to enable distributed compilation
     1454  --enable-static[=PKGS]  build static libraries [default=no]
    14541455  --enable-shared[=PKGS]  build shared libraries [default=yes]
    1455   --enable-static[=PKGS]  build static libraries [default=yes]
    14561456  --enable-fast-install[=PKGS]
    14571457                          optimize for fast installation [default=yes]
     
    80308030
    80318031# Set options
     8032# Check whether --enable-static was given.
     8033if test "${enable_static+set}" = set; then :
     8034  enableval=$enable_static; p=${PACKAGE-default}
     8035    case $enableval in
     8036    yes) enable_static=yes ;;
     8037    no) enable_static=no ;;
     8038    *)
     8039     enable_static=no
     8040      # Look at the argument we got.  We use all the common list separators.
     8041      lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
     8042      for pkg in $enableval; do
     8043        IFS=$lt_save_ifs
     8044        if test "X$pkg" = "X$p"; then
     8045          enable_static=yes
     8046        fi
     8047      done
     8048      IFS=$lt_save_ifs
     8049      ;;
     8050    esac
     8051else
     8052  enable_static=no
     8053fi
     8054
     8055
     8056
     8057
     8058
     8059
     8060
    80328061
    80338062
     
    80628091fi
    80638092
    8064 
    8065 
    8066 
    8067 
    8068 
    8069 
    8070 
    8071 
    8072   # Check whether --enable-static was given.
    8073 if test "${enable_static+set}" = set; then :
    8074   enableval=$enable_static; p=${PACKAGE-default}
    8075     case $enableval in
    8076     yes) enable_static=yes ;;
    8077     no) enable_static=no ;;
    8078     *)
    8079      enable_static=no
    8080       # Look at the argument we got.  We use all the common list separators.
    8081       lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
    8082       for pkg in $enableval; do
    8083         IFS=$lt_save_ifs
    8084         if test "X$pkg" = "X$p"; then
    8085           enable_static=yes
    8086         fi
    8087       done
    8088       IFS=$lt_save_ifs
    8089       ;;
    8090     esac
    8091 else
    8092   enable_static=yes
    8093 fi
    80948093
    80958094
     
    1772817727macro_version='`$ECHO "$macro_version" | $SED "$delay_single_quote_subst"`'
    1772917728macro_revision='`$ECHO "$macro_revision" | $SED "$delay_single_quote_subst"`'
     17729enable_static='`$ECHO "$enable_static" | $SED "$delay_single_quote_subst"`'
    1773017730enable_shared='`$ECHO "$enable_shared" | $SED "$delay_single_quote_subst"`'
    17731 enable_static='`$ECHO "$enable_static" | $SED "$delay_single_quote_subst"`'
    1773217731pic_mode='`$ECHO "$pic_mode" | $SED "$delay_single_quote_subst"`'
    1773317732enable_fast_install='`$ECHO "$enable_fast_install" | $SED "$delay_single_quote_subst"`'
     
    1885718856macro_revision=$macro_revision
    1885818857
     18858# Whether or not to build static libraries.
     18859build_old_libs=$enable_static
     18860
    1885918861# Whether or not to build shared libraries.
    1886018862build_libtool_libs=$enable_shared
    18861 
    18862 # Whether or not to build static libraries.
    18863 build_old_libs=$enable_static
    1886418863
    1886518864# What type of objects to build.
  • libcfa/configure.ac

    rdd4e2d7 r6c12fd28  
    109109
    110110# Checks for programs.
    111 LT_INIT
     111LT_INIT([disable-static])
    112112
    113113AC_PROG_CXX
  • libcfa/src/bits/locks.hfa

    rdd4e2d7 r6c12fd28  
    115115                char * strerror(int);
    116116        }
    117         #define CHECKED(x) { int err = x; if( err != 0 ) abort("KERNEL ERROR: %s\n", strerror(err)); }
     117        #define CHECKED(x) { int err = x; if( err != 0 ) abort("KERNEL ERROR: Operation \"" #x "\" return error %d - %s\n", err, strerror(err)); }
    118118
    119119        struct __bin_sem_t {
  • libcfa/src/concurrency/kernel.cfa

    rdd4e2d7 r6c12fd28  
    901901        // Wake them up
    902902        __cfadbg_print_safe(runtime_core, "Kernel : waking Processor %p\n", this->idles.head);
     903        /* paranoid */ verify( ! kernelTLS.preemption_state.enabled );
    903904        post( this->idles.head->idle );
    904905
     
    911912static bool __wake_proc(processor * this) {
    912913        __cfadbg_print_safe(runtime_core, "Kernel : waking Processor %p\n", this);
    913         return post( this->idle );
     914
     915        disable_interrupts();
     916                /* paranoid */ verify( ! kernelTLS.preemption_state.enabled );
     917                bool ret = post( this->idle );
     918        enable_interrupts( __cfaabi_dbg_ctx );
     919
     920        return ret;
    914921}
    915922
  • libcfa/src/heap.cfa

    rdd4e2d7 r6c12fd28  
    1010// Created On       : Tue Dec 19 21:58:35 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Apr 18 17:43:15 2020
    13 // Update Count     : 718
     12// Last Modified On : Wed May  6 17:29:26 2020
     13// Update Count     : 727
    1414//
    1515
     
    1919#include <errno.h>                                                                              // errno
    2020#include <string.h>                                                                             // memset, memcpy
     21#include <limits.h>                                                                             // ULONG_MAX
    2122extern "C" {
    2223#include <sys/mman.h>                                                                   // mmap, munmap
    2324} // extern "C"
    2425
    25 // #comment TD : Many of these should be merged into math I believe
    2626#include "bits/align.hfa"                                                               // libPow2
    2727#include "bits/defs.hfa"                                                                // likely, unlikely
     
    3030//#include "stdlib.hfa"                                                                 // bsearchl
    3131#include "malloc.h"
     32#include "bitmanip.hfa"                                                                 // ceiling
    3233
    3334#define MIN(x, y) (y > x ? x : y)
     
    8182};
    8283
     84size_t default_heap_expansion() __attribute__(( weak )) {
     85        return __CFA_DEFAULT_HEAP_EXPANSION__;
     86} // default_heap_expansion
     87
    8388size_t default_mmap_start() __attribute__(( weak )) {
    8489        return __CFA_DEFAULT_MMAP_START__;
    8590} // default_mmap_start
    86 
    87 size_t default_heap_expansion() __attribute__(( weak )) {
    88         return __CFA_DEFAULT_HEAP_EXPANSION__;
    89 } // default_heap_expansion
    9091
    9192
     
    360361
    361362
    362 static inline bool setHeapExpand( size_t value ) {
    363   if ( heapExpand < pageSize ) return true;
    364         heapExpand = value;
    365         return false;
    366 } // setHeapExpand
    367 
    368 
    369363// thunk problem
    370364size_t Bsearchl( unsigned int key, const unsigned int * vals, size_t dim ) {
     
    383377
    384378static inline bool setMmapStart( size_t value ) {               // true => mmapped, false => sbrk
    385   if ( value < pageSize || bucketSizes[NoBucketSizes - 1] < value ) return true;
     379  if ( value < pageSize || bucketSizes[NoBucketSizes - 1] < value ) return false;
    386380        mmapStart = value;                                                                      // set global
    387381
     
    390384        assert( maxBucketsUsed < NoBucketSizes );                       // subscript failure ?
    391385        assert( mmapStart <= bucketSizes[maxBucketsUsed] ); // search failure ?
    392         return false;
     386        return true;
    393387} // setMmapStart
    394388
     
    449443
    450444        #ifdef __CFA_DEBUG__
    451         checkHeader( addr < heapBegin || header < (HeapManager.Storage.Header *)heapBegin, name, addr ); // bad low address ?
     445        checkHeader( addr < heapBegin, name, addr );            // bad low address ?
    452446        #endif // __CFA_DEBUG__
    453447
     
    508502        // along with the block and is a multiple of the alignment size.
    509503
    510   if ( unlikely( size > ~0ul - sizeof(HeapManager.Storage) ) ) return 0p;
     504  if ( unlikely( size > ULONG_MAX - sizeof(HeapManager.Storage) ) ) return 0p;
    511505        size_t tsize = size + sizeof(HeapManager.Storage);
    512506        if ( likely( tsize < mmapStart ) ) {                            // small size => sbrk
     
    560554                block->header.kind.real.home = freeElem;                // pointer back to free list of apropriate size
    561555        } else {                                                                                        // large size => mmap
    562   if ( unlikely( size > ~0ul - pageSize ) ) return 0p;
     556  if ( unlikely( size > ULONG_MAX - pageSize ) ) return 0p;
    563557                tsize = libCeiling( tsize, pageSize );                  // must be multiple of page size
    564558                #ifdef __STATISTICS__
     
    702696        #endif // FASTLOOKUP
    703697
    704         if ( setMmapStart( default_mmap_start() ) ) {
     698        if ( ! setMmapStart( default_mmap_start() ) ) {
    705699                abort( "HeapManager : internal error, mmap start initialization failure." );
    706700        } // if
     
    708702
    709703        char * end = (char *)sbrk( 0 );
    710         sbrk( (char *)libCeiling( (long unsigned int)end, libAlign() ) - end ); // move start of heap to multiple of alignment
    711         heapBegin = heapEnd = sbrk( 0 );                                        // get new start point
     704        heapBegin = heapEnd = sbrk( (char *)libCeiling( (long unsigned int)end, libAlign() ) - end ); // move start of heap to multiple of alignment
    712705} // HeapManager
    713706
     
    735728        //assert( heapManager.heapBegin != 0 );
    736729        //heapManager{};
    737         if ( heapManager.heapBegin == 0p ) heapManager{};
     730        if ( heapManager.heapBegin == 0p ) heapManager{};       // sanity check
    738731} // memory_startup
    739732
     
    863856                #endif // __STATISTICS__
    864857
    865                 size_t size = dim * elemSize;
    866                 char * addr = (char *)mallocNoStats( size );
    867           if ( unlikely( addr == 0p ) ) return 0p;
    868 
    869                 HeapManager.Storage.Header * header;
    870                 HeapManager.FreeHeader * freeElem;
    871                 size_t bsize, alignment;
    872                 headers( "aalloc", addr, header, freeElem, bsize, alignment );
    873 
    874                 header->kind.real.blockSize |= 2;                               // mark as zero filled
    875                 return addr;
     858                return mallocNoStats( dim * elemSize );
    876859        } // aalloc
    877860
     
    914897       
    915898                // change size, DO NOT preserve STICKY PROPERTIES.
     899                free( oaddr );
    916900                void * naddr = mallocNoStats( size );                   // create new area
    917                 free( oaddr );
    918901                return naddr;
    919902        } // resize
     
    988971                #endif // __STATISTICS__
    989972
    990                 size_t size = dim * elemSize;
    991                 char * addr = (char *)memalignNoStats( alignment, size );
    992           if ( unlikely( addr == 0p ) ) return 0p;
    993                 HeapManager.Storage.Header * header;
    994                 HeapManager.FreeHeader * freeElem;
    995                 size_t bsize;
    996                 headers( "amemalign", addr, header, freeElem, bsize, alignment );
    997 
    998                 header->kind.real.blockSize |= 2;                               // mark as zero filled
    999                 return addr;
     973                return memalignNoStats( alignment, dim * elemSize );
    1000974        } // amemalign
    1001975
     
    10431017
    10441018        // Frees the memory space pointed to by ptr, which must have been returned by a previous call to malloc(), calloc()
    1045         // or realloc().  Otherwise, or if free(ptr) has already been called before, undefined behavior occurs. If ptr is
     1019        // or realloc().  Otherwise, or if free(ptr) has already been called before, undefined behaviour occurs. If ptr is
    10461020        // 0p, no operation is performed.
    10471021        void free( void * addr ) {
     
    11701144
    11711145
    1172         // Adjusts parameters that control the behavior of the memory-allocation functions (see malloc). The param argument
     1146        // Adjusts parameters that control the behaviour of the memory-allocation functions (see malloc). The param argument
    11731147        // specifies the parameter to be modified, and value specifies the new value for that parameter.
    11741148        int mallopt( int option, int value ) {
    11751149                choose( option ) {
    11761150                  case M_TOP_PAD:
    1177                         if ( setHeapExpand( value ) ) return 1;
     1151                        heapExpand = ceiling( value, pageSize ); return 1;
    11781152                  case M_MMAP_THRESHOLD:
    11791153                        if ( setMmapStart( value ) ) return 1;
     1154                        break;
    11801155                } // switch
    11811156                return 0;                                                                               // error, unsupported
  • libcfa/src/iostream.cfa

    rdd4e2d7 r6c12fd28  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Apr 30 10:50:31 2020
    13 // Update Count     : 1001
     12// Last Modified On : Sat May  2 18:30:25 2020
     13// Update Count     : 1017
    1414//
    1515
     
    583583                                        if ( fmt.flags.pc && fmt.pc > 64 ) fmt.pc -= 64; else { fmt.flags.pc = false; fmt.pc = 0; } \
    584584                                        if ( fmt.flags.left ) { \
    585                                                 fmt2.wd = fmt.wd; \
    586                                                 if ( fmt2.wd <= 64 ) { \
    587                                                         fmt2.wd = 64; \
    588                                                 } else { \
    589                                                         if ( fmt.pc > 0 ) { \
    590                                                                 fmt2.wd -= fmt.pc; \
    591                                                         } else { \
    592                                                                 fmt2.wd = fmt.wd - high1( msig ); \
    593                                                         } /* if */ \
    594                                                         if ( ! fmt.flags.nobsdp ) fmt2.wd -= 2; \
    595                                                         if ( fmt2.wd < 0 ) fmt2.wd = 0; \
    596                                                         fmt2.flags.left = true; \
    597                                                         fmt.wd = 0; \
    598                                                 } /* if */ \
    599                                                 printf( "left %d %d %x\n", f.wd, f.pc, f.all ); \
    600                                                 printf( "left %d %d %x\n", fmt.wd, fmt.pc, fmt.all ); \
     585                                                fmt.flags.left = false; \
     586                                                fmt.wd = 0; \
     587                                                /* printf( "L %llo %llo %llo %d %d '%c' %x\n", msig, lsig, fmt.val, fmt.wd, fmt.pc, fmt.base, fmt.all ); */ \
     588                                                fmt2.flags.left = true; \
     589                                                int msigd = high1( msig ); \
     590                                                fmt2.wd = f.wd - (fmt.pc > msigd ? fmt.pc : msigd); \
     591                                                if ( ! fmt.flags.nobsdp ) fmt2.wd -= 2; /* compensate for 0b base specifier */ \
     592                                                if ( (int)fmt2.wd < 64 ) fmt2.wd = 64; /* cast deals with negative value */ \
     593                                                fmt2.flags.pc = true; fmt2.pc = 64; \
    601594                                        } else { \
    602595                                                if ( fmt.wd > 64 ) fmt.wd -= 64; \
    603                                                 /* if ( ! fmt.flags.nobsdp && fmt.pc < fmt.wd ) fmt.wd -= 1; */ \
     596                                                else fmt.wd = 1; \
     597                                                /* printf( "R %llo %llo %llo %d %d '%c' %x\n", msig, lsig, fmt.val, fmt.wd, fmt.pc, fmt.base, fmt.all ); */ \
    604598                                                fmt2.wd = 64; \
    605                                                 /* printf( "R %llo %llo %llo %llo %d %d '%c' %x\n", msig, lsig, fmt.val, fmt2.val, fmt.wd, fmt.pc, fmt.base, fmt.all ); */ \
    606599                                        } /* if */ \
    607                                         /* printf( "\nC %llo %d %d '%c' %x\n", fmt2.val, fmt2.wd, fmt2.pc, fmt2.base, fmt2.all ); */ \
     600                                        /* printf( "C %llo %d %d '%c' %x\n", fmt2.val, fmt2.wd, fmt2.pc, fmt2.base, fmt2.all ); */ \
    608601                                        (ostype &)(os | fmt | "" | fmt2); \
    609602                                } else if ( f.base == 'o' ) { \
     
    614607                                                fmt.flags.left = false; \
    615608                                                fmt.wd = 0; \
    616                                                 /* if ( fmt2.val > 1 && fmt.flags.pc && fmt.pc > 0 ) fmt.pc -= 1; */ \
    617609                                                /* printf( "L %llo %llo %llo %d %d '%c' %x %llo %d %d '%c' %x\n", msig, lsig, fmt.val, fmt.wd, fmt.pc, fmt.base, fmt.all, fmt2.val, fmt2.wd, fmt2.pc, fmt2.base, fmt2.all ); */ \
    618610                                                (ostype &)(os | fmt | "" | fmt2); \
    619611                                                sepOff( os ); \
    620612                                                fmt2.flags.left = true; \
    621                                                 int msigd = ceiling( high1( fmt.val ), 3 ) + 1; \
    622                                                 fmt2.wd = f.wd - (fmt.pc > msigd ? fmt.pc : msigd) - 1; \
     613                                                int msigd = ceiling( high1( fmt.val ), 3 ); \
     614                                                fmt2.wd = f.wd - (fmt.pc > msigd ? fmt.pc : msigd); \
     615                                                if ( ! fmt.flags.nobsdp ) fmt2.wd -= 1; /* compensate for 0 base specifier */ \
    623616                                                if ( (int)fmt2.wd < 21 ) fmt2.wd = 21; /* cast deals with negative value */ \
    624617                                                fmt2.flags.pc = true; fmt2.pc = 21; \
    625618                                        } else { \
    626619                                                if ( fmt.wd > 22 ) fmt.wd -= 22; \
    627                                                 /* compensate for leading 0 */ \
    628                                                 /*if ( ! fmt.flags.nobsdp && fmt.pc < fmt.wd ) fmt.wd -= 1;*/ \
    629                                                 fmt2.wd = 1; \
     620                                                else fmt.wd = 1; \
    630621                                                /* printf( "R %llo %llo %llo %d %d '%c' %x %llo %d %d '%c' %x\n", msig, lsig, fmt.val, fmt.wd, fmt.pc, fmt.base, fmt.all, fmt2.val, fmt2.wd, fmt2.pc, fmt2.base, fmt2.all ); */ \
    631622                                                (ostype &)(os | fmt | "" | fmt2); \
     
    636627                                        /* printf( "\nC %llo %d %d '%c' %x\n", fmt2.val, fmt2.wd, fmt2.pc, fmt2.base, fmt2.all ); */ \
    637628                                        (ostype &)(os | fmt2); \
    638                                 } else { \
    639                                         if ( fmt.flags.pc && fmt.pc > 16 ) fmt.pc -= 16; \
     629                                } else { /* f.base == 'x'  | f.base == 'X' */ \
     630                                        if ( fmt.flags.pc && fmt.pc > 16 ) fmt.pc -= 16; else { fmt.flags.pc = false; fmt.pc = 0; } \
    640631                                        if ( fmt.flags.left ) { \
    641                                                 fmt2.wd = fmt.wd; \
    642                                                 if ( fmt2.wd <= 16 ) { \
    643                                                         fmt2.wd = 16; \
    644                                                 } else { \
    645                                                         if ( fmt.pc > 0 ) { \
    646                                                                 fmt2.wd -= fmt.pc; \
    647                                                         } else { \
    648                                                                 fmt2.wd = fmt.wd - ceiling2( high1( msig ), 4 ) / 4; \
    649                                                         } /* if */ \
    650                                                         if ( ! fmt.flags.nobsdp ) fmt2.wd -= 2; \
    651                                                         if ( fmt2.wd < 0 ) fmt2.wd = 0; \
    652                                                         fmt2.flags.left = true; \
    653                                                         fmt.wd = 0; \
    654                                                 } /* if */ \
     632                                                fmt.flags.left = false; \
     633                                                fmt.wd = 0; \
     634                                                /* printf( "L %llo %llo %llo %d %d '%c' %x\n", msig, lsig, fmt.val, fmt.wd, fmt.pc, fmt.base, fmt.all ); */ \
     635                                                fmt2.flags.left = true; \
     636                                                int msigd = high1( msig ); \
     637                                                fmt2.wd = f.wd - (fmt.pc > msigd ? fmt.pc : msigd); \
     638                                                if ( ! fmt.flags.nobsdp ) fmt2.wd -= 2; /* compensate for 0x base specifier */ \
     639                                                if ( (int)fmt2.wd < 16 ) fmt2.wd = 16; /* cast deals with negative value */ \
     640                                                fmt2.flags.pc = true; fmt2.pc = 16; \
    655641                                        } else { \
     642                                                if ( fmt.wd > 16 ) fmt.wd -= 16; \
     643                                                else fmt.wd = 1; \
     644                                                /* printf( "R %llo %llo %llo %d %d '%c' %x\n", msig, lsig, fmt.val, fmt.wd, fmt.pc, fmt.base, fmt.all ); */ \
    656645                                                fmt2.wd = 16; \
    657                                                 if ( fmt.wd > 16 ) fmt.wd -= 16; \
    658646                                        } /* if */ \
    659                                         fmt2.pc = 16; fmt2.flags.pc = true; \
     647                                        /* printf( "C %llo %d %d '%c' %x\n", fmt2.val, fmt2.wd, fmt2.pc, fmt2.base, fmt2.all ); */ \
    660648                                        (ostype &)(os | fmt | "" | fmt2); \
    661649                                } /* if */ \
Note: See TracChangeset for help on using the changeset viewer.