6 years agoConsistency in namespace-closing comments v2017.07.31.00
Yedidya Feldblum [Mon, 31 Jul 2017 06:14:36 +0000 (23:14 -0700)]
Consistency in namespace-closing comments

Summary: [Folly] Consistency in namespace-closing comments.

Reviewed By: Orvid

Differential Revision: D5524744

fbshipit-source-id: ced4dd2398ed6baa3ad5b68b74eee6a5d6b2b103

6 years agoFormatting for template parameters
Yedidya Feldblum [Mon, 31 Jul 2017 02:40:25 +0000 (19:40 -0700)]
Formatting for template parameters

Summary: [Folly] Formatting for template parameters.

Reviewed By: Orvid

Differential Revision: D5525123

fbshipit-source-id: 4feb772300cfdd6ae3168fe9f59f5a951fb85d0e

6 years agoSimplify the StateSize helper in Random
Yedidya Feldblum [Mon, 31 Jul 2017 00:58:29 +0000 (17:58 -0700)]
Simplify the StateSize helper in Random

[Folly] Simplify the `StateSize` helper in `Random`.

* Using member type aliases rather than class constants means we can remove definitions.
* Partially specializing over all RNG types with `state_size` class constants means we can remove the `mersenne_twister` specializations, which have many template parameters and are a pain.

Reviewed By: Orvid

Differential Revision: D5525144

fbshipit-source-id: bc27f112ed0d9b55befe9dabe08c4d345a402435

6 years agoOutline throw statements in format
Yedidya Feldblum [Sun, 30 Jul 2017 21:31:01 +0000 (14:31 -0700)]
Outline throw statements in format

Summary: [Folly] Outline `throw` statements in `format`.

Reviewed By: Orvid

Differential Revision: D5523933

fbshipit-source-id: 371c9ecc707e48dcc05fa4aab4fd326111466161

6 years agoLet MacAddress use a helper hex-table
Yedidya Feldblum [Sun, 30 Jul 2017 21:28:44 +0000 (14:28 -0700)]
Let MacAddress use a helper hex-table

[Folly] Let `MacAddress` use a helper hex-table.

The table is in the `folly::detail` namespace so it is non-public to users of folly, but the rules may not be quite as strict in at least some cases within folly.

Also the helper `unhex` function that this replaces is not `clang-format`-clean, so this lets us sidestep that.

Reviewed By: Orvid

Differential Revision: D5524229

fbshipit-source-id: 21d6938e20cd675e65499a5b64d2af934f980222

6 years agoConsistent indentation for class visibility labels
Yedidya Feldblum [Sun, 30 Jul 2017 03:09:05 +0000 (20:09 -0700)]
Consistent indentation for class visibility labels

Summary: [Folly] Consistent indentation for class visibility labels (`public:`, `protected:`, `private:`). Style is +1 column relative to the `class` keyword.

Reviewed By: andrewjcg

Differential Revision: D5524869

fbshipit-source-id: 53e4b6cbda10d5b63bafbd535794a8b7ae01a8e0

6 years agotemplate< -> template <
Yedidya Feldblum [Sun, 30 Jul 2017 02:30:13 +0000 (19:30 -0700)]
template< -> template <

[Folly] `template<` -> `template <`.

And then apply `clang-format` style to affected `template <...>` lines.

Reviewed By: andrewjcg

Differential Revision: D5524792

fbshipit-source-id: 6614eecf384bf3e3ccc2f0cc7c5334a0cb9c76af

6 years agoMark two implicit ctors as explicit
Yedidya Feldblum [Sun, 30 Jul 2017 00:54:14 +0000 (17:54 -0700)]
Mark two implicit ctors as explicit

[Folly] Mark two implicit ctors as `explicit`.

They did not need to be implicit.

Reviewed By: andrewjcg

Differential Revision: D5524798

fbshipit-source-id: a50bc6bfc9da2642891faf0aa38a19f46e75b9da

6 years agoDefine IPAddressV6 comparison ops in terms of its fields
Yedidya Feldblum [Sat, 29 Jul 2017 19:52:49 +0000 (12:52 -0700)]
Define IPAddressV6 comparison ops in terms of its fields

Summary: [Folly] Define `IPAddressV6` comparison ops in terms of its fields using `std::tie`.

Reviewed By: andrewjcg

Differential Revision: D5524248

fbshipit-source-id: 5f5f2acd6e9cfd6dfd148cc7d95bda720bf81ee9

6 years agoMerge IPAddressTest.h into the IPAddressTest.cpp
Yedidya Feldblum [Sat, 29 Jul 2017 19:51:53 +0000 (12:51 -0700)]
Merge IPAddressTest.h into the IPAddressTest.cpp

[Folly] Merge `IPAddressTest.h` into the `IPAddressTest.cpp`.

There is no real need to split anything out into a header file.

Reviewed By: andrewjcg

Differential Revision: D5524267

fbshipit-source-id: e128c69c7da38663f19d0ccd73edaae36c3f469a

6 years agoOutline throw statements in folly/futures/
Yedidya Feldblum [Sat, 29 Jul 2017 19:19:18 +0000 (12:19 -0700)]
Outline throw statements in folly/futures/

Summary: [Folly] Outline `throw` statements in `folly/futures/`.

Reviewed By: ericniebler

Differential Revision: D5522791

fbshipit-source-id: 545185bc580ea8628075b9ecae46c2f19308e937

6 years agoCompute masks in IPAddressV4
Yedidya Feldblum [Sat, 29 Jul 2017 18:51:38 +0000 (11:51 -0700)]
Compute masks in IPAddressV4

Summary: [Folly] Compute masks in `IPAddressV4`. Just like in `IPAddressV6`.

Reviewed By: WillerZ

Differential Revision: D5524197

fbshipit-source-id: ebeeab28304bff4f6150cf76216d170908e62aa4

6 years agoFix the copy constructor in Replaceable
Phil Willoughby [Sat, 29 Jul 2017 07:08:27 +0000 (00:08 -0700)]
Fix the copy constructor in Replaceable

Fix the copy constructor, and add the missing testcase which would have found
this problem.

Reviewed By: yfeldblum

Differential Revision: D5516628

fbshipit-source-id: 3e688c34f061511df5b68243111fecb83483d79d

6 years agoOptimal make_integer_sequence
Yedidya Feldblum [Fri, 28 Jul 2017 21:39:32 +0000 (14:39 -0700)]
Optimal make_integer_sequence

[Folly] Optimal `make_integer_sequence`.

When the builtin `__make_integer_seq` is available, use that. It is the most optimal implementation.

Otherwise, use a tweaked divide-and-conquer implementation. Designed to reuse more template instantiations than the straightforward divide-and-conquer approach in libstdc++ >= 6. And definitely not linearly recursive as in libstdc++ < 6.

