Debian Codegraph @

include/ruby/internal/attr/artificial.h

raw
1 #ifndef RBIMPL_ATTR_ARTIFICIAL_H /*-*-C++-*-vi:se ft=cpp:*/
2 #define RBIMPL_ATTR_ARTIFICIAL_H
3 /**
4 * @file
5 * @author Ruby developers <[email protected]>
6 * @copyright This file is a part of the programming language Ruby.
7 * Permission is hereby granted, to either redistribute and/or
8 * modify this file, provided that the conditions mentioned in the
9 * file COPYING are met. Consult the file for details.
10 * @warning Symbols prefixed with either `RBIMPL` or `rbimpl` are
11 * implementation details. Don't take them as canon. They could
12 * rapidly appear then vanish. The name (path) of this header file
13 * is also an implementation detail. Do not expect it to persist
14 * at the place it is now. Developers are free to move it anywhere
15 * anytime at will.
16 * @note To ruby-core: remember that this header can be possibly
17 * recursively included from extension libraries written in C++.
18 * Do not expect for instance `__VA_ARGS__` is always available.
19 * We assume C99 for ruby itself but we don't assume languages of
20 * extension libraries. They could be written in C++98.
21 * @brief Defines #RBIMPL_ATTR_ARTIFICIAL.
22 *
23 * ### Q&A ###
24 *
25 * - Q: What is this attribute? I don't get what GCC manual is talking about.
26 *
27 * - A: In short it is an attribute to manipulate GDB backtraces. The
28 * attribute makes the best sense when it comes with
29 * __attribute__((always_inline)). When a function annotated with this
30 * attribute gets inlined, and when you somehow look at a backtrace which
31 * includes such inlined call site, then the backtrace shows the caller
32 * and not the callee. This is handy for instance when an identical
33 * function is inlined more than once in a single big function. On such
34 * case it gets vital to know where the inlining happened in the callee.
35 * See also https://stackoverflow.com/a/21936099
36 */
37 #include "ruby/internal/has/attribute.h"
38
39 /** Wraps (or simulates) `__attribute__((artificial))` */
40 #if RBIMPL_HAS_ATTRIBUTE(artificial)
41 # define RBIMPL_ATTR_ARTIFICIAL() __attribute__((__artificial__))
42 #else
43 # define RBIMPL_ATTR_ARTIFICIAL() /* void */
44 #endif
45
46 #endif /* RBIMPL_ATTR_ARTIFICIAL_H */