Changeset fc19129 for src


Ignore:
Timestamp:
Apr 3, 2017, 10:38:04 AM (8 years ago)
Author:
Aaron Moss <a3moss@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
1d29d46
Parents:
814525c (diff), 36e05a2 (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 changes to generics paper

Location:
src
Files:
4 added
20 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/CodeGenerator.cc

    r814525c rfc19129  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Mar 17 09:06:01 2017
    13 // Update Count     : 481
     12// Last Modified On : Thu Mar 30 16:38:01 2017
     13// Update Count     : 482
    1414//
    1515
     
    674674
    675675        void CodeGenerator::visit( CompoundLiteralExpr *compLitExpr ) {
    676                 assert( compLitExpr->get_type() && dynamic_cast< ListInit * > ( compLitExpr->get_initializer() ) );
    677                 output << "(" << genType( compLitExpr->get_type(), "", pretty ) << ")";
     676                assert( compLitExpr->get_result() && dynamic_cast< ListInit * > ( compLitExpr->get_initializer() ) );
     677                output << "(" << genType( compLitExpr->get_result(), "", pretty ) << ")";
    678678                compLitExpr->get_initializer()->accept( *this );
    679679        }
  • src/Parser/ExpressionNode.cc

    r814525c rfc19129  
    1010// Created On       : Sat May 16 13:17:07 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Mar  4 06:58:47 2017
    13 // Update Count     : 509
     12// Last Modified On : Thu Mar 30 17:02:46 2017
     13// Update Count     : 515
    1414//
    1515
     
    356356        // these types do not have associated type information
    357357        } else if ( StructDecl * newDeclStructDecl = dynamic_cast< StructDecl * >( newDecl )  ) {
    358                 return new CompoundLiteralExpr( new StructInstType( Type::Qualifiers(), newDeclStructDecl->get_name() ), maybeMoveBuild< Initializer >(kids) );
     358                if ( newDeclStructDecl->has_body() ) {
     359                        return new CompoundLiteralExpr( new StructInstType( Type::Qualifiers(), newDeclStructDecl ), maybeMoveBuild< Initializer >(kids) );
     360                } else {
     361                        return new CompoundLiteralExpr( new StructInstType( Type::Qualifiers(), newDeclStructDecl->get_name() ), maybeMoveBuild< Initializer >(kids) );
     362                } // if
    359363        } else if ( UnionDecl * newDeclUnionDecl = dynamic_cast< UnionDecl * >( newDecl )  ) {
    360                 return new CompoundLiteralExpr( new UnionInstType( Type::Qualifiers(), newDeclUnionDecl->get_name() ), maybeMoveBuild< Initializer >(kids) );
     364                if ( newDeclUnionDecl->has_body() ) {
     365                        return new CompoundLiteralExpr( new UnionInstType( Type::Qualifiers(), newDeclUnionDecl ), maybeMoveBuild< Initializer >(kids) );
     366                } else {
     367                        return new CompoundLiteralExpr( new UnionInstType( Type::Qualifiers(), newDeclUnionDecl->get_name() ), maybeMoveBuild< Initializer >(kids) );
     368                } // if
    361369        } else if ( EnumDecl * newDeclEnumDecl = dynamic_cast< EnumDecl * >( newDecl )  ) {
    362                 return new CompoundLiteralExpr( new EnumInstType( Type::Qualifiers(), newDeclEnumDecl->get_name() ), maybeMoveBuild< Initializer >(kids) );
     370                if ( newDeclEnumDecl->has_body() ) {
     371                        return new CompoundLiteralExpr( new EnumInstType( Type::Qualifiers(), newDeclEnumDecl ), maybeMoveBuild< Initializer >(kids) );
     372                } else {
     373                        return new CompoundLiteralExpr( new EnumInstType( Type::Qualifiers(), newDeclEnumDecl->get_name() ), maybeMoveBuild< Initializer >(kids) );
     374                } // if
    363375        } else {
    364376                assert( false );
  • src/Parser/parser.yy

    r814525c rfc19129  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Mar 17 15:42:22 2017
    13 // Update Count     : 2317
     12// Last Modified On : Thu Mar 30 15:42:32 2017
     13// Update Count     : 2318
    1414//
    1515
     
    423423        | postfix_expression DECR
    424424                { $$ = new ExpressionNode( build_unary_ptr( OperKinds::DecrPost, $1 ) ); }
    425         | '(' type_name_no_function ')' '{' initializer_list comma_opt '}' // C99
     425        | '(' type_name_no_function ')' '{' initializer_list comma_opt '}' // C99, compound-literal
    426426                { $$ = new ExpressionNode( build_compoundLiteral( $2, new InitializerNode( $5, true ) ) ); }
    427427        | postfix_expression '{' argument_expression_list '}' // CFA
  • src/SymTab/Indexer.cc

    r814525c rfc19129  
    1010// Created On       : Sun May 17 21:37:33 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Mar 14 08:07:34 2017
    13 // Update Count     : 17
     12// Last Modified On : Thu Mar 30 16:38:47 2017
     13// Update Count     : 19
    1414//
    1515
     
    483483        void Indexer::visit( CompoundLiteralExpr *compLitExpr ) {
    484484                acceptNewScope( compLitExpr->get_result(), *this );
    485                 maybeAccept( compLitExpr->get_type(), *this );
    486485                maybeAccept( compLitExpr->get_initializer(), *this );
    487486        }
  • src/SymTab/Validate.cc

    r814525c rfc19129  
    1010// Created On       : Sun May 17 21:50:04 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Mar 16 16:39:15 2017
    13 // Update Count     : 353
     12// Last Modified On : Thu Mar 30 16:50:13 2017
     13// Update Count     : 357
    1414//
    1515
     
    222222                CompoundLiteral compoundliteral;
    223223
     224                HoistStruct::hoistStruct( translationUnit );
    224225                EliminateTypedef::eliminateTypedef( translationUnit );
    225                 HoistStruct::hoistStruct( translationUnit );
    226226                ReturnTypeFixer::fix( translationUnit ); // must happen before autogen
    227227                acceptAll( translationUnit, lrt ); // must happen before autogen, because sized flag needs to propagate to generated functions
     
    824824                static UniqueName indexName( "_compLit" );
    825825
    826                 ObjectDecl *tempvar = new ObjectDecl( indexName.newName(), storageClasses, LinkageSpec::C, 0, compLitExpr->get_type(), compLitExpr->get_initializer() );
    827                 compLitExpr->set_type( 0 );
     826                ObjectDecl *tempvar = new ObjectDecl( indexName.newName(), storageClasses, LinkageSpec::C, 0, compLitExpr->get_result(), compLitExpr->get_initializer() );
     827                compLitExpr->set_result( 0 );
    828828                compLitExpr->set_initializer( 0 );
    829829                delete compLitExpr;
  • src/SynTree/Expression.cc

    r814525c rfc19129  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Mar 17 09:42:04 2017
    13 // Update Count     : 51
     12// Last Modified On : Thu Mar 30 16:41:13 2017
     13// Update Count     : 52
    1414//
    1515
     
    571571
    572572
    573 CompoundLiteralExpr::CompoundLiteralExpr( Type * type, Initializer * initializer ) : type( type ), initializer( initializer ) {
     573CompoundLiteralExpr::CompoundLiteralExpr( Type * type, Initializer * initializer ) : initializer( initializer ) {
    574574        assert( type && initializer );
    575         set_result( type->clone() );
    576 }
    577 
    578 CompoundLiteralExpr::CompoundLiteralExpr( const CompoundLiteralExpr &other ) : Expression( other ), type( other.type->clone() ), initializer( other.initializer->clone() ) {}
     575        set_result( type );
     576}
     577
     578CompoundLiteralExpr::CompoundLiteralExpr( const CompoundLiteralExpr &other ) : Expression( other ), initializer( other.initializer->clone() ) {}
    579579
    580580CompoundLiteralExpr::~CompoundLiteralExpr() {
    581581        delete initializer;
    582         delete type;
    583582}
    584583
     
    586585        os << "Compound Literal Expression: " << std::endl;
    587586        os << std::string( indent+2, ' ' );
    588         type->print( os, indent + 2 );
     587        get_result()->print( os, indent + 2 );
    589588        os << std::string( indent+2, ' ' );
    590589        initializer->print( os, indent + 2 );
  • src/SynTree/Expression.h

    r814525c rfc19129  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jan 14 14:37:54 2017
    13 // Update Count     : 37
     12// Last Modified On : Thu Mar 30 16:44:00 2017
     13// Update Count     : 41
    1414//
    1515
     
    3535
    3636        Type *& get_result() { return result; }
     37        const Type * get_result() const { return result; }
    3738        void set_result( Type * newValue ) { result = newValue; }
    3839        bool has_result() const { return result != nullptr; }
     
    586587        virtual ~CompoundLiteralExpr();
    587588
    588         Type * get_type() const { return type; }
    589         void set_type( Type * t ) { type = t; }
    590 
    591589        Initializer * get_initializer() const { return initializer; }
    592590        void set_initializer( Initializer * i ) { initializer = i; }
     
    597595        virtual void print( std::ostream & os, int indent = 0 ) const;
    598596  private:
    599         Type * type;
    600597        Initializer * initializer;
    601598};
  • src/SynTree/Mutator.cc

    r814525c rfc19129  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Feb 16 15:02:23 2017
    13 // Update Count     : 21
     12// Last Modified On : Thu Mar 30 16:45:19 2017
     13// Update Count     : 22
    1414//
    1515
     
    369369        compLitExpr->set_env( maybeMutate( compLitExpr->get_env(), *this ) );
    370370        compLitExpr->set_result( maybeMutate( compLitExpr->get_result(), *this ) );
    371         compLitExpr->set_type( maybeMutate( compLitExpr->get_type(), *this ) );
    372371        compLitExpr->set_initializer( maybeMutate( compLitExpr->get_initializer(), *this ) );
    373372        return compLitExpr;
  • src/SynTree/Visitor.cc

    r814525c rfc19129  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Feb 16 15:01:25 2017
    13 // Update Count     : 23
     12// Last Modified On : Thu Mar 30 16:45:25 2017
     13// Update Count     : 24
    1414//
    1515
     
    292292void Visitor::visit( CompoundLiteralExpr *compLitExpr ) {
    293293        maybeAccept( compLitExpr->get_result(), *this );
    294         maybeAccept( compLitExpr->get_type(), *this );
    295294        maybeAccept( compLitExpr->get_initializer(), *this );
    296295}
  • src/driver/cfa.cc

    r814525c rfc19129  
    269269                args[nargs] = "-lpthread";
    270270                nargs += 1;
     271                args[nargs] = "-ldl";
     272                nargs += 1;
     273                args[nargs] = "-Xlinker";
     274                nargs += 1;
     275                args[nargs] = "--undefined=__lib_debug_write";
     276                nargs += 1;
     277
    271278        } // if
    272279#endif //HAVE_LIBCFA
  • src/libcfa/Makefile.am

    r814525c rfc19129  
    4949
    5050libobjs = ${headers:=.o}
    51 libsrc = libcfa-prelude.c ${headers:=.c}
     51libsrc = libcfa-prelude.c interpose.c libhdr/libdebug.c ${headers:=.c}
    5252
    5353# not all platforms support concurrency, add option do disable it
  • src/libcfa/Makefile.in

    r814525c rfc19129  
    4343
    4444# not all platforms support concurrency, add option do disable it
    45 @BUILD_CONCURRENCY_TRUE@am__append_3 = containers/vector concurrency/coroutine concurrency/thread concurrency/kernel concurrency/monitor
     45@BUILD_CONCURRENCY_TRUE@am__append_3 = concurrency/coroutine concurrency/thread concurrency/kernel concurrency/monitor
    4646
    4747# not all platforms support concurrency, add option do disable it
     
    9797libcfa_d_a_AR = $(AR) $(ARFLAGS)
    9898libcfa_d_a_LIBADD =
    99 am__libcfa_d_a_SOURCES_DIST = libcfa-prelude.c limits.c stdlib.c \
    100         math.c iostream.c fstream.c iterator.c rational.c assert.c \
    101         containers/vector.c concurrency/coroutine.c \
    102         concurrency/thread.c concurrency/kernel.c \
    103         concurrency/monitor.c concurrency/CtxSwitch-@MACHINE_TYPE@.S \
    104         concurrency/invoke.c
     99am__libcfa_d_a_SOURCES_DIST = libcfa-prelude.c interpose.c \
     100        libhdr/libdebug.c limits.c stdlib.c math.c iostream.c \
     101        fstream.c iterator.c rational.c assert.c containers/vector.c \
     102        concurrency/coroutine.c concurrency/thread.c \
     103        concurrency/kernel.c concurrency/monitor.c \
     104        concurrency/CtxSwitch-@MACHINE_TYPE@.S concurrency/invoke.c
    105105am__dirstamp = $(am__leading_dot)dirstamp
    106 @BUILD_CONCURRENCY_TRUE@am__objects_1 = containers/libcfa_d_a-vector.$(OBJEXT) \
    107 @BUILD_CONCURRENCY_TRUE@        concurrency/libcfa_d_a-coroutine.$(OBJEXT) \
     106@BUILD_CONCURRENCY_TRUE@am__objects_1 = concurrency/libcfa_d_a-coroutine.$(OBJEXT) \
    108107@BUILD_CONCURRENCY_TRUE@        concurrency/libcfa_d_a-thread.$(OBJEXT) \
    109108@BUILD_CONCURRENCY_TRUE@        concurrency/libcfa_d_a-kernel.$(OBJEXT) \
     
    113112        libcfa_d_a-iostream.$(OBJEXT) libcfa_d_a-fstream.$(OBJEXT) \
    114113        libcfa_d_a-iterator.$(OBJEXT) libcfa_d_a-rational.$(OBJEXT) \
    115         libcfa_d_a-assert.$(OBJEXT) $(am__objects_1)
     114        libcfa_d_a-assert.$(OBJEXT) \
     115        containers/libcfa_d_a-vector.$(OBJEXT) $(am__objects_1)
    116116@BUILD_CONCURRENCY_TRUE@am__objects_3 = concurrency/CtxSwitch-@MACHINE_TYPE@.$(OBJEXT) \
    117117@BUILD_CONCURRENCY_TRUE@        concurrency/libcfa_d_a-invoke.$(OBJEXT)
    118 am__objects_4 = libcfa_d_a-libcfa-prelude.$(OBJEXT) $(am__objects_2) \
     118am__objects_4 = libcfa_d_a-libcfa-prelude.$(OBJEXT) \
     119        libcfa_d_a-interpose.$(OBJEXT) \
     120        libhdr/libcfa_d_a-libdebug.$(OBJEXT) $(am__objects_2) \
    119121        $(am__objects_3)
    120122am_libcfa_d_a_OBJECTS = $(am__objects_4)
     
    122124libcfa_a_AR = $(AR) $(ARFLAGS)
    123125libcfa_a_LIBADD =
    124 am__libcfa_a_SOURCES_DIST = libcfa-prelude.c limits.c stdlib.c math.c \
    125         iostream.c fstream.c iterator.c rational.c assert.c \
    126         containers/vector.c concurrency/coroutine.c \
    127         concurrency/thread.c concurrency/kernel.c \
    128         concurrency/monitor.c concurrency/CtxSwitch-@MACHINE_TYPE@.S \
    129         concurrency/invoke.c
    130 @BUILD_CONCURRENCY_TRUE@am__objects_5 =  \
    131 @BUILD_CONCURRENCY_TRUE@        containers/libcfa_a-vector.$(OBJEXT) \
    132 @BUILD_CONCURRENCY_TRUE@        concurrency/libcfa_a-coroutine.$(OBJEXT) \
     126am__libcfa_a_SOURCES_DIST = libcfa-prelude.c interpose.c \
     127        libhdr/libdebug.c limits.c stdlib.c math.c iostream.c \
     128        fstream.c iterator.c rational.c assert.c containers/vector.c \
     129        concurrency/coroutine.c concurrency/thread.c \
     130        concurrency/kernel.c concurrency/monitor.c \
     131        concurrency/CtxSwitch-@MACHINE_TYPE@.S concurrency/invoke.c
     132@BUILD_CONCURRENCY_TRUE@am__objects_5 = concurrency/libcfa_a-coroutine.$(OBJEXT) \
    133133@BUILD_CONCURRENCY_TRUE@        concurrency/libcfa_a-thread.$(OBJEXT) \
    134134@BUILD_CONCURRENCY_TRUE@        concurrency/libcfa_a-kernel.$(OBJEXT) \
     
    138138        libcfa_a-fstream.$(OBJEXT) libcfa_a-iterator.$(OBJEXT) \
    139139        libcfa_a-rational.$(OBJEXT) libcfa_a-assert.$(OBJEXT) \
    140         $(am__objects_5)
     140        containers/libcfa_a-vector.$(OBJEXT) $(am__objects_5)
    141141@BUILD_CONCURRENCY_TRUE@am__objects_7 = concurrency/CtxSwitch-@MACHINE_TYPE@.$(OBJEXT) \
    142142@BUILD_CONCURRENCY_TRUE@        concurrency/libcfa_a-invoke.$(OBJEXT)
    143 am__objects_8 = libcfa_a-libcfa-prelude.$(OBJEXT) $(am__objects_6) \
     143am__objects_8 = libcfa_a-libcfa-prelude.$(OBJEXT) \
     144        libcfa_a-interpose.$(OBJEXT) \
     145        libhdr/libcfa_a-libdebug.$(OBJEXT) $(am__objects_6) \
    144146        $(am__objects_7)
    145147am_libcfa_a_OBJECTS = $(am__objects_8)
     
    308310AM_CCASFLAGS = @CFA_FLAGS@
    309311headers = limits stdlib math iostream fstream iterator rational assert \
    310         $(am__append_3)
     312        containers/vector $(am__append_3)
    311313libobjs = ${headers:=.o}
    312 libsrc = libcfa-prelude.c ${headers:=.c} $(am__append_4)
     314libsrc = libcfa-prelude.c interpose.c libhdr/libdebug.c ${headers:=.c} \
     315        $(am__append_4)
    313316libcfa_a_SOURCES = ${libsrc}
    314317libcfa_a_CFLAGS = -nodebug -O2
     
    383386clean-libLIBRARIES:
    384387        -test -z "$(lib_LIBRARIES)" || rm -f $(lib_LIBRARIES)
     388libhdr/$(am__dirstamp):
     389        @$(MKDIR_P) libhdr
     390        @: > libhdr/$(am__dirstamp)
     391libhdr/$(DEPDIR)/$(am__dirstamp):
     392        @$(MKDIR_P) libhdr/$(DEPDIR)
     393        @: > libhdr/$(DEPDIR)/$(am__dirstamp)
     394libhdr/libcfa_d_a-libdebug.$(OBJEXT): libhdr/$(am__dirstamp) \
     395        libhdr/$(DEPDIR)/$(am__dirstamp)
    385396containers/$(am__dirstamp):
    386397        @$(MKDIR_P) containers
     
    415426        $(AM_V_AR)$(libcfa_d_a_AR) libcfa-d.a $(libcfa_d_a_OBJECTS) $(libcfa_d_a_LIBADD)
    416427        $(AM_V_at)$(RANLIB) libcfa-d.a
     428libhdr/libcfa_a-libdebug.$(OBJEXT): libhdr/$(am__dirstamp) \
     429        libhdr/$(DEPDIR)/$(am__dirstamp)
    417430containers/libcfa_a-vector.$(OBJEXT): containers/$(am__dirstamp) \
    418431        containers/$(DEPDIR)/$(am__dirstamp)
     
    447460        -rm -f containers/libcfa_a-vector.$(OBJEXT)
    448461        -rm -f containers/libcfa_d_a-vector.$(OBJEXT)
     462        -rm -f libhdr/libcfa_a-libdebug.$(OBJEXT)
     463        -rm -f libhdr/libcfa_d_a-libdebug.$(OBJEXT)
    449464
    450465distclean-compile:
     
    453468@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa_a-assert.Po@am__quote@
    454469@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa_a-fstream.Po@am__quote@
     470@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa_a-interpose.Po@am__quote@
    455471@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa_a-iostream.Po@am__quote@
    456472@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa_a-iterator.Po@am__quote@
     
    462478@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa_d_a-assert.Po@am__quote@
    463479@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa_d_a-fstream.Po@am__quote@
     480@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa_d_a-interpose.Po@am__quote@
    464481@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa_d_a-iostream.Po@am__quote@
    465482@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa_d_a-iterator.Po@am__quote@
     
    482499@AMDEP_TRUE@@am__include@ @am__quote@containers/$(DEPDIR)/libcfa_a-vector.Po@am__quote@
    483500@AMDEP_TRUE@@am__include@ @am__quote@containers/$(DEPDIR)/libcfa_d_a-vector.Po@am__quote@
     501@AMDEP_TRUE@@am__include@ @am__quote@libhdr/$(DEPDIR)/libcfa_a-libdebug.Po@am__quote@
     502@AMDEP_TRUE@@am__include@ @am__quote@libhdr/$(DEPDIR)/libcfa_d_a-libdebug.Po@am__quote@
    484503
    485504.S.o:
     
    522541@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o libcfa_d_a-libcfa-prelude.obj `if test -f 'libcfa-prelude.c'; then $(CYGPATH_W) 'libcfa-prelude.c'; else $(CYGPATH_W) '$(srcdir)/libcfa-prelude.c'; fi`
    523542
     543libcfa_d_a-interpose.o: interpose.c
     544@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT libcfa_d_a-interpose.o -MD -MP -MF $(DEPDIR)/libcfa_d_a-interpose.Tpo -c -o libcfa_d_a-interpose.o `test -f 'interpose.c' || echo '$(srcdir)/'`interpose.c
     545@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_d_a-interpose.Tpo $(DEPDIR)/libcfa_d_a-interpose.Po
     546@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='interpose.c' object='libcfa_d_a-interpose.o' libtool=no @AMDEPBACKSLASH@
     547@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     548@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o libcfa_d_a-interpose.o `test -f 'interpose.c' || echo '$(srcdir)/'`interpose.c
     549
     550libcfa_d_a-interpose.obj: interpose.c
     551@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT libcfa_d_a-interpose.obj -MD -MP -MF $(DEPDIR)/libcfa_d_a-interpose.Tpo -c -o libcfa_d_a-interpose.obj `if test -f 'interpose.c'; then $(CYGPATH_W) 'interpose.c'; else $(CYGPATH_W) '$(srcdir)/interpose.c'; fi`
     552@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_d_a-interpose.Tpo $(DEPDIR)/libcfa_d_a-interpose.Po
     553@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='interpose.c' object='libcfa_d_a-interpose.obj' libtool=no @AMDEPBACKSLASH@
     554@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     555@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o libcfa_d_a-interpose.obj `if test -f 'interpose.c'; then $(CYGPATH_W) 'interpose.c'; else $(CYGPATH_W) '$(srcdir)/interpose.c'; fi`
     556
     557libhdr/libcfa_d_a-libdebug.o: libhdr/libdebug.c
     558@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT libhdr/libcfa_d_a-libdebug.o -MD -MP -MF libhdr/$(DEPDIR)/libcfa_d_a-libdebug.Tpo -c -o libhdr/libcfa_d_a-libdebug.o `test -f 'libhdr/libdebug.c' || echo '$(srcdir)/'`libhdr/libdebug.c
     559@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) libhdr/$(DEPDIR)/libcfa_d_a-libdebug.Tpo libhdr/$(DEPDIR)/libcfa_d_a-libdebug.Po
     560@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='libhdr/libdebug.c' object='libhdr/libcfa_d_a-libdebug.o' libtool=no @AMDEPBACKSLASH@
     561@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     562@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o libhdr/libcfa_d_a-libdebug.o `test -f 'libhdr/libdebug.c' || echo '$(srcdir)/'`libhdr/libdebug.c
     563
     564libhdr/libcfa_d_a-libdebug.obj: libhdr/libdebug.c
     565@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT libhdr/libcfa_d_a-libdebug.obj -MD -MP -MF libhdr/$(DEPDIR)/libcfa_d_a-libdebug.Tpo -c -o libhdr/libcfa_d_a-libdebug.obj `if test -f 'libhdr/libdebug.c'; then $(CYGPATH_W) 'libhdr/libdebug.c'; else $(CYGPATH_W) '$(srcdir)/libhdr/libdebug.c'; fi`
     566@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) libhdr/$(DEPDIR)/libcfa_d_a-libdebug.Tpo libhdr/$(DEPDIR)/libcfa_d_a-libdebug.Po
     567@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='libhdr/libdebug.c' object='libhdr/libcfa_d_a-libdebug.obj' libtool=no @AMDEPBACKSLASH@
     568@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     569@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o libhdr/libcfa_d_a-libdebug.obj `if test -f 'libhdr/libdebug.c'; then $(CYGPATH_W) 'libhdr/libdebug.c'; else $(CYGPATH_W) '$(srcdir)/libhdr/libdebug.c'; fi`
     570
    524571libcfa_d_a-limits.o: limits.c
    525572@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT libcfa_d_a-limits.o -MD -MP -MF $(DEPDIR)/libcfa_d_a-limits.Tpo -c -o libcfa_d_a-limits.o `test -f 'limits.c' || echo '$(srcdir)/'`limits.c
     
    717764@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    718765@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o libcfa_a-libcfa-prelude.obj `if test -f 'libcfa-prelude.c'; then $(CYGPATH_W) 'libcfa-prelude.c'; else $(CYGPATH_W) '$(srcdir)/libcfa-prelude.c'; fi`
     766
     767libcfa_a-interpose.o: interpose.c
     768@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT libcfa_a-interpose.o -MD -MP -MF $(DEPDIR)/libcfa_a-interpose.Tpo -c -o libcfa_a-interpose.o `test -f 'interpose.c' || echo '$(srcdir)/'`interpose.c
     769@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_a-interpose.Tpo $(DEPDIR)/libcfa_a-interpose.Po
     770@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='interpose.c' object='libcfa_a-interpose.o' libtool=no @AMDEPBACKSLASH@
     771@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     772@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o libcfa_a-interpose.o `test -f 'interpose.c' || echo '$(srcdir)/'`interpose.c
     773
     774libcfa_a-interpose.obj: interpose.c
     775@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT libcfa_a-interpose.obj -MD -MP -MF $(DEPDIR)/libcfa_a-interpose.Tpo -c -o libcfa_a-interpose.obj `if test -f 'interpose.c'; then $(CYGPATH_W) 'interpose.c'; else $(CYGPATH_W) '$(srcdir)/interpose.c'; fi`
     776@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_a-interpose.Tpo $(DEPDIR)/libcfa_a-interpose.Po
     777@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='interpose.c' object='libcfa_a-interpose.obj' libtool=no @AMDEPBACKSLASH@
     778@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     779@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o libcfa_a-interpose.obj `if test -f 'interpose.c'; then $(CYGPATH_W) 'interpose.c'; else $(CYGPATH_W) '$(srcdir)/interpose.c'; fi`
     780
     781libhdr/libcfa_a-libdebug.o: libhdr/libdebug.c
     782@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT libhdr/libcfa_a-libdebug.o -MD -MP -MF libhdr/$(DEPDIR)/libcfa_a-libdebug.Tpo -c -o libhdr/libcfa_a-libdebug.o `test -f 'libhdr/libdebug.c' || echo '$(srcdir)/'`libhdr/libdebug.c
     783@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) libhdr/$(DEPDIR)/libcfa_a-libdebug.Tpo libhdr/$(DEPDIR)/libcfa_a-libdebug.Po
     784@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='libhdr/libdebug.c' object='libhdr/libcfa_a-libdebug.o' libtool=no @AMDEPBACKSLASH@
     785@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     786@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o libhdr/libcfa_a-libdebug.o `test -f 'libhdr/libdebug.c' || echo '$(srcdir)/'`libhdr/libdebug.c
     787
     788libhdr/libcfa_a-libdebug.obj: libhdr/libdebug.c
     789@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT libhdr/libcfa_a-libdebug.obj -MD -MP -MF libhdr/$(DEPDIR)/libcfa_a-libdebug.Tpo -c -o libhdr/libcfa_a-libdebug.obj `if test -f 'libhdr/libdebug.c'; then $(CYGPATH_W) 'libhdr/libdebug.c'; else $(CYGPATH_W) '$(srcdir)/libhdr/libdebug.c'; fi`
     790@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) libhdr/$(DEPDIR)/libcfa_a-libdebug.Tpo libhdr/$(DEPDIR)/libcfa_a-libdebug.Po
     791@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='libhdr/libdebug.c' object='libhdr/libcfa_a-libdebug.obj' libtool=no @AMDEPBACKSLASH@
     792@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     793@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o libhdr/libcfa_a-libdebug.obj `if test -f 'libhdr/libdebug.c'; then $(CYGPATH_W) 'libhdr/libdebug.c'; else $(CYGPATH_W) '$(srcdir)/libhdr/libdebug.c'; fi`
    719794
    720795libcfa_a-limits.o: limits.c
     
    10481123        -rm -f containers/$(DEPDIR)/$(am__dirstamp)
    10491124        -rm -f containers/$(am__dirstamp)
     1125        -rm -f libhdr/$(DEPDIR)/$(am__dirstamp)
     1126        -rm -f libhdr/$(am__dirstamp)
    10501127
    10511128maintainer-clean-generic:
     
    10571134
    10581135distclean: distclean-am
    1059         -rm -rf ./$(DEPDIR) concurrency/$(DEPDIR) containers/$(DEPDIR)
     1136        -rm -rf ./$(DEPDIR) concurrency/$(DEPDIR) containers/$(DEPDIR) libhdr/$(DEPDIR)
    10601137        -rm -f Makefile
    10611138distclean-am: clean-am distclean-compile distclean-generic \
     
    11031180
    11041181maintainer-clean: maintainer-clean-am
    1105         -rm -rf ./$(DEPDIR) concurrency/$(DEPDIR) containers/$(DEPDIR)
     1182        -rm -rf ./$(DEPDIR) concurrency/$(DEPDIR) containers/$(DEPDIR) libhdr/$(DEPDIR)
    11061183        -rm -f Makefile
    11071184maintainer-clean-am: distclean-am maintainer-clean-generic \
  • src/libcfa/assert.c

    r814525c rfc19129  
    1717#include "stdlib"                                                                               // abort
    1818
     19#include "libhdr/libdebug.h"
     20
    1921extern "C" {
    2022        #include <stdarg.h>                                                             // varargs
     
    2325        extern const char * __progname;                                         // global name of running executable (argv[0])
    2426
    25         #define CFA_ASSERT_FMT "*CFA assertion error* from program \"%s\" in \"%s\" at line %d in file \"%s\""
     27        #define CFA_ASSERT_FMT "Cforall Assertion error from program \"%s\" in \"%s\" at line %d in file \"%s\""
    2628
    2729        // called by macro assert in assert.h
    2830        void __assert_fail( const char *assertion, const char *file, unsigned int line, const char *function ) {
    29                 fprintf( stderr, CFA_ASSERT_FMT ".\n", __progname, function, line, file );
     31                __lib_debug_print_safe( CFA_ASSERT_FMT ".\n", __progname, function, line, file );
    3032                abort();
    3133        }
     
    3335        // called by macro assertf
    3436        void __assert_fail_f( const char *assertion, const char *file, unsigned int line, const char *function, const char *fmt, ... ) {
    35                 fprintf( stderr, CFA_ASSERT_FMT ": ", __progname, function, line, file );
     37                __lib_debug_acquire();
     38                __lib_debug_print_nolock( CFA_ASSERT_FMT ": ", __progname, function, line, file );
     39
    3640                va_list args;
    3741                va_start( args, fmt );
    38                 vfprintf( stderr, fmt, args );
     42                __lib_debug_print_vararg( fmt, args );
    3943                va_end( args );
    40                 fprintf( stderr, "\n" );
     44
     45                __lib_debug_print_nolock( "\n" );
     46                __lib_debug_release();
    4147                abort();
    4248        }
  • src/libcfa/concurrency/kernel.c

    r814525c rfc19129  
    1515//
    1616
     17#include "startup.h"
     18
    1719//Start and stop routine for the kernel, declared first to make sure they run first
    18 void kernel_startup(void)  __attribute__((constructor(101)));
    19 void kernel_shutdown(void) __attribute__((destructor(101)));
     20void kernel_startup(void)  __attribute__(( constructor( STARTUP_PRIORITY_KERNEL ) ));
     21void kernel_shutdown(void) __attribute__(( destructor ( STARTUP_PRIORITY_KERNEL ) ));
    2022
    2123//Header
     
    2527#include <stddef.h>
    2628extern "C" {
     29#include <stdio.h>
    2730#include <fenv.h>
    2831#include <sys/resource.h>
     32#include <signal.h>
     33#include <unistd.h>
    2934}
    3035
     
    146151
    147152        this->runner = runner;
    148         LIB_DEBUG_PRINTF("Kernel : constructing processor context %p\n", runner);
     153        LIB_DEBUG_PRINT_SAFE("Kernel : constructing processor context %p\n", runner);
    149154        runner{ this };
    150155}
     
    152157void ^?{}(processor * this) {
    153158        if( ! this->is_terminated ) {
    154                 LIB_DEBUG_PRINTF("Kernel : core %p signaling termination\n", this);
     159                LIB_DEBUG_PRINT_SAFE("Kernel : core %p signaling termination\n", this);
    155160                this->is_terminated = true;
    156161                wait( &this->terminated );
     
    173178void main(processorCtx_t * runner) {
    174179        processor * this = runner->proc;
    175         LIB_DEBUG_PRINTF("Kernel : core %p starting\n", this);
     180        LIB_DEBUG_PRINT_SAFE("Kernel : core %p starting\n", this);
    176181
    177182        thread_desc * readyThread = NULL;
     
    195200        }
    196201
    197         LIB_DEBUG_PRINTF("Kernel : core %p unlocking thread\n", this);
     202        LIB_DEBUG_PRINT_SAFE("Kernel : core %p unlocking thread\n", this);
    198203        signal( &this->terminated );
    199         LIB_DEBUG_PRINTF("Kernel : core %p terminated\n", this);
     204        LIB_DEBUG_PRINT_SAFE("Kernel : core %p terminated\n", this);
    200205}
    201206
     
    255260        processorCtx_t proc_cor_storage = { proc, &info };
    256261
    257         LIB_DEBUG_PRINTF("Coroutine : created stack %p\n", proc_cor_storage.__cor.stack.base);
     262        LIB_DEBUG_PRINT_SAFE("Coroutine : created stack %p\n", proc_cor_storage.__cor.stack.base);
    258263
    259264        //Set global state
     
    262267
    263268        //We now have a proper context from which to schedule threads
    264         LIB_DEBUG_PRINTF("Kernel : core %p created (%p, %p)\n", proc, proc->runner, &ctx);
     269        LIB_DEBUG_PRINT_SAFE("Kernel : core %p created (%p, %p)\n", proc, proc->runner, &ctx);
    265270
    266271        // SKULLDUGGERY: Since the coroutine doesn't have its own stack, we can't
     
    273278
    274279        // Main routine of the core returned, the core is now fully terminated
    275         LIB_DEBUG_PRINTF("Kernel : core %p main ended (%p)\n", proc, proc->runner);     
     280        LIB_DEBUG_PRINT_SAFE("Kernel : core %p main ended (%p)\n", proc, proc->runner);
    276281
    277282        return NULL;
     
    279284
    280285void start(processor * this) {
    281         LIB_DEBUG_PRINTF("Kernel : Starting core %p\n", this);
     286        LIB_DEBUG_PRINT_SAFE("Kernel : Starting core %p\n", this);
    282287       
    283288        // pthread_attr_t attributes;
     
    288293        // pthread_attr_destroy( &attributes );
    289294
    290         LIB_DEBUG_PRINTF("Kernel : core %p started\n", this);   
     295        LIB_DEBUG_PRINT_SAFE("Kernel : core %p started\n", this);       
    291296}
    292297
     
    334339// Kernel boot procedures
    335340void kernel_startup(void) {
    336         LIB_DEBUG_PRINTF("Kernel : Starting\n");       
     341        LIB_DEBUG_PRINT_SAFE("Kernel : Starting\n");   
    337342
    338343        // Start by initializing the main thread
     
    369374
    370375        // THE SYSTEM IS NOW COMPLETELY RUNNING
    371         LIB_DEBUG_PRINTF("Kernel : Started\n--------------------------------------------------\n\n");
     376        LIB_DEBUG_PRINT_SAFE("Kernel : Started\n--------------------------------------------------\n\n");
    372377}
    373378
    374379void kernel_shutdown(void) {
    375         LIB_DEBUG_PRINTF("\n--------------------------------------------------\nKernel : Shutting down\n");
     380        LIB_DEBUG_PRINT_SAFE("\n--------------------------------------------------\nKernel : Shutting down\n");
    376381
    377382        // SKULLDUGGERY: Notify the systemProcessor it needs to terminates.
     
    392397        ^(mainThread){};
    393398
    394         LIB_DEBUG_PRINTF("Kernel : Shutdown complete\n");       
     399        LIB_DEBUG_PRINT_SAFE("Kernel : Shutdown complete\n");   
     400}
     401
     402static spinlock kernel_abort_lock;
     403static spinlock kernel_debug_lock;
     404static bool kernel_abort_called = false;
     405
     406void * kernel_abort    (void) __attribute__ ((__nothrow__)) {
     407        // abort cannot be recursively entered by the same or different processors because all signal handlers return when
     408        // the globalAbort flag is true.
     409        lock( &kernel_abort_lock );
     410
     411        // first task to abort ?
     412        if ( !kernel_abort_called ) {                   // not first task to abort ?
     413                kernel_abort_called = true;
     414                unlock( &kernel_abort_lock );
     415        }
     416        else {
     417                unlock( &kernel_abort_lock );
     418               
     419                sigset_t mask;
     420                sigemptyset( &mask );
     421                sigaddset( &mask, SIGALRM );                    // block SIGALRM signals
     422                sigaddset( &mask, SIGUSR1 );                    // block SIGUSR1 signals
     423                sigsuspend( &mask );                            // block the processor to prevent further damage during abort
     424                _exit( EXIT_FAILURE );                          // if processor unblocks before it is killed, terminate it             
     425        }
     426
     427        return this_thread();
     428}
     429
     430void kernel_abort_msg( void * kernel_data, char * abort_text, int abort_text_size ) {
     431        thread_desc * thrd = kernel_data;
     432
     433        int len = snprintf( abort_text, abort_text_size, "Error occurred while executing task %.256s (%p)", thrd->cor.name, thrd );
     434        __lib_debug_write( STDERR_FILENO, abort_text, len );
     435
     436        if ( thrd != this_coroutine() ) {
     437                len = snprintf( abort_text, abort_text_size, " in coroutine %.256s (%p).\n", this_coroutine()->name, this_coroutine() );
     438                __lib_debug_write( STDERR_FILENO, abort_text, len );
     439        }
     440        else {
     441                __lib_debug_write( STDERR_FILENO, ".\n", 2 );
     442        }
     443}
     444
     445extern "C" {
     446        void __lib_debug_acquire() {
     447                lock(&kernel_debug_lock);
     448        }
     449
     450        void __lib_debug_release() {
     451                unlock(&kernel_debug_lock);
     452        }
    395453}
    396454
  • src/libcfa/concurrency/thread.c

    r814525c rfc19129  
    7171        this_processor->current_coroutine = thrd_c;
    7272
    73         LIB_DEBUG_PRINTF("Thread start : %p (t %p, c %p)\n", this, thrd_c, thrd_h);
     73        LIB_DEBUG_PRINT_SAFE("Thread start : %p (t %p, c %p)\n", this, thrd_c, thrd_h);
    7474
    7575        create_stack(&thrd_c->stack, thrd_c->stack.size);
  • src/libcfa/libhdr/libdebug.h

    r814525c rfc19129  
    2525#endif
    2626
     27#ifdef __cforall
     28extern "C" {
     29#endif
     30      #include <stdarg.h>
     31
     32      extern void __lib_debug_write( int fd, const char *buffer, int len );
     33      extern void __lib_debug_acquire();
     34      extern void __lib_debug_release();
     35      extern void __lib_debug_print_safe  ( const char fmt[], ... ) __attribute__(( format (printf, 1, 2) ));
     36      extern void __lib_debug_print_nolock( const char fmt[], ... ) __attribute__(( format (printf, 1, 2) ));
     37      extern void __lib_debug_print_vararg( const char fmt[], va_list arg );
     38      extern void __lib_debug_print_buffer( char buffer[], int buffer_size, const char fmt[], ... ) __attribute__(( format (printf, 3, 4) ));
     39#ifdef __cforall
     40}
     41#endif
     42
    2743#ifdef __CFA_DEBUG_PRINT__
    28       #define LIB_DEBUG_PRINTF(...)   printf (__VA_ARGS__)
    29       #define LIB_DEBUG_FPRINTF(...) fprintf (stderr, __VA_ARGS__)
     44      #define LIB_DEBUG_WRITE( fd, buffer, len )  __lib_debug_write( fd, buffer, len )
     45      #define LIB_DEBUG_ACQUIRE()                 __lib_debug_acquire()
     46      #define LIB_DEBUG_RELEASE()                 __lib_debug_release()
     47      #define LIB_DEBUG_PRINT_SAFE(...)           __lib_debug_print_safe   (__VA_ARGS__)
     48      #define LIB_DEBUG_PRINT_NOLOCK(...)         __lib_debug_print_nolock (__VA_ARGS__)
     49      #define LIB_DEBUG_PRINT_BUFFER(...)         __lib_debug_print_buffer (__VA_ARGS__)
    3050#else
    31       #define LIB_DEBUG_PRINTF(...)  ((void)0)
    32       #define LIB_DEBUG_FPRINTF(...) ((void)0)
     51      #define LIB_DEBUG_WRITE(...)          ((void)0)
     52      #define LIB_DEBUG_ACQUIRE()           ((void)0)
     53      #define LIB_DEBUG_RELEASE()           ((void)0)
     54      #define LIB_DEBUG_PRINT_SAFE(...)     ((void)0)
     55      #define LIB_DEBUG_PRINT_NOLOCK(...)   ((void)0)
     56      #define LIB_DEBUG_PRINT_BUFFER(...)   ((void)0)
    3357#endif
    3458
  • src/libcfa/stdlib

    r814525c rfc19129  
    1010// Created On       : Thu Jan 28 17:12:35 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Mar  4 22:03:54 2017
    13 // Update Count     : 102
     12// Last Modified On : Sat Apr  1 17:35:24 2017
     13// Update Count     : 104
    1414//
    1515
     
    8484forall( otype T | { int ?<?( T, T ); } )
    8585T * bsearch( T key, const T * arr, size_t dimension );
     86forall( otype T | { int ?<?( T, T ); } )
     87unsigned int bsearch( T key, const T * arr, size_t dimension );
    8688
    8789forall( otype T | { int ?<?( T, T ); } )
  • src/libcfa/stdlib.c

    r814525c rfc19129  
    1010// Created On       : Thu Jan 28 17:10:29 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Mar  4 22:02:22 2017
    13 // Update Count     : 172
     12// Last Modified On : Sat Apr  1 18:31:26 2017
     13// Update Count     : 181
    1414//
    1515
     
    228228
    229229forall( otype T | { int ?<?( T, T ); } )
     230unsigned int bsearch( T key, const T * arr, size_t dimension ) {
     231        int comp( const void * t1, const void * t2 ) { return *(T *)t1 < *(T *)t2 ? -1 : *(T *)t2 < *(T *)t1 ? 1 : 0; }
     232        T *result = (T *)bsearch( &key, arr, dimension, sizeof(T), comp );
     233        return result ? result - arr : dimension;                       // pointer subtraction includes sizeof(T)
     234} // bsearch
     235
     236forall( otype T | { int ?<?( T, T ); } )
    230237void qsort( const T * arr, size_t dimension ) {
    231238        int comp( const void * t1, const void * t2 ) { return *(T *)t1 < *(T *)t2 ? -1 : *(T *)t2 < *(T *)t1 ? 1 : 0; }
  • src/tests/.expect/searchsort.txt

    r814525c rfc19129  
    1 10, 9, 8, 7, 6, 5, 4, 3, 2, 1,
    2 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
    3110, 9, 8, 7, 6, 5, 4, 3, 2, 1,
    42
    531, 2, 3, 4, 5, 6, 7, 8, 9, 10,
     410, 9, 8, 7, 6, 5, 4, 3, 2, 1,
     510, 9, 8, 7, 6, 5, 4, 3, 2, 1,
     610, 9, 8, 7, 6, 5, 4, 3, 2, 1,
     7
     81, 2, 3, 4, 5, 6, 7, 8, 9, 10,
     910, 9, 8, 7, 6, 5, 4, 3, 2, 1,
    61010, 9, 8, 7, 6, 5, 4, 3, 2, 1,
    71110, 9, 8, 7, 6, 5, 4, 3, 2, 1,
     
    10141.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5,
    111510.5, 9.5, 8.5, 7.5, 6.5, 5.5, 4.5, 3.5, 2.5, 1.5,
     1610.5, 9.5, 8.5, 7.5, 6.5, 5.5, 4.5, 3.5, 2.5, 1.5,
    1217
    131810 11, 9 10, 8 9, 7 8, 6 7, 5 6, 4 5, 3 4, 2 3, 1 2,
    14191 2, 2 3, 3 4, 4 5, 5 6, 6 7, 7 8, 8 9, 9 10, 10 11,
    152010 11, 9 10, 8 9, 7 8, 6 7, 5 6, 4 5, 3 4, 2 3, 1 2,
     2110 11, 9 10, 8 9, 7 8, 6 7, 5 6, 4 5, 3 4, 2 3, 1 2,
    1622
  • src/tests/searchsort.c

    r814525c rfc19129  
    1010// Created On       : Thu Feb  4 18:17:50 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Jul  5 18:06:07 2016
    13 // Update Count     : 56
     12// Last Modified On : Sun Apr  2 11:29:30 2017
     13// Update Count     : 76
    1414//
    1515
    1616#include <fstream>
    1717#include <stdlib>                                                                               // bsearch, qsort
     18#include <stdlib.h>                                                                             // C version of bsearch
     19
     20int comp( const void * t1, const void * t2 ) { return *(int *)t1 < *(int *)t2 ? -1 : *(int *)t2 < *(int *)t1 ? 1 : 0; }
    1821
    1922int main( void ) {
     
    2528                sout | iarr[i] | ", ";
    2629        } // for
    27         sout | endl;
     30        sout | endl | endl;
     31
     32        // ascending sort/search by changing < to >
    2833        qsort( iarr, size );
    2934        for ( unsigned int i = 0; i < size; i += 1 ) {
     
    3136        } // for
    3237        sout | endl;
     38        for ( unsigned int i = 0; i < size; i += 1 ) {          // C version
     39                int key = size - i;
     40                int *v = bsearch( &key, iarr, size, sizeof( iarr[0] ), comp );
     41                sout | *v | ", ";
     42        } // for
     43        sout | endl;
    3344        for ( unsigned int i = 0; i < size; i += 1 ) {
    3445                int *v = bsearch( size - i, iarr, size );
    3546                sout | *v | ", ";
     47        } // for
     48        sout | endl;
     49        for ( unsigned int i = 0; i < size; i += 1 ) {
     50                unsigned int posn = bsearch( size - i, iarr, size );
     51                sout | iarr[posn] | ", ";
    3652        } // for
    3753        sout | endl | endl;
     
    5470                        sout | *v | ", ";
    5571                } // for
     72                sout | endl;
     73                for ( unsigned int i = 0; i < size; i += 1 ) {
     74                        unsigned int posn = bsearch( size - i, iarr, size );
     75                        sout | iarr[posn] | ", ";
     76                } // for
    5677        }
    5778        sout | endl | endl;
     
    7192                double *v = bsearch( size - i + 0.5, darr, size );
    7293                sout | *v | ", ";
     94        } // for
     95        sout | endl;
     96        for ( unsigned int i = 0; i < size; i += 1 ) {
     97                unsigned int posn = bsearch( size - i + 0.5, darr, size );
     98                sout | darr[posn] | ", ";
    7399        } // for
    74100        sout | endl | endl;
     
    93119                sout | *v | ", ";
    94120        } // for
     121        sout | endl;
     122        for ( unsigned int i = 0; i < size; i += 1 ) {
     123                S temp = { size - i, size - i + 1 };
     124                unsigned int posn = bsearch( temp, sarr, size );
     125                sout | sarr[posn] | ", ";
     126        } // for
    95127        sout | endl | endl;
    96128} // main
Note: See TracChangeset for help on using the changeset viewer.