ruby-changes:72449
From: =E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3 <ko1@a...>
Date: Thu, 7 Jul 2022 22:11:11 +0900 (JST)
Subject: [ruby-changes:72449] 7f64989e5c (master): do not define our own version of memcpy
https://git.ruby-lang.org/ruby.git/commit/?id=7f64989e5c From 7f64989e5c913ef7624e084badd1a43ce65b3ccc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3?= <shyouhei@r...> Date: Wed, 6 Jul 2022 09:18:28 +0900 Subject: do not define our own version of memcpy The (sole) use of memcpy in our public header is now replaced to directly call ruby_nonempty_memcpy, and the previous definition of memcpy is now internal-only. [Bug#18893] --- include/ruby/internal/memory.h | 6 +----- internal.h | 3 +++ 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/include/ruby/internal/memory.h b/include/ruby/internal/memory.h index aa3464465d..0f59262a91 100644 --- a/include/ruby/internal/memory.h +++ b/include/ruby/internal/memory.h @@ -363,7 +363,7 @@ typedef uint128_t DSIZE_T; https://github.com/ruby/ruby/blob/trunk/include/ruby/internal/memory.h#L363 * @return `p1`. * @post First `n` elements of `p2` are copied into `p1`. */ -#define MEMCPY(p1,p2,type,n) memcpy((p1), (p2), rbimpl_size_mul_or_raise(sizeof(type), (n))) +#define MEMCPY(p1,p2,type,n) ruby_nonempty_memcpy((p1), (p2), rbimpl_size_mul_or_raise(sizeof(type), (n))) /** * Handy macro to call memmove. @@ -644,7 +644,6 @@ rb_alloc_tmp_buffer2(volatile VALUE *store, long count, size_t elsize) https://github.com/ruby/ruby/blob/trunk/include/ruby/internal/memory.h#L644 return rb_alloc_tmp_buffer_with_count(store, total_size, cnt); } -#if ! defined(__MINGW32__) && ! defined(__DOXYGEN__) RBIMPL_SYMBOL_EXPORT_BEGIN() RBIMPL_ATTR_NOALIAS() RBIMPL_ATTR_NONNULL((1)) @@ -663,8 +662,5 @@ ruby_nonempty_memcpy(void *dest, const void *src, size_t n) https://github.com/ruby/ruby/blob/trunk/include/ruby/internal/memory.h#L662 } } RBIMPL_SYMBOL_EXPORT_END() -#undef memcpy -#define memcpy ruby_nonempty_memcpy -#endif #endif /* RBIMPL_MEMORY_H */ diff --git a/internal.h b/internal.h index 00a8295295..236d68524c 100644 --- a/internal.h +++ b/internal.h @@ -106,4 +106,7 @@ RUBY_SYMBOL_EXPORT_END https://github.com/ruby/ruby/blob/trunk/internal.h#L106 #define RBOOL(v) ((v) ? Qtrue : Qfalse) #define RB_BIGNUM_TYPE_P(x) RB_TYPE_P((x), T_BIGNUM) +#ifndef __MINGW32__ +#define memcpy ruby_nonempty_memcpy +#endif #endif /* RUBY_INTERNAL_H */ -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/