auto merge of #13315 : alexcrichton/rust/libc, r=alexcrichton,me
auto merge of #13315 : alexcrichton/rust/libc, r=alexcrichton,me

Rebasing of #12526 with a very obscure bug fixed on windows.

bluss/rand,arthurprs/rand,waynenilsen/rand,huonw/rand,GrahamDennis/rand,shepmaster/rand,achanda/rand,ebfull/rand,bhickey/rand,retep998/rand