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

Ruby 3.2.5p208 (2024-07-26 revision 31d0f1a2e7dbfb60731d1f05b868e1d578cda493)

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
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
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 */
attribute.h
Defines RBIMPL_HAS_ATTRIBUTE.
compiler_since.h
Defines RBIMPL_COMPILER_SINCE.