StaticTracepoint.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. * Copyright 2016-present Facebook, Inc.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #pragma once
  17. #if defined(__ELF__) && (defined(__x86_64__) || defined(__i386__))
  18. #include <folly/tracing/StaticTracepoint-ELFx86.h>
  19. #define FOLLY_SDT(provider, name, ...) \
  20. FOLLY_SDT_PROBE_N( \
  21. provider, name, 0, FOLLY_SDT_NARG(0, ##__VA_ARGS__), ##__VA_ARGS__)
  22. // Use FOLLY_SDT_DEFINE_SEMAPHORE(provider, name) to define the semaphore
  23. // as global variable before using the FOLLY_SDT_WITH_SEMAPHORE macro
  24. #define FOLLY_SDT_WITH_SEMAPHORE(provider, name, ...) \
  25. FOLLY_SDT_PROBE_N( \
  26. provider, name, 1, FOLLY_SDT_NARG(0, ##__VA_ARGS__), ##__VA_ARGS__)
  27. #define FOLLY_SDT_IS_ENABLED(provider, name) \
  28. (FOLLY_SDT_SEMAPHORE(provider, name) > 0)
  29. #else
  30. #define FOLLY_SDT(provider, name, ...) \
  31. do { \
  32. } while (0)
  33. #define FOLLY_SDT_WITH_SEMAPHORE(provider, name, ...) \
  34. do { \
  35. } while (0)
  36. #define FOLLY_SDT_IS_ENABLED(provider, name) (false)
  37. #define FOLLY_SDT_DEFINE_SEMAPHORE(provider, name)
  38. #define FOLLY_SDT_DECLARE_SEMAPHORE(provider, name)
  39. #endif