Illustrating with an example. Let `M` be whatever template type implements `make_integer_sequence`. For `M<17>`, libstdc++ < 6 does linear recursion (least optimal), instantiating `M<16>`, `M<15>`, ..., `M<1>`. libstdc++ >= 6 does straightforward divide-and-conquer recursion, instantiating `M<8>` and `M<9>`, recursing into `M<4>` and `M<5>`, recursing into `M<2>` and `M<3>`, recursing into `M<1>`. Our implementation does a variant of divide-and-conquer recursion to maximize reuse, instantiating `M<8>` and `M<1>`, recursing into `M<4>`, recursing into `M<2>`.

Implementation derived from `fatal/type/sequence.h`.

Reviewed By: ericniebler

Differential Revision: D5496975

fbshipit-source-id: 449b4e0a1c7b4a5b602752c1d3dd8914bf9a8e71

6 years agoPrevent IsOneOf unused template specialization instantiation
stryku [Fri, 28 Jul 2017 20:05:08 +0000 (13:05 -0700)]
Prevent IsOneOf unused template specialization instantiation

Current `IsOneOf` implementation does unnecessary work because it instantiates all of the possible template specializations, even if type is same as the first of the tested ones. E.g.
`IsOneOf<char, char, int, float>` will instantiate:
IsOneOf<char, char, int, float>
IsOneOf<char, char, int>
IsOneOf<char, char>

With the proposed inheritance, compiler will stop initializing at the first match.

Reviewed By: ericniebler

Differential Revision: D5482783

Pulled By: yfeldblum

fbshipit-source-id: 3d04c750ce72fa9b19b4d0588cccfb396a9e0715

6 years agoAdd X509_REVOKED_get0_* OpenSSL shims
Mingtao Yang [Fri, 28 Jul 2017 16:57:24 +0000 (09:57 -0700)]
Add X509_REVOKED_get0_* OpenSSL shims

Reviewed By: yfeldblum

Differential Revision: D5509756

fbshipit-source-id: 0b9581dafb073c5e3e5a229c032c6cf272ceb2e0

6 years agoFix StringPiece ostream overloads to properly not rely on <ostream>
Andrew Krieger [Fri, 28 Jul 2017 15:20:06 +0000 (08:20 -0700)]
Fix StringPiece ostream overloads to properly not rely on <ostream>

std::ostream may be incomplete because Range.h doesn't use <ostream>,
only <iosfwd>. Changing the operator<< overloads to be templated on the char
type defers typechecking until callsites, which will avoid the potential problem.

Reviewed By: yfeldblum, ericniebler

Differential Revision: D5494648

fbshipit-source-id: e59b6fdfba6c08ec70ebb1e10c14a43307a1119f

6 years agostd::basic_ostream operator<< overload for FixedString
Andrew Krieger [Fri, 28 Jul 2017 15:20:05 +0000 (08:20 -0700)]
std::basic_ostream operator<< overload for FixedString

When attempting to output a FixedString into eg. glog or
some other ostream, it is first being implicitly converted to StringPiece
and then that is printed using the overloaded operator<<. If another
suitable implicit conversion is provided, eg. to `dynamic`, compilers
cannot choose between either one. Instead, overload operator<< directly
on FixedString to resolve the ambiguity.

Reviewed By: yfeldblum, ericniebler

Differential Revision: D5492779

fbshipit-source-id: 92d661e5471a91057d7a0d010420709c5d59232f

6 years agoSwitch to folly/Optional.h to use std::aligned_storage
Michael Lee [Thu, 27 Jul 2017 16:20:04 +0000 (09:20 -0700)]
Switch to folly/Optional.h to use std::aligned_storage

Summary: Older versions of libc++ do not support `std::aligned_storage_t`, switch to something more widely supported.

Differential Revision: D5506449

fbshipit-source-id: 3f5cf5dddf00bda76d4f16cfd4d8944ee5f1ba55

6 years agoAdd FOLLY_HAS_FEATURE and use it
Yedidya Feldblum [Wed, 26 Jul 2017 21:18:41 +0000 (14:18 -0700)]
Add FOLLY_HAS_FEATURE and use it

[Folly] Add `FOLLY_HAS_FEATURE` and use it.

Use it in the definitions of `FOLLY_SANITIZE_ADDRESS` and `FOLLY_SANITIZE_THREAD`.

Reviewed By: meyering

Differential Revision: D5496915

fbshipit-source-id: e272137ad8ba891e64fc98444edf573115764ee2

6 years agoCut moveFromTry
Yedidya Feldblum [Wed, 26 Jul 2017 18:52:29 +0000 (11:52 -0700)]
Cut moveFromTry

Summary: [Folly] Cut `moveFromTry`. Not necessary, and is even longer than `std::move`.

Reviewed By: WillerZ, ericniebler

Differential Revision: D5478450

fbshipit-source-id: ecd01cb1bcd435e49268a76dd558e57ba8dd9b9e

6 years agoOutline throw statements in dynamic
Yedidya Feldblum [Wed, 26 Jul 2017 18:39:53 +0000 (11:39 -0700)]
Outline throw statements in dynamic

[Folly] Outline `throw` statements in `dynamic`.

There is no need for them to be inline - definitionally, they are always cold.

Reviewed By: WillerZ

Differential Revision: D5497457

fbshipit-source-id: 7b649c59b5b2609f838eb10e9329468d1bd1d558

6 years agoKill folly::SSLContext::switchCiphersIfTLS11.
Xiangyu Bu [Wed, 26 Jul 2017 18:32:54 +0000 (11:32 -0700)]
Kill folly::SSLContext::switchCiphersIfTLS11.

Summary: It has been years since BEAST attack surfaced. The vulnerabilities have been patched and the mitigation using RC4 cipher is no longer needed. This diff removes the code relevant to mitigating BEAST years ago.

Reviewed By: anirudhvr

Differential Revision: D5409859

fbshipit-source-id: 58178e68a447f372b19491832a7be590af9402e9

6 years agoAdd getEventBase() to AsyncUDPSocket
Neel Goyal [Wed, 26 Jul 2017 18:31:11 +0000 (11:31 -0700)]
Add getEventBase() to AsyncUDPSocket

Summary: Add an event base getter for AsyncUDPSocket similar to the other socket classes.

Reviewed By: knekritz

Differential Revision: D5498587

fbshipit-source-id: ac3179e03485328417ed9863f6bb790de7c691cb

6 years agoConcurrentHashMap
Dave Watson [Wed, 26 Jul 2017 16:41:45 +0000 (09:41 -0700)]

A ConcurrentHashMap with wait-free readers, as in Java's ConcurrentHashMap.

It's a pretty generic closed-addressing chaining hashtable, except find() uses two hazard pointers
to do hand-over-hand traversal of the list, so it never takes a lock.

On rehash, only the part of the chain that remains the same (i.e. is still hashed to the same bucket)
is reused, otherwise we have to allocate new nodes.

