Ignore:
File:
1 edited

Legend:

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

    re3fea42 rc1581a0  
    99// Author           : Thierry Delisle
    1010// Created On       : Mon Nov 28 12:27:26 2016
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Feb  4 12:29:21 2020
    13 // Update Count     : 9
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Mon Apr 27 10:15:00 2020
     13// Update Count     : 10
    1414//
    1515
     
    2323        #define __cfaabi_dbg_ctx_param const char caller[]
    2424        #define __cfaabi_dbg_ctx_param2 , const char caller[]
     25        #define __cfaabi_dbg_ctx_fwd caller
     26        #define __cfaabi_dbg_ctx_fwd2 , caller
    2527#else
    2628        #define __cfaabi_dbg_debug_do(...)
     
    3032        #define __cfaabi_dbg_ctx_param
    3133        #define __cfaabi_dbg_ctx_param2
     34        #define __cfaabi_dbg_ctx_fwd
     35        #define __cfaabi_dbg_ctx_fwd2
    3236#endif
    3337
     
    3640#endif
    3741        #include <stdarg.h>
    38         #include <stdio.h>
    3942
    4043        extern void __cfaabi_bits_write( int fd, const char buffer[], int len );
     
    4548        extern void __cfaabi_bits_print_vararg( int fd, const char fmt[], va_list arg );
    4649        extern void __cfaabi_bits_print_buffer( int fd, char buffer[], int buffer_size, const char fmt[], ... ) __attribute__(( format(printf, 4, 5) ));
     50
     51#if defined(__CFA_DEBUG_PRINT__) \
     52                || defined(__CFA_DEBUG_PRINT_IO__) || defined(__CFA_DEBUG_PRINT_IO_CORE__) \
     53                || defined(__CFA_DEBUG_PRINT_MONITOR__) || defined(__CFA_DEBUG_PRINT_PREEMPTION__) \
     54                || defined(__CFA_DEBUG_PRINT_RUNTIME_CORE__) || defined(__CFA_DEBUG_PRINT_EXCEPTION__)
     55        #include <stdio.h>
     56        #include <unistd.h>
     57#endif
    4758#ifdef __cforall
    4859}
    4960#endif
    5061
     62// Deprecated: Use the versions with the new module names.
    5163#ifdef __CFA_DEBUG_PRINT__
    5264        #define __cfaabi_dbg_write( buffer, len )         __cfaabi_bits_write( STDERR_FILENO, buffer, len )
    5365        #define __cfaabi_dbg_acquire()                    __cfaabi_bits_acquire()
    5466        #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 );
     67        #define __cfaabi_dbg_print_safe(...)              __cfaabi_bits_print_safe   ( STDERR_FILENO, __VA_ARGS__ )
     68        #define __cfaabi_dbg_print_nolock(...)            __cfaabi_bits_print_nolock ( STDERR_FILENO, __VA_ARGS__ )
     69        #define __cfaabi_dbg_print_buffer(...)            __cfaabi_bits_print_buffer ( STDERR_FILENO, __VA_ARGS__ )
     70        #define __cfaabi_dbg_print_buffer_decl(...)       char __dbg_text[256]; int __dbg_len = snprintf( __dbg_text, 256, __VA_ARGS__ ); __cfaabi_bits_write( STDERR_FILENO, __dbg_text, __dbg_len );
     71        #define __cfaabi_dbg_print_buffer_local(...)      __dbg_len = snprintf( __dbg_text, 256, __VA_ARGS__ ); __cfaabi_dbg_write( STDERR_FILENO, __dbg_text, __dbg_len );
    6072#else
    6173        #define __cfaabi_dbg_write(...)               ((void)0)
     
    6981#endif
    7082
     83// Debug print functions and statements:
     84// Most are wrappers around the bits printing function but are not always used.
     85// If they are used depends if the group (first argument) is active or not. The group must be one
     86// defined belowe. The other arguments depend on the wrapped function.
     87#define __cfadbg_write(group, buffer, len) \
     88        __CFADBG_PRINT_GROUP_##group(__cfaabi_bits_write(STDERR_FILENO, buffer, len))
     89#define __cfadbg_acquire(group) \
     90        __CFADBG_PRINT_GROUP_##group(__cfaabi_bits_acquire())
     91#define __cfadbg_release(group) \
     92        __CFADBG_PRINT_GROUP_##group(__cfaabi_bits_release())
     93#define __cfadbg_print_safe(group, ...) \
     94        __CFADBG_PRINT_GROUP_##group(__cfaabi_bits_print_safe(STDERR_FILENO, __VA_ARGS__))
     95#define __cfadbg_print_nolock(group, ...) \
     96        __CFADBG_PRINT_GROUP_##group(__cfaabi_bits_print_nolock(STDERR_FILENO, __VA_ARGS__))
     97#define __cfadbg_print_buffer(group, ...) \
     98        __CFADBG_PRINT_GROUP_##group(__cfaabi_bits_print_buffer(STDERR_FILENO, __VA_ARGS__))
     99#define __cfadbg_print_buffer_decl(group, ...) \
     100        __CFADBG_PRINT_GROUP_##group(char __dbg_text[256]; int __dbg_len = snprintf( __dbg_text, 256, __VA_ARGS__ ); __cfaabi_bits_write( __dbg_text, __dbg_len ))
     101#define __cfadbg_print_buffer_local(group, ...) \
     102        __CFADBG_PRINT_GROUP_##group(__dbg_len = snprintf( __dbg_text, 256, __VA_ARGS__ ); __cfaabi_bits_write(STDERR_FILENO, __dbg_text, __dbg_len))
     103
     104// The debug print groups:
     105#if defined(__CFA_DEBUG_PRINT__) || defined(__CFA_DEBUG_PRINT_IO__)
     106#       define __CFADBG_PRINT_GROUP_io(...) __VA_ARGS__
     107#else
     108#       define __CFADBG_PRINT_GROUP_io(...) ((void)0)
     109#endif
     110#if defined(__CFA_DEBUG_PRINT__) || defined(__CFA_DEBUG_PRINT_IO__) || defined(__CFA_DEBUG_PRINT_IO_CORE__)
     111#       define __CFADBG_PRINT_GROUP_io_core(...) __VA_ARGS__
     112#else
     113#       define __CFADBG_PRINT_GROUP_io_core(...) ((void)0)
     114#endif
     115#if defined(__CFA_DEBUG_PRINT__) || defined(__CFA_DEBUG_PRINT_MONITOR__)
     116#       define __CFADBG_PRINT_GROUP_monitor(...) __VA_ARGS__
     117#else
     118#       define __CFADBG_PRINT_GROUP_monitor(...) ((void)0)
     119#endif
     120#if defined(__CFA_DEBUG_PRINT__) || defined(__CFA_DEBUG_PRINT_PREEMPTION__)
     121#       define __CFADBG_PRINT_GROUP_preemption(...) __VA_ARGS__
     122#else
     123#       define __CFADBG_PRINT_GROUP_preemption(...) ((void)0)
     124#endif
     125#if defined(__CFA_DEBUG_PRINT__) || defined(__CFA_DEBUG_PRINT_RUNTIME_CORE__)
     126#       define __CFADBG_PRINT_GROUP_runtime_core(...) __VA_ARGS__
     127#else
     128#       define __CFADBG_PRINT_GROUP_runtime_core(...) ((void)0)
     129#endif
     130#if defined(__CFA_DEBUG_PRINT__) || defined(__CFA_DEBUG_PRINT_READY_QUEUE__)
     131#       define __CFADBG_PRINT_GROUP_ready_queue(...) __VA_ARGS__
     132#else
     133#       define __CFADBG_PRINT_GROUP_ready_queue(...) ((void)0)
     134#endif
     135#if defined(__CFA_DEBUG_PRINT__) || defined(__CFA_DEBUG_PRINT_EXCEPTION__)
     136#       define __CFADBG_PRINT_GROUP_exception(...) __VA_ARGS__
     137#else
     138#       define __CFADBG_PRINT_GROUP_exception(...) ((void)0)
     139#endif
     140
    71141// Local Variables: //
    72142// mode: c //
Note: See TracChangeset for help on using the changeset viewer.