diff options
Diffstat (limited to 'include/ruby/backward/2/attributes.h')
| -rw-r--r-- | include/ruby/backward/2/attributes.h | 118 |
1 files changed, 61 insertions, 57 deletions
diff --git a/include/ruby/backward/2/attributes.h b/include/ruby/backward/2/attributes.h index 043646eb4b..916d9e9d5b 100644 --- a/include/ruby/backward/2/attributes.h +++ b/include/ruby/backward/2/attributes.h @@ -1,13 +1,12 @@ #ifndef RUBY_BACKWARD2_ATTRIBUTES_H /*-*-C++-*-vi:se ft=cpp:*/ #define RUBY_BACKWARD2_ATTRIBUTES_H /** - * @file * @author Ruby developers <ruby-core@ruby-lang.org> * @copyright This file is a part of the programming language Ruby. * Permission is hereby granted, to either redistribute and/or * modify this file, provided that the conditions mentioned in the * file COPYING are met. Consult the file for details. - * @warning Symbols prefixed with either `RUBY3` or `ruby3` are + * @warning Symbols prefixed with either `RBIMPL` or `rbimpl` are * implementation details. Don't take them as canon. They could * rapidly appear then vanish. The name (path) of this header file * is also an implementation detail. Do not expect it to persist @@ -17,7 +16,7 @@ * recursively included from extension libraries written in C++. * Do not expect for instance `__VA_ARGS__` is always available. * We assume C99 for ruby itself but we don't assume languages of - * extension libraries. They could be written in C++98. + * extension libraries. They could be written in C++98. * @brief Various attribute-related macros. * * ### Q&A ### @@ -28,65 +27,73 @@ * - A: Don't know. Don't blame me. Backward compatibility is the key here. * I'm just preserving what they have been. */ -#include "ruby/3/config.h" -#include "ruby/3/attr/alloc_size.h" -#include "ruby/3/attr/cold.h" -#include "ruby/3/attr/const.h" -#include "ruby/3/attr/deprecated.h" -#include "ruby/3/attr/error.h" -#include "ruby/3/attr/forceinline.h" -#include "ruby/3/attr/format.h" -#include "ruby/3/attr/maybe_unused.h" -#include "ruby/3/attr/noinline.h" -#include "ruby/3/attr/nonnull.h" -#include "ruby/3/attr/noreturn.h" -#include "ruby/3/attr/pure.h" -#include "ruby/3/attr/restrict.h" -#include "ruby/3/attr/returns_nonnull.h" -#include "ruby/3/attr/warning.h" -#include "ruby/3/has/attribute.h" +#include "ruby/internal/config.h" +#include "ruby/internal/attr/alloc_size.h" +#include "ruby/internal/attr/cold.h" +#include "ruby/internal/attr/const.h" +#include "ruby/internal/attr/deprecated.h" +#include "ruby/internal/attr/error.h" +#include "ruby/internal/attr/forceinline.h" +#include "ruby/internal/attr/format.h" +#include "ruby/internal/attr/maybe_unused.h" +#include "ruby/internal/attr/noinline.h" +#include "ruby/internal/attr/nonnull.h" +#include "ruby/internal/attr/noreturn.h" +#include "ruby/internal/attr/packed_struct.h" +#include "ruby/internal/attr/pure.h" +#include "ruby/internal/attr/restrict.h" +#include "ruby/internal/attr/returns_nonnull.h" +#include "ruby/internal/attr/warning.h" +#include "ruby/internal/has/attribute.h" /* function attributes */ #undef CONSTFUNC -#define CONSTFUNC(x) RUBY3_ATTR_CONST() x +#define CONSTFUNC(x) RBIMPL_ATTR_CONST() x #undef PUREFUNC -#define PUREFUNC(x) RUBY3_ATTR_PURE() x +#define PUREFUNC(x) RBIMPL_ATTR_PURE() x #undef DEPRECATED -#define DEPRECATED(x) RUBY3_ATTR_DEPRECATED(("")) x +#define DEPRECATED(x) RBIMPL_ATTR_DEPRECATED(("")) x #undef DEPRECATED_BY -#define DEPRECATED_BY(n,x) RUBY3_ATTR_DEPRECATED(("by: " # n)) x +#define DEPRECATED_BY(n,x) RBIMPL_ATTR_DEPRECATED(("by: " # n)) x #undef DEPRECATED_TYPE -#define DEPRECATED_TYPE(mseg, decl) decl RUBY3_ATTR_DEPRECATED(mseg) +#if defined(__GNUC__) +# define DEPRECATED_TYPE(mesg, decl) \ + _Pragma("message \"DEPRECATED_TYPE is deprecated\""); \ + decl RBIMPL_ATTR_DEPRECATED(mseg) +#elif defined(_MSC_VER) +# pragma deprecated(DEPRECATED_TYPE) +# define DEPRECATED_TYPE(mesg, decl) \ + __pragma(message(__FILE__"("STRINGIZE(__LINE__)"): warning: " \ + "DEPRECATED_TYPE is deprecated")) \ + decl RBIMPL_ATTR_DEPRECATED(mseg) +#else +# define DEPRECATED_TYPE(mesg, decl) \ + <-<-"DEPRECATED_TYPE is deprecated"->-> +#endif #undef RUBY_CXX_DEPRECATED -#define RUBY_CXX_DEPRECATED(mseg) RUBY3_ATTR_DEPRECATED((mseg)) +#define RUBY_CXX_DEPRECATED(mseg) RBIMPL_ATTR_DEPRECATED((mseg)) #undef NOINLINE -#define NOINLINE(x) RUBY3_ATTR_NOINLINE() x +#define NOINLINE(x) RBIMPL_ATTR_NOINLINE() x -#ifndef MJIT_HEADER -# undef ALWAYS_INLINE -# define ALWAYS_INLINE(x) RUBY3_ATTR_FORCEINLINE() x -#endif +#undef ALWAYS_INLINE +#define ALWAYS_INLINE(x) RBIMPL_ATTR_FORCEINLINE() x #undef ERRORFUNC -#define ERRORFUNC(mesg, x) RUBY3_ATTR_ERROR(mesg) x -#if RUBY3_HAS_ATTRIBUTE(error) +#define ERRORFUNC(mesg, x) RBIMPL_ATTR_ERROR(mesg) x +#if RBIMPL_HAS_ATTRIBUTE(error) # define HAVE_ATTRIBUTE_ERRORFUNC 1 -#else -# define HAVE_ATTRIBUTE_ERRORFUNC 0 #endif #undef WARNINGFUNC -#define WARNINGFUNC(mesg, x) RUBY3_ATTR_WARNING(mesg) x -#if RUBY3_HAS_ATTRIBUTE(warning) +#define WARNINGFUNC(mesg, x) RBIMPL_ATTR_WARNING(mesg) x +#if RBIMPL_HAS_ATTRIBUTE(warning) # define HAVE_ATTRIBUTE_WARNINGFUNC 1 -#else -# define HAVE_ATTRIBUTE_WARNINGFUNC 0 #endif /* @@ -94,20 +101,20 @@ RUBY_FUNC_ATTRIBUTE not used because MSVC does not like nested func macros */ #undef COLDFUNC -#define COLDFUNC RUBY3_ATTR_COLD() +#define COLDFUNC RBIMPL_ATTR_COLD() #define PRINTF_ARGS(decl, string_index, first_to_check) \ - RUBY3_ATTR_FORMAT(RUBY3_PRINTF_FORMAT, (string_index), (first_to_check)) \ + RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, (string_index), (first_to_check)) \ decl #undef RUBY_ATTR_ALLOC_SIZE -#define RUBY_ATTR_ALLOC_SIZE RUBY3_ATTR_ALLOC_SIZE +#define RUBY_ATTR_ALLOC_SIZE RBIMPL_ATTR_ALLOC_SIZE #undef RUBY_ATTR_MALLOC -#define RUBY_ATTR_MALLOC RUBY3_ATTR_RESTRICT() +#define RUBY_ATTR_MALLOC RBIMPL_ATTR_RESTRICT() #undef RUBY_ATTR_RETURNS_NONNULL -#define RUBY_ATTR_RETURNS_NONNULL RUBY3_ATTR_RETURNS_NONNULL() +#define RUBY_ATTR_RETURNS_NONNULL RBIMPL_ATTR_RETURNS_NONNULL() #ifndef FUNC_MINIMIZED #define FUNC_MINIMIZED(x) x @@ -133,25 +140,22 @@ #endif #undef RUBY_FUNC_NONNULL -#define RUBY_FUNC_NONNULL(n, x) RUBY3_ATTR_NONNULL(n) x +#define RUBY_FUNC_NONNULL(n, x) RBIMPL_ATTR_NONNULL(n) x #undef NORETURN -#define NORETURN(x) RUBY3_ATTR_NORETURN() x +#define NORETURN(x) RBIMPL_ATTR_NORETURN() x #define NORETURN_STYLE_NEW -#ifndef PACKED_STRUCT -# define PACKED_STRUCT(x) x -#endif +#undef PACKED_STRUCT +#define PACKED_STRUCT(x) \ + RBIMPL_ATTR_PACKED_STRUCT_BEGIN() x RBIMPL_ATTR_PACKED_STRUCT_END() -#ifndef PACKED_STRUCT_UNALIGNED -# if UNALIGNED_WORD_ACCESS -# define PACKED_STRUCT_UNALIGNED(x) PACKED_STRUCT(x) -# else -# define PACKED_STRUCT_UNALIGNED(x) x -# endif -#endif +#undef PACKED_STRUCT_UNALIGNED +#define PACKED_STRUCT_UNALIGNED(x) \ + RBIMPL_ATTR_PACKED_STRUCT_UNALIGNED_BEGIN() x \ + RBIMPL_ATTR_PACKED_STRUCT_UNALIGNED_END() #undef RB_UNUSED_VAR -#define RB_UNUSED_VAR(x) x RUBY3_ATTR_MAYBE_UNUSED() +#define RB_UNUSED_VAR(x) x RBIMPL_ATTR_MAYBE_UNUSED() #endif /* RUBY_BACKWARD2_ATTRIBUTES_H */ |
