Changeset 44aad8f for libcfa/src/bits


Ignore:
Timestamp:
Apr 27, 2020, 4:36:58 PM (4 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:
c59a346
Parents:
038be32 (diff), c680a4b (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

File:
1 edited

Legend:

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

    r038be32 r44aad8f  
    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
     
    4040#endif
    4141        #include <stdarg.h>
    42         #include <stdio.h>
    4342
    4443        extern void __cfaabi_bits_write( int fd, const char buffer[], int len );
     
    4948        extern void __cfaabi_bits_print_vararg( int fd, const char fmt[], va_list arg );
    5049        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__) || defined(__CFA_DEBUG_PRINT_IO__) \
     52                || defined(__CFA_DEBUG_PRINT_MONITOR__) || defined(__CFA_DEBUG_PRINT_PREEMPTION__) \
     53                || defined(__CFA_DEBUG_PRINT_RUNTIME_CORE__) || defined(__CFA_DEBUG_PRINT_EXCEPTION__)
     54        #include <stdio.h>
     55        #include <unistd.h>
     56#endif
    5157#ifdef __cforall
    5258}
    5359#endif
    5460
     61// Deprecated: Use the versions with the new module names.
    5562#ifdef __CFA_DEBUG_PRINT__
    5663        #define __cfaabi_dbg_write( buffer, len )         __cfaabi_bits_write( STDERR_FILENO, buffer, len )
    5764        #define __cfaabi_dbg_acquire()                    __cfaabi_bits_acquire()
    5865        #define __cfaabi_dbg_release()                    __cfaabi_bits_release()
    59         #define __cfaabi_dbg_print_safe(...)              __cfaabi_bits_print_safe   (__VA_ARGS__)
    60         #define __cfaabi_dbg_print_nolock(...)            __cfaabi_bits_print_nolock (__VA_ARGS__)
    61         #define __cfaabi_dbg_print_buffer(...)            __cfaabi_bits_print_buffer (__VA_ARGS__)
    62         #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 );
    63         #define __cfaabi_dbg_print_buffer_local(...)      __dbg_len = snprintf( __dbg_text, 256, __VA_ARGS__ ); __cfaabi_dbg_write( __dbg_text, __dbg_len );
     66        #define __cfaabi_dbg_print_safe(...)              __cfaabi_bits_print_safe   ( STDERR_FILENO, __VA_ARGS__ )
     67        #define __cfaabi_dbg_print_nolock(...)            __cfaabi_bits_print_nolock ( STDERR_FILENO, __VA_ARGS__ )
     68        #define __cfaabi_dbg_print_buffer(...)            __cfaabi_bits_print_buffer ( STDERR_FILENO, __VA_ARGS__ )
     69        #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 );
     70        #define __cfaabi_dbg_print_buffer_local(...)      __dbg_len = snprintf( __dbg_text, 256, __VA_ARGS__ ); __cfaabi_dbg_write( STDERR_FILENO, __dbg_text, __dbg_len );
    6471#else
    6572        #define __cfaabi_dbg_write(...)               ((void)0)
     
    7380#endif
    7481
     82// Debug print functions and statements:
     83// Most are wrappers around the bits printing function but are not always used.
     84// If they are used depends if the group (first argument) is active or not. The group must be one
     85// defined belowe. The other arguments depend on the wrapped function.
     86#define __cfadbg_write(group, buffer, len) \
     87        __CFADBG_PRINT_GROUP_##group(__cfaabi_bits_write(STDERR_FILENO, buffer, len))
     88#define __cfadbg_acquire(group) \
     89        __CFADBG_PRINT_GROUP_##group(__cfaabi_bits_acquire())
     90#define __cfadbg_release(group) \
     91        __CFADBG_PRINT_GROUP_##group(__cfaabi_bits_release())
     92#define __cfadbg_print_safe(group, ...) \
     93        __CFADBG_PRINT_GROUP_##group(__cfaabi_bits_print_safe(STDERR_FILENO, __VA_ARGS__))
     94#define __cfadbg_print_nolock(group, ...) \
     95        __CFADBG_PRINT_GROUP_##group(__cfaabi_bits_print_nolock(STDERR_FILENO, __VA_ARGS__))
     96#define __cfadbg_print_buffer(group, ...) \
     97        __CFADBG_PRINT_GROUP_##group(__cfaabi_bits_print_buffer(STDERR_FILENO, __VA_ARGS__))
     98#define __cfadbg_print_buffer_decl(group, ...) \
     99        __CFADBG_PRINT_GROUP_##group(char __dbg_text[256]; int __dbg_len = snprintf( __dbg_text, 256, __VA_ARGS__ ); __cfaabi_bits_write( __dbg_text, __dbg_len ))
     100#define __cfadbg_print_buffer_local(group, ...) \
     101        __CFADBG_PRINT_GROUP_##group(__dbg_len = snprintf( __dbg_text, 256, __VA_ARGS__ ); __cfaabi_bits_write(STDERR_FILENO, __dbg_text, __dbg_len))
     102
     103// The debug print groups:
     104#if defined(__CFA_DEBUG_PRINT__) || defined(__CFA_DEBUG_PRINT_IO__)
     105#       define __CFADBG_PRINT_GROUP_io(...) __VA_ARGS__
     106#else
     107#       define __CFADBG_PRINT_GROUP_io(...) ((void)0)
     108#endif
     109#if defined(__CFA_DEBUG_PRINT__) || defined(__CFA_DEBUG_PRINT_MONITOR__)
     110#       define __CFADBG_PRINT_GROUP_monitor(...) __VA_ARGS__
     111#else
     112#       define __CFADBG_PRINT_GROUP_monitor(...) ((void)0)
     113#endif
     114#if defined(__CFA_DEBUG_PRINT__) || defined(__CFA_DEBUG_PRINT_PREEMPTION__)
     115#       define __CFADBG_PRINT_GROUP_preemption(...) __VA_ARGS__
     116#else
     117#       define __CFADBG_PRINT_GROUP_preemption(...) ((void)0)
     118#endif
     119#if defined(__CFA_DEBUG_PRINT__) || defined(__CFA_DEBUG_PRINT_RUNTIME_CORE__)
     120#       define __CFADBG_PRINT_GROUP_runtime_core(...) __VA_ARGS__
     121#else
     122#       define __CFADBG_PRINT_GROUP_runtime_core(...) ((void)0)
     123#endif
     124#if defined(__CFA_DEBUG_PRINT__) || defined(__CFA_DEBUG_PRINT_READY_QUEUE__)
     125#       define __CFADBG_PRINT_GROUP_ready_queue(...) __VA_ARGS__
     126#else
     127#       define __CFADBG_PRINT_GROUP_ready_queue(...) ((void)0)
     128#endif
     129#if defined(__CFA_DEBUG_PRINT__) || defined(__CFA_DEBUG_PRINT_EXCEPTION__)
     130#       define __CFADBG_PRINT_GROUP_exception(...) __VA_ARGS__
     131#else
     132#       define __CFADBG_PRINT_GROUP_exception(...) ((void)0)
     133#endif
     134
    75135// Local Variables: //
    76136// mode: c //
Note: See TracChangeset for help on using the changeset viewer.