move these functions to the appropriate place

and include the necessary header
use proper declarations for zend_stat_t
better description for the toolset config option
update UPGRADING.INTERNALS