mudgangster

Tiny, scriptable MUD client
Log | Files | Refs | README

TracyC.h (10531B)


      1 #ifndef __TRACYC_HPP__
      2 #define __TRACYC_HPP__
      3 
      4 #include <stddef.h>
      5 #include <stdint.h>
      6 
      7 #include "client/TracyCallstack.h"
      8 
      9 #ifdef __cplusplus
     10 extern "C" {
     11 #endif
     12 
     13 #ifndef TRACY_ENABLE
     14 
     15 typedef const void* TracyCZoneCtx;
     16 
     17 #define TracyCZone(c,x)
     18 #define TracyCZoneN(c,x,y)
     19 #define TracyCZoneC(c,x,y)
     20 #define TracyCZoneNC(c,x,y,z)
     21 #define TracyCZoneEnd(c)
     22 #define TracyCZoneText(c,x,y)
     23 #define TracyCZoneName(c,x,y)
     24 
     25 #define TracyCAlloc(x,y)
     26 #define TracyCFree(x)
     27 
     28 #define TracyCFrameMark
     29 #define TracyCFrameMarkNamed(x)
     30 #define TracyCFrameMarkStart(x)
     31 #define TracyCFrameMarkEnd(x)
     32 #define TracyCFrameImage(x,y,z,w,a)
     33 
     34 #define TracyCPlot(x,y)
     35 #define TracyCMessage(x,y)
     36 #define TracyCMessageL(x)
     37 #define TracyCMessageC(x,y,z)
     38 #define TracyCMessageLC(x,y)
     39 #define TracyCAppInfo(x,y)
     40 
     41 #define TracyCZoneS(x,y,z)
     42 #define TracyCZoneNS(x,y,z,w)
     43 #define TracyCZoneCS(x,y,z,w)
     44 #define TracyCZoneNCS(x,y,z,w,a)
     45 
     46 #define TracyCAllocS(x,y,z)
     47 #define TracyCFreeS(x,y)
     48 
     49 #define TracyCMessageS(x,y,z)
     50 #define TracyCMessageLS(x,y)
     51 #define TracyCMessageCS(x,y,z,w)
     52 #define TracyCMessageLCS(x,y,z)
     53 
     54 #else
     55 
     56 #ifndef TracyConcat
     57 #  define TracyConcat(x,y) TracyConcatIndirect(x,y)
     58 #endif
     59 #ifndef TracyConcatIndirect
     60 #  define TracyConcatIndirect(x,y) x##y
     61 #endif
     62 
     63 struct ___tracy_source_location_data
     64 {
     65     const char* name;
     66     const char* function;
     67     const char* file;
     68     uint32_t line;
     69     uint32_t color;
     70 };
     71 
     72 struct ___tracy_c_zone_context
     73 {
     74     uint32_t id;
     75     int active;
     76 };
     77 
     78 // Some containers don't support storing const types.
     79 // This struct, as visible to user, is immutable, so treat it as if const was declared here.
     80 typedef /*const*/ struct ___tracy_c_zone_context TracyCZoneCtx;
     81 
     82 TRACY_API TracyCZoneCtx ___tracy_emit_zone_begin( const struct ___tracy_source_location_data* srcloc, int active );
     83 TRACY_API TracyCZoneCtx ___tracy_emit_zone_begin_callstack( const struct ___tracy_source_location_data* srcloc, int depth, int active );
     84 TRACY_API void ___tracy_emit_zone_end( TracyCZoneCtx ctx );
     85 TRACY_API void ___tracy_emit_zone_text( TracyCZoneCtx ctx, const char* txt, size_t size );
     86 TRACY_API void ___tracy_emit_zone_name( TracyCZoneCtx ctx, const char* txt, size_t size );
     87 
     88 #if defined TRACY_HAS_CALLSTACK && defined TRACY_CALLSTACK
     89 #  define TracyCZone( ctx, active ) static const struct ___tracy_source_location_data TracyConcat(__tracy_source_location,__LINE__) = { NULL, __FUNCTION__,  __FILE__, (uint32_t)__LINE__, 0 }; TracyCZoneCtx ctx = ___tracy_emit_zone_begin_callstack( &TracyConcat(__tracy_source_location,__LINE__), TRACY_CALLSTACK, active );
     90 #  define TracyCZoneN( ctx, name, active ) static const struct ___tracy_source_location_data TracyConcat(__tracy_source_location,__LINE__) = { name, __FUNCTION__,  __FILE__, (uint32_t)__LINE__, 0 }; TracyCZoneCtx ctx = ___tracy_emit_zone_begin_callstack( &TracyConcat(__tracy_source_location,__LINE__), TRACY_CALLSTACK, active );
     91 #  define TracyCZoneC( ctx, color, active ) static const struct ___tracy_source_location_data TracyConcat(__tracy_source_location,__LINE__) = { NULL, __FUNCTION__,  __FILE__, (uint32_t)__LINE__, color }; TracyCZoneCtx ctx = ___tracy_emit_zone_begin_callstack( &TracyConcat(__tracy_source_location,__LINE__), TRACY_CALLSTACK, active );
     92 #  define TracyCZoneNC( ctx, name, color, active ) static const struct ___tracy_source_location_data TracyConcat(__tracy_source_location,__LINE__) = { name, __FUNCTION__,  __FILE__, (uint32_t)__LINE__, color }; TracyCZoneCtx ctx = ___tracy_emit_zone_begin_callstack( &TracyConcat(__tracy_source_location,__LINE__), TRACY_CALLSTACK, active );
     93 #else
     94 #  define TracyCZone( ctx, active ) static const struct ___tracy_source_location_data TracyConcat(__tracy_source_location,__LINE__) = { NULL, __FUNCTION__,  __FILE__, (uint32_t)__LINE__, 0 }; TracyCZoneCtx ctx = ___tracy_emit_zone_begin( &TracyConcat(__tracy_source_location,__LINE__), active );
     95 #  define TracyCZoneN( ctx, name, active ) static const struct ___tracy_source_location_data TracyConcat(__tracy_source_location,__LINE__) = { name, __FUNCTION__,  __FILE__, (uint32_t)__LINE__, 0 }; TracyCZoneCtx ctx = ___tracy_emit_zone_begin( &TracyConcat(__tracy_source_location,__LINE__), active );
     96 #  define TracyCZoneC( ctx, color, active ) static const struct ___tracy_source_location_data TracyConcat(__tracy_source_location,__LINE__) = { NULL, __FUNCTION__,  __FILE__, (uint32_t)__LINE__, color }; TracyCZoneCtx ctx = ___tracy_emit_zone_begin( &TracyConcat(__tracy_source_location,__LINE__), active );
     97 #  define TracyCZoneNC( ctx, name, color, active ) static const struct ___tracy_source_location_data TracyConcat(__tracy_source_location,__LINE__) = { name, __FUNCTION__,  __FILE__, (uint32_t)__LINE__, color }; TracyCZoneCtx ctx = ___tracy_emit_zone_begin( &TracyConcat(__tracy_source_location,__LINE__), active );
     98 #endif
     99 
    100 #define TracyCZoneEnd( ctx ) ___tracy_emit_zone_end( ctx );
    101 
    102 #define TracyCZoneText( ctx, txt, size ) ___tracy_emit_zone_text( ctx, txt, size );
    103 #define TracyCZoneName( ctx, txt, size ) ___tracy_emit_zone_name( ctx, txt, size );
    104 
    105 
    106 TRACY_API void ___tracy_emit_memory_alloc( const void* ptr, size_t size );
    107 TRACY_API void ___tracy_emit_memory_alloc_callstack( const void* ptr, size_t size, int depth );
    108 TRACY_API void ___tracy_emit_memory_free( const void* ptr );
    109 TRACY_API void ___tracy_emit_memory_free_callstack( const void* ptr, int depth );
    110 
    111 TRACY_API void ___tracy_emit_message( const char* txt, size_t size, int callstack );
    112 TRACY_API void ___tracy_emit_messageL( const char* txt, int callstack );
    113 TRACY_API void ___tracy_emit_messageC( const char* txt, size_t size, uint32_t color, int callstack );
    114 TRACY_API void ___tracy_emit_messageLC( const char* txt, uint32_t color, int callstack );
    115 
    116 #if defined TRACY_HAS_CALLSTACK && defined TRACY_CALLSTACK
    117 #  define TracyCAlloc( ptr, size ) ___tracy_emit_memory_alloc_callstack( ptr, size, TRACY_CALLSTACK )
    118 #  define TracyCFree( ptr ) ___tracy_emit_memory_alloc_free_callstack( ptr, TRACY_CALLSTACK )
    119 
    120 #  define TracyCMessage( txt, size ) ___tracy_emit_message( txt, size, TRACY_CALLSTACK );
    121 #  define TracyCMessageL( txt ) ___tracy_emit_messageL( txt, TRACY_CALLSTACK );
    122 #  define TracyCMessageC( txt, size, color ) ___tracy_emit_messageC( txt, size, color, TRACY_CALLSTACK );
    123 #  define TracyCMessageLC( txt, color ) ___tracy_emit_messageLC( txt, color, TRACY_CALLSTACK );
    124 #else
    125 #  define TracyCAlloc( ptr, size ) ___tracy_emit_memory_alloc( ptr, size );
    126 #  define TracyCFree( ptr ) ___tracy_emit_memory_free( ptr );
    127 
    128 #  define TracyCMessage( txt, size ) ___tracy_emit_message( txt, size, 0 );
    129 #  define TracyCMessageL( txt ) ___tracy_emit_messageL( txt, 0 );
    130 #  define TracyCMessageC( txt, size, color ) ___tracy_emit_messageC( txt, size, color, 0 );
    131 #  define TracyCMessageLC( txt, color ) ___tracy_emit_messageLC( txt, color, 0 );
    132 #endif
    133 
    134 
    135 TRACY_API void ___tracy_emit_frame_mark( const char* name );
    136 TRACY_API void ___tracy_emit_frame_mark_start( const char* name );
    137 TRACY_API void ___tracy_emit_frame_mark_end( const char* name );
    138 TRACY_API void ___tracy_emit_frame_image( const void* image, uint16_t w, uint16_t h, uint8_t offset, int flip );
    139 
    140 #define TracyCFrameMark ___tracy_emit_frame_mark( 0 );
    141 #define TracyCFrameMarkNamed( name ) ___tracy_emit_frame_mark( name );
    142 #define TracyCFrameMarkStart( name ) ___tracy_emit_frame_mark_start( name );
    143 #define TracyCFrameMarkEnd( name ) ___tracy_emit_frame_mark_end( name );
    144 #define TracyCFrameImage( image, width, height, offset, flip ) ___tracy_emit_frame_image( image, width, height, offset, flip );
    145 
    146 
    147 TRACY_API void ___tracy_emit_plot( const char* name, double val );
    148 TRACY_API void ___tracy_emit_message_appinfo( const char* txt, size_t size );
    149 
    150 #define TracyCPlot( name, val ) ___tracy_emit_plot( name, val );
    151 #define TracyCAppInfo( txt, color ) ___tracy_emit_message_appinfo( txt, color );
    152 
    153 
    154 #ifdef TRACY_HAS_CALLSTACK
    155 #  define TracyCZoneS( ctx, depth, active ) static const struct ___tracy_source_location_data TracyConcat(__tracy_source_location,__LINE__) = { NULL, __FUNCTION__,  __FILE__, (uint32_t)__LINE__, 0 }; TracyCZoneCtx ctx = ___tracy_emit_zone_begin_callstack( &TracyConcat(__tracy_source_location,__LINE__), depth, active );
    156 #  define TracyCZoneNS( ctx, name, depth, active ) static const struct ___tracy_source_location_data TracyConcat(__tracy_source_location,__LINE__) = { name, __FUNCTION__,  __FILE__, (uint32_t)__LINE__, 0 }; TracyCZoneCtx ctx = ___tracy_emit_zone_begin_callstack( &TracyConcat(__tracy_source_location,__LINE__), depth, active );
    157 #  define TracyCZoneCS( ctx, color, depth, active ) static const struct ___tracy_source_location_data TracyConcat(__tracy_source_location,__LINE__) = { NULL, __FUNCTION__,  __FILE__, (uint32_t)__LINE__, color }; TracyCZoneCtx ctx = ___tracy_emit_zone_begin_callstack( &TracyConcat(__tracy_source_location,__LINE__), depth, active );
    158 #  define TracyCZoneNCS( ctx, name, color, depth, active ) static const struct ___tracy_source_location_data TracyConcat(__tracy_source_location,__LINE__) = { name, __FUNCTION__,  __FILE__, (uint32_t)__LINE__, color }; TracyCZoneCtx ctx = ___tracy_emit_zone_begin_callstack( &TracyConcat(__tracy_source_location,__LINE__), depth, active );
    159 
    160 #  define TracyCAllocS( ptr, size, depth ) ___tracy_emit_memory_alloc_callstack( ptr, size, depth )
    161 #  define TracyCFreeS( ptr, depth ) ___tracy_emit_memory_alloc_free_callstack( ptr, depth )
    162 
    163 #  define TracyCMessageS( txt, size, depth ) ___tracy_emit_message( txt, size, depth );
    164 #  define TracyCMessageLS( txt, depth ) ___tracy_emit_messageL( txt, depth );
    165 #  define TracyCMessageCS( txt, size, color, depth ) ___tracy_emit_messageC( txt, size, color, depth );
    166 #  define TracyCMessageLCS( txt, color, depth ) ___tracy_emit_messageLC( txt, color, depth );
    167 #else
    168 #  define TracyCZoneS( ctx, depth, active ) TracyCZone( ctx, active )
    169 #  define TracyCZoneNS( ctx, name, depth, active ) TracyCZoneN( ctx, name, active )
    170 #  define TracyCZoneCS( ctx, color, depth, active ) TracyCZoneC( ctx, color, active )
    171 #  define TracyCZoneNCS( ctx, name, color, depth, active ) TracyCZoneNC( ctx, name, color, active )
    172 
    173 #  define TracyCAllocS( ptr, size, depth ) TracyCAlloc( ptr, size )
    174 #  define TracyCFreeS( ptr, depth ) TracyCFree( ptr )
    175 
    176 #  define TracyCMessageS( txt, size, depth ) TracyCMessage( txt, size )
    177 #  define TracyCMessageLS( txt, depth ) TracyCMessageL( txt )
    178 #  define TracyCMessageCS( txt, size, color, depth ) TracyCMessageC( txt, size, color )
    179 #  define TracyCMessageLCS( txt, color, depth ) TracyCMessageLC( txt, color )
    180 #endif
    181 
    182 #endif
    183 
    184 #ifdef __cplusplus
    185 }
    186 #endif
    187 
    188 #endif