(folly) QueuedImmediateExecutor

Summary: Add the `QueuedImmediateExecutor` which behaves like `InlineExecutor` but with different (and usually better) ordering semantics for nested calls.
@override-unit-failures

Test Plan: unit tests

Reviewed By: davejwatson@fb.com

Subscribers: folly@lists, net-systems@, fugalh, exa

FB internal diff: D1364904

Tasks: 3789661
Fix bizarre optimization

Summary:
I have no idea why the compiler is gettings its britches in a bunch because a unit test has a predictable output. Really, gcc?!

But whatever, avoiding inlining by putting it in the cpp file solves it.

Test Plan: fbmake runtests_opt

Reviewed By: davejwatson@fb.com

Subscribers: net-systems@, fugalh, exa

FB internal diff: D1405811

Tasks: 4591823
nuke executeWith

Summary: Removing this crufty API. The only callsite for `executeWith` was `Later::via` so I just folded it in there.

Test Plan:
unit tests
contbuild

Reviewed By: hannesr@fb.com

Subscribers: net-systems@, fugalh, exa

FB internal diff: D1406592

Tasks: 4480567
(wangle) s/continuation/callback

Summary: The word "continuation" is too ambiguous. Prefer callback (except where we are actually talking about CSP continuations in the README).

Test Plan: Still builds. Nothing external is or should be calling `setContinuation`. But I'll wait for contbuild anyway.

Reviewed By: hannesr@fb.com

Subscribers: net-systems@, fugalh, exa

FB internal diff: D1406753

Tasks: 4480567
(wangle) noexcept move constructor

Summary: to make lint happy

Test Plan: builds

Reviewed By: hannesr@fb.com

Subscribers: net-systems@, fugalh, exa

FB internal diff: D1406766

Tasks: 4480567
Fix use-after-free in futexWaitUntilImpl

Summary: Handle wake-ups correctly in futexWaitUntilImpl.

Test Plan:
-- ran all folly unit tests
-- ran TimeoutWorkQueue test under tao/queues

Reviewed By: ngbronson@fb.com, meyering@fb.com

FB internal diff: D1406845

Tasks: 4494871
folly: futexWaitUntilImpl: avoid abort triggered via tao/queues tests

Summary:
* folly/test/DeterministicSchedule.cpp (folly): Tao/queues tests exposed
an unhandled case in this code: when (futex->data == expected) happens,
we would call futexErrnoToFutexResult with a futexErrno value of 0,
which would cause an abort (unhandled valued in switch).
Here's a stack trace from the abort: https://phabricator.fb.com/P12558008
showing the invalid futexErrno value in frame #4.

Test Plan:
fbconfig -r --platform-all=gcc-4.8.1-glibc-2.17 --sanitize=address tao/queues:TimeoutWorkQueueTests
_bin/tao/queues/WorkQueueTests -fbunit_test_regexp '^mt\_stress\_deterministic$'

Reviewed By: mssarang@fb.com

FB internal diff: D1404572

Tasks: 4494871
(wangle) Return a Later from Future::via

Summary: Stroke of brilliance, Hannes.

Test Plan:
unit tests, including a new one
Looked through `fbgs 'via('` and all the extant `via`s are attached to `Later`s already so it shouldn't break anything. But check contbuild before commit.

Reviewed By: hannesr@fb.com

Subscribers: net-systems@, fugalh, exa

FB internal diff: D1406976

Tasks: 4480567
Fix folly on OSX and BSD in prep for FastCGI on HHVM

Summary:
A recent change in folly/MemoryMapping.cpp uses MAP_ANONYMOUS, which is
named MAP_ANON on OSX/BSD.

We need folly and third-party changes in order to land a pull request for HHVM
that starts to get FastCGI running on OSX.

See the checklist of the HHVM pull request here: https://github.com/facebook/hhvm/pull/2944#issuecomment-47281003

Closes #67

GitHub Author: Daniel Sloof <goapsychadelic@gmail.com>

@override-unit-failures

Test Plan: fbmake runtests 100%

Reviewed By: pt@fb.com, njormrod@fb.com

FB internal diff: D1407393
Be explicit about what we're passing to Endian::big

Summary:
This prevents a linker error on OSX:
```
Undefined symbols for architecture x86_64:
"folly::detail::EndianIntBase::swap(unsigned long)",
referenced from:
__GLOBAL__sub_I_MacAddress.cpp in libfolly.a(MacAddress.cpp.o)
ld: symbol(s) not found for architecture x86_64
```

We need folly and third-party changes in order to land a pull request for HHVM
that starts to get FastCGI running on OSX.

See the checklist of the HHVM pull request here: https://github.com/facebook/hhvm/pull/2944#issuecomment-47281003

Closes #68

GitHub Author: Daniel Sloof <goapsychadelic@gmail.com>

@override-unit-failures

Test Plan: fbmake runtests 100%

Reviewed By: pt@fb.com, njormrod@fb.com

FB internal diff: D1407426
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
Add packaging/, that allows for a folly SRPM to be created

The SRPM can be built, as long as the double-converion-devel RPM is
installed. The change include a spec file for the SRPM, and a bash
script that can run on a Fedora-system to generate the srpm in
a user-provided directory.

For example:

    ./packaging/build-srpm -o .

Will generate an SRPM in the local directory, for example:

    folly-2014.01.17.092909.gitfc78584-1.fc19.src.rpm
Depend on a system-provided google-gtest library