fix pthread inclusion for emscripten, made to work better for other targets