Reallocating nodes means we either have to copy the value_type, or add in an extra indirection
to access it.  Both are supported.

There's still a couple opportunities to squeeze some more perf out with optimistic loading
of nodes / cachelines, but I didn't go that far yet, it sill looks pretty good.

Reviewed By: davidtgoldblatt

Differential Revision: D5349966

fbshipit-source-id: 022e8adacd0ddd32b2a4563caa99c0c4878851d8

6 years agoAllow stealing pointer bits
Dave Watson [Wed, 26 Jul 2017 15:07:56 +0000 (08:07 -0700)]
Allow stealing pointer bits

Currently hazard pointers doesn't support stealing any of the pointer bits.
You can *almost* roll it yourself using try_protect, but this prevents
implementations from choosing their type of barrier.

This adds a new get_protected interface that you can use to steal bits, or
otherwise manipulate pointers as you would like.

This also adds a MWMR list based set example that uses it, that is wait-free
for readers (unlike the SWMR example, that is only lock-free).

Reviewed By: magedm

Differential Revision: D5455615

fbshipit-source-id: 53d282eda433e00b6b53cd804d4e1c32c74c2fb8

6 years agoUpdate Optional
Phil Willoughby [Wed, 26 Jul 2017 12:52:11 +0000 (05:52 -0700)]
Update Optional

Summary: Now const-optimizer safe, and safe when the contained value overloads unary operator&

Reviewed By: yfeldblum

Differential Revision: D5480170

fbshipit-source-id: 3b53b0b6ce608857aa29d3f61eccd0b793b4cddc

6 years agoclang-format Optional.h
Phil Willoughby [Wed, 26 Jul 2017 12:12:29 +0000 (05:12 -0700)]
clang-format Optional.h

Reviewed By: yfeldblum

Differential Revision: D5497522

fbshipit-source-id: bb208aeb37b5b9ce99619193d4cd2d0f3fb39178

6 years agoAdd FOLLY_HAS_BUILTIN and use it
Yedidya Feldblum [Wed, 26 Jul 2017 08:51:44 +0000 (01:51 -0700)]
Add FOLLY_HAS_BUILTIN and use it

[Folly] Add `FOLLY_HAS_BUILTIN` and use it.

Use it in the definition of `folly::launder`. Of course, since GCC does not have `__has_builtin`, we still have to check its version.

Reviewed By: WillerZ

Differential Revision: D5496748

fbshipit-source-id: 3bd6e89424dfd2c9cb9795ee4d88f66c4294cc4c

6 years agoCut throwOnFail
Yedidya Feldblum [Wed, 26 Jul 2017 07:04:24 +0000 (00:04 -0700)]
Cut throwOnFail

[Folly] Cut `throwOnFail`.

It is not necessary, and `CHECK_THROW`, its reason for existing, can be implemented without it.

It can also easily be a pessimization because there is no way to delay computation of the arguments to the exception ctor until after the check. So if there is, say, a computation using `sformat` to compute a string argument to the exception ctor, that will always be performed rather than being performed only should the check fail.

Reviewed By: Orvid

Differential Revision: D5478804

fbshipit-source-id: 71a125c126eae76c6e95ef1bd23ee883b1db39a5

6 years agofolly: changes to make nvcc happy
Yangqing Jia [Wed, 26 Jul 2017 06:45:53 +0000 (23:45 -0700)]
folly: changes to make nvcc happy

(1) small_vector.h line 1099: wrap the default return in an else statement to
avoid compiler warning of "unreachable statement".
(2) Constexpr.h: need to treat cudacc similarly to msvc.

(Note: this ignores all push blocking failures!)

Reviewed By: dzhulgakov

Differential Revision: D5387061

fbshipit-source-id: f002ab5ec00d4dcd85d86386f87a0327023afa1b

6 years agoMove __CLANG_PREREQ to folly/CPortabiilty.h
Yedidya Feldblum [Wed, 26 Jul 2017 03:50:18 +0000 (20:50 -0700)]
Move __CLANG_PREREQ to folly/CPortabiilty.h

Summary: [Folly] Move `__CLANG_PREREQ` to `folly/CPortabiilty.h`.

Reviewed By: Orvid

Differential Revision: D5496372

fbshipit-source-id: 710af3d30aa8bd0e5f645beede354e3463f1bb25

6 years agoThere is no HAVE_SHADOW_LOCAL_WARNINGS
Yedidya Feldblum [Wed, 26 Jul 2017 03:50:16 +0000 (20:50 -0700)]



Reviewed By: Orvid

Differential Revision: D5496247

fbshipit-source-id: 689f40180180465bdc44593059e44fb64cf3e415

6 years agoFix include typo
Mingtao Yang [Tue, 25 Jul 2017 22:27:18 +0000 (15:27 -0700)]
Fix include typo

Reviewed By: anirudhvr

Differential Revision: D5492790

fbshipit-source-id: 10e868976a7ea42673d5b5c906a53c6c9495a288

6 years agoadd import to main in logging example
nicksbyman [Tue, 25 Jul 2017 20:04:17 +0000 (13:04 -0700)]
add import to main in logging example

Summary: Closes

Reviewed By: Orvid

Differential Revision: D5471368

Pulled By: yfeldblum

fbshipit-source-id: 3bbafd04b93828121ba829027959b6b3e0e55888

6 years agoMove OpenSSL locking code out of SSLContext
Mingtao Yang [Tue, 25 Jul 2017 18:52:40 +0000 (11:52 -0700)]
Move OpenSSL locking code out of SSLContext

OpenSSL 1.1.0 deprecates the callback based locking setup in favor
for platform native mutexes.

Added `OPENSSL_init_ssl` in the OpenSSL portability module for OpenSSL API < 1.1.0. This implements
the standard OpenSSL library initialization routines (taken from SSLContext::initializeOpenSSL).

Added `OPENSSL_cleanup` in the OpenSSL portability module for OpenSSL API < 1.1.0. This implements
the cleanup routine from SSLContext::cleanupOpenSSL.

Removed `SSLContext::SSLLockType`. Replaced with `folly::ssl::LockType`.

Reviewed By: mzlee, ngoyal

Differential Revision: D5404777

fbshipit-source-id: 7e5d9bf4a6683afb5560ada0a5b73cac3ff2662b

6 years agoFix double-free in DynamicConverter
Nicholas Ormrod [Tue, 25 Jul 2017 17:50:36 +0000 (10:50 -0700)]
Fix double-free in DynamicConverter

If an exception is thrown during the construction of value in a container, then the Transformer iterator will not successfully reconstruct a cache_ object after explicitly calling its destructor (due to the exception being thrown), which results in a double-free when cache_ is destroyed as part of Transformer's destructor.

Conveniently, there exists a piece of code designed to solve just this problem: folly::Optional. Replace cache_ and valid_ with folly::Optional.

