Calling memcpy() inside handle_signal() breaks TSan since the memcpy()
call is intercepted by TSan. If this happens while another interceptor
is being handled, the TSan runtime crashes. Avoid this by using a local
memcpy() implementation that cannot be intercepted.
This also adds a local memset() implementation since otherwise TSan
reports lots of false-positive races when multiple threads use thr_calloc
(due to memset accessing the same data without a lock visible to TSan).
Supersedes https://reviews.freebsd.org/D28531
Depends on D29536 (-Werror fixes)
Depends on D29535 (-Werror fixes)