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