This also fixes the unnecessary requirement that container value types have default constructors, since cache_ is no longer default constructed inside of Transformer.

Reviewed By: markisaa

Differential Revision: D5472342

fbshipit-source-id: eade1f7ce260b9b3406d92af8255b5ffa4e4a51c

6 years agoReplaceable
Phil Willoughby [Tue, 25 Jul 2017 07:17:24 +0000 (00:17 -0700)]

An instance of `Replaceable<T>` wraps an instance of `T`.

You access the inner `T` instance with `operator*` and `operator->` (as if
it were a smart pointer).

`Replaceable<T>` adds no indirection cost and performs no allocations.

`Replaceable<T>` has the same size and alignment as `T`.

You can replace the `T` within a `Replaceable<T>` using the `emplace` method
(presuming that it is constructible and destructible without throwing
exceptions). If the destructor or constructor you're using could throw an
exception you should use `Optional<T>` instead, as it's not a logic error for
that to be empty.

Reviewed By: yfeldblum

Differential Revision: D5346528

fbshipit-source-id: c7d72e73ea04e371325327a7ff0b345315d6e5ac

6 years agoMove the SpookyHash libraries into folly/hash v2017.07.24.00
Yedidya Feldblum [Mon, 24 Jul 2017 05:24:46 +0000 (22:24 -0700)]
Move the SpookyHash libraries into folly/hash

[Folly] Move the SpookyHash libraries into `folly/hash`.

And propagate the changes to `#include` lines, etc.

Reviewed By: Orvid

Differential Revision: D5477735

fbshipit-source-id: 94fe95ece05b52bde1466ab5f9fb8b53a4c59bed

6 years agoOutline the throw statements in Try
Yedidya Feldblum [Mon, 24 Jul 2017 04:43:04 +0000 (21:43 -0700)]
Outline the throw statements in Try

[Folly] Outline the `throw` statements in `Try`.

They are by definition cold and so we gain nothing from inlining them.

Reviewed By: Orvid

Differential Revision: D5478237

fbshipit-source-id: f413251a56ca4cbddcf3baea6679a552ae5bb19e

6 years agoAdd fnv1-a hash to Hash
Subodh Iyengar [Sun, 23 Jul 2017 18:15:06 +0000 (11:15 -0700)]
Add fnv1-a hash to Hash

Add fnv1-a 64 bit hash to Hash.h.
fnv1-a is supposed to be preferred over

Reviewed By: yfeldblum

Differential Revision: D5453401

fbshipit-source-id: c13f12ef11eb6745c95f3901b14ceafce90ea0ea

6 years agoRevert D5455584: [Folly] Move the SpookyHash libraries into folly/hash
Mihaela Ogrezeanu [Sat, 22 Jul 2017 10:03:41 +0000 (03:03 -0700)]
Revert D5455584: [Folly] Move the SpookyHash libraries into folly/hash

This reverts commit 616b04579eb6c822023b04840b075f3ac9fbb720


Differential Revision: D5455584

fbshipit-source-id: afc712fe40121232f52a5bad781350581cec6ce8

6 years agoMove the SpookyHash libraries into folly/hash
Yedidya Feldblum [Sat, 22 Jul 2017 08:17:31 +0000 (01:17 -0700)]
Move the SpookyHash libraries into folly/hash

[Folly] Move the SpookyHash libraries into `folly/hash`.

And propagate the changes to `#include` lines, etc.

Reviewed By: ot, ericniebler, Orvid

Differential Revision: D5455584

fbshipit-source-id: 616b04579eb6c822023b04840b075f3ac9fbb720

6 years agocrc32c: add missing header for std::runtime_error
Stephen Chen [Fri, 21 Jul 2017 21:24:04 +0000 (14:24 -0700)]
crc32c: add missing header for std::runtime_error

Summary: On the non sse42 path, we throw std::runtime_error, but Crc32cDetail.cpp is missing the header for it so it fails to compile on aarch64.

Reviewed By: yfeldblum

Differential Revision: D5468906

fbshipit-source-id: 2d5408621cb2b6758d3501407ed3d2a40d79f1b0

6 years agoApply clang-format to folly/experimental/symbolizer/
Yedidya Feldblum [Fri, 21 Jul 2017 08:45:34 +0000 (01:45 -0700)]
Apply clang-format to folly/experimental/symbolizer/

Summary: [Folly] Apply `clang-format` to `folly/experimental/symbolizer/`.

Reviewed By: Orvid

Differential Revision: D5468832

fbshipit-source-id: 94a0f82312769be0e8be724c11f97e14425ead10

6 years agoApply clang-format to folly/experimental/io/
Yedidya Feldblum [Fri, 21 Jul 2017 08:44:43 +0000 (01:44 -0700)]
Apply clang-format to folly/experimental/io/

Summary: [Folly] Apply `clang-format` to `folly/experimental/io/`.

Reviewed By: Orvid

Differential Revision: D5460571

fbshipit-source-id: d19aff829316dd277e65620196e12db8cad46787

6 years agoStyle tweaks to max_align_v calculation
Yedidya Feldblum [Fri, 21 Jul 2017 07:20:14 +0000 (00:20 -0700)]
Style tweaks to max_align_v calculation

[Folly] Style tweaks to `max_align_v` calculation.

* Change ns from `folly::detail` since that can be crowded and many other folly libraries may include this header.
* Extract a 2-param `max` alias.
* Fix an incorrectly hardcoded `size_t`.

Reviewed By: WillerZ

Differential Revision: D5468758

fbshipit-source-id: 14a3f67323020a3cfce2b3b46f5f64f3e6125027

6 years agoApply clang-format to folly/tracing/
Yedidya Feldblum [Fri, 21 Jul 2017 02:29:51 +0000 (19:29 -0700)]
Apply clang-format to folly/tracing/

Summary: [Folly] Apply `clang-format` to `folly/tracing/`.

Reviewed By: Orvid

Differential Revision: D5460511

fbshipit-source-id: c7a7d34211044a1b76934f184a8552a96d0bad91

6 years agoParse suffixes without switch-fallthrough in huge-pages
Yedidya Feldblum [Fri, 21 Jul 2017 02:29:14 +0000 (19:29 -0700)]
Parse suffixes without switch-fallthrough in huge-pages

Summary: [Folly] Parse suffixes without switch-fallthrough in huge-pages. It is clever, but weird. We can use an immediately-executed lambda expression to make it convenient.

Reviewed By: Orvid

Differential Revision: D5467585

fbshipit-source-id: 02ddb97641db97e38e3f40388ecc522eccd436cb

6 years agoApply clang-format to folly/experimental/bser/
Yedidya Feldblum [Thu, 20 Jul 2017 23:52:28 +0000 (16:52 -0700)]
Apply clang-format to folly/experimental/bser/

