mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-25 23:44:35 +00:00
Expose TRACY_MANUAL_LIFETIME APIs to C API clients
These are extremely useful for ecosystems such as Rust. There are a couple of reasons why: 1. Rust strongly advises against relying on life before/after main, as it is difficult to reason about. Most users working in Rust will generally be quite surprised when encountering this concept. 2. Rust and its package manager makes it easy to use packages (crates) and somewhat less straightforward to consider the implications of including a dependency. In case of the `rust_tracy_client` set of packages, I currently have to warn throughout the documentation of the package that simply adding a dependency on the bindings package is sufficient to potentially accidentally broadcast a lot of information about the instrumented binary to the broader world. This seems like a major footgun given how easy is it to forget about having added this dependency. Ability to manually manage the lifetime of the profiler would be a great solution to these problems.
This commit is contained in:
parent
e929946120
commit
54ee3d8a94
6
TracyC.h
6
TracyC.h
@ -101,6 +101,12 @@ struct ___tracy_c_zone_context
|
||||
// This struct, as visible to user, is immutable, so treat it as if const was declared here.
|
||||
typedef /*const*/ struct ___tracy_c_zone_context TracyCZoneCtx;
|
||||
|
||||
|
||||
#ifdef TRACY_MANUAL_LIFETIME
|
||||
TRACY_API void ___tracy_startup_profiler(void);
|
||||
TRACY_API void ___tracy_shutdown_profiler(void);
|
||||
#endif
|
||||
|
||||
TRACY_API uint64_t ___tracy_alloc_srcloc( uint32_t line, const char* source, size_t sourceSz, const char* function, size_t functionSz );
|
||||
TRACY_API uint64_t ___tracy_alloc_srcloc_name( uint32_t line, const char* source, size_t sourceSz, const char* function, size_t functionSz, const char* name, size_t nameSz );
|
||||
|
||||
|
@ -3602,6 +3602,18 @@ TRACY_API uint64_t ___tracy_alloc_srcloc_name( uint32_t line, const char* source
|
||||
return tracy::Profiler::AllocSourceLocation( line, source, sourceSz, function, functionSz, name, nameSz );
|
||||
}
|
||||
|
||||
# ifdef TRACY_MANUAL_LIFETIME
|
||||
TRACY_API void ___tracy_startup_profiler( void )
|
||||
{
|
||||
tracy::StartupProfiler();
|
||||
}
|
||||
|
||||
TRACY_API void ___tracy_shutdown_profiler( void )
|
||||
{
|
||||
tracy::ShutdownProfiler();
|
||||
}
|
||||
# endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user