Skip to content

Commit

Permalink
Enable a way to globally enable/disable COZ tracepoints
Browse files Browse the repository at this point in the history
It can be useful to leave coz tracepoints committed in the code but only
conditionally enable coz.
  • Loading branch information
vlovich committed Mar 11, 2022
1 parent 9ece196 commit aff0963
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions include/coz.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@
#if !defined(COZ_H)
#define COZ_H

// Embedders can define COZ_ENABLED explicitly to 1 or 0 to globally to enable/disable coz
// tracepoints.
#ifndef COZ_ENABLED
#define COZ_ENABLED 1
#endif

#if COZ_ENABLED

#ifndef __USE_GNU
# define __USE_GNU
#endif
Expand Down Expand Up @@ -119,4 +127,17 @@ static void _call_coz_wake_other() {
}
#endif

#else

#define _COZ_NOOP() do {} while(0)
#define COZ_PROGRESS_NAMED(name) _COZ_NOOP()
#define COZ_PROGRESS() _COZ_NOOP()
#define COZ_BEGIN(name) _COZ_NOOP()
#define COZ_END(name) _COZ_NOOP()
#define COZ_PRE_BLOCK() _COZ_NOOP()
#define COZ_POST_BLOCK() _COZ_NOOP()
#define COZ_WAKE_OTHER() _COZ_NOOP()

#endif

#endif

0 comments on commit aff0963

Please sign in to comment.