Changes in / [49d3128:2909b51]


Ignore:
Location:
libcfa/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/assert.cfa

    r49d3128 r2909b51  
    1010// Created On       : Mon Nov 28 12:27:26 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jul 20 15:10:26 2017
    13 // Update Count     : 2
     12// Last Modified On : Thu Nov 21 17:09:26 2019
     13// Update Count     : 5
    1414//
    1515
     
    1717#include <stdarg.h>                                                             // varargs
    1818#include <stdio.h>                                                              // fprintf
     19#include <unistd.h>                                                             // STDERR_FILENO
    1920#include "bits/debug.hfa"
    2021
     
    2627        // called by macro assert in assert.h
    2728        void __assert_fail( const char *assertion, const char *file, unsigned int line, const char *function ) {
    28                 __cfaabi_dbg_bits_print_safe( CFA_ASSERT_FMT ".\n", assertion, __progname, function, line, file );
     29                __cfaabi_bits_print_safe( STDERR_FILENO, CFA_ASSERT_FMT ".\n", assertion, __progname, function, line, file );
    2930                abort();
    3031        }
     
    3233        // called by macro assertf
    3334        void __assert_fail_f( const char *assertion, const char *file, unsigned int line, const char *function, const char *fmt, ... ) {
    34                 __cfaabi_dbg_bits_acquire();
    35                 __cfaabi_dbg_bits_print_nolock( CFA_ASSERT_FMT ": ", assertion, __progname, function, line, file );
     35                __cfaabi_bits_acquire();
     36                __cfaabi_bits_print_nolock( STDERR_FILENO, CFA_ASSERT_FMT ": ", assertion, __progname, function, line, file );
    3637
    3738                va_list args;
    3839                va_start( args, fmt );
    39                 __cfaabi_dbg_bits_print_vararg( fmt, args );
     40                __cfaabi_bits_print_vararg( STDERR_FILENO, fmt, args );
    4041                va_end( args );
    4142
    42                 __cfaabi_dbg_bits_print_nolock( "\n" );
    43                 __cfaabi_dbg_bits_release();
     43                __cfaabi_bits_print_nolock( STDERR_FILENO, "\n" );
     44                __cfaabi_bits_release();
    4445                abort();
    4546        }
  • libcfa/src/bits/align.hfa

    r49d3128 r2909b51  
    1010// Created On       : Mon Nov 28 12:27:26 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jul 21 23:05:35 2017
    13 // Update Count     : 2
     12// Last Modified On : Sat Nov 16 18:58:22 2019
     13// Update Count     : 3
    1414//
    1515// This  library is free  software; you  can redistribute  it and/or  modify it
     
    3333
    3434// Minimum size used to align memory boundaries for memory allocations.
    35 #define libAlign() (sizeof(double))
     35//#define libAlign() (sizeof(double))
     36// gcc-7 uses xmms instructions, which require 16 byte alignment.
     37#define libAlign() (16)
    3638
    3739// Check for power of 2
  • libcfa/src/bits/debug.cfa

    r49d3128 r2909b51  
    1010// Created On       : Thu Mar 30 12:30:01 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Jul 14 22:17:35 2019
    13 // Update Count     : 4
     12// Last Modified On : Thu Nov 21 17:16:30 2019
     13// Update Count     : 10
    1414//
    1515
     
    2828extern "C" {
    2929
    30         void __cfaabi_dbg_bits_write( const char *in_buffer, int len ) {
     30        void __cfaabi_bits_write( int fd, const char *in_buffer, int len ) {
    3131                // ensure all data is written
    3232                for ( int count = 0, retcode; count < len; count += retcode ) {
     
    3434
    3535                        for ( ;; ) {
    36                                 retcode = write( STDERR_FILENO, in_buffer, len - count );
     36                                retcode = write( fd, in_buffer, len - count );
    3737
    3838                                // not a timer interrupt ?
     
    4444        }
    4545
    46         void __cfaabi_dbg_bits_acquire() __attribute__((__weak__)) {}
    47         void __cfaabi_dbg_bits_release() __attribute__((__weak__)) {}
     46        void __cfaabi_bits_acquire() __attribute__((__weak__)) {}
     47        void __cfaabi_bits_release() __attribute__((__weak__)) {}
    4848
    49         void __cfaabi_dbg_bits_print_safe  ( const char fmt[], ... ) __attribute__(( format(printf, 1, 2) )) {
     49        void __cfaabi_bits_print_safe  ( int fd, const char fmt[], ... ) __attribute__(( format(printf, 2, 3) )) {
    5050                va_list args;
    5151
    5252                va_start( args, fmt );
    53                 __cfaabi_dbg_bits_acquire();
     53                __cfaabi_bits_acquire();
    5454
    5555                int len = vsnprintf( buffer, buffer_size, fmt, args );
    56                 __cfaabi_dbg_bits_write( buffer, len );
     56                __cfaabi_bits_write( fd, buffer, len );
    5757
    58                 __cfaabi_dbg_bits_release();
     58                __cfaabi_bits_release();
    5959                va_end( args );
    6060        }
    6161
    62         void __cfaabi_dbg_bits_print_nolock( const char fmt[], ... ) __attribute__(( format(printf, 1, 2) )) {
     62        void __cfaabi_bits_print_nolock( int fd, const char fmt[], ... ) __attribute__(( format(printf, 2, 3) )) {
    6363                va_list args;
    6464
     
    6666
    6767                int len = vsnprintf( buffer, buffer_size, fmt, args );
    68                 __cfaabi_dbg_bits_write( buffer, len );
     68                __cfaabi_bits_write( fd, buffer, len );
    6969
    7070                va_end( args );
    7171        }
    7272
    73         void __cfaabi_dbg_bits_print_vararg( const char fmt[], va_list args ) {
     73        void __cfaabi_bits_print_vararg( int fd, const char fmt[], va_list args ) {
    7474                int len = vsnprintf( buffer, buffer_size, fmt, args );
    75                 __cfaabi_dbg_bits_write( buffer, len );
     75                __cfaabi_bits_write( fd, buffer, len );
    7676        }
    7777
    78         void __cfaabi_dbg_bits_print_buffer( char in_buffer[], int in_buffer_size, const char fmt[], ... ) __attribute__(( format(printf, 3, 4) )) {
     78        void __cfaabi_bits_print_buffer( int fd, char in_buffer[], int in_buffer_size, const char fmt[], ... ) __attribute__(( format(printf, 4, 5) )) {
    7979                va_list args;
    8080
     
    8282
    8383                int len = vsnprintf( in_buffer, in_buffer_size, fmt, args );
    84                 __cfaabi_dbg_bits_write( in_buffer, len );
     84                __cfaabi_bits_write( fd, in_buffer, len );
    8585
    8686                va_end( args );
  • libcfa/src/bits/debug.hfa

    r49d3128 r2909b51  
    1010// Created On       : Mon Nov 28 12:27:26 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Feb  8 12:35:19 2018
    13 // Update Count     : 2
     12// Last Modified On : Thu Nov 21 17:06:58 2019
     13// Update Count     : 8
    1414//
    1515
     
    3838        #include <stdio.h>
    3939
    40       extern void __cfaabi_dbg_bits_write( const char *buffer, int len );
    41       extern void __cfaabi_dbg_bits_acquire();
    42       extern void __cfaabi_dbg_bits_release();
    43       extern void __cfaabi_dbg_bits_print_safe  ( const char fmt[], ... ) __attribute__(( format(printf, 1, 2) ));
    44       extern void __cfaabi_dbg_bits_print_nolock( const char fmt[], ... ) __attribute__(( format(printf, 1, 2) ));
    45       extern void __cfaabi_dbg_bits_print_vararg( const char fmt[], va_list arg );
    46       extern void __cfaabi_dbg_bits_print_buffer( char buffer[], int buffer_size, const char fmt[], ... ) __attribute__(( format(printf, 3, 4) ));
     40        extern void __cfaabi_bits_write( int fd, const char *buffer, int len );
     41        extern void __cfaabi_bits_acquire();
     42        extern void __cfaabi_bits_release();
     43        extern void __cfaabi_bits_print_safe  ( int fd, const char fmt[], ... ) __attribute__(( format(printf, 2, 3) ));
     44        extern void __cfaabi_bits_print_nolock( int fd, const char fmt[], ... ) __attribute__(( format(printf, 2, 3) ));
     45        extern void __cfaabi_bits_print_vararg( int fd, const char fmt[], va_list arg );
     46        extern void __cfaabi_bits_print_buffer( int fd, char buffer[], int buffer_size, const char fmt[], ... ) __attribute__(( format(printf, 4, 5) ));
    4747#ifdef __cforall
    4848}
     
    5050
    5151#ifdef __CFA_DEBUG_PRINT__
    52         #define __cfaabi_dbg_write( buffer, len )         __cfaabi_dbg_bits_write( buffer, len )
    53         #define __cfaabi_dbg_acquire()                    __cfaabi_dbg_bits_acquire()
    54         #define __cfaabi_dbg_release()                    __cfaabi_dbg_bits_release()
    55         #define __cfaabi_dbg_print_safe(...)              __cfaabi_dbg_bits_print_safe   (__VA_ARGS__)
    56         #define __cfaabi_dbg_print_nolock(...)            __cfaabi_dbg_bits_print_nolock (__VA_ARGS__)
    57         #define __cfaabi_dbg_print_buffer(...)            __cfaabi_dbg_bits_print_buffer (__VA_ARGS__)
    58         #define __cfaabi_dbg_print_buffer_decl(...)       char __dbg_text[256]; int __dbg_len = snprintf( __dbg_text, 256, __VA_ARGS__ ); __cfaabi_dbg_bits_write( __dbg_text, __dbg_len );
    59         #define __cfaabi_dbg_print_buffer_local(...)      __dbg_len = snprintf( __dbg_text, 256, __VA_ARGS__ ); __cfaabi_dbg_bits_write( __dbg_text, __dbg_len );
     52        #define __cfaabi_dbg_write( buffer, len )         __cfaabi_bits_write( STDERR_FILENO, buffer, len )
     53        #define __cfaabi_dbg_acquire()                    __cfaabi_bits_acquire()
     54        #define __cfaabi_dbg_release()                    __cfaabi_bits_release()
     55        #define __cfaabi_dbg_print_safe(...)              __cfaabi_bits_print_safe   (__VA_ARGS__)
     56        #define __cfaabi_dbg_print_nolock(...)            __cfaabi_bits_print_nolock (__VA_ARGS__)
     57        #define __cfaabi_dbg_print_buffer(...)            __cfaabi_bits_print_buffer (__VA_ARGS__)
     58        #define __cfaabi_dbg_print_buffer_decl(...)       char __dbg_text[256]; int __dbg_len = snprintf( __dbg_text, 256, __VA_ARGS__ ); __cfaabi_bits_write( __dbg_text, __dbg_len );
     59        #define __cfaabi_dbg_print_buffer_local(...)      __dbg_len = snprintf( __dbg_text, 256, __VA_ARGS__ ); __cfaabi_dbg_write( __dbg_text, __dbg_len );
    6060#else
    6161        #define __cfaabi_dbg_write(...)               ((void)0)
  • libcfa/src/concurrency/kernel.cfa

    r49d3128 r2909b51  
    1010// Created On       : Tue Jan 17 12:27:26 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jun 20 17:21:23 2019
    13 // Update Count     : 25
     12// Last Modified On : Thu Nov 21 16:46:59 2019
     13// Update Count     : 27
    1414//
    1515
     
    824824        if(thrd) {
    825825                int len = snprintf( abort_text, abort_text_size, "Error occurred while executing thread %.256s (%p)", thrd->self_cor.name, thrd );
    826                 __cfaabi_dbg_bits_write( abort_text, len );
     826                __cfaabi_bits_write( STDERR_FILENO, abort_text, len );
    827827
    828828                if ( &thrd->self_cor != thrd->curr_cor ) {
    829829                        len = snprintf( abort_text, abort_text_size, " in coroutine %.256s (%p).\n", thrd->curr_cor->name, thrd->curr_cor );
    830                         __cfaabi_dbg_bits_write( abort_text, len );
     830                        __cfaabi_bits_write( STDERR_FILENO, abort_text, len );
    831831                }
    832832                else {
    833                         __cfaabi_dbg_bits_write( ".\n", 2 );
     833                        __cfaabi_bits_write( STDERR_FILENO, ".\n", 2 );
    834834                }
    835835        }
    836836        else {
    837837                int len = snprintf( abort_text, abort_text_size, "Error occurred outside of any thread.\n" );
    838                 __cfaabi_dbg_bits_write( abort_text, len );
     838                __cfaabi_bits_write( STDERR_FILENO, abort_text, len );
    839839        }
    840840}
     
    847847
    848848extern "C" {
    849         void __cfaabi_dbg_bits_acquire() {
     849        void __cfaabi_bits_acquire() {
    850850                lock( kernel_debug_lock __cfaabi_dbg_ctx2 );
    851851        }
    852852
    853         void __cfaabi_dbg_bits_release() {
     853        void __cfaabi_bits_release() {
    854854                unlock( kernel_debug_lock );
    855855        }
  • libcfa/src/interpose.cfa

    r49d3128 r2909b51  
    1010// Created On       : Wed Mar 29 16:10:31 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Jul 14 22:57:16 2019
    13 // Update Count     : 116
     12// Last Modified On : Thu Nov 21 16:47:02 2019
     13// Update Count     : 118
    1414//
    1515
     
    163163        abort_lastframe = kernel_abort_lastframe();
    164164        len = snprintf( abort_text, abort_text_size, "Cforall Runtime error (UNIX pid:%ld) ", (long int)getpid() ); // use UNIX pid (versus getPid)
    165         __cfaabi_dbg_bits_write( abort_text, len );
     165        __cfaabi_dbg_write( abort_text, len );
    166166
    167167        if ( fmt ) {
     
    171171                len = vsnprintf( abort_text, abort_text_size, fmt, args );
    172172                va_end( args );
    173                 __cfaabi_dbg_bits_write( abort_text, len );
     173                __cfaabi_dbg_write( abort_text, len );
    174174
    175175                if ( fmt[strlen( fmt ) - 1] != '\n' ) {         // add optional newline if missing at the end of the format text
    176                         __cfaabi_dbg_bits_write( "\n", 1 );
     176                        __cfaabi_dbg_write( "\n", 1 );
    177177                }
    178178        }
     
    194194        // find executable name
    195195        *index( messages[0], '(' ) = '\0';
    196         __cfaabi_dbg_bits_print_nolock( "Stack back trace for: %s\n", messages[0]);
     196        __cfaabi_bits_print_nolock( STDERR_FILENO, "Stack back trace for: %s\n", messages[0]);
    197197
    198198        for ( int i = Start; i < size - abort_lastframe && messages != NULL; i += 1 ) {
     
    200200
    201201                for ( char * p = messages[i]; *p; ++p ) {
    202                         //__cfaabi_dbg_bits_print_nolock( "X %s\n", p);
     202                        //__cfaabi_bits_print_nolock( "X %s\n", p);
    203203                        // find parantheses and +offset
    204204                        if ( *p == '(' ) {
     
    220220                        *offset_end++ = '\0';
    221221
    222                         __cfaabi_dbg_bits_print_nolock( "(%i) %s : %s + %s %s\n", frameNo, messages[i], name, offset_begin, offset_end);
     222                        __cfaabi_bits_print_nolock( STDERR_FILENO, "(%i) %s : %s + %s %s\n", frameNo, messages[i], name, offset_begin, offset_end);
    223223                } else {                                                                                // otherwise, print the whole line
    224                         __cfaabi_dbg_bits_print_nolock( "(%i) %s\n", frameNo, messages[i] );
     224                        __cfaabi_bits_print_nolock( STDERR_FILENO, "(%i) %s\n", frameNo, messages[i] );
    225225                }
    226226        }
Note: See TracChangeset for help on using the changeset viewer.