Fix freebsd build
fix build with thread_local
fix compile with future
Global thread support vars
Merge remote-tracking branch 'upstream/master' into octree
Small changes from future
Merge remote-tracking branch 'upstream/master' into octree