Summary: [Folly] Apply `clang-format` to `folly/experimental/bser/`.

Reviewed By: Orvid

Differential Revision: D5460552

fbshipit-source-id: e103f8920eb29b7c14688f5bbb3e28129ef35e96

6 years agoDrop a remnant of gcc48 support in futures
Yedidya Feldblum [Thu, 20 Jul 2017 22:10:41 +0000 (15:10 -0700)]
Drop a remnant of gcc48 support in futures

Summary: [Folly] Drop a remnant of gcc48 support in futures. Because gcc48 is no longer supported.

Reviewed By: Orvid, meyering

Differential Revision: D5460788

fbshipit-source-id: 86e2985a0980357641d18f59fd25b9667ec30ab0

6 years agofix ExceptionWrapper comment
Jeff Cai [Thu, 20 Jul 2017 20:09:10 +0000 (13:09 -0700)]
fix ExceptionWrapper comment

Fix comment for exception_wrapper's `operator bool()`.
It reads "return `true` if `*this` is not holding an exception"
but the actual behavior is to return `true` if `*this` *is* holding
an exception.

Reviewed By: yfeldblum

Differential Revision: D5456386

fbshipit-source-id: ec3a472ea441476d835881e94036a3957bb2ab32

6 years agoIntroduce folly::max_align_t and folly::max_align_v
Phil Willoughby [Thu, 20 Jul 2017 12:28:49 +0000 (05:28 -0700)]
Introduce folly::max_align_t and folly::max_align_v

`folly::max_align_t` is a portable replacement for `std::max_align_t`.

`folly::max_align_v` is a `constexpr size_t` with the same value as `alignof(folly::max_align_t)`

32-bit iOS environments have `alignof(std::max_align_t) == 4`, which is not correct. This is more
correct in that I have not yet found a more-aligned basic type.

Reviewed By: yfeldblum

Differential Revision: D5442333

fbshipit-source-id: 0a93e48a730d65ef76e04f132b5976c93587b14c

6 years agoAdd folly non null
Subodh Iyengar [Thu, 20 Jul 2017 11:51:25 +0000 (04:51 -0700)]
Add folly non null

Add non null annotation to
folly to help with linters
complaining when a pointer could
be null, however it never is.

Reviewed By: yfeldblum

Differential Revision: D5453255

fbshipit-source-id: cf7ccbcc86d171ef4f6d373b6f751f709e4587b1

6 years agoMove futures helper types into folly::futures::detail
Yedidya Feldblum [Thu, 20 Jul 2017 08:59:24 +0000 (01:59 -0700)]
Move futures helper types into folly::futures::detail

[Folly] Move futures helper types into `folly::futures::detail`.

From `folly::detail`, where it would be easier to collide. Especially for names like `Core`.

Reviewed By: WillerZ

Differential Revision: D5460766

fbshipit-source-id: 3f7bff784bbb89c7c86d2f1824323d71321c7ad6

6 years agodo not crash process by default when ExceptionTracer fails to reflect over cxxabi
Benjamin Reesman [Thu, 20 Jul 2017 07:08:50 +0000 (00:08 -0700)]
do not crash process by default when ExceptionTracer fails to reflect over cxxabi

Summary: It is possible in certain cirucmstances for the cxxabi reflection code in `ExceptionTracer` to fail to cope with exceptions that we've seen in production and it currently aborts the process in that case. This diff switches this to `DFATAL`/`DCHECK`.

Reviewed By: yfeldblum

Differential Revision: D5431445

fbshipit-source-id: c3d68372c2fadbb518f78fe99e817db611953d22

6 years agoVisit, for monitoring or mutating pipelines
Tom Jackson [Thu, 20 Jul 2017 00:22:27 +0000 (17:22 -0700)]
Visit, for monitoring or mutating pipelines

Summary: The pattern `mapped([](auto&& i) { ...; return std::move(i); }` is quite common. Evidently people need some good mechanism to just observe or possibly mutate items in pipelines. Note that this is still lazy, it is only called when the pipeline is run.

Reviewed By: yfeldblum

Differential Revision: D5457196

fbshipit-source-id: 3a892b8895e02dd8fcd6a7fd4d3b27063d1b071f

6 years agochange the definition of FOLLY_MAYBE_UNUSED
Victor Gao [Wed, 19 Jul 2017 23:24:54 +0000 (16:24 -0700)]
change the definition of FOLLY_MAYBE_UNUSED

Currently gcc does not support attributes declared using square brackets well and some builds might break because of this.

Since `__attribute__((...))` works for both clang and gcc, we should switch to it for now.

Reviewed By: yfeldblum

Differential Revision: D5456734

fbshipit-source-id: d7a8bf1389afc5d60604f22d37c93611dc46259c

6 years ago3-way crc32c
Dave Watson [Wed, 19 Jul 2017 20:47:15 +0000 (13:47 -0700)]
3-way crc32c

Summary: Current folly version uses a single crc32c.  crc32c has a latency of 3, so pipelining three in a row makes it nearly 3x faster (for data all in cache).

Reviewed By: yfeldblum

Differential Revision: D5418228

fbshipit-source-id: d3a250e1b4fe1f0bc99b44c660df94cf233aebd6

6 years agoAdd SSLOptions to
Xiangyu Bu [Wed, 19 Jul 2017 19:24:46 +0000 (12:24 -0700)]
Add SSLOptions to

Summary: Add paths of SSLOptions.{cpp, h} to folly/

Reviewed By: Orvid

Differential Revision: D5453343

fbshipit-source-id: ba0b8b065ed964dfff1757533db17e31aa672e83

6 years agoappend the interface index instead of throwing an exception when the scope id lookup...
Eli Lindsey [Wed, 19 Jul 2017 15:51:26 +0000 (08:51 -0700)]
append the interface index instead of throwing an exception when the scope id lookup fails

Summary: As written, this str() method depends on the current state of the host - if an interface disappears (as is commong with eg. mobile, ipsec, etc.) then attempting to generate a string representation of this v6 address will currently throw an exception. Instead, we're going toignore the lookup failure and append the index i; this form is interchangeable, though slightly less legible.

Reviewed By: yfeldblum

Differential Revision: D5443618

fbshipit-source-id: bbd3b4edaee8098671140af7400377d5e2b1937b

6 years agoAtomicCoreCachedSharedPtr
Dave Watson [Wed, 19 Jul 2017 13:24:33 +0000 (06:24 -0700)]

Summary: A folly::atomic_shared_ptr version of CoreCachedSharedPtr.

Reviewed By: yfeldblum

Differential Revision: D5389603

fbshipit-source-id: 942700cd66f5f5219418f4c6112146dc40351aa0

6 years agoSupport if_indextoname in the socket portability header v2017.07.17.01
Christopher Dykes [Tue, 18 Jul 2017 22:52:33 +0000 (15:52 -0700)]
Support if_indextoname in the socket portability header

