Move Ruby-related checks from autoconf to extconf.rb; add extra check for rb_alloc_func_t

Ruby ships its own config.h which may or may not define the same
relevant constants as our autoconf-generated config.h. Instead of
trying to specify the exact path to the wanted header file we may just
as well simply use Ruby's autoconf-inspired checks and macros.