summaryrefslogtreecommitdiff
path: root/include/ruby/impl/memory.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/ruby/impl/memory.h')
-rw-r--r--include/ruby/impl/memory.h72
1 files changed, 36 insertions, 36 deletions
diff --git a/include/ruby/impl/memory.h b/include/ruby/impl/memory.h
index 5c9a3c9c14..9d8b5c8412 100644
--- a/include/ruby/impl/memory.h
+++ b/include/ruby/impl/memory.h
@@ -1,5 +1,5 @@
-#ifndef RUBY3_MEMORY_H /*-*-C++-*-vi:se ft=cpp:*/
-#define RUBY3_MEMORY_H
+#ifndef RBIMPL_MEMORY_H /*-*-C++-*-vi:se ft=cpp:*/
+#define RBIMPL_MEMORY_H
/**
* @file
* @author Ruby developers <ruby-core@ruby-lang.org>
@@ -7,7 +7,7 @@
* 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 `ruby3` 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
@@ -65,7 +65,7 @@
/* Make alloca work the best possible way. */
#if defined(alloca)
# /* Take that. */
-#elif RUBY3_HAS_BUILTIN(__builtin_alloca)
+#elif RBIMPL_HAS_BUILTIN(__builtin_alloca)
# define alloca __builtin_alloca
#elif defined(_AIX)
# pragma alloca
@@ -102,24 +102,24 @@ extern void *alloca();
#endif
/* Casts needed because void* is NOT compaible with others in C++. */
-#define RB_ALLOC_N(type,n) RUBY3_CAST((type *)ruby_xmalloc2((n), sizeof(type)))
-#define RB_ALLOC(type) RUBY3_CAST((type *)ruby_xmalloc(sizeof(type)))
-#define RB_ZALLOC_N(type,n) RUBY3_CAST((type *)ruby_xcalloc((n), sizeof(type)))
+#define RB_ALLOC_N(type,n) RBIMPL_CAST((type *)ruby_xmalloc2((n), sizeof(type)))
+#define RB_ALLOC(type) RBIMPL_CAST((type *)ruby_xmalloc(sizeof(type)))
+#define RB_ZALLOC_N(type,n) RBIMPL_CAST((type *)ruby_xcalloc((n), sizeof(type)))
#define RB_ZALLOC(type) (RB_ZALLOC_N(type, 1))
#define RB_REALLOC_N(var,type,n) \
- ((var) = RUBY3_CAST((type *)ruby_xrealloc2((void *)(var), (n), sizeof(type))))
+ ((var) = RBIMPL_CAST((type *)ruby_xrealloc2((void *)(var), (n), sizeof(type))))
/* I don't know why but __builtin_alloca_with_align's second argument
takes bits rather than bytes. */
-#if RUBY3_HAS_BUILTIN(__builtin_alloca_with_align)
+#if RBIMPL_HAS_BUILTIN(__builtin_alloca_with_align)
# define ALLOCA_N(type, n) \
- RUBY3_CAST((type *) \
+ RBIMPL_CAST((type *) \
__builtin_alloca_with_align( \
ruby3_size_mul_or_raise(sizeof(type), (n)), \
RUBY_ALIGNOF(type) * CHAR_BIT))
#else
# define ALLOCA_N(type,n) \
- RUBY3_CAST((type *)alloca(ruby3_size_mul_or_raise(sizeof(type), (n))))
+ RBIMPL_CAST((type *)alloca(ruby3_size_mul_or_raise(sizeof(type), (n))))
#endif
/* allocates _n_ bytes temporary buffer and stores VALUE including it
@@ -129,7 +129,7 @@ extern void *alloca();
((v) = 0, alloca(n)) : \
rb_alloc_tmp_buffer(&(v), (n)))
#define RB_ALLOCV_N(type, v, n) \
- RUBY3_CAST((type *) \
+ RBIMPL_CAST((type *) \
(((size_t)(n) < RUBY_ALLOCV_LIMIT / sizeof(type)) ? \
((v) = 0, alloca((n) * sizeof(type))) : \
rb_alloc_tmp_buffer2(&(v), (n), sizeof(type))))
@@ -155,26 +155,26 @@ struct ruby3_size_mul_overflow_tag {
size_t right;
};
-RUBY3_SYMBOL_EXPORT_BEGIN()
-RUBY3_ATTR_RESTRICT()
-RUBY3_ATTR_RETURNS_NONNULL()
-RUBY3_ATTR_ALLOC_SIZE((2))
+RBIMPL_SYMBOL_EXPORT_BEGIN()
+RBIMPL_ATTR_RESTRICT()
+RBIMPL_ATTR_RETURNS_NONNULL()
+RBIMPL_ATTR_ALLOC_SIZE((2))
void *rb_alloc_tmp_buffer(volatile VALUE *store, long len);
-RUBY3_ATTR_RESTRICT()
-RUBY3_ATTR_RETURNS_NONNULL()
-RUBY3_ATTR_ALLOC_SIZE((2,3))
+RBIMPL_ATTR_RESTRICT()
+RBIMPL_ATTR_RETURNS_NONNULL()
+RBIMPL_ATTR_ALLOC_SIZE((2,3))
void *rb_alloc_tmp_buffer_with_count(volatile VALUE *store, size_t len,size_t count);
void rb_free_tmp_buffer(volatile VALUE *store);
-RUBY3_ATTR_NORETURN()
+RBIMPL_ATTR_NORETURN()
void ruby_malloc_size_overflow(size_t, size_t);
#ifdef HAVE_RB_GC_GUARDED_PTR_VAL
volatile VALUE *rb_gc_guarded_ptr_val(volatile VALUE *ptr, VALUE val);
#endif
-RUBY3_SYMBOL_EXPORT_END()
+RBIMPL_SYMBOL_EXPORT_END()
#ifdef _MSC_VER
# pragma optimize("", off)
@@ -198,7 +198,7 @@ rb_mul_size_overflow(size_t a, size_t b, size_t max, size_t *c)
db = b;
c2 = da * db;
if (c2 > max) return 1;
- *c = RUBY3_CAST((size_t)c2);
+ *c = RBIMPL_CAST((size_t)c2);
#else
if (b != 0 && a > max / b) return 1;
*c = a * b;
@@ -206,18 +206,18 @@ rb_mul_size_overflow(size_t a, size_t b, size_t max, size_t *c)
return 0;
}
-#if RUBY3_COMPILER_SINCE(GCC, 7, 0, 0)
-RUBY3_ATTR_CONSTEXPR(CXX14) /* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70507 */
-#elif RUBY3_COMPILER_SINCE(Clang, 7, 0, 0)
-RUBY3_ATTR_CONSTEXPR(CXX14) /* https://bugs.llvm.org/show_bug.cgi?id=37633 */
+#if RBIMPL_COMPILER_SINCE(GCC, 7, 0, 0)
+RBIMPL_ATTR_CONSTEXPR(CXX14) /* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70507 */
+#elif RBIMPL_COMPILER_SINCE(Clang, 7, 0, 0)
+RBIMPL_ATTR_CONSTEXPR(CXX14) /* https://bugs.llvm.org/show_bug.cgi?id=37633 */
#endif
-RUBY3_ATTR_CONST()
+RBIMPL_ATTR_CONST()
static inline struct ruby3_size_mul_overflow_tag
ruby3_size_mul_overflow(size_t x, size_t y)
{
struct ruby3_size_mul_overflow_tag ret = { false, 0, };
-#if RUBY3_HAS_BUILTIN(__builtin_mul_overflow)
+#if RBIMPL_HAS_BUILTIN(__builtin_mul_overflow)
ret.left = __builtin_mul_overflow(x, y, &ret.right);
#elif defined(DSIZE_T)
@@ -225,13 +225,13 @@ ruby3_size_mul_overflow(size_t x, size_t y)
RB_GNUC_EXTENSION DSIZE_T dy = y;
RB_GNUC_EXTENSION DSIZE_T dz = dx * dy;
ret.left = dz > SIZE_MAX;
- ret.right = RUBY3_CAST((size_t)dz);
+ ret.right = RBIMPL_CAST((size_t)dz);
#elif defined(_MSC_VER) && defined(_WIN64)
unsigned __int64 dp = 0;
unsigned __int64 dz = _umul128(x, y, &dp);
- ret.left = RUBY3_CAST((bool)dp);
- ret.right = RUBY3_CAST((size_t)dz);
+ ret.left = RBIMPL_CAST((bool)dp);
+ ret.right = RBIMPL_CAST((size_t)dz);
#else
/* https://wiki.sei.cmu.edu/confluence/display/c/INT30-C.+Ensure+that+unsigned+integer+operations+do+not+wrap */
@@ -253,7 +253,7 @@ ruby3_size_mul_or_raise(size_t x, size_t y)
}
else {
ruby_malloc_size_overflow(x, y);
- RUBY3_UNREACHABLE_RETURN(0);
+ RBIMPL_UNREACHABLE_RETURN(0);
}
}
@@ -264,9 +264,9 @@ rb_alloc_tmp_buffer2(volatile VALUE *store, long count, size_t elsize)
store, ruby3_size_mul_or_raise(count, elsize), count);
}
-RUBY3_ATTR_NOALIAS()
-RUBY3_ATTR_NONNULL((1))
-RUBY3_ATTR_RETURNS_NONNULL()
+RBIMPL_ATTR_NOALIAS()
+RBIMPL_ATTR_NONNULL((1))
+RBIMPL_ATTR_RETURNS_NONNULL()
/* At least since 2004, glibc's <string.h> annotates memcpy to be
* __attribute__((__nonnull__(1, 2))). However it is safe to pass NULL to the
* source pointer, if n is 0. Let's wrap memcpy. */
@@ -283,4 +283,4 @@ ruby_nonempty_memcpy(void *dest, const void *src, size_t n)
#undef memcpy
#define memcpy ruby_nonempty_memcpy
-#endif /* RUBY3_MEMORY_H */
+#endif /* RBIMPL_MEMORY_H */