Summary: Windows doesn't have `net/if.h` and instead needs `iphlpapi.h` included, and `ntddndis.h` is ultimately needed to get the definition of `IF_NAMESIZE`.

Reviewed By: yfeldblum

Differential Revision: D5438188

fbshipit-source-id: 48a786f7d10ca4b8479bb20b257ed1e857431654

6 years agoadd FOLLY_MAYBE_UNUSED
Victor Gao [Tue, 18 Jul 2017 20:19:24 +0000 (13:19 -0700)]

Summary: This adds a macro `FOLLY_MAYBE_UNUSED` in `folly/CppAttributes.h` that can be used to suppress `-Wunused` warnings.

Reviewed By: yfeldblum

Differential Revision: D5444742

fbshipit-source-id: b16e8efefd76282498ad6114bac9548064cf38d5

6 years agoFunctions to set common ciphers and sig algs for SSLContext.
Xiangyu Bu [Tue, 18 Jul 2017 19:27:32 +0000 (12:27 -0700)]
Functions to set common ciphers and sig algs for SSLContext.

This diff contains some helper functions that set a `SSLContext` object with recommended
lists of ciphers and signature algorithms for given scenarios. In addition, DES and CHACHA are removed from the cipher list.

Reviewed By: yfeldblum

Differential Revision: D5373599

fbshipit-source-id: 04de11fe90cac734caa12a80e56f70532803f94e

6 years agoEnsure the allocator types in the string keyed tests have value_types matching the...
Christopher Dykes [Tue, 18 Jul 2017 17:01:30 +0000 (10:01 -0700)]
Ensure the allocator types in the string keyed tests have value_types matching the value type of the collection

Because MSVC's standard library implementation is now checking that this is actually the case:
error C2338: set<T, Compare, Allocator> requires that Allocator's value_type match T (See N4659 26.2.1 [container.requirements.general]/16 allocator_type) Either fix the allocator value_type or define _ENFORCE_MATCHING_ALLOCATORS=0 to suppress this diagnostic.

I've gone with the "Fix the `value_type`" approach.

Reviewed By: yfeldblum

Differential Revision: D5441017

fbshipit-source-id: b30403d2e48f815177cac29c4e6eec4e79583660

6 years agoRelax alignment restriction in CachelinePadded
Phil Willoughby [Tue, 18 Jul 2017 10:14:07 +0000 (03:14 -0700)]
Relax alignment restriction in CachelinePadded

Summary: 32-bit iOS environments were triggering the previous condition with LifoSem.

Reviewed By: yfeldblum

Differential Revision: D5442057

fbshipit-source-id: 64ee32b4ad35150c7f295a2a30bbede8fa13e79e

6 years agoAdd support for tagging a test as BROKEN in the CMake build
Christopher Dykes [Tue, 18 Jul 2017 01:59:11 +0000 (18:59 -0700)]
Add support for tagging a test as BROKEN in the CMake build

Summary: Also use it to disable function_test and indexed_mem_pool_test for now while the source of their breakage is being investigated.

Reviewed By: yfeldblum

Differential Revision: D5440415

fbshipit-source-id: 630c884ccd2db660bfc3e4529a2d35941d3bd0d3

6 years agoLua exception handling test
Dan Melnic [Tue, 18 Jul 2017 01:50:41 +0000 (18:50 -0700)]
Lua exception handling test

Summary: Lua exception handling test - start with the failing test first - code from D5431445

Reviewed By: yfeldblum

Differential Revision: D5432254

fbshipit-source-id: 87f5934f28ac6ef7b55314acb3c150b9ccf6c799

6 years agoDon't build the async signal handler test on Windows
Christopher Dykes [Mon, 17 Jul 2017 22:47:32 +0000 (15:47 -0700)]
Don't build the async signal handler test on Windows

Summary: `AsyncSignalHandler` is not currently supported on Windows, so we shouldn't be attempting to build it.

Reviewed By: yfeldblum

Differential Revision: D5437276

fbshipit-source-id: b3f281bfc501444bb22056860ee785a2beb9b671

6 years agoUse more libstdc++ specific macro
Tommy Nguyen [Mon, 17 Jul 2017 20:03:48 +0000 (13:03 -0700)]
Use more libstdc++ specific macro

- The __GNUC__ macro is used by other compilers like Clang and
  ICC, but ext/stdio_filebuf.h is a libstdc++ only extension.

fixes #636

Reviewed By: yfeldblum

Differential Revision: D5434532

Pulled By: Orvid

fbshipit-source-id: ce4f966a74aa9f82ae907c67807ac87ec1588173

6 years agoEnable a couple of AsyncFileWriter tests on Windows
Christopher Dykes [Mon, 17 Jul 2017 19:57:29 +0000 (12:57 -0700)]
Enable a couple of AsyncFileWriter tests on Windows

There is no longer anything keeping them from working on Windows.
Except for that `signal(SIGPIPE, SIG_IGN)` call; that has to stay disabled.

Reviewed By: simpkins

Differential Revision: D5308007

fbshipit-source-id: 74a392cf484404f41a6c51e50b5a9e6fbd05b4a9

6 years agoLet exception_wrapper::handle, when empty, show the right error message v2017.07.17.00
Yedidya Feldblum [Mon, 17 Jul 2017 05:07:08 +0000 (22:07 -0700)]
Let exception_wrapper::handle, when empty, show the right error message

[Folly] Let `exception_wrapper::handle`, when empty, show the right error message.

The error message currently says that `throw_exception` cannot be called on an empty `exception_wrapper`, but should say that `handle` cannot be called on an empty `exception_wrapper`.

Reviewed By: Orvid

Differential Revision: D5432380

fbshipit-source-id: ffa69c7675ee332e596e861e59ea273c39fc4717

6 years agoCodeMod: Prefer ADD_FAILURE() over EXPECT_TRUE(false), et cetera
Yedidya Feldblum [Mon, 17 Jul 2017 04:23:33 +0000 (21:23 -0700)]
CodeMod: Prefer ADD_FAILURE() over EXPECT_TRUE(false), et cetera

CodeMod: Prefer `ADD_FAILURE()` over `EXPECT_TRUE(false)`, et cetera.

The tautologically-conditioned and tautologically-contradicted boolean expectations/assertions have better alternatives: unconditional passes and failures.

Reviewed By: Orvid

Differential Revision:

Tags: codemod, codemod-opensource

fbshipit-source-id: d16b447e8696a6feaa94b41199f5052226ef6914

6 years agoUse long long for the 64-bit fingerprint table
Christopher Dykes [Sat, 15 Jul 2017 07:48:16 +0000 (00:48 -0700)]
Use long long for the 64-bit fingerprint table

Summary: Because these are always 64-bit values. This hasn't actually been an issue but is the correct thing to do.

Reviewed By: yfeldblum

Differential Revision: D5425658

