control-internal.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * Interface for configuring and controlling the state of tracing events.
  3. *
  4. * Copyright (C) 2011-2014 Lluís Vilanova <vilanova@ac.upc.edu>
  5. *
  6. * This work is licensed under the terms of the GNU GPL, version 2 or later.
  7. * See the COPYING file in the top-level directory.
  8. */
  9. #ifndef TRACE__CONTROL_INTERNAL_H
  10. #define TRACE__CONTROL_INTERNAL_H
  11. #include <string.h>
  12. extern TraceEvent trace_events[];
  13. static inline TraceEventID trace_event_count(void)
  14. {
  15. return TRACE_EVENT_COUNT;
  16. }
  17. static inline TraceEvent *trace_event_id(TraceEventID id)
  18. {
  19. assert(id < trace_event_count());
  20. return &trace_events[id];
  21. }
  22. static inline bool trace_event_is_pattern(const char *str)
  23. {
  24. assert(str != NULL);
  25. return strchr(str, '*') != NULL;
  26. }
  27. static inline TraceEventID trace_event_get_id(TraceEvent *ev)
  28. {
  29. assert(ev != NULL);
  30. return ev->id;
  31. }
  32. static inline const char * trace_event_get_name(TraceEvent *ev)
  33. {
  34. assert(ev != NULL);
  35. return ev->name;
  36. }
  37. static inline bool trace_event_get_state_static(TraceEvent *ev)
  38. {
  39. assert(ev != NULL);
  40. return ev->sstate;
  41. }
  42. static inline bool trace_event_get_state_dynamic(TraceEvent *ev)
  43. {
  44. assert(ev != NULL);
  45. return ev->dstate;
  46. }
  47. static inline void trace_event_set_state_dynamic(TraceEvent *ev, bool state)
  48. {
  49. assert(ev != NULL);
  50. assert(trace_event_get_state_static(ev));
  51. ev->dstate = state;
  52. }
  53. #endif /* TRACE__CONTROL_INTERNAL_H */