]>
Commit | Line | Data |
---|---|---|
3a097cc7 | 1 | /* Macros for defining Systemtap <sys/sdt.h> static probe points. |
d4697bc9 | 2 | Copyright (C) 2012-2014 Free Software Foundation, Inc. |
3a097cc7 RM |
3 | This file is part of the GNU C Library. |
4 | ||
5 | The GNU C Library is free software; you can redistribute it and/or | |
6 | modify it under the terms of the GNU Lesser General Public | |
7 | License as published by the Free Software Foundation; either | |
8 | version 2.1 of the License, or (at your option) any later version. | |
9 | ||
10 | The GNU C Library is distributed in the hope that it will be useful, | |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 | Lesser General Public License for more details. | |
14 | ||
15 | You should have received a copy of the GNU Lesser General Public | |
16 | License along with the GNU C Library; if not, see | |
17 | <http://www.gnu.org/licenses/>. */ | |
18 | ||
19 | #ifndef _STAP_PROBE_H | |
20 | #define _STAP_PROBE_H 1 | |
21 | ||
22 | #ifdef USE_STAP_PROBE | |
23 | ||
24 | # include <sys/sdt.h> | |
25 | ||
26 | /* Our code uses one macro LIBC_PROBE (name, n, arg1, ..., argn). | |
27 | ||
28 | Without USE_STAP_PROBE, that does nothing but evaluates all | |
29 | its arguments (to prevent bit rot, unlike e.g. assert). | |
30 | ||
31 | Systemtap's header defines the macros STAP_PROBE (provider, name) and | |
32 | STAP_PROBEn (provider, name, arg1, ..., argn). For "provider" we paste | |
33 | in the IN_LIB name (libc, libpthread, etc.) automagically. */ | |
34 | ||
35 | # ifndef NOT_IN_libc | |
36 | # define IN_LIB libc | |
37 | # elif !defined IN_LIB | |
38 | /* This is intentionally defined with extra unquoted commas in it so | |
39 | that macro substitution will bomb out when it is used. We don't | |
40 | just use #error here, so that this header can be included by | |
41 | other headers that use LIBC_PROBE inside their own macros. We | |
42 | only want such headers to fail to compile if those macros are | |
43 | actually used in a context where IN_LIB has not been defined. */ | |
44 | # define IN_LIB ,,,missing -DIN_LIB=... -- not extra-lib.mk?,,, | |
45 | # endif | |
46 | ||
47 | # define LIBC_PROBE(name, n, ...) \ | |
48 | LIBC_PROBE_1 (IN_LIB, name, n, ## __VA_ARGS__) | |
49 | ||
50 | # define LIBC_PROBE_1(lib, name, n, ...) \ | |
51 | STAP_PROBE##n (lib, name, ## __VA_ARGS__) | |
52 | ||
53 | # define STAP_PROBE0 STAP_PROBE | |
54 | ||
55 | # define LIBC_PROBE_ASM(name, template) \ | |
56 | STAP_PROBE_ASM (IN_LIB, name, template) | |
57 | ||
58 | # define LIBC_PROBE_ASM_OPERANDS STAP_PROBE_ASM_OPERANDS | |
59 | ||
60 | #else /* Not USE_STAP_PROBE. */ | |
61 | ||
62 | # ifndef __ASSEMBLER__ | |
63 | /* Evaluate all the arguments and verify that N matches their number. */ | |
520d437b SP |
64 | #define LIBC_PROBE(name, n, ...) STAP_PROBE##n (__VA_ARGS__) |
65 | ||
66 | #define STAP_PROBE0() | |
67 | #define STAP_PROBE1(a1) | |
68 | #define STAP_PROBE2(a1, a2) | |
69 | #define STAP_PROBE3(a1, a2, a3) | |
70 | #define STAP_PROBE4(a1, a2, a3, a4) | |
71 | ||
3a097cc7 RM |
72 | # else |
73 | # define LIBC_PROBE(name, n, ...) /* Nothing. */ | |
74 | # endif | |
75 | ||
76 | # define LIBC_PROBE_ASM(name, template) /* Nothing. */ | |
77 | # define LIBC_PROBE_ASM_OPERANDS(n, ...) /* Nothing. */ | |
78 | ||
79 | #endif /* USE_STAP_PROBE. */ | |
80 | ||
81 | #endif /* stap-probe.h */ |