Changeset b7d6a36 for libcfa/src/bits


Ignore:
Timestamp:
Feb 20, 2020, 4:15:51 PM (6 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:
6a490b2
Parents:
dca5802 (diff), 2cbfe92 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' into relaxed_ready

Location:
libcfa/src/bits
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/bits/containers.hfa

    rdca5802 rb7d6a36  
    1010// Created On       : Tue Oct 31 16:38:50 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Jun 26 08:52:20 2019
    13 // Update Count     : 4
     12// Last Modified On : Wed Jan 15 07:42:35 2020
     13// Update Count     : 28
    1414
    1515#pragma once
     
    4444
    4545        forall(dtype T | sized(T))
    46         static inline T& ?[?]( __small_array(T) & this, __lock_size_t idx) {
     46        static inline T & ?[?]( __small_array(T) & this, __lock_size_t idx ) {
    4747                return ((typeof(this.data))this.data)[idx];
    4848        }
    4949
    5050        forall(dtype T | sized(T))
    51         static inline T& ?[?]( const __small_array(T) & this, __lock_size_t idx) {
     51        static inline T & ?[?]( const __small_array(T) & this, __lock_size_t idx ) {
    5252                return ((typeof(this.data))this.data)[idx];
    5353        }
    5454
     55        forall(dtype T)
     56        static inline T * begin( const __small_array(T) & this ) {
     57                return ((typeof(this.data))this.data);
     58        }
     59
    5560        forall(dtype T | sized(T))
    56         static inline T* begin( const __small_array(T) & this ) {
    57                 return ((typeof(this.data))this.data);
    58         }
    59 
    60         forall(dtype T | sized(T))
    61         static inline T* end( const __small_array(T) & this ) {
     61        static inline T * end( const __small_array(T) & this ) {
    6262                return ((typeof(this.data))this.data) + this.size;
    6363        }
     
    7070#ifdef __cforall
    7171        trait is_node(dtype T) {
    72                 T*& get_next( T& );
     72                T *& get_next( T & );
    7373        };
    7474#endif
     
    9797        forall(dtype T)
    9898        static inline void ?{}( __stack(T) & this ) {
    99                 (this.top){ NULL };
    100         }
    101 
    102         forall(dtype T | is_node(T) | sized(T))
    103         static inline void push( __stack(T) & this, T * val ) {
    104                 verify( !get_next( *val ) );
    105                 get_next( *val ) = this.top;
    106                 this.top = val;
    107         }
    108 
    109         forall(dtype T | is_node(T) | sized(T))
    110         static inline T * pop( __stack(T) & this ) {
    111                 T * top = this.top;
    112                 if( top ) {
    113                         this.top = get_next( *top );
    114                         get_next( *top ) = NULL;
    115                 }
    116                 return top;
    117         }
    118 
    119         forall(dtype T | is_node(T))
    120         static inline int ?!=?( const __stack(T) & this, __attribute__((unused)) zero_t zero ) {
    121                 return this.top != 0;
     99                (this.top){ 0p };
     100        }
     101
     102        static inline forall( dtype T | is_node(T) ) {
     103                void push( __stack(T) & this, T * val ) {
     104                        verify( !get_next( *val ) );
     105                        get_next( *val ) = this.top;
     106                        this.top = val;
     107                }
     108
     109                T * pop( __stack(T) & this ) {
     110                        T * top = this.top;
     111                        if( top ) {
     112                                this.top = get_next( *top );
     113                                get_next( *top ) = 0p;
     114                        }
     115                        return top;
     116                }
     117
     118                int ?!=?( const __stack(T) & this, __attribute__((unused)) zero_t zero ) {
     119                        return this.top != 0;
     120                }
    122121        }
    123122#endif
     
    145144
    146145#ifdef __cforall
    147 
    148         forall(dtype T)
    149         static inline void ?{}( __queue(T) & this ) with( this ) {
    150                 head{ NULL };
    151                 tail{ &head };
    152         }
    153 
    154         forall(dtype T | is_node(T) | sized(T))
    155         static inline void append( __queue(T) & this, T * val ) with( this ) {
    156                 verify(tail != NULL);
    157                 *tail = val;
    158                 tail = &get_next( *val );
    159         }
    160 
    161         forall(dtype T | is_node(T) | sized(T))
    162         static inline T * pop_head( __queue(T) & this ) {
    163                 T * head = this.head;
    164                 if( head ) {
    165                         this.head = get_next( *head );
    166                         if( !get_next( *head ) ) {
    167                                 this.tail = &this.head;
    168                         }
    169                         get_next( *head ) = NULL;
    170                 }
    171                 return head;
    172         }
    173 
    174         forall(dtype T | is_node(T) | sized(T))
    175         static inline T * remove( __queue(T) & this, T ** it ) with( this ) {
    176                 T * val = *it;
    177                 verify( val );
    178 
    179                 (*it) = get_next( *val );
    180 
    181                 if( tail == &get_next( *val ) ) {
    182                         tail = it;
    183                 }
    184 
    185                 get_next( *val ) = NULL;
    186 
    187                 verify( (head == NULL) == (&head == tail) );
    188                 verify( *tail == NULL );
    189                 return val;
    190         }
    191 
    192         forall(dtype T | is_node(T))
    193         static inline int ?!=?( const __queue(T) & this, __attribute__((unused)) zero_t zero ) {
    194                 return this.head != 0;
     146        static inline forall( dtype T | is_node(T) ) {
     147                void ?{}( __queue(T) & this ) with( this ) {
     148                        head{ 0p };
     149                        tail{ &head };
     150                }
     151
     152                void append( __queue(T) & this, T * val ) with( this ) {
     153                        verify(tail != 0p);
     154                        *tail = val;
     155                        tail = &get_next( *val );
     156                }
     157
     158                T * pop_head( __queue(T) & this ) {
     159                        T * head = this.head;
     160                        if( head ) {
     161                                this.head = get_next( *head );
     162                                if( !get_next( *head ) ) {
     163                                        this.tail = &this.head;
     164                                }
     165                                get_next( *head ) = 0p;
     166                        }
     167                        return head;
     168                }
     169
     170                T * remove( __queue(T) & this, T ** it ) with( this ) {
     171                        T * val = *it;
     172                        verify( val );
     173
     174                        (*it) = get_next( *val );
     175
     176                        if( tail == &get_next( *val ) ) {
     177                                tail = it;
     178                        }
     179
     180                        get_next( *val ) = 0p;
     181
     182                        verify( (head == 0p) == (&head == tail) );
     183                        verify( *tail == 0p );
     184                        return val;
     185                }
     186
     187                int ?!=?( const __queue(T) & this, __attribute__((unused)) zero_t zero ) {
     188                        return this.head != 0;
     189                }
    195190        }
    196191#endif
     
    223218
    224219#ifdef __cforall
    225 
    226         forall(dtype T | sized(T))
     220        forall(dtype T )
    227221        static inline [void] ?{}( __dllist(T) & this, * [T * & next, T * & prev] ( T & ) __get ) {
    228                 this.head{ NULL };
     222                this.head{ 0p };
    229223                this.__get = __get;
    230224        }
     
    232226        #define next 0
    233227        #define prev 1
    234         forall(dtype T | sized(T))
    235         static inline void push_front( __dllist(T) & this, T & node ) with( this ) {
    236                 verify(__get);
    237                 if ( head ) {
    238                         __get( node ).next = head;
    239                         __get( node ).prev = __get( *head ).prev;
    240                         // inserted node must be consistent before it is seen
     228        static inline forall(dtype T) {
     229                void push_front( __dllist(T) & this, T & node ) with( this ) {
     230                        verify(__get);
     231                        if ( head ) {
     232                                __get( node ).next = head;
     233                                __get( node ).prev = __get( *head ).prev;
     234                                // inserted node must be consistent before it is seen
     235                                // prevent code movement across barrier
     236                                asm( "" : : : "memory" );
     237                                __get( *head ).prev = &node;
     238                                T & _prev = *__get( node ).prev;
     239                                __get( _prev ).next = &node;
     240                        } else {
     241                                __get( node ).next = &node;
     242                                __get( node ).prev = &node;
     243                        }
     244
    241245                        // prevent code movement across barrier
    242246                        asm( "" : : : "memory" );
    243                         __get( *head ).prev = &node;
    244                         T & _prev = *__get( node ).prev;
    245                         __get( _prev ).next = &node;
    246                 }
    247                 else {
    248                         __get( node ).next = &node;
    249                         __get( node ).prev = &node;
    250                 }
    251 
    252                 // prevent code movement across barrier
    253                 asm( "" : : : "memory" );
    254                 head = &node;
    255         }
    256 
    257         forall(dtype T | sized(T))
    258         static inline void remove( __dllist(T) & this, T & node ) with( this ) {
    259                 verify(__get);
    260                 if ( &node == head ) {
    261                         if ( __get( *head ).next == head ) {
    262                                 head = NULL;
    263                         }
    264                         else {
    265                                 head = __get( *head ).next;
    266                         }
    267                 }
    268                 __get( *__get( node ).next ).prev = __get( node ).prev;
    269                 __get( *__get( node ).prev ).next = __get( node ).next;
    270                 __get( node ).next = NULL;
    271                 __get( node ).prev = NULL;
    272         }
    273 
    274         forall(dtype T | sized(T))
    275         static inline int ?!=?( const __dllist(T) & this, __attribute__((unused)) zero_t zero ) {
    276                 return this.head != 0;
     247                        head = &node;
     248                }
     249
     250                void remove( __dllist(T) & this, T & node ) with( this ) {
     251                        verify(__get);
     252                        if ( &node == head ) {
     253                                if ( __get( *head ).next == head ) {
     254                                        head = 0p;
     255                                } else {
     256                                        head = __get( *head ).next;
     257                                }
     258                        }
     259                        __get( *__get( node ).next ).prev = __get( node ).prev;
     260                        __get( *__get( node ).prev ).next = __get( node ).next;
     261                        __get( node ).next = 0p;
     262                        __get( node ).prev = 0p;
     263                }
     264
     265                int ?!=?( const __dllist(T) & this, __attribute__((unused)) zero_t zero ) {
     266                        return this.head != 0;
     267                }
    277268        }
    278269        #undef next
     
    286277
    287278#endif
     279
     280// Local Variables: //
     281// tab-width: 4 //
     282// End: //
  • libcfa/src/bits/debug.cfa

    rdca5802 rb7d6a36  
    1010// Created On       : Thu Mar 30 12:30:01 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Nov 21 17:16:30 2019
    13 // Update Count     : 10
     12// Last Modified On : Tue Feb  4 13:03:16 2020
     13// Update Count     : 11
    1414//
    1515
     
    2727
    2828extern "C" {
    29 
    30         void __cfaabi_bits_write( int fd, const char *in_buffer, int len ) {
     29        void __cfaabi_bits_write( int fd, const char in_buffer[], int len ) {
    3130                // ensure all data is written
    3231                for ( int count = 0, retcode; count < len; count += retcode ) {
  • libcfa/src/bits/debug.hfa

    rdca5802 rb7d6a36  
    1010// Created On       : Mon Nov 28 12:27:26 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Nov 21 17:06:58 2019
    13 // Update Count     : 8
     12// Last Modified On : Tue Feb  4 12:29:21 2020
     13// Update Count     : 9
    1414//
    1515
     
    2121        #define __cfaabi_dbg_ctx __PRETTY_FUNCTION__
    2222        #define __cfaabi_dbg_ctx2 , __PRETTY_FUNCTION__
    23         #define __cfaabi_dbg_ctx_param const char * caller
    24         #define __cfaabi_dbg_ctx_param2 , const char * caller
     23        #define __cfaabi_dbg_ctx_param const char caller[]
     24        #define __cfaabi_dbg_ctx_param2 , const char caller[]
    2525#else
    2626        #define __cfaabi_dbg_debug_do(...)
     
    3939        #include <unistd.h>
    4040
    41         extern void __cfaabi_bits_write( int fd, const char *buffer, int len );
     41        extern void __cfaabi_bits_write( int fd, const char buffer[], int len );
    4242        extern void __cfaabi_bits_acquire();
    4343        extern void __cfaabi_bits_release();
  • libcfa/src/bits/defs.hfa

    rdca5802 rb7d6a36  
    1010// Created On       : Thu Nov  9 13:24:10 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Feb  8 16:22:41 2018
    13 // Update Count     : 8
     12// Last Modified On : Tue Jan 28 22:38:27 2020
     13// Update Count     : 9
    1414//
    1515
     
    3434
    3535#ifdef __cforall
    36 void abort ( const char fmt[], ... ) __attribute__ (( format(printf, 1, 2), __nothrow__, __leaf__, __noreturn__ ));
     36void abort( const char fmt[], ... ) __attribute__ (( format(printf, 1, 2), __nothrow__, __leaf__, __noreturn__ ));
     37void abort( bool signalAbort, const char fmt[], ... ) __attribute__ (( format(printf, 2, 3), __nothrow__, __leaf__, __noreturn__ ));
    3738extern "C" {
    3839#endif
  • libcfa/src/bits/locks.hfa

    rdca5802 rb7d6a36  
    1010// Created On       : Tue Oct 31 15:14:38 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Aug 11 15:42:24 2018
    13 // Update Count     : 10
     12// Last Modified On : Tue Feb  4 13:03:19 2020
     13// Update Count     : 11
    1414//
    1515
     
    5454
    5555                #ifdef __CFA_DEBUG__
    56                         void __cfaabi_dbg_record(__spinlock_t & this, const char * prev_name);
     56                        void __cfaabi_dbg_record(__spinlock_t & this, const char prev_name[]);
    5757                #else
    5858                        #define __cfaabi_dbg_record(x, y)
  • libcfa/src/bits/signal.hfa

    rdca5802 rb7d6a36  
    3737
    3838        act.sa_sigaction = (void (*)(int, siginfo_t *, void *))handler;
     39        sigemptyset( &act.sa_mask );
     40        sigaddset( &act.sa_mask, SIGALRM );             // disabled during signal handler
     41        sigaddset( &act.sa_mask, SIGUSR1 );
     42        sigaddset( &act.sa_mask, SIGSEGV );
     43        sigaddset( &act.sa_mask, SIGBUS );
     44        sigaddset( &act.sa_mask, SIGILL );
     45        sigaddset( &act.sa_mask, SIGFPE );
     46        sigaddset( &act.sa_mask, SIGHUP );              // revert to default on second delivery
     47        sigaddset( &act.sa_mask, SIGTERM );
     48        sigaddset( &act.sa_mask, SIGINT );
    3949        act.sa_flags = flags;
    4050
    41         if ( sigaction( sig, &act, NULL ) == -1 ) {
     51        if ( sigaction( sig, &act, 0p ) == -1 ) {
    4252                __cfaabi_dbg_print_buffer_decl(
    4353                        " __cfaabi_sigaction( sig:%d, handler:%p, flags:%d ), problem installing signal handler, error(%d) %s.\n",
     
    4555                );
    4656                _exit( EXIT_FAILURE );
    47         }
     57        } // if
    4858}
    49 
    50 // Sigaction wrapper : restore default handler
    51 static void __cfaabi_sigdefault( int sig ) {
    52         struct sigaction act;
    53 
    54         act.sa_handler = SIG_DFL;
    55         act.sa_flags = 0;
    56         sigemptyset( &act.sa_mask );
    57 
    58         if ( sigaction( sig, &act, NULL ) == -1 ) {
    59                 __cfaabi_dbg_print_buffer_decl(
    60                         " __cfaabi_sigdefault( sig:%d ), problem reseting signal handler, error(%d) %s.\n",
    61                         sig, errno, strerror( errno )
    62                 );
    63                 _exit( EXIT_FAILURE );
    64         }
    65 }
Note: See TracChangeset for help on using the changeset viewer.