Ignore:
Timestamp:
Jan 7, 2021, 3:27:00 PM (5 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
2b4daf2, 64aeca0
Parents:
3c64c668 (diff), eef8dfb (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 park_unpark

File:
1 edited

Legend:

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

    r3c64c668 r58fe85a  
    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
    1616#pragma once
     17
     18#include <assert.h>
    1719
    1820#ifdef __CFA_DEBUG__
     
    2325        #define __cfaabi_dbg_ctx_param const char caller[]
    2426        #define __cfaabi_dbg_ctx_param2 , const char caller[]
     27        #define __cfaabi_dbg_ctx_fwd caller
     28        #define __cfaabi_dbg_ctx_fwd2 , caller
    2529#else
    2630        #define __cfaabi_dbg_debug_do(...)
     
    3034        #define __cfaabi_dbg_ctx_param
    3135        #define __cfaabi_dbg_ctx_param2
     36        #define __cfaabi_dbg_ctx_fwd
     37        #define __cfaabi_dbg_ctx_fwd2
    3238#endif
    3339
     
    3642#endif
    3743        #include <stdarg.h>
    38         #include <stdio.h>
    3944
    4045        extern void __cfaabi_bits_write( int fd, const char buffer[], int len );
     
    4550        extern void __cfaabi_bits_print_vararg( int fd, const char fmt[], va_list arg );
    4651        extern void __cfaabi_bits_print_buffer( int fd, char buffer[], int buffer_size, const char fmt[], ... ) __attribute__(( format(printf, 4, 5) ));
     52
     53#if defined(__CFA_DEBUG_PRINT__) \
     54                || defined(__CFA_DEBUG_PRINT_IO__) || defined(__CFA_DEBUG_PRINT_IO_CORE__) \
     55                || defined(__CFA_DEBUG_PRINT_MONITOR__) || defined(__CFA_DEBUG_PRINT_PREEMPTION__) \
     56                || defined(__CFA_DEBUG_PRINT_RUNTIME_CORE__) || defined(__CFA_DEBUG_PRINT_EXCEPTION__) \
     57                || defined(__CFA_DEBUG_PRINT_READY_QUEUE__)
     58        #include <stdio.h>
     59        #include <unistd.h>
     60#endif
    4761#ifdef __cforall
    4862}
    4963#endif
    5064
     65// Deprecated: Use the versions with the new module names.
    5166#ifdef __CFA_DEBUG_PRINT__
    5267        #define __cfaabi_dbg_write( buffer, len )         __cfaabi_bits_write( STDERR_FILENO, buffer, len )
    5368        #define __cfaabi_dbg_acquire()                    __cfaabi_bits_acquire()
    5469        #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 );
     70        #define __cfaabi_dbg_print_safe(...)              __cfaabi_bits_print_safe   ( STDERR_FILENO, __VA_ARGS__ )
     71        #define __cfaabi_dbg_print_nolock(...)            __cfaabi_bits_print_nolock ( STDERR_FILENO, __VA_ARGS__ )
     72        #define __cfaabi_dbg_print_buffer(...)            __cfaabi_bits_print_buffer ( STDERR_FILENO, __VA_ARGS__ )
     73        #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 );
     74        #define __cfaabi_dbg_print_buffer_local(...)      __dbg_len = snprintf( __dbg_text, 256, __VA_ARGS__ ); __cfaabi_dbg_write( STDERR_FILENO, __dbg_text, __dbg_len );
    6075#else
    6176        #define __cfaabi_dbg_write(...)               ((void)0)
     
    6984#endif
    7085
     86// Debug print functions and statements:
     87// Most are wrappers around the bits printing function but are not always used.
     88// If they are used depends if the group (first argument) is active or not. The group must be one
     89// defined belowe. The other arguments depend on the wrapped function.
     90#define __cfadbg_write(group, buffer, len) \
     91        __CFADBG_PRINT_GROUP_##group(__cfaabi_bits_write(STDERR_FILENO, buffer, len))
     92#define __cfadbg_acquire(group) \
     93        __CFADBG_PRINT_GROUP_##group(__cfaabi_bits_acquire())
     94#define __cfadbg_release(group) \
     95        __CFADBG_PRINT_GROUP_##group(__cfaabi_bits_release())
     96#define __cfadbg_print_safe(group, ...) \
     97        __CFADBG_PRINT_GROUP_##group(__cfaabi_bits_print_safe(STDERR_FILENO, __VA_ARGS__))
     98#define __cfadbg_print_nolock(group, ...) \
     99        __CFADBG_PRINT_GROUP_##group(__cfaabi_bits_print_nolock(STDERR_FILENO, __VA_ARGS__))
     100#define __cfadbg_print_buffer(group, ...) \
     101        __CFADBG_PRINT_GROUP_##group(__cfaabi_bits_print_buffer(STDERR_FILENO, __VA_ARGS__))
     102#define __cfadbg_print_buffer_decl(group, ...) \
     103        __CFADBG_PRINT_GROUP_##group(char __dbg_text[256]; int __dbg_len = snprintf( __dbg_text, 256, __VA_ARGS__ ); __cfaabi_bits_write( __dbg_text, __dbg_len ))
     104#define __cfadbg_print_buffer_local(group, ...) \
     105        __CFADBG_PRINT_GROUP_##group(__dbg_len = snprintf( __dbg_text, 256, __VA_ARGS__ ); __cfaabi_bits_write(STDERR_FILENO, __dbg_text, __dbg_len))
     106
     107// The debug print groups:
     108#if defined(__CFA_DEBUG_PRINT__) || defined(__CFA_DEBUG_PRINT_IO__)
     109#       define __CFADBG_PRINT_GROUP_io(...) __VA_ARGS__
     110#else
     111#       define __CFADBG_PRINT_GROUP_io(...) ((void)0)
     112#endif
     113#if defined(__CFA_DEBUG_PRINT__) || defined(__CFA_DEBUG_PRINT_IO__) || defined(__CFA_DEBUG_PRINT_IO_CORE__)
     114#       define __CFADBG_PRINT_GROUP_io_core(...) __VA_ARGS__
     115#else
     116#       define __CFADBG_PRINT_GROUP_io_core(...) ((void)0)
     117#endif
     118#if defined(__CFA_DEBUG_PRINT__) || defined(__CFA_DEBUG_PRINT_MONITOR__)
     119#       define __CFADBG_PRINT_GROUP_monitor(...) __VA_ARGS__
     120#else
     121#       define __CFADBG_PRINT_GROUP_monitor(...) ((void)0)
     122#endif
     123#if defined(__CFA_DEBUG_PRINT__) || defined(__CFA_DEBUG_PRINT_PREEMPTION__)
     124#       define __CFADBG_PRINT_GROUP_preemption(...) __VA_ARGS__
     125#else
     126#       define __CFADBG_PRINT_GROUP_preemption(...) ((void)0)
     127#endif
     128#if defined(__CFA_DEBUG_PRINT__) || defined(__CFA_DEBUG_PRINT_RUNTIME_CORE__)
     129#       define __CFADBG_PRINT_GROUP_runtime_core(...) __VA_ARGS__
     130#else
     131#       define __CFADBG_PRINT_GROUP_runtime_core(...) ((void)0)
     132#endif
     133#if defined(__CFA_DEBUG_PRINT__) || defined(__CFA_DEBUG_PRINT_READY_QUEUE__)
     134#       define __CFADBG_PRINT_GROUP_ready_queue(...) __VA_ARGS__
     135#else
     136#       define __CFADBG_PRINT_GROUP_ready_queue(...) ((void)0)
     137#endif
     138#if defined(__CFA_DEBUG_PRINT__) || defined(__CFA_DEBUG_PRINT_EXCEPTION__)
     139#       define __CFADBG_PRINT_GROUP_exception(...) __VA_ARGS__
     140#else
     141#       define __CFADBG_PRINT_GROUP_exception(...) ((void)0)
     142#endif
     143
    71144// Local Variables: //
    72145// mode: c //
Note: See TracChangeset for help on using the changeset viewer.