/* date = September 2nd 2023 6:05 pm */

#ifndef BASE_PROFILING_H
#define BASE_PROFILING_H

////////////////////////////////
// NOTE(allen): Profiling Implementable Interface

#if ENABLE_ANY_PROFILE

link_function void prof_open(char *name);
link_function void prof_close(void);
link_function void prof_thread_begin(void);
link_function void prof_thread_end(void);
link_function void prof_thread_flush(void);
link_function void prof_begin(char *name, U32 len);
link_function void prof_end(void);

#endif

////////////////////////////////
// NOTE(allen): Profiling Provider

#if ENABLE_ANY_PROFILE
# if PROFILER_SPALL
#  include "base_profiling_by_spall.h"
# else
#  error no profiler setup but manual profiling is enabled
# endif
#endif

////////////////////////////////
// NOTE(allen): Profiling User Interface

#if ENABLE_ANY_PROFILE
# define ProfOpen(n)       prof_open((char*)(n))
# define ProfClose()       prof_close()
# define ProfThreadBegin() prof_thread_begin()
# define ProfThreadEnd()   prof_thread_end()
# define ProfThreadFlush() prof_thread_flush()
# define ProfBegin(n)      prof_begin_inl((n), sizeof(n) - 1)
# define ProfEnd()         prof_end_inl()
#else
# define ProfOpen(n)
# define ProfClose()
# define ProfThreadBegin()
# define ProfThreadEnd()
# define ProfThreadFlush()
# define ProfBegin(n)
# define ProfEnd()
#endif

#if ENABLE_MANUAL_PROFILE
# define ProfBeginManual(n) ProfBegin(n)
# define ProfEndManual()    ProfEnd()
#else
# define ProfBeginManual(n)
# define ProfEndManual()
#endif

#define ProfBeginFunc() ProfBeginManual(__FUNCTION__)
#define ProfEndFunc()   ProfEndManual()

#endif //BASE_PROFILING_H