fbshipit-source-id: 5bc204b3d1af2c710bd8b1665211d2971ccf7be7

6 years agoReplace all includes of pthread.h with the portability header
Christopher Dykes [Fri, 14 Jul 2017 22:59:17 +0000 (15:59 -0700)]
Replace all includes of pthread.h with the portability header

Summary: It is a non-portable include as it is include-order sensitive.

Reviewed By: yfeldblum

Differential Revision: D5427885

fbshipit-source-id: 50850064fc8fa3ed6f8fc235f31edbda4144663c

6 years agoSwitch future's Core<T> to std::is_nothrow_constructible
Christopher Dykes [Fri, 14 Jul 2017 22:17:31 +0000 (15:17 -0700)]
Switch future's Core<T> to std::is_nothrow_constructible

MSVC has issues with the way it was written, so just use the standard version instead.

Upstream bug report:

Reviewed By: yfeldblum

Differential Revision: D5427029

fbshipit-source-id: ae3737175d5b8e9738ed6b9573412d1d566b0e1c

6 years agoAdd an sfmt19937 benchmark (again)
Christopher Dykes [Fri, 14 Jul 2017 18:07:28 +0000 (11:07 -0700)]
Add an sfmt19937 benchmark (again)

Summary: `__gnu_cxx::sfmt19937` is 3.5x faster than `std::mt19937` according to the benchmark.

Reviewed By: yfeldblum

Differential Revision: D5410705

fbshipit-source-id: d503544a0b9b1b0c614a27466a297a4e6902fc15

6 years agoRe-align LifoSem
Phil Willoughby [Fri, 14 Jul 2017 17:44:50 +0000 (10:44 -0700)]
Re-align LifoSem

Previously it generated a warning if compiled with -Wover-align because its alignment exceeded alignof(std::max_align_t).

This also meant that heap-allocated LifoSem objects were not guaranteed to be on their own cache-line, potentially degrading performance.

This change adds padding before the important part of the LifoSem (to match the existing after-padding) and reduces its alignment requirement.

Reviewed By: yfeldblum

Differential Revision: D5380700

fbshipit-source-id: 7fdd593a58a2e0c7b03df11152ee4bb66f57e717

6 years agoFix building the stl_vector tests with -Wshadow-compatible-local
Christopher Dykes [Fri, 14 Jul 2017 17:29:54 +0000 (10:29 -0700)]
Fix building the stl_vector tests with -Wshadow-compatible-local

Summary: It was shadowing locals.

Reviewed By: yfeldblum

Differential Revision: D5422356

fbshipit-source-id: 91da6fcf0b2ea3821394068e9847976e04f43ca9

6 years agoreplace getnameinfo with inet_ntop in v6 string formatting
Eli Lindsey [Fri, 14 Jul 2017 13:07:12 +0000 (06:07 -0700)]
replace getnameinfo with inet_ntop in v6 string formatting

Summary: Some implementations of getnameinfo are triggering reverse DNS lookups despite us specifying NI_NUMERICHOST. Avoid all that by instead producing our string representations of v6 addresses manually via inet_ntop and if_indextoname.

Reviewed By: yangchi

Differential Revision: D5415477

fbshipit-source-id: 67853a85db6517d374d94c8261e56400f4c00fc5

6 years agoUpdate CachelinePadded
Phil Willoughby [Fri, 14 Jul 2017 09:56:14 +0000 (02:56 -0700)]
Update CachelinePadded

The C++ standard doesn't guarantee alignment of things bigger than std::max_align_t which is typically 16 bytes. This means that to ensure something is the only thing on a cache-line we need padding on each side of it to exclude anything else.

CachelinePadded<T> will now be larger than it was before, and reinterpret_cast to/from T is no longer valid.

Reviewed By: yfeldblum

Differential Revision: D5380849

fbshipit-source-id: 20f275c875eb4bede4aef19ac7224913ce9b6d51

6 years agoBreak long lines in SSLContext.
Xiangyu Bu [Fri, 14 Jul 2017 00:58:22 +0000 (17:58 -0700)]
Break long lines in SSLContext.

Summary: Break a few long lines in folly::SSLContext.

Reviewed By: yfeldblum

Differential Revision: D5418517

fbshipit-source-id: fc2ac310d1f931a1f8a4af077aa5cde347b1042d

6 years agoFix the build of the socket tests on Windows
Christopher Dykes [Thu, 13 Jul 2017 18:53:11 +0000 (11:53 -0700)]
Fix the build of the socket tests on Windows

Summary: There were references to things that don't exist or have an equivalent on Windows.

Reviewed By: yfeldblum

Differential Revision: D5099802

fbshipit-source-id: 9a5a2d0e5cb3a33ecad00bf8a2e1c13315a015cc

6 years agoAdd support for closing a TemporaryFile early
Christopher Dykes [Thu, 13 Jul 2017 18:50:36 +0000 (11:50 -0700)]
Add support for closing a TemporaryFile early

The file itself will still get removed when `TemporaryFile` is destroyed, but closing it before then allows it to be read when on Windows, because `TemporaryFile` opens the temporary file with `O_EXCL`, so Windows denies read access of the file to everything else.
This is needed to fix one of the AsyncFileWriter tests on Windows.

Reviewed By: simpkins

Differential Revision: D5307719

fbshipit-source-id: bd65962cc3d34f382cc7b0b55dbf2659ed5ebfce

6 years agoForce string pooling to workaround a codegen bug
Christopher Dykes [Thu, 13 Jul 2017 17:57:07 +0000 (10:57 -0700)]
Force string pooling to workaround a codegen bug

There are bugs in MSVC's codegen that causes `StringPiece`'s evaluated in a `constexpr` context to have the start pointer point to one copy of the string and the end pointer point to another. Using the `StringPiece` at compile-time is perfectly fine, it just has the wrong values at runtime.
We can work around this issue by enabling string pooling in all modes.

Original bug report:

Reviewed By: yfeldblum

Differential Revision: D5409753

fbshipit-source-id: 24e2b343209ba7c86d0dd39a1358d0abe9ee6d4d

6 years agoGetters and setters for ECDSA_SIG
Ankit Shah [Thu, 13 Jul 2017 17:06:49 +0000 (10:06 -0700)]
Getters and setters for ECDSA_SIG

Added getters and setters for ECDSA_SIG to allow for compatibility
between OpenSSL 1.1.0 and 1.0.2

Reviewed By: knekritz

Differential Revision: D5408934

fbshipit-source-id: 7a3d9df774728c81270cc4da34c75202018e430d

6 years agoSort #include lines
Yedidya Feldblum [Thu, 13 Jul 2017 02:53:53 +0000 (19:53 -0700)]
Sort #include lines

Summary: [Folly] Sort `#include` lines, as required by `clang-format`.

Reviewed By: igorsugak, Orvid

Differential Revision: D5405153

