Code extracted from: https://github.com/libuv/libuv.git at commit dc596109d5a22db1dbf57098630eebd30fce8068 (v1.x).