fix AsyncIO::doWait

Summary:
As it turns out, `io_getevents` may actually return less than
`min_nr` events.  According to the aio logic
(https://github.com/torvalds/linux/blob/10b5b5361a3c2a7fff9dbfa0f127adc2531e7732/fs/aio.c#L1634),
there may be a couple of rounds required to get at least `nr_min` events, and
if interrupted after the first one, incomplete results would be returned

Test Plan:
fbconfig -r folly/experimental/io/test && fbmake runtests_opt -32

and was no longer able to repro #4609062

Reviewed By: soren@fb.com

FB internal diff: D1410389

Tasks: 4609062
Codemod: use #include angle brackets in folly and thrift

Summary: Also changed the thrift compilers to emit code with <...>.

Test Plan: fbconfig -r folly thrift && fbmake opt && fbmake runtests_opt

Reviewed By: davejwatson@fb.com

Subscribers: ruibalp, nli, shilin, tjackson, fugalh, alandau, bmatheny, njormrod

FB internal diff: D1411225
Simplify include path, make sure .. is in it

Summary: so #include <folly/File.h> works

Test Plan: built OSS folly, make check, built tiny program out of tree

Reviewed By: davejwatson@fb.com

FB internal diff: D1412123
update make check targets

Summary:
Update targets so that gtest isn't required unless you run 'make check'.

Simply make everything that uses gtest a 'check_PROGRAM' instead of a 'noinst_PROGRAM'

Test Plan: build folly with 'make -j32', gtest isn't required.

Reviewed By: andrewjcg@fb.com

Subscribers: pavlo, doug

FB internal diff: D1408288
Add Random-inl.h to Makefile.am

Test Plan: OSS

Reviewed By: lesha@fb.com

FB internal diff: D1415190

@override-unit-failures
Fix string split when last part is shorter than delimiter

Summary: The bug is when ignoreEmpty is true, we use the wrong token size, which will be 0 when last token is shorter than delimiter.

Test Plan:
1. Add unit test
2. fbconfig -r folly && fbmake runtests

Reviewed By: philipp@fb.com

Subscribers: maxime, xiaol

FB internal diff: D1415803
(wangle) s/FutureObject/detail::State/

Summary:
codemod
I never was satisfied with this name. `State` feels a little better. More descriptive. But still pretty generic, so I'm open to alternative ideas.

Test Plan: It still builds and tests pass.

Reviewed By: hannesr@fb.com

Subscribers: jsedgwick, net-systems@, fugalh, exa

FB internal diff: D1411506
(wangle) s/continuation_/callback/ (missed some)

Summary: In the spirit of D1406753

Test Plan: still builds and tests pass

Reviewed By: hannesr@fb.com

Subscribers: jsedgwick, net-systems@, fugalh, exa

FB internal diff: D1412002
s/setCallback_/setCallback/ for detail::State

Summary: This isn't really an internal-to-this-class method. :-/

Test Plan: builds

Reviewed By: hannesr@fb.com

Subscribers: jsedgwick, net-systems@, fugalh, exa

FB internal diff: D1412008
folly: StringPiece: add skipWhitespace

Test Plan: copied from folly::json

Reviewed By: philipp@fb.com, soren@fb.com

FB internal diff: D1417992

Tasks: 4527315
(Folly/FBString) Enum class for category

Summary: Suggested by @aalexandre.

Test Plan: Compile.

Reviewed By: andrei.alexandrescu@fb.com

Subscribers: folly@lists, njormrod, aalexandre

FB internal diff: D1246180
(wangle) Future/Promise detachment

Summary:
Bring a bit more sanity to the lifetime. Now Future and Promise detach by calling the respective methods on State, and they do it during their destruction only. State manages its own lifetime.

Besides being cleaner, this also sets the stage for cancellation (where we'll need Future to hang on to its reference to State after setting the callback), and for folding in Later (we will have a bool for whether the future is hot and hold off executing the callback if it isn't).

Also cleans up various things I noticed while auditing the code for usages of `state_`.

Test Plan:
All the unit tests still pass.
Ran with ASAN (and found I had introduced a bug, then fixed it. yay)

Reviewed By: hannesr@fb.com

Subscribers: jsedgwick, net-systems@, fugalh, exa

FB internal diff: D1412038

Tasks: 4618297
(wangle) cold via

Summary:
Instead of returning a Later, `via` returns a cold future.
This works without keeping a backreference like Later does, because an inactive Future will always activate on destruction. Alternatively we could have an extra Promise, a la Later, and pass that along like Later does, and require launch() at the end (though, implicit launching on destruction would be an option there too).

If you think this approach is viable I'll clean it up on Wednesday: make sure all the calling sites work, etc.

Test Plan:
new unit test
This may fail in contbuild, I haven't done the codemod for calling sites, if there are any.

Reviewed By: hannesr@fb.com

Subscribers: jsedgwick, net-systems@, fugalh, exa

FB internal diff: D1412499

Tasks: 4480567
gflags now likes namespace gflags, not google

Summary:
Use namespace gflags going forward, import namespace google into it if
backward.

Also added a few "checking for..." messages in autoconf.

Test Plan: fbconfig -r folly && fbmake runtests_opt, OSS build

Reviewed By: meyering@fb.com

Subscribers: fjargsto, ntv, jhj, lesha, kma, davejwatson

FB internal diff: D1420575
fix Makefile.am

Summary: wangle/detail.h -> wangle/detail/State.h

Test Plan: OSS build

Reviewed By: meyering@fb.com

Subscribers: fugalh, lesha

FB internal diff: D1421490
(wangle) fix shadow

Summary: Not sure why this shadow error didn't turn up in my tests, but whatevs

Test Plan: traffic manager builds without warning-errors

Reviewed By: suhas@fb.com

Subscribers: hannesr, net-systems@, fugalh, exa

FB internal diff: D1421495

Tasks: 4653938
Move the branchless, parallel ASCII toLower into folly

Summary:
* Moved the fast toLower code into folly
* Updated the name to emphasize that it's ASCII-only

Test Plan: * Unit tests and benchmarks included.

Reviewed By: tudorb@fb.com

Subscribers: ruibalp, bmatheny

FB internal diff: D1421056
stride()

Summary: thatwaseasy

Test Plan: iloveunittests

Reviewed By: lucian@fb.com

Subscribers: philipp

FB internal diff: D1419848

Tasks: 4636617
Use pipe2 in Subprocess; platform-specific config

Summary:
We've wanted to use pipe2 in Subprocess for a while, but that's not supported
on glibc 2.5.1. This is not a problem in OSS (autoconf can solve this),
but, internally, we don't run autoconf; add an internal platform include file
with such per-platform differences.

Test Plan: fbconfig -r folly && fbmake runtests_opt

Reviewed By: meyering@fb.com

Subscribers: jhj, lesha, kma, agallagher

FB internal diff: D1422128
Fix libc++ build errors

Summary:
Reported externally:

https://github.com/facebook/folly/issues/70
https://github.com/facebook/folly/issues/71
https://github.com/facebook/folly/issues/72
https://github.com/facebook/folly/issues/73

Note that I can't test on libc++ myself, but the reports suggested fixes which
sounded good.

Test Plan: fbconfig -r folly && fbmake runtests_opt

Reviewed By: marcelo.juchem@fb.com

Subscribers: jhj, ntv, lesha, kma, fugalh, jdelong

FB internal diff: D1421029