Debian Codegraph @

include/ruby/internal/attr/restrict.h

raw
1 #ifndef RBIMPL_ATTR_RESTRICT_H /*-*-C++-*-vi:se ft=cpp:*/
2 #define RBIMPL_ATTR_RESTRICT_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_RESTRICT.
22 */
23 #include "ruby/internal/compiler_since.h"
24 #include "ruby/internal/has/attribute.h"
25
26 /* :FIXME: config.h includes conflicting `#define restrict`. MSVC can be
27 * detected using `RBIMPL_COMPILER_SINCE()`, but Clang & family cannot use
28 * `__has_declspec_attribute()` which involves macro substitution. */
29
30 /** Wraps (or simulates) `__declspec(restrict)` */
31 #if RBIMPL_COMPILER_SINCE(MSVC, 14, 0, 0)
32 # define RBIMPL_ATTR_RESTRICT() __declspec(re ## strict)
33
34 #elif RBIMPL_HAS_ATTRIBUTE(malloc)
35 # define RBIMPL_ATTR_RESTRICT() __attribute__((__malloc__))
36
37 #elif RBIMPL_COMPILER_SINCE(SunPro, 5, 10, 0)
38 # define RBIMPL_ATTR_RESTRICT() _Pragma("returns_new_memory")
39
40 #else
41 # define RBIMPL_ATTR_RESTRICT() /* void */
42 #endif
43
44 #endif /* RBIMPL_ATTR_RESTRICT_H */