xref: /aosp_15_r20/external/bcc/tests/python/include/folly/tracing/StaticTracepoint.h (revision 387f9dfdfa2baef462e92476d413c7bc2470293e)
1 /*
2  * Copyright (c) Facebook, Inc. and its affiliates.
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 
17 #pragma once
18 
19 #if defined(__ELF__) && (defined(__x86_64__) || defined(__i386__)) && \
20     !FOLLY_DISABLE_SDT
21 
22 #include <folly/tracing/StaticTracepoint-ELFx86.h>
23 
24 #define FOLLY_SDT(provider, name, ...) \
25   FOLLY_SDT_PROBE_N(                   \
26       provider, name, 0, FOLLY_SDT_NARG(0, ##__VA_ARGS__), ##__VA_ARGS__)
27 // Use FOLLY_SDT_DEFINE_SEMAPHORE(provider, name) to define the semaphore
28 // as global variable before using the FOLLY_SDT_WITH_SEMAPHORE macro
29 #define FOLLY_SDT_WITH_SEMAPHORE(provider, name, ...) \
30   FOLLY_SDT_PROBE_N(                                  \
31       provider, name, 1, FOLLY_SDT_NARG(0, ##__VA_ARGS__), ##__VA_ARGS__)
32 #define FOLLY_SDT_IS_ENABLED(provider, name) \
33   (FOLLY_SDT_SEMAPHORE(provider, name) > 0)
34 
35 #else
36 
37 #define FOLLY_SDT(provider, name, ...) \
38   do {                                 \
39   } while (0)
40 #define FOLLY_SDT_WITH_SEMAPHORE(provider, name, ...) \
41   do {                                                \
42   } while (0)
43 #define FOLLY_SDT_IS_ENABLED(provider, name) (false)
44 #define FOLLY_SDT_DEFINE_SEMAPHORE(provider, name)
45 #define FOLLY_SDT_DECLARE_SEMAPHORE(provider, name)
46 #endif
47