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

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]
This commit is contained in:
卜部昌平 2022-07-06 09:18:28 +09:00
parent 8794cc6289
commit 7f64989e5c
Notes: git 2022-07-07 22:11:16 +09:00
2 changed files with 4 additions and 5 deletions

View file

@ -363,7 +363,7 @@ typedef uint128_t DSIZE_T;
* @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)
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)
}
}
RBIMPL_SYMBOL_EXPORT_END()
#undef memcpy
#define memcpy ruby_nonempty_memcpy
#endif
#endif /* RBIMPL_MEMORY_H */

View file

@ -106,4 +106,7 @@ RUBY_SYMBOL_EXPORT_END
#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 */