Use ioctl to implement tcdrain on Android
Don't attempt to call *grent functions on Android
Move Threads package search into ConfigureChecks

It was called far too late in the process resulting in unexpected build
failures.
Fix build failures on Linux caused by 9943a9e309d7282bcddbcfa16381a70cbf3183f3