Bi Xue [Thu, 29 Dec 2016 06:18:32 +0000 (22:18 -0800)]
Make FunctionRef support bool operator
Summary:
To support following code:
```
void foo(folly::FunctionRef<void(void)> callback = {}) {
if (callback) {
callback();
}
}
```
Reviewed By: yfeldblum
Differential Revision:
D4372296
fbshipit-source-id:
7d21e6a44b6f6b046b424f0139465511dbae7b8b
Giuseppe Ottaviano [Thu, 29 Dec 2016 04:18:43 +0000 (20:18 -0800)]
Avoid shadowing warnings in SYNCHRONIZED
Summary: If two `SYNCHRONIZED` blocks are nested the internal `SYNCHRONIZED_*` variables can be compatible shadows (`SYNCHRONIZED_state` always is), so GCC will issue a warning with `-Wshadow-compatible-local`. This diff disambiguates the variable names for each `SYNCHRONIZED` block (as long as they appear on different lines).
Reviewed By: yfeldblum, philippv
Differential Revision:
D4371263
fbshipit-source-id:
b467a1a2651667c679382a1cc1eaa28f7ee4e6b3
Anirudh Ramachandran [Thu, 29 Dec 2016 02:54:04 +0000 (18:54 -0800)]
Add OpenSSL portability layer
Summary:
Enable folly to build with OpenSSL alternatives (e.g., BoringSSL).
Some SSL-related tests are disabled:
- Async session cache ones (BoringSSL has an async cache impl but with a different API)
- TFO tests
- Some changes to error tests which expect specific error strings. This is
flaky as a test because it will break everytime even within a version, so we
should fix that first.
This should be a noop for OpenSSL 1.0.2.
BoringSSL commit used is
35c8afd3143289c99aa3820e01950c564d7aced8 (10/26/2016)
Closes: https://github.com/facebook/folly/issues/198
Reviewed By: siyengar
Differential Revision:
D3280382
fbshipit-source-id:
4141d992e0d8dd797ac4af479cfe90844a23278f
Yedidya Feldblum [Thu, 29 Dec 2016 02:03:39 +0000 (18:03 -0800)]
folly::copy
Summary:
[Folly] `folly::copy`.
Usable when you have a function with two overloads:
class MyData;
void something(MyData&&);
void something(const MyData&);
Where the purpose is to make copies and moves explicit without having to spell out the full type names - in this case, for copies, to invoke copy constructors.
When the caller wants to pass a copy of an lvalue, the caller may:
void foo() {
MyData data;
something(folly::copy(data)); // explicit copy
something(std::move(data)); // explicit move
something(data); // const& - neither move nor copy
}
Reviewed By: markisaa, ericniebler
Differential Revision:
D3462023
fbshipit-source-id:
6c777be288f2a7012c1b4b46dc988890b8662595
Philip Pronin [Thu, 29 Dec 2016 00:28:30 +0000 (16:28 -0800)]
nuke UNSYNCHRONIZED
Summary:
API of `UNSYNCHRONIZED` is confusing as if you have two nested
`SYNCHRONIZED` blocks, `UNSYNCHRONIZED` always unlocks the inner-most,
even if you pass in the variable name used in the outer `SYNCHRONIZED`
block.
The macro was marked as "deprecated" in
D3526489, remove it here.
Reviewed By: yfeldblum
Differential Revision:
D4371297
fbshipit-source-id:
13ddc1ff77cb3d5045844c5ade0e95dbe2bccf6d
Yedidya Feldblum [Wed, 28 Dec 2016 17:57:15 +0000 (09:57 -0800)]
A smaller implementation of try_and_catch
Summary:
[Folly] A smaller implementation of `try_and_catch`.
No longer done as a derived class. This lets us make the protected members of `exception_wrapper` into private members.
Reviewed By: ericniebler
Differential Revision:
D4366065
fbshipit-source-id:
ae4763b55e431ac08260f74f6a23a257581247c9
Adrian Hamza [Tue, 27 Dec 2016 22:18:20 +0000 (14:18 -0800)]
Make UncaughtExceptionCounter public
Summary: Make UncaughtExceptionCounter public by moving it from folly/detail to folly. I am adding a scope performance counter that works in a similar way to SCOPE_EXIT/SCOPE_ERROR and I need the UncaughtExceptionCounter functionality.
Reviewed By: yfeldblum, ericniebler
Differential Revision:
D4342783
fbshipit-source-id:
a1848e89cbb6340e2ac48adabf7bf76cece1b86d
Eric Niebler [Tue, 27 Dec 2016 18:45:34 +0000 (10:45 -0800)]
Add proper Doxygen comment markings around exception_wrapper example.
Summary: The Doxegen-generated documentation for exception_wrapper is unreadable. The code needs to be denoted with \code...\endcode tags; otherwise, it is formatted like a paragraph and newlines are ignored.
Reviewed By: igorsugak
Differential Revision:
D4367636
fbshipit-source-id:
680bedfb152300d8a6287bf441dd9b81b9b94c80
Christopher Small [Tue, 27 Dec 2016 00:45:14 +0000 (16:45 -0800)]
pass RNG by reference so state is updated on each call
Summary: folly::Random was taking the RNG by value (not reference) so it was not updating the RNG's state on each invocation -- so the RNG would not advance to the next value in the sequence.
Reviewed By: yfeldblum, nbronson
Differential Revision:
D4362999
fbshipit-source-id:
f93fc11911b92e230ac0cc2406151474d15f85af
Sven Over [Sun, 25 Dec 2016 08:40:42 +0000 (00:40 -0800)]
fix include dependencies in folly/stats
Summary:
Histogram-defs.h depends on Histogram.h, so it should include it.
This missing dependency is especially annoying because users who
include both Histogram.h and Histogram-defs.h will find that
clang-format reorders the includes such that Histogram-defs.h will
be included before Histogram.h, which breaks the build.
Same for BucketedTimeSeries-defs.h and TimeseriesHistogram-defs.h.
Reviewed By: pixelb
Differential Revision:
D4366282
fbshipit-source-id:
518ef315154c28beb091e5c097db2bec6eea3ba0
Yedidya Feldblum [Sat, 24 Dec 2016 19:07:39 +0000 (11:07 -0800)]
Fix a wrong filename in a comment in ExceptionWrapper.h
Summary: [Folly] Fix a wrong filename in a comment in `ExceptionWrapper.h`.
Reviewed By: pixelb
Differential Revision:
D4366224
fbshipit-source-id:
cab31dc0a934ae9e9714436e28c8a1a295f7d3de
Christopher Dykes [Fri, 23 Dec 2016 21:09:25 +0000 (13:09 -0800)]
Use std::chrono for timeouts to sslAccept and sslConn in AsyncSSLSocket
Summary: Because `std::chrono` makes it clear exactly what unit of time is in use.
Reviewed By: yfeldblum
Differential Revision:
D4363560
fbshipit-source-id:
47aeef21f842f39d8e886bec441897ecf1f3761b
Jacob Bower [Fri, 23 Dec 2016 08:09:51 +0000 (00:09 -0800)]
Enable making libfollyinit even when libdwarf is not available
Summary:
The hard requirement for libdwarf when building libfollyinit does not appear to be needed.
Without libfollyinit, code with calls to folly::init() won't build. Notably this is breaking build/execution of tests + examples for the Watchman C++ client in Watchman.
Reviewed By: yfeldblum
Differential Revision:
D4361498
fbshipit-source-id:
f3586d8cdca36eda3634663e95a4a61d879de6cf
Yedidya Feldblum [Thu, 22 Dec 2016 20:13:29 +0000 (12:13 -0800)]
Move Thrower into exception_wrapper
Summary:
[Folly] Move `Thrower` into `exception_wrapper`.
It is only used by `exception_wrapper`, so it might as well be a member type.
Also, make it private. That means we need to tweak `try_and_catch`.
Since we are tweaking `try_and_catch`, tweak all similar cases.
Reviewed By: luciang
Differential Revision:
D4361815
fbshipit-source-id:
c5025894465a2c7760bd79dbbd272079fd34dd79
Yedidya Feldblum [Thu, 22 Dec 2016 08:17:20 +0000 (00:17 -0800)]
Move the guts of try_and_catch into a detail namespace
Summary:
[Folly] Move the guts of `try_and_catch` into a `detail` namespace.
Just a bit cleaner this way. Also, now we always slice before returning the derived object, so the derived type never escapes.
Reviewed By: luciang
Differential Revision:
D4361471
fbshipit-source-id:
5c9567d3c5480ee9943a85139b8f27ba3b9da2d6
Jason Leng [Thu, 22 Dec 2016 07:32:08 +0000 (23:32 -0800)]
Update future interrupts example in README
Summary: Updated the future interrupts example to get rid of the shared pointer circular reference problem
Reviewed By: djwatson
Differential Revision:
D4360037
fbshipit-source-id:
cb959929a508df4dcf3b81d01012bc55044a0b17
Jacob Bower [Thu, 22 Dec 2016 06:10:37 +0000 (22:10 -0800)]
Make folly pkg-config more usable on OS X
Summary:
As part of open-sourcing the Watchman C++ client I'm adding an (optional) dependency in Watchman to Folly. When I tried to build this client with Folly on OS X I ran into some problems using the libfolly pkg-config file. This diff addresses these issues:
1. When using `build/bootstrap-osx-homebrew.sh`, the compile config for gflags and OpenSSL are overriden. If present, these custom flags will now be propagated to `libfolly.pc`.
2. I changed the the package requirements in `libfolly.pc` from `Requires.private` to just `Requires`.
Both of these changes are needed as much of Folly's implementation is in header files. As such, consumers of libfolly need to use the same library/include paths when building.
Reviewed By: yfeldblum
Differential Revision:
D4332720
fbshipit-source-id:
6a051ae318ac10bdeb4dc383a16de81f1c0327bb
Yedidya Feldblum [Thu, 22 Dec 2016 04:29:00 +0000 (20:29 -0800)]
to_weak_ptr
Summary:
[Folly] `to_weak_ptr`.
Make a `weak_ptr` and return it from a `shared_ptr` without specifying the template type parameter and letting the compiler deduce it.
So you can write this:
auto wptr = to_weak_ptr(getSomethingShared<T>());
Instead of this:
auto wptr = weak_ptr<T>(getSomethingShared<T>());
Useful when `T` is long, such as:
using T = foobar::FooBarAsyncClient;
Reviewed By: nbronson
Differential Revision:
D4361276
fbshipit-source-id:
782a1d2d57b6e5823cb4018e445110098f1ce41f
Christopher Dykes [Thu, 22 Dec 2016 03:38:12 +0000 (19:38 -0800)]
Support fchmod and include the correct portability headers for FileUtil
Summary: `FileUtil.cpp` uses `fchmod`, which Windows doesn't have, so implement it and also include the correct portability headers for the use of `mkstemp` and now `fchmod` as well.
Reviewed By: yfeldblum
Differential Revision:
D4360650
fbshipit-source-id:
300163689c54574548e7bf274a56264714d216ed
Yedidya Feldblum [Thu, 22 Dec 2016 03:17:55 +0000 (19:17 -0800)]
Add missing includes in folly/experimental/observer
Summary:
[Folly] Add missing includes in `folly/experimental/observer`.
In particular, the missing includes of `folly/ExceptionString.h`.
Motivation.
Reviewed By: andrewjcg, nbronson
Differential Revision:
D4360991
fbshipit-source-id:
4e4407669926b55d6d85df08edea70784a8f348c
Amir Shalem [Thu, 22 Dec 2016 00:47:55 +0000 (16:47 -0800)]
FBString: remove unnecessary 7-byte padding in large strings
Summary:
RefCounted struct contains a pointer to `Char data_[1]`
This saved us a +1 when calculating sizes for the null terminator,
but the compiler made the struct size to be 16, instead of a 8+1.
Reviewed By: Gownta, ot
Differential Revision:
D4356429
fbshipit-source-id:
420694feb4b367b0c73d44f83c21a9559ac5e7a3
Christopher Dykes [Wed, 21 Dec 2016 21:04:24 +0000 (13:04 -0800)]
Fix the return type for sysconf in the unistd portability header
Summary: It was incorrectly typed.
Reviewed By: yfeldblum
Differential Revision:
D4351015
fbshipit-source-id:
b0114d536db66ff4429fa135e9ed7b2051a42d6e
Amir Shalem [Wed, 21 Dec 2016 06:25:34 +0000 (22:25 -0800)]
Fix bug where capacity is not updated correctly after reserveLarge()
Summary:
When reallocating new large string, using reserveLarge(), make sure to update the new capacity for the RefCounted string data
to reflect the amount of data allocated by jemalloc for our block (using goodMallocSize())
Reviewed By: Gownta
Differential Revision:
D4355440
fbshipit-source-id:
f2d58e8888e973418781220d57ff46f674e20556
Eric Niebler [Tue, 20 Dec 2016 22:56:37 +0000 (14:56 -0800)]
use folly::FunctionRef for EventBase::run(ImmediatelyOrRun)?InEventBaseThreadAndWait
Summary: folly::FunctionRef never allocates memory and is cheaper to pass around. Use it in the interface of EventBase where we can.
Reviewed By: yfeldblum
Differential Revision:
D4353992
fbshipit-source-id:
259c5214ed48d30981eb8e38b062aad31d80a080
Michael Lee [Tue, 20 Dec 2016 14:21:48 +0000 (06:21 -0800)]
Fix sysconf return type
Summary: The sysconf return type is supposed to be long, not unsigned.
Reviewed By: Orvid
Differential Revision:
D4350903
fbshipit-source-id:
29d86081bf75d123e76b831a669b0fd3936ce102
Christopher Dykes [Tue, 20 Dec 2016 03:32:26 +0000 (19:32 -0800)]
Enable -Wunreachable-code
Summary:
Because it finds dead code.
This also removes the dead code found.
Reviewed By: yfeldblum
Differential Revision:
D4342893
fbshipit-source-id:
e500734ff5927320b2356106d10016e298d67393
Misty De Meo [Tue, 20 Dec 2016 03:31:52 +0000 (19:31 -0800)]
Fix search name for gflags's .pc file
Summary:
gflags's pkg-config file is installed by default under the name gflags.pc; however, folly has been searching for it under the name libgflags.pc.
Several package managers (Homebrew, apt) install the .pc file under its default upstream name; as such it seems appropriate for folly to look for it under that name, too.
refs Homebrew/homebrew-core#7977.
Closes https://github.com/facebook/folly/pull/531
Reviewed By: yfeldblum
Differential Revision:
D4348089
Pulled By: Orvid
fbshipit-source-id:
6adec290ec88b5d3f66103cf8e5094e99f2512ad
Guobao Sun [Tue, 20 Dec 2016 03:19:45 +0000 (19:19 -0800)]
Fix library name for thread_local_test in open source builds
Summary: Test case ThreadLocal.SharedLibrary is failing due to looking for "thread_local_test_lib.so", while the actual .so generated is "lib_thread_local_test.so". Change Makefile.am to conform it.
Reviewed By: Orvid
Differential Revision:
D4350758
fbshipit-source-id:
9a2a23325059ed71529821620398ffa6ed84f83e
Eric Niebler [Mon, 19 Dec 2016 23:12:31 +0000 (15:12 -0800)]
rename ExpectedStorage::isThis to isSelfAssign so that the self-assign check in operator= works
Summary: This corrects an oversight in folly::Expected where self-assign was not being detected correctly due to a half-applied edit.
Reviewed By: yfeldblum
Differential Revision:
D4348181
fbshipit-source-id:
710b25c4c6d7aeaaea50493ccc5788d875ec4c2e
Jim Meyering [Mon, 19 Dec 2016 17:53:32 +0000 (09:53 -0800)]
folly/fibers/TimedMutex-inl.h: avoid shadowing warnings
Summary:
Fix a warning exposed by gcc's -Wshadow-compatible-local.
Rename inner "lockStolen" to "stolen".
Differential Revision:
D4346385
fbshipit-source-id:
323cb6c96ecfe18b5540525f4124dbd75faf0b1b
Jim Meyering [Mon, 19 Dec 2016 17:30:11 +0000 (09:30 -0800)]
folly/io/async/test/EventBaseTest.cpp: doubly-nested for-loop, do not reuse index
Summary:
Fix a warning exposed by gcc's -Wshadow-compatible-local option.
Rename inner "i" to "j".
Reviewed By: knekritz
Differential Revision:
D4346505
fbshipit-source-id:
f0a4ac32fefd6614900e58d1c8c7f15e8934fd04
Mathieu Baudet [Sun, 18 Dec 2016 02:23:24 +0000 (18:23 -0800)]
fbcode: remove unused includes from .cpp files with no #if and #define
Summary:
This is a first diff to remove the "easiest" unused includes in fbcode.
* For safety, we only touch .cpp files without #if and #define,
* We do not try to remove redundant systems headers (aka. "packing").
The diff was generated as follows:
```
foundation/scripts/ls-cpp-dirs | grep -v '^\(\.\.\|external/\|.*/external\)' | xargs ffmr -o /tmp/ffmr-diff-1 codegraph/scripts/ffmr/analyze_includes_no_headers_no_packing_skipping_ifdefs.sh
cat /tmp/ffmr-diff-1/*.diff | patch -p2
hg commit -m something
arc diff --prepare --nolint --nounit --less-context --excuse refactoring
```
Note: `grep -v` is just an optimization. The actual configuration is in these two files:
diffusion/FBS/browse/master/fbcode/codegraph/analysis/config.py
diffusion/FBS/browse/master/fbcode/codegraph/scripts/ffmr/analyze_includes_no_headers_no_packing_skipping_ifdefs.sh
See the task for more context, and the recent "safety" improvements on the tool.
depends on
D4317825 for very few cases where `nolint` had to be manually added.
Reviewed By: igorsugak
Differential Revision:
D4312617
fbshipit-source-id:
ecc1f0addfd0651fa4770fcc43cd1314661a311a
Yedidya Feldblum [Sat, 17 Dec 2016 08:53:05 +0000 (00:53 -0800)]
Let ScopedEventBaseThread destruct the EventBase in the IO thread
Summary: [Folly] Let `ScopedEventBaseThread` destruct the `EventBase` in the IO thread.
Reviewed By: andriigrynenko
Differential Revision:
D4330951
fbshipit-source-id:
5b0e7071800e1d49048b08aa1233d72b820fe55d
Yedidya Feldblum [Sat, 17 Dec 2016 04:20:35 +0000 (20:20 -0800)]
Split EventBaseThread from ScopedEventBaseThread
Summary:
[Folly] Split `EventBaseThread` from `ScopedEventBaseThread`.
Now `ScopedEventBaseThread` is really scoped and immovable, while `EventBaseThread` is movable and can be started and stopped.
Users which will never move, and will never start or stop, the `ScopedEventBaseThread` can continue using it. Users which need to move, or which need to start and stop, the object will use `EventBaseThread` instead.
Reviewed By: andriigrynenko
Differential Revision:
D4338447
fbshipit-source-id:
57c186630bc199a7a7b7223b1fcb077ce3d86743
Christopher Dykes [Fri, 16 Dec 2016 23:09:24 +0000 (15:09 -0800)]
Fix some implicit truncation and implicit sign coersion warnings in the Windows portability layer
Summary: More progress towards being able to build Folly cleanly with MSVC's truncation and sign coersion warnings enabled.
Reviewed By: yfeldblum
Differential Revision:
D4288060
fbshipit-source-id:
ce42d2099163ed5a9c9a9bb736a80bb2407f7595
Junlin Zhang [Fri, 16 Dec 2016 23:07:47 +0000 (15:07 -0800)]
add cancelFunctionAndWait and cancelAllFunctionsAndWait to FunctionScheduler
Summary: In FunctionScheduler, cancelFunction and cancelAllFunction will not wait for current running function, which will lead to segmentation fault if the function captures resource to be destructed right after calling cancelFunction or cancelAllFunction. This diff introduces cancelFunctionAndWait and cancelAllFunctionsAndWait, making it possible to wait for completion of current running function.
Reviewed By: yfeldblum
Differential Revision:
D4324384
fbshipit-source-id:
ac4b272894f753ef3bb175173f10d1ca20c17c41
Andrii Grynenko [Fri, 16 Dec 2016 21:27:33 +0000 (13:27 -0800)]
Fix TimedMutex deadlock when used both from fiber and main context
Summary: TimedMutex is a fair mutex, which can cause a deadlock if same mutex is requested first in a fiber, and then in main context.
Reviewed By: yfeldblum
Differential Revision:
D4209155
fbshipit-source-id:
0623d9a2e6a0b5cc310fb71ad1b1cf33afd6a30e
Yinghai Lu [Fri, 16 Dec 2016 16:46:45 +0000 (08:46 -0800)]
Add BEXTR instruction support
Summary: BEXTR is an instruction in BMI set, which extract given number of bits from a 64 bit register starting from a given position. The position and size of extracted bits are packed into a one 64bit integer.
Reviewed By: Orvid
Differential Revision:
D4316516
fbshipit-source-id:
3f752388763b0e26c506d7d49cf6c05cf28271c0
Christopher Dykes [Fri, 16 Dec 2016 08:01:29 +0000 (00:01 -0800)]
Revert
D4310312: [Folly] Enable -Wunreachable-code
Summary: This reverts commit
8178dacc9268e1001efc5f803a35ef49e23d692a
Differential Revision:
D4310312
fbshipit-source-id:
7c4b90e834f1a95e51524e1e82ac5294e5ba2dc5
Yedidya Feldblum [Fri, 16 Dec 2016 05:21:21 +0000 (21:21 -0800)]
Always use an EventBaseManager with ScopedEventBaseThread
Summary: [Folly] Always use an `EventBaseManager` with `ScopedEventBaseThread`.
Reviewed By: andriigrynenko
Differential Revision:
D4336412
fbshipit-source-id:
459a679f8fda0db1ca0a9fdca2f852bb00c5231e
Christopher Dykes [Fri, 16 Dec 2016 04:11:07 +0000 (20:11 -0800)]
Enable -Wunreachable-code
Summary:
Because it finds dead code.
This also removes the dead code found.
Reviewed By: yfeldblum
Differential Revision:
D4310312
fbshipit-source-id:
8178dacc9268e1001efc5f803a35ef49e23d692a
Christopher Dykes [Fri, 16 Dec 2016 04:09:21 +0000 (20:09 -0800)]
Allow folly to compile cleanly with most of the rest of MSVC's sign mismatch warnings
Summary:
This allows folly to compile with warnings 4245, 4287 and 4365 enabled, all of which are sign mismatch warnings.
This is labeled as 'mostly' because I'll probably have to clean up a few more of these.
Reviewed By: yfeldblum
Differential Revision:
D4263259
fbshipit-source-id:
0db618f0405817503a63094edd75b24ec1e5c9ad
Christopher Dykes [Fri, 16 Dec 2016 04:09:19 +0000 (20:09 -0800)]
More implicit truncation warning fixes
Summary:
This makes the changes required to compile Folly cleanly with the rest of MSVC's truncation warnings, 4244 & 4267.
Only another 2800 sign mismatch warnings left to go.
Reviewed By: yfeldblum
Differential Revision:
D4257094
fbshipit-source-id:
1651eca875a31f53774d36c682f5e2745ddfcda5
Christopher Dykes [Fri, 16 Dec 2016 03:59:27 +0000 (19:59 -0800)]
Refactor stats to use the same type for indexes
Summary:
This refactors folly/stats/* to use a single type for indexes rather than `size_t`, `int`, `unsigned int`, `uint64_t` and `int64_t` depending on where you looked.
This also has the result of getting MSVC to not complain about implicit sign conversions and implicit truncations.
Reviewed By: simpkins
Differential Revision:
D4282174
fbshipit-source-id:
8529be34dce8ad18bc64395330bbdf2cd7305be4
Christopher Dykes [Fri, 16 Dec 2016 01:31:48 +0000 (17:31 -0800)]
Include <cassert> when using assert
Summary:
We were using `assert` without including anything that defines it.
Closes https://github.com/facebook/folly/issues/530
Reviewed By: yfeldblum
Differential Revision:
D4337047
fbshipit-source-id:
327d19a685e7a4cc1e1eb6e471a6457fe9dee6c7
Yedidya Feldblum [Thu, 15 Dec 2016 09:37:21 +0000 (01:37 -0800)]
Check the baton waits in the ScopedEventBaseThread tests
Summary:
[Folly] Check the baton waits in the `ScopedEventBaseThread` tests.
Also:
* `Baton<T>::timed_wait` can take a `duration`, not just a `time_point`.
* Allow a bit more time for waiting, just in case the machine running the tests is under load.
Reviewed By: andriigrynenko
Differential Revision:
D4330126
fbshipit-source-id:
55878577b1deeb260686647e5f22a81d6fb9e06d
Andrii Grynenko [Thu, 15 Dec 2016 04:06:38 +0000 (20:06 -0800)]
Require runBeforeLoop callbacks to be canceled prior to EventBase destruction
Summary: This makes it similar to other other events registered with EventBase.
Reviewed By: yfeldblum
Differential Revision:
D4331277
fbshipit-source-id:
5d728d4ae5faff1a72ed724b4e2a6c0dd6c3b02d
Wez Furlong [Thu, 15 Dec 2016 04:03:32 +0000 (20:03 -0800)]
add folly::init to libfolly for OSS build
Summary:
We use this in eden and this avoids needing to patch the homebrew recipe.
I've also made the use of the folly symbolizer specific to the facebook
internal build of folly, because it fails to compile in the Linux OSS build
too.
Reviewed By: yfeldblum
Differential Revision:
D4292166
fbshipit-source-id:
b69153be8ab9cc461bc7f456248e73972ba7f461
Andrii Grynenko [Thu, 15 Dec 2016 04:03:18 +0000 (20:03 -0800)]
Make FunctionLoopCallback available outside of EventBase.cpp
Reviewed By: yfeldblum
Differential Revision:
D4331194
fbshipit-source-id:
1e1579e3b775b1b4e329aa28aae11a2b54294697
Andrii Grynenko [Thu, 15 Dec 2016 04:02:46 +0000 (20:02 -0800)]
Make SingletonVault state use ReadPriority mutex
Summary: This fixes a deadlock possible when singleton chain is created concurrently with destroyInstances().
Reviewed By: lbrandy, yfeldblum
Differential Revision:
D4329028
fbshipit-source-id:
a11b3ff42d164ead2f8e3e77e0e17be43a8ad306
Eric Niebler [Wed, 14 Dec 2016 20:21:25 +0000 (12:21 -0800)]
work around GCC#61971 (spurious -Warray-bounds warnings) in folly::FixedString
Summary:
GCC has the temerity to insinuate that my code has out-of-array-bounds access. After cross-checking with clang and ubsan, reviewing the code, and running constexpr tests (for which out-of-range errors are caught at compile time), I can say with pretty high confidence that this is an instance of GCC#61971 (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61971). Basically, the gcc-4 series is known to issue spurious -Warray-bounds warnings. The "fix" is to route internal accesses to some helper functions, for which -Warray-bounds has been suppressed.
User code that accesses elements with operator[] will still warn on out-of-bounds access. If this is a problem in practice, we can suppress the warning there, too. Trying this for now since it is less likely to hide real problems.
Reviewed By: yfeldblum
Differential Revision:
D4317305
fbshipit-source-id:
7bf92f993ac1a29631463c582c1b64d76f755181
Nathan Bronson [Wed, 14 Dec 2016 17:03:02 +0000 (09:03 -0800)]
fix ExceptionTracerTest build
Summary:
A recent diff added [[noreturn]] annotations that cause buck
build to fail for ExceptionTracerTest.cpp, due to our use of -Werror
and -Wunreachable-code-return. This diff removes the unreachable return
statement.
Differential Revision:
D4326888
fbshipit-source-id:
7863c163eedcf2a7e19730c1de194f05c544a2c0
Christopher Dykes [Wed, 14 Dec 2016 06:05:21 +0000 (22:05 -0800)]
Allow building with -Wmissing-noreturn
Summary: If your function doesn't return you should be explicit about it.
Reviewed By: meyering
Differential Revision:
D4309893
fbshipit-source-id:
ce275ec8f42e2cb3253a1e40e263934649f09d9e
Andrii Grynenko [Wed, 14 Dec 2016 01:50:27 +0000 (17:50 -0800)]
Update fibers GDB docs
Reviewed By: yfeldblum
Differential Revision:
D4323918
fbshipit-source-id:
8dcd4ef3629fff061a9f149093ef1fe087f1c7e2
Michael Lee [Tue, 13 Dec 2016 22:02:10 +0000 (14:02 -0800)]
Find and remove unused headers
Summary: Find and remove a couple of unnecessary includes
Reviewed By: matbd
Differential Revision:
D4322316
fbshipit-source-id:
7b55119bd7566fd62762ace5e35aa536489fafad
Andrii Grynenko [Tue, 13 Dec 2016 21:57:32 +0000 (13:57 -0800)]
Move GDB scripts for fibers into folly
Reviewed By: igorsugak
Differential Revision:
D4320762
fbshipit-source-id:
2028de6ccc6fb129381b03d694b88677a5aa50d6
Neel Goyal [Tue, 13 Dec 2016 18:25:19 +0000 (10:25 -0800)]
Add evb change callback to SSL Socket
Summary: Allow observers to be notified when AsyncSocket attaches and detaches from EVB
Reviewed By: siyengar
Differential Revision:
D4256175
fbshipit-source-id:
a3ff96811f885e508f20cf11ce52e0f00e5ee461
Christopher Dykes [Tue, 13 Dec 2016 18:01:00 +0000 (10:01 -0800)]
Enable -Wunreachable-code-return
Summary: The most common place this happened was in tests where it was being used to force the return type of a lambda, but there were a couple of places in the main code that triggered this as well.
Reviewed By: yfeldblum
Differential Revision:
D4310187
fbshipit-source-id:
e3701cff9827eacaf3be8d28296441466eb2fa11
Philip Pronin [Tue, 13 Dec 2016 09:53:43 +0000 (01:53 -0800)]
move JemallocNodumpAllocator to folly/experimental
Summary:
Moving russoue's `JemallocNodumpAllocator` (
D3147173) from
`mcrouter` codebase to `folly`, so we can use it in a few other services
that suffer from a huge core dump problem.
Reviewed By: russoue, jmswen, luciang
Differential Revision:
D4311394
fbshipit-source-id:
6a13c478b939bd411e0fd37e655125f62434c366
Igor Zinkovsky [Tue, 13 Dec 2016 07:21:55 +0000 (23:21 -0800)]
allow run-once callbacks
Summary: Adding new `addFunctionOnce` method that executes provided callback only once.
Reviewed By: yfeldblum
Differential Revision:
D4315635
fbshipit-source-id:
4819ec30b4f2e4ab3185a37158404e1c7a96758a
Christopher Dykes [Mon, 12 Dec 2016 23:15:27 +0000 (15:15 -0800)]
Allow building with -Wshift-sign-overflow
Summary: Prior to C++14 these shifts are undefined behavior, but the unsigned version is not, so do the shifts on unsigned values before converting to the final type.
Reviewed By: yfeldblum
Differential Revision:
D4309311
fbshipit-source-id:
914b207bac2f77a96c07a8a5df81980c672aa677
Christopher Dykes [Mon, 12 Dec 2016 19:46:03 +0000 (11:46 -0800)]
Allow building with -Wgnu-conditional-omitted-operand
Summary: Which warns about the use of a ternary statement with the first operand omitted. This is a GCC extension and MSVC does not support it, so eliminate the last use of it.
Reviewed By: yfeldblum
Differential Revision:
D4309989
fbshipit-source-id:
04c968708e47f8cb707fd0892e8780bc676df0de
Christopher Dykes [Mon, 12 Dec 2016 19:39:32 +0000 (11:39 -0800)]
Don't declare a variable for exceptions we discard
Summary: They aren't needed and they count as initialized but unused variables.
Reviewed By: yfeldblum
Differential Revision:
D4308844
fbshipit-source-id:
a6833dbf434ebdefff0b375729a4e62495463ac0
Christopher Dykes [Mon, 12 Dec 2016 19:34:23 +0000 (11:34 -0800)]
Fix some implicit truncation and sign coersion in the networking APIs
Summary: Split out of an earlier pair of diffs, this focuses exclusively on Folly's networking APIs and works to eliminate places where values were being implicitly truncated.
Reviewed By: yfeldblum
Differential Revision:
D4288042
fbshipit-source-id:
dd6e19acd319296a45c29c8050dc62f06571e1e6
Christopher Dykes [Sat, 10 Dec 2016 02:26:52 +0000 (18:26 -0800)]
Enable -Wunreachable-code-break
Summary: Because the `break;` can be dead, and sometimes is indicitive of a different type of error.
Reviewed By: meyering
Differential Revision:
D4310056
fbshipit-source-id:
ad215eb9b2e5bb4d5c703582203efce893b26a76
Kyle Nekritz [Sat, 10 Dec 2016 00:09:42 +0000 (16:09 -0800)]
Log supported versions extension in AsyncSSLSocket.
Summary: To monitor client support of TLS 1.3.
Reviewed By: ngoyal
Differential Revision:
D4308473
fbshipit-source-id:
cb6fb444c8b7ced39e6655a0f63b18523c2fb9c5
Nathan Bronson [Fri, 9 Dec 2016 20:42:28 +0000 (12:42 -0800)]
folly/io/async/tests: always detach event base in tests, fixes UBSAN tests
Summary:
In AsyncSSLSocket tests the shared_ptr structure means that the
AsyncSSLSocket-s outlive the stack-allocated EventBase on which they were
created. Previously there were scattered calls to detachEventBase on the
last interesting callback, but several calls were missing. This diff
switches to a model where the SSLServerAcceptCallbackBase is responsible
for detaching the sockets.
This diff also fixes a low-firing race between shutdown
of the TestSSLAsyncCacheServer Main thread and a call to
EmptyReadCallback::readEOF. Most uses of EmptyReadCallback don't attach
the TCP socket, so they can't actually tolerate a call to readError
or readEOF.
These use-after-destruction problems were discovered by UBSAN.
Reviewed By: djwatson
Differential Revision:
D4301416
fbshipit-source-id:
127fb5e506d0694c5ca81d7a38c704d69f4ab3eb
Christopher Dykes [Fri, 9 Dec 2016 19:04:19 +0000 (11:04 -0800)]
Enable -Wextra-semi
Summary:
Because the extra semicolons are useless and all typos...
GCC doesn't have this warning. Neither does MSVC, but that won't stop me.
Reviewed By: igorsugak
Differential Revision:
D4304218
fbshipit-source-id:
a06586edc6b9bafd5dd074e9fd4e0ed152181abc
Christopher Dykes [Fri, 9 Dec 2016 01:37:20 +0000 (17:37 -0800)]
Don't shadow locals, parameters or fields
Summary:
This accounts for the places that were triggering warnings 4456, 4457, and 4458, which are all related to shadowing names, be they locals, parameters, or even types.
This doesn't deal with 4459, which is specifically for shadowing global variables, because folly/gen defines globals by the name of `count`, `min`, `max` and a few other similar names.
Reviewed By: meyering
Differential Revision:
D4296781
fbshipit-source-id:
a2e625095e2c65a53a9226b000aaf0ca95a3a393
David Goldblatt [Fri, 9 Dec 2016 01:20:46 +0000 (17:20 -0800)]
Fix SimpleBarrier
Summary:
Do the barrier completion test in a loop. (std::condition_variable has pthreads-style spurious wakeups).
(Sorry for missing this in review).
Reviewed By: djwatson
Differential Revision:
D4302035
fbshipit-source-id:
3322d6a0ffba8c47c46bafb1d88034e1a0a9c652
Dave Watson [Thu, 8 Dec 2016 18:28:21 +0000 (10:28 -0800)]
update small locks benchmark
Summary: Add fairness benchmark, contended benchmark
Reviewed By: davidtgoldblatt
Differential Revision:
D3706680
fbshipit-source-id:
01814fcd6b0cc3dd12815a2b2c248abc6a3771ec
Qinfan Wu [Thu, 8 Dec 2016 16:38:14 +0000 (08:38 -0800)]
Fix sorted_vector_set::erase
Summary: It deletes things even when input isn't in the container.
Reviewed By: luciang
Differential Revision:
D4298340
fbshipit-source-id:
3e8fc04c2c21eb231dcaf82239ac5f6d25e49e2c
David Lam [Wed, 7 Dec 2016 23:32:30 +0000 (15:32 -0800)]
Fix Synchronized.md documentation to use correct condition_variable::wait call
Summary:
`condition_variable::wait_for` takes as second param `std::chrono::duration`
and not a predicate; what we want is `condition_variable::wait`.
Reviewed By: simpkins
Differential Revision:
D4295305
fbshipit-source-id:
05f735fe6e7ecb9d8f42cb38a2985b9ce9dad984
Christopher Dykes [Wed, 7 Dec 2016 22:16:59 +0000 (14:16 -0800)]
Fix some implicit truncations in the interaction with OpenSSL APIs
Summary: MSVC has the ability to warn about implicit truncations and places where implicit sign coercions are occuring, so do some cleanup to make it possible to compile with the warnings enabled.
Reviewed By: yfeldblum
Differential Revision:
D4288028
fbshipit-source-id:
f8330c62b2dcb76f696dfc47888f0e3e1eefc21a
Yedidya Feldblum [Wed, 7 Dec 2016 22:14:47 +0000 (14:14 -0800)]
Cut some includes from Executor.h
Summary: [Folly] Cut some includes from `Executor.h`.
Reviewed By: mzlee
Differential Revision:
D4256618
fbshipit-source-id:
1728f48b3c0ec4e0c4c84c44bd8afb583d438129
Wez Furlong [Wed, 7 Dec 2016 20:53:52 +0000 (12:53 -0800)]
USE_JEMALLOC in the OSS build if we have jemalloc
Summary:
Nothing defines USE_JEMALLOC in the OSS build today and that causes
some portability problems.
Specifically, the homebrew recipe will make libjemalloc available and our
configure script will detect it and add it to the library flags.
Our subsequent check for `malloc_usable_size` then finds this function in
libjemalloc.
When later attempting to build wangle against the homebrew folly we get
compilation failures because the prototype for `malloc_usable_size` is only
available in the jemalloc headers and nothing in the saved configuration for
folly is set up for this to be pulled in as it it guarded by `USE_JEMALLOC`.
This attempts to resolve the situation by forcing on `USE_JEMALLOC` when
we detect the library in configure.
This is made a little more complicated because we cannot set `USE_JEMALLOC`
in the OSS build; it gets rewritten to have a `FOLLY_` prefix. Since we
have code outside of folly that requires that this symbol be `USE_JEMALLOC`,
I've changed the conditional to check for both flavors of the symbol, with
and without the prefix.
Reviewed By: yfeldblum
Differential Revision:
D4289176
fbshipit-source-id:
756bc815c3ef1fac454e603feb72155d98c5aadd
Eric Niebler [Wed, 7 Dec 2016 20:43:21 +0000 (12:43 -0800)]
add folly::FixedString, a constexpr-usable string with a fixed-size internal buffer
Summary: Inspired by http://wg21.link/p0259, folly::BasicFixedString is a std::string replacement that is usable in constexpr contexts. It uses an internal fixed-size buffer to store up to N characters, where N is a template parameter.
Reviewed By: luciang
Differential Revision:
D4249529
fbshipit-source-id:
10f12ea2510a8d21ec60a07a8f15ecc3e35c5431
Christopher Dykes [Wed, 7 Dec 2016 19:42:17 +0000 (11:42 -0800)]
Rename stdin, etc. in Subprocess to work with MSVC
Summary:
`stdin`, `stdout` and `stderr` are macros that expand to function calls with the MSVC CRT implementation. This is also the case for musl-libc. This means that Subprocess simply cannot be compiled on those platforms without changing the API.
To solve that, we change the API and deprecate the old API.
For more fun, `stdin`, `stdout` and `stderr` are also macros in glibc, they just expand to other identifiers rather than a function call.
Reviewed By: yfeldblum
Differential Revision:
D4229544
fbshipit-source-id:
97f1a3b228b83cfdcaffee56d729063ea235e608
Nathan Bronson [Wed, 7 Dec 2016 19:39:00 +0000 (11:39 -0800)]
fix FutureTest/RequestContext
Summary: Fix use-after-destroy of NewThreadExecutor. Detected by opt-ubsan tests.
Reviewed By: yfeldblum
Differential Revision:
D4291900
fbshipit-source-id:
206f1d7b80fa04e1570e4b7a20e50b9a8ceb7bcb
Nathan Bronson [Wed, 7 Dec 2016 19:20:21 +0000 (11:20 -0800)]
increase writeLen for tests that want to trigger buffering
Summary:
Freshly opened TCP sockets can have a send buffer size bigger
than wmem_default, because connection parameters are cached in the
route cache. Some of the async socket tests assumed that writing 8M of
data was enough to guarantee blocking behavior, but since wmem_max is
20M on our systems the resulting tests are flaky.
Reviewed By: marcinpe
Differential Revision:
D4292201
fbshipit-source-id:
ba5d606d080330e455eee2b17bcae6cf546bf981
Dan Schatzberg [Wed, 7 Dec 2016 16:08:34 +0000 (08:08 -0800)]
Add EvictingCacheMap MoveConstructor
Summary:
Add the default move constructor and move operator
to EvictingCacheMap so it can be moved.
Reviewed By: markisaa, luciang
Differential Revision:
D4287472
fbshipit-source-id:
130e9d5467d6da14ba95a9e769cf8e8d541a704c
Andrii Grynenko [Tue, 6 Dec 2016 23:11:57 +0000 (15:11 -0800)]
Increase fiber stack size if UBSAN is enabled
Summary: UBSAN instrumentation results in more stack being used. Applying the same logic we already have for ASAN there.
Reviewed By: igorsugak
Differential Revision:
D4287455
fbshipit-source-id:
1a224cb5a3654c23b15fa298bf80476234a1418c
Michael Lee [Tue, 6 Dec 2016 21:58:20 +0000 (13:58 -0800)]
Remove unecessary iostream include
Summary: MacAddress only needs to include ostream and the test header does not need iostream.
Differential Revision:
D4286405
fbshipit-source-id:
e64fdd4e8428c62279ed7c185188f3dfc14096d3
Michael Lee [Tue, 6 Dec 2016 20:08:49 +0000 (12:08 -0800)]
More iostream removal.
Summary:
We do not need it and it adds a static initialization
This is the last extra one in liger. The other places actually need iostream to print things
Reviewed By: yfeldblum
Differential Revision:
D4286095
fbshipit-source-id:
44a827e48e9fb9106626e784592eb194dff83bf6
Christopher Dykes [Tue, 6 Dec 2016 18:51:35 +0000 (10:51 -0800)]
Make bm_min_iters a 32-bit flag
Summary:
The benchmark API only supports `unsigned int` as the iteration number, so this being 64-bit means it has to be truncated for no reason.
This change gets us closer to being able to enable MSVC's implicit truncation warnings.
Reviewed By: yfeldblum
Differential Revision:
D4281264
fbshipit-source-id:
27397e3f23bace20f3cc457665ea6f21bf994da5
Misha Shneerson [Tue, 6 Dec 2016 04:33:09 +0000 (20:33 -0800)]
fix gbd debugging script
Summary:
I was getting an error when running commands in
https://our.intern.facebook.com/intern/dex/fibers/gdb/
Reviewed By: andriigrynenko
Differential Revision:
D4283229
fbshipit-source-id:
fe45847d0ec6cadfbce6fe9818066cce3e275a46
Eric Niebler [Mon, 5 Dec 2016 21:06:16 +0000 (13:06 -0800)]
constexpr_strlen works for types other than char. Remove bogus check for nullptr.
Summary: overload constexpr_strlen to work with other character types
Reviewed By: yfeldblum, luciang, Orvid, ot
Differential Revision:
D4269654
fbshipit-source-id:
2fcd666669efb51d77e847ff31bda3a301e763da
Eric Niebler [Mon, 5 Dec 2016 20:51:19 +0000 (12:51 -0800)]
Reformulate constexpr_min and constexpr_max to achieve stability in sorting as described in stepanovpapers.com/notes.pdf
Summary: There is a famous long-standing "bug" in the standard library regarding the semantics of min and max wrt values that are equivalent wrt op< but not equal. Let's not make the same mistake with constexpr_min and constexpr_max.
Reviewed By: yfeldblum, luciang, Orvid, ot
Differential Revision:
D4269635
fbshipit-source-id:
19b464c949dc0cf07afb08eaf657ae8b242ca42d
Amir Shalem [Sun, 4 Dec 2016 19:15:34 +0000 (11:15 -0800)]
Fix potential double close() on exception
Summary:
Fix potential double close() on exception when SO_REUSEPORT fails.
The fd will be closed twice, once by close() and second by the scope guard above.
Reviewed By: yfeldblum
Differential Revision:
D4272300
fbshipit-source-id:
a163be822d7522cadb9dc3c3eddca10df453de14
Christopher Dykes [Sat, 3 Dec 2016 00:45:01 +0000 (16:45 -0800)]
Get ConcurrentSkipList functional
Summary:
MSVC was getting thoroughly confused while trying to eval the constexpr function, so switch it to a template instead.
MSVC was also failing to wrap it's head around what a NodeRecycler is, so delay its resolution via typename.
Reviewed By: yfeldblum
Differential Revision:
D3478755
fbshipit-source-id:
f687f4538fb12ef8eee525557f4cc988a09e714d
Christopher Dykes [Fri, 2 Dec 2016 22:23:36 +0000 (14:23 -0800)]
Begin making folly compile cleanly with a few of MSVC's sign mismatch warnings enabled
Summary:
This makes the changes required to allow folly to compile cleanly with the sign/unsigned mismatch warnings 4388 and 4389, as well as with warnings 4804 and 4805, which are about comparisons between scalars and bool.
Most of the changes in this are to `DCHECK_*` calls which are translated to a templated call which does the comparison internally based on the inferred type of the argument, which for a literal `0` is `int`, causing the warnings to get generated when the comparison is done.
Reviewed By: yfeldblum
Differential Revision:
D4253427
fbshipit-source-id:
cd17973a78e948a62c886a2959f9abf40a69f9f5
Scott Michelson [Fri, 2 Dec 2016 19:48:48 +0000 (11:48 -0800)]
support getting timer from eventbase
Summary: This brings the EventBase functionality of getting a timer for the eventbase into the virtual interface
Differential Revision:
D4264135
fbshipit-source-id:
e5526610eca808e1d7b549a7cd6cd7b2c65d3ce1
Adam Simpkins [Thu, 1 Dec 2016 23:45:22 +0000 (15:45 -0800)]
add a new writeFileAtomic() function
Summary:
Add a utility function to more safely set a file's contents by writing to a
temporary file first, then renaming the temporary file into place. On Linux
systems where renames are atomic, this ensures that the operation either
succeeds or that the old file state is left unchanged on failure.
Note that unlike most of the other APIs in FileUtil.h, I intentionally made
writeFileAtomic() throw an exception on failure. This is implemented using a
lower-level writeFileAtomicNoThrow() version. Callers who care about the
exception overhead can use the lower level version instead. (Exception
overhead should be relatively low compared to the file I/O operations, though,
so I suspect most users will prefer the throwing APIs.)
Reviewed By: yfeldblum
Differential Revision:
D4253964
fbshipit-source-id:
5301e2791b82c6f90b63bb509b0411841c266705
Yedidya Feldblum [Thu, 1 Dec 2016 20:43:06 +0000 (12:43 -0800)]
Future<typename>::getTryVia
Summary:
[Folly] `Future<typename>::getTryVia`.
We have `waitVia` and `getVia` and `getTry`, but `getTryVia` was missing.
Reviewed By: fugalh
Differential Revision:
D4254972
fbshipit-source-id:
403e1a3496ad5dfc93c4c55ab75a83bcc89e6c64
Subodh Iyengar [Thu, 1 Dec 2016 14:39:24 +0000 (06:39 -0800)]
Fix assertion in unit test
Summary:
Fix test for AsyncSSLSocket. When a timeout
occurs during a handshake it's possible that
invokeConnectError is called with sslState_ ==
CONNECTING. This just removes the assertion in
this case. This doesnt affect prod code, only
tests
Reviewed By: yfeldblum
Differential Revision:
D4252677
fbshipit-source-id:
4db3a94ae28aa140546554c087bedcee7f06d201
Andrii Grynenko [Thu, 1 Dec 2016 01:59:58 +0000 (17:59 -0800)]
Use singleton EventBasePool in ServiceRouter
Summary:
Switching ServiceRouter code to use VirtualEventBase instead of EventBase allows us to have same thread-pool shared between multiple ServiceRouter instances.
In future this allows us to replace EventBasePoolImpl with some generic thread-pool implementation (e.g. IOThreadPoolExecutor). It also makes it trivial to have ServiceRouter run on a any existing thread-pool if necessary.
Reviewed By: smichelson
Differential Revision:
D3935283
fbshipit-source-id:
3275bbace15a0df8b06d12c970ccc098a631658d
Andrii Grynenko [Thu, 1 Dec 2016 00:50:04 +0000 (16:50 -0800)]
Use SingletonThreadLocal in folly::Random
Summary: folly::SingletonThreadLocal should be used for all thread-local singletons to avoid SDOF.
Reviewed By: yfeldblum
Differential Revision:
D4253009
fbshipit-source-id:
5b4ca57a7a77b7b54c94630a2a29d13b84a3af27
Christopher Dykes [Wed, 30 Nov 2016 19:17:39 +0000 (11:17 -0800)]
Start fixing implicit truncations
Summary:
Truncations should be explicit, but for some reason, MSVC seems to be the only compiler that will warn you when you implicitly truncate integer or float values.
This allows Folly to be compiled with warnings 4018, 4242, 4244 and 4305 enabled.
Technically 4018 is a sign mismatch warning, but there was only one place it was being triggered so I included it anyways. The other 3 are warnings for implicit truncation.
There is one other implicit truncation warning that currently triggers in Folly, 4267, but there are a lot more places where that triggers so I'll do that in a separate diff.
Reviewed By: yfeldblum
Differential Revision:
D4249471
fbshipit-source-id:
e18a93d85856c998576934a6229c9edd1638a54e
Teng Qin [Wed, 30 Nov 2016 19:07:23 +0000 (11:07 -0800)]
Add optional Tracepoint for RequestContext switch
Summary: Using newly added `StaticTracepoint.h`, add a Tracepoint for `RequestContext` switch that could be enabled by compiler flag.
Reviewed By: drarmstr
Differential Revision:
D4238658
fbshipit-source-id:
043a035ba8251b48d7b29d63a2219ad2edda164f
Eric Niebler [Wed, 30 Nov 2016 03:42:04 +0000 (19:42 -0800)]
Add constexpr to the simple folly::Range accessors (begin, end, data, empty, etc)
Summary: More constexpr is better!
Reviewed By: yfeldblum, luciang, ot
Differential Revision:
D4244996
fbshipit-source-id:
30a9b726c115a92bb18538d7f18e50eccb0a1ef6