1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

internal/gc.h rework

Improved readability by reducing the use of macros.  Also moved some
part of internal/compilers.h into this file, because it seems to be the
right place for them.
This commit is contained in:
卜部昌平 2019-12-04 10:26:41 +09:00
parent adc49f0f9a
commit c27bcd7057
Notes: git 2019-12-26 20:46:00 +09:00
2 changed files with 106 additions and 53 deletions

View file

@ -236,22 +236,4 @@ rb_obj_builtin_type(VALUE obj)
# define BITFIELD(type, name, size) unsigned int name : size
#endif
#if defined(USE_UNALIGNED_MEMBER_ACCESS) && USE_UNALIGNED_MEMBER_ACCESS && \
(defined(__clang__) || GCC_VERSION_SINCE(9, 0, 0))
#include "warnings.h"
# define UNALIGNED_MEMBER_ACCESS(expr) __extension__({ \
COMPILER_WARNING_PUSH; \
COMPILER_WARNING_IGNORED(-Waddress-of-packed-member); \
typeof(expr) unaligned_member_access_result = (expr); \
COMPILER_WARNING_POP; \
unaligned_member_access_result; \
})
#else
# define UNALIGNED_MEMBER_ACCESS(expr) expr
#endif
#define UNALIGNED_MEMBER_PTR(ptr, mem) UNALIGNED_MEMBER_ACCESS(&(ptr)->mem)
#undef RB_OBJ_WRITE
#define RB_OBJ_WRITE(a, slot, b) UNALIGNED_MEMBER_ACCESS(rb_obj_write((VALUE)(a), (VALUE *)(slot), (VALUE)(b), __FILE__, __LINE__))
#endif /* INTERNAL_COMPILERS_H */