Added SCOPE_FAIL and SCOPE_SUCCESS macros in non-portable C++.

Summary:
Added SCOPE_FAIL and SCOPE_SUCCESS macros in non-portable C++. The macros are similar to D's scope(failure) and scope(success).
Currently the supported platforms are GCC and MSVC. For all others, std::uncaught_exception() is used, which will fail if the macros are used in a destructor called during stack unwinding.
@override-unit-failures

Test Plan:
1. Added new unit test to ScopeGuardTest.cpp.
2. Ran fbconfig -r folly && fbmake dbg
3. Ran _build/dbg/folly/test/scope_guard_test to make sure my unit test was running and passing.

Reviewed By: andrei.alexandrescu@fb.com

FB internal diff: D1033621
Move byLine to FileGen.h, add explanatory note

Summary: There's a bit of a gotcha here, let's provide at least a note on this.

Test Plan: Unit tests

Reviewed By: tudorb@fb.com

FB internal diff: D1058244
Fix bad implementation of fnv32

Summary: See https://www.facebook.com/groups/fbcode/permalink/601496126553897/

Test Plan: contbuild

Reviewed By: ldbrandy@fb.com

FB internal diff: D1055852

@override-unit-failures
some hphp_dbg tests postponed for 1.5 days, all other hphp tests
(including some hphp_dbg ones) are passing
Improve CompressionTest

Summary: Test compressing low-entropy (constant) data as well.

Test Plan: ran it

Reviewed By: tuomas.pelkonen@fb.com

FB internal diff: D1061444

@override-unit-failures
Add generated files to Makefile.am

Summary: Missed these on the first pass because they're generated

Test Plan: Built open source folly, links

Reviewed By: pgriess@fb.com

FB internal diff: D1062451
Port TimeseriesHistogram from common/stats to folly

Summary:
Port TimeseriesHistogram from common/stats to folly. Similarly to
MultiLevelTimeSeries and Histogram classes we've converted before.

Test Plan:
Ported the old unittest for TimeseriesHistogram from common/stats to
folly/test. The same unittest is left in tact and is still passing as well. Ran
all tests in folly/test and common/stats

Reviewed By: simpkins@fb.com

FB internal diff: D1054291
fix broken clang build: add missing template keyword

Summary: Broken in D1054291

Test Plan: build adpublisher in clang mode which was one of the two projects that failed to build.

Reviewed By: bmaurer@fb.com

FB internal diff: D1067652

@override-unit-failures
Avoid copy in folly::toJson

Summary: Adding const avoids a copy constuctor.

Test Plan:
Unit tests, new benchmark:
toJson        1.83us  546.15K
toJson        1.54us  649.98K

Reviewed By: tudorb@fb.com

FB internal diff: D1071781
Handle lack of <bits/c++config.h> and <bits/functexcept.h>

Summary:
- Clang's libc++ doesn't provide these header files. Detect libc++ via
the _LIBCPP_VERSION symbol (pulling it in by sourcing some header
files earlier if necessary) and avoid using these files.

Test Plan:
- fbconfig -r folly && fbmake runtests
- ./configure && make check on Ubuntu/FC/Mac

Reviewed By: andrewjcg@fb.com

FB internal diff: D998595
Handle lack of weak symbols on some platforms

Summary:
- It turns out that it's not always desirable to perform runtime
resolution of weak symbols. For example, on iOS, weak symbols are
resolved at runtime only if *all* symbol resolution is deferred util
then, which is undesirable for othe reasons. Detect such platforms at
configure time and use that information to populate detail/Malloc.h
with the correct declarations: weak symbols or extern symbols with
a value of nullptr.

Test Plan:
- fbconfig -r folly && fbmake runtests
- ./configure && make check on Ubuntu/FC/Mac

Reviewed By: andrei.alexandrescu@fb.com

FB internal diff: D1002959
Handle platforms that don't support __thread.

Summary:
- Apple platforms either have different __thread behavior than Linux: on
i386 __thread values are zeroed out before the destructor provided to
pthread_key_create(3) is called; on ARM, __thread isn't supported at
all. To handle this, use pthread_getspecific(3) to manage the array of
IDs on these platforms only.

Test Plan:
- fbconfig -r folly && fbmake runtests
- ./configure && make check on Ubuntu/FC/Mac

Reviewed By: simpkins@fb.com

FB internal diff: D1008923
Fix broken clause11_21_4_6_6 test in Apple Clang.

Summary:
- Prior to this fix, the test relied upon begin() being evaluated after
the fbstring constructor (even thoug the order of evaluation of
function arguments is un-defined). When this assumption was violated,
begin() ended up with an iterator that was invalid since it points to
data internal to fbstring, and the fbstring copy constructor can end
up triggering re-allocation in the source.

Test Plan:
- fbconfig -r folly && fbmake runtests
- ./configure && make check on Ubuntu/FC/Mac

Reviewed By: andrei.alexandrescu@fb.com

FB internal diff: D1014093
Remove generated .cpp files on 'make clean'

Summary:
- Add generated .cpp files to CLEANFILES so that they get swept up
during 'make clean' and friends

Test Plan: - autoreconf -i && ./configure && make check && make clean

Reviewed By: davejwatson@fb.com

FB internal diff: D1066270
Revert D998590

Summary:
- It looks like Xcode 5.0.2 / clang 500.2.79 changed this behavior. The
prior behavior was seen against Xcode 5.0.1 / clang 500.2.75. Blerg.
If we really have to support different Xcode flavors we can come up
with a real solution for this, but for now just take advantage of the
fact that clang and gcc seem to agree on this.

Test Plan: - make check on Mac OS X

Reviewed By: andrei.alexandrescu@fb.com

FB internal diff: D1066272

Blame Revision: D998590
Get Subprocess running for Mac OS X

Summary:
- D1030008 added Subprocess to libfolly in automake builds. This
surfaced some ambient compilation errors that slipped through in my
prior run through porting this.
- Mac OS X uses a nonstandard location for wait.h
- Non-Linux platforms don't support prctl; gate that on Linux

Test Plan:
- fbmake runtests in fbcode
- make check on Mac OS X

Reviewed By: davejwatson@fb.com

FB internal diff: D1066273

Blame Revision: D1030008