Harden usingJEMalloc()

Summary:
In a shared library, we're using whichever memory allocator the main program
uses, but we may still believe we're using jemalloc if we load libjemalloc.so
(because rallocm is defined). This means we'll pass to rallocm pointers that
were not allocated by jemalloc, which is bad.

Test Plan: tests added

Reviewed By: ngbronson@fb.com

FB internal diff: D1228483
(Wangle) Fix tests for clang

Summary: `std::async` doesn't play nicely with our clang. Replace it with `std::thread`.

Test Plan: `fbconfig --clang folly/wangle && fbmake runtests`

Reviewed By: marccelani@fb.com

FB internal diff: D1230197
Performance Improvement for AsciiCaseInsensitive

Summary:
This implementation improves the performance of AsciiCaseInsensitive.
AsciiCaseInsensitive uses toupper, and it's slow.
Since toupper only works for ascii characters and this function does exactly the same thing over the range of [0..256), we can gain 3x performance here.

Test Plan: unit test and benchmark

Reviewed By: lucian@fb.com

FB internal diff: D1217596

@override-unit-failures
EventBase cleanup

Summary: Moar c++11 features.  marccelani's comments in D1195393, but in a separate diff.

Test Plan:
contbuild
fbconfig thrift/lib/cpp/test/
fbmake runtests

Reviewed By: rajat@fb.com

FB internal diff: D1219158
(Wangle) Sanity check for the small_vector test

Summary:
Let's double check that `small_vector` is doing the right thing. So
it doesn't just accidentally work.

Test Plan:
`fbconfig folly/wangle && fbmake runtests`
`fbconfig --clang folly/wangle && fbmake runtests`

Reviewed By: marccelani@fb.com

FB internal diff: D1231360
Optionally specify page size in MemoryMapping ctor

Summary:
For proper rounding, and also so memOpInChunks doesn't try to mlock / munlock /
madvise / munmap in chunks smaller than the page size.

Test Plan: memory_mapping_test

Reviewed By: lucian@fb.com

FB internal diff: D1232153
Range::contains(x)

Test Plan: Unit tests

Reviewed By: marcelo.juchem@fb.com

FB internal diff: D1236630
NULL -> nullptr

Summary:
Change NULLs to nullptrs.

Facebook:
I was tired of seeing lint errors for NULL -> nullptr, so I
fixed it.

How: modified flint's tokenizer to output lines of the form

sed -i '__LINE__s|\<NULL\>|nullptr|g' __FILE__

for each NULL token encountered.

Ran the sed lines, restricted to filepaths with extensions
h,hpp,cc,cpp,tcc. Did not apply to FacebookUpdate, due to weird
formatting; hphp, to be done in a separate diff; payment, due to a large
number of generated text which didn't play well with my flow; and
memcache, which has lots of .h's that cannot contain nullptr's because
they are included from .c's.

@bypass-lint

Test Plan:
fbconfig -r common folly && fbmake opt && fbmake runtests_opt
^ of the 4k+ test cases, about two dozen are failing. Slightly more
failed in master than with my diff applied.

arc unit

Reviewed By: andrei.alexandrescu@fb.com

FB internal diff: D1234261
(Folly/FBString) Use a lambda to throw an exception for NULL input

Summary:
This should be standard compliant. `__PRETTY_FUNCTION__` seems
unnecessary, it just prints `basic_fbstring`, might as well use that and
simplify the code.

Test Plan:
`fbconfig --platform-all=gcc-4.8.1-glibc-2.17-fb folly/test`
`fbmake runtests_dbg`
`fbmake runtests_opt`

`fbconfig --platform-all=gcc-4.7.1-glibc-2.14.1 folly/test`
`fbmake runtests_dbg`
`fbmake runtests_opt`

`fbconfig --clang folly/test`
`...`

Reviewed By: andrei.alexandrescu@fb.com

FB internal diff: D1243670
cmake deps for finding libraries

current smake deps are boost (included), double-conversion, gflags,
glob, and pthreads
initial cmake file

deps are done and work well - moving stuff from config.ac into
cmake file for platform checks, then need to move testing stuff into
cmake - might move the testing stuff to subfiles
cmake build system working

Although the build system is not entirely complete (file generation and
test building and running is not finished yet, nor is more than a stock
folly build) this should be "good enough" to get a working makefile and
config for folly
Additional cmake features

Added noexcept to c++11 checks

added additional deps needed for IO portions of library (that apparently
don't build with the automake system)

organized libraries to be built and listed source files for each
properly
generation of files can now be forces

Commit generated files, these don't change much and not every windows
box wants to install python to create these
Additional adjustments to cmake

Prefix some items with FOLLY_ and add some c++11 workaround capabilities
some prefixed include define blocks

for byteswap and c++config.h
noexcept def support

also make sure crazy windows.h does not overwrite min/max with a macro
Rearranging and adding win32 include dir

include win32 dir for includes which will have windows specific
posix wrappers, and move compiler options flag to compiler.cmake
fix win32 include path
Fix constexpr definition

also add generated fingerprinttables file