fbshipit-source-id: 3bb1c2b84271bcf7a195e07680777dbfdd499823

6 years agoRevert D5408572: replace getnameinfo with inet_ntop in v6 string formatting
Eli Lindsey [Thu, 13 Jul 2017 00:47:29 +0000 (17:47 -0700)]
Revert D5408572: replace getnameinfo with inet_ntop in v6 string formatting

Summary: This reverts commit 69b0171a9a54738045f9041381aea5512b17eb13

Differential Revision: D5408572

fbshipit-source-id: 3ec8ce96575b632fb134be99cc0d2538a01a7d85

6 years agoreplace getnameinfo with inet_ntop in v6 string formatting
Eli Lindsey [Wed, 12 Jul 2017 23:36:57 +0000 (16:36 -0700)]
replace getnameinfo with inet_ntop in v6 string formatting

Summary: Some implementations of getnameinfo are triggering reverse DNS lookups despite us specifying NI_NUMERICHOST. Avoid all that by instead producing our string representations of v6 addresses manually via inet_ntop and if_indextoname.

Differential Revision: D5408572

fbshipit-source-id: 69b0171a9a54738045f9041381aea5512b17eb13

6 years agoFix documentation for folly's to<double>() method's handling of 'NaN' and unparseable...
Mickey Phoenix [Wed, 12 Jul 2017 20:49:10 +0000 (13:49 -0700)]
Fix documentation for folly's to<double>() method's handling of 'NaN' and unparseable inputs

The documentation for folly::to<double>()'s handling of unparseable inputs (including "") is incorrect.  Additionally, the documentation does not document to<double>()'s handling of the inputs "NaN", "-NaN", "inf", "infinity", "-inf", and "-infinity".

This corrects the documentation.

See under the heading "Parsing floating-point types" for the incorrect documentation as rendered.

Reviewed By: yfeldblum

Differential Revision: D5367656

fbshipit-source-id: 22b38e2bb85d2e647975798360ead39eed6caae8

6 years agoDon't use range construction for associative containers in convertTo()
Tom Jackson [Wed, 12 Jul 2017 18:32:18 +0000 (11:32 -0700)]
Don't use range construction for associative containers in convertTo()

Summary: This avoids having exceptions occur while constructing hashtables.

Reviewed By: ot, yfeldblum

Differential Revision: D5384419

fbshipit-source-id: ba2de8cffa46df550bdc62abbe529801249e45cd

6 years agoImprove launder
Phil Willoughby [Wed, 12 Jul 2017 07:36:17 +0000 (00:36 -0700)]
Improve launder

Should now work on GCC-compatible compilers, and all other compilers which don't attempt any inter-TU optimizations.

Moved out of Utility.h because it now requires a supporting .cpp file and some clients presume that Utility.h can be used header-only.

Reviewed By: ot

Differential Revision: D5381042

fbshipit-source-id: 7e954fed47de4386c85d46a61d56a8fe7fc516f4

6 years agoRevert D5393697: [Folly] Add an sfmt19937 benchmark
Christopher Dykes [Tue, 11 Jul 2017 23:46:22 +0000 (16:46 -0700)]
Revert D5393697: [Folly] Add an sfmt19937 benchmark

Summary: This reverts commit bc725838dc7f62d030c7e68bc6d229042df2b46c

Differential Revision: D5393697

fbshipit-source-id: 4b9ef1e733b0ad73e6deea7ac8a52dfe785b4f2b

6 years agoadd helper method to generate same crc32 results as php and boost::crc_32_type
Benjamin Renard [Tue, 11 Jul 2017 22:54:24 +0000 (15:54 -0700)]
add helper method to generate same crc32 results as php and boost::crc_32_type

This revision adds a helper method in folly/Checksum.h, that returns the same crc32 value as php's built-in implementationa and boost::crc_32_type.

folly's default implementation only differs from the final xor (with 0xFFFFFFFF for boost and php, 0 for folly), which is added here.

Reviewed By: djwatson

Differential Revision: D5396671

fbshipit-source-id: 14874af2d5a80408c772875142de6e340ce01038

6 years agoAdd an sfmt19937 benchmark
Christopher Dykes [Tue, 11 Jul 2017 20:45:18 +0000 (13:45 -0700)]
Add an sfmt19937 benchmark

Summary: `__gnu_cxx::sfmt19937` is 3.5x faster than `std::mt19937` according to the benchmark.

Reviewed By: yfeldblum

Differential Revision: D5393697

fbshipit-source-id: bc725838dc7f62d030c7e68bc6d229042df2b46c

6 years agoAllow fiber to be called on both type Fiber and Fiber*
Peter DeLong [Tue, 11 Jul 2017 20:42:46 +0000 (13:42 -0700)]
Allow fiber to be called on both type Fiber and Fiber*

Summary: The fiber command can now be run on a value of type folly::fibers::Fiber or a value of type folly::fibers::Fiber*

Reviewed By: andriigrynenko

Differential Revision: D5393491

fbshipit-source-id: 1f48e08288f75c59852c939062db616eb06cea73

6 years agoUse Baton (again) in EventBase::runInEventBaseThreadAndWait
Giuseppe Ottaviano [Tue, 11 Jul 2017 17:21:38 +0000 (10:21 -0700)]
Use Baton (again) in EventBase::runInEventBaseThreadAndWait

`Baton` is more lightweight than a mutex+condition variable, and the code is much simpler. This was actually the original implementation, but the dependency had to be dropped because `Baton` was unsupported on some architectures. That is not a problem anymore.

Also reorganize the includes to follow the conventions.

Reviewed By: andriigrynenko, yfeldblum

Differential Revision: D5396631

fbshipit-source-id: d782cf271eb35723aaeb3c372e1c1dafeaaf0f0a

6 years agoUpdate providedCiphersStr_ in one place.
Xiangyu Bu [Tue, 11 Jul 2017 17:00:51 +0000 (10:00 -0700)]
Update providedCiphersStr_ in one place.

The function `setCipherList` seems to forget to update the data member
`providedCipherString_`. This diff updates `providedCiphersString_` at
a single place `setCiphersOrThrow()`, and adds two test cases to make
sure the derived `SSL*` uses the desired set of ciphers.

Reviewed By: yfeldblum

Differential Revision: D5372758

fbshipit-source-id: 8144ab3bc518b2b9fa8090af62f3bd6475bbbece

6 years agoCompute masks in IPAddressV6
Yedidya Feldblum [Tue, 11 Jul 2017 08:20:38 +0000 (01:20 -0700)]
Compute masks in IPAddressV6

[Folly] Compute masks in `IPAddressV6`.

At runtime, instead of storing a 2Kb masks array in the binary.

Reviewed By: WillerZ, ot

Differential Revision: D5369901

fbshipit-source-id: 031a4eeda1670021236d8ab97f6e85e753675ae5