Ruby: include/ruby/internal/attr/restrict.h Source File

Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)

restrict.h
Go to the documentation of this file.
1#ifndef RBIMPL_ATTR_RESTRICT_H /*-*-C++-*-vi:se ft=cpp:*/
2#define RBIMPL_ATTR_RESTRICT_H
23#include "ruby/internal/compiler_since.h"
24#include "ruby/internal/has/attribute.h"
25#include "ruby/internal/token_paste.h"
26
27/* :FIXME: config.h includes conflicting `#define restrict`. MSVC can be
28 * detected using `RBIMPL_COMPILER_SINCE()`, but Clang & family cannot use
29 * `__has_declspec_attribute()` which involves macro substitution. */
30
32#if RBIMPL_COMPILER_SINCE(MSVC, 14, 0, 0)
33# define RBIMPL_ATTR_RESTRICT() __declspec(RBIMPL_TOKEN_PASTE(re, strict))
34
35#elif RBIMPL_HAS_ATTRIBUTE(malloc)
36# define RBIMPL_ATTR_RESTRICT() __attribute__((__malloc__))
37
38#elif RBIMPL_COMPILER_SINCE(SunPro, 5, 10, 0)
39# define RBIMPL_ATTR_RESTRICT() _Pragma("returns_new_memory")
40
41#else
42# define RBIMPL_ATTR_RESTRICT() /* void */
43#endif
44
45#endif /* RBIMPL_ATTR_RESTRICT_H */
attribute.h
Defines RBIMPL_HAS_ATTRIBUTE.
compiler_since.h
Defines RBIMPL_COMPILER_SINCE.
token_paste.h
Defines RBIMPL_TOKEN_PASTE.