5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 years agoAdd function to to get the address of a specific fiber from a fiberMa...
Peter DeLong [Tue, 11 Jul 2017 01:22:14 +0000 (18:22 -0700)]
Add function to to get the address of a specific fiber from a fiberManager

Summary: Add a fiber_address(fiberManager, index) function so that you can programatically get the address of a given fiber in a fiberManager

Reviewed By: andriigrynenko

Differential Revision: D5377605

fbshipit-source-id: b9504f7d253e8f702e9329c6f08ff406d4296a6e

5 years agoAdd some more OpenSSL 1.1 APIs for folly/portability/
Fred Emmott [Mon, 10 Jul 2017 20:43:13 +0000 (13:43 -0700)]
Add some more OpenSSL 1.1 APIs for folly/portability/

Summary: refs hhvm/packaging#128

Reviewed By: anirudhvr

Differential Revision: D5380271

fbshipit-source-id: 1cc206d9970b843c3582556096f3ceabeb8d01f6

5 years agoadd the getnameinfo error code and v6 scope id to exception text
Eli Lindsey [Mon, 10 Jul 2017 15:54:21 +0000 (08:54 -0700)]
add the getnameinfo error code and v6 scope id to exception text

Summary: Making the exception text more useful by adding getnameinfo's error code and the v6 scope id

Reviewed By: yangchi

Differential Revision: D5389137

fbshipit-source-id: e6b9b4edd7dd1859e0ed4d784b2f89a60a701955

5 years agoIn-place construction for Future v2017.07.10.00
Yedidya Feldblum [Sun, 9 Jul 2017 03:59:42 +0000 (20:59 -0700)]
In-place construction for Future

[Folly] In-place construction for `Future`.

Using `in_place` as the first argument. Avoid constructing a contained object and then moving it into the `Future`, which may be more expensive, by providing an unambiguous way to specify perfect forwarding.

And a matching overload of `makeFuture` for no particularly good reason.

Differential Revision: D5362324

fbshipit-source-id: e612965f34ed0fae5fac17db631f7eab9984c696

5 years agoOption to set thread name for EventBaseThread
Alan Frindell [Sat, 8 Jul 2017 04:06:02 +0000 (21:06 -0700)]
Option to set thread name for EventBaseThread

Summary: as in title

Reviewed By: yfeldblum

Differential Revision: D5382995

fbshipit-source-id: 87534e6092f167399943287182ec61ae21e608c6

5 years agomake FunctionRef constexpr on compilers that support it
Eric Niebler [Fri, 7 Jul 2017 23:31:31 +0000 (16:31 -0700)]
make FunctionRef constexpr on compilers that support it

`constexpr` All The Things! Although only very recent versions of modern compilers support this, FunctionRef can and should be `constexpr` (demonstration here:

This change also changes the `FunctionRef` constructor such that it no longer participates in overload resolution if the argument is not callable with the specified arguments. In addition, it perfectly forwards the callable object such that if it was an rvalue when it was passed to the constructor, it will be invoked as an rvalue in `operator()`.

Reviewed By: yfeldblum

Differential Revision: D5366720

fbshipit-source-id: bc64053213478aab5a5bd5950c7b2d6f364d86bd

5 years agoAdds `make_mock` to `folly::LeakySingleton`.
Jiahao Li [Fri, 7 Jul 2017 19:22:51 +0000 (12:22 -0700)]
Adds `make_mock` to `folly::LeakySingleton`.

Provides a `make_mock` interface to `folly::LeakySingleton` for unit test

Reviewed By: andriigrynenko

Differential Revision: D5382003

fbshipit-source-id: 9ab81dd64703f4f02772bfb8c85e020680abcc85

5 years agoDetermine noexcept'ness of folly::Optional with std::is_nothrow_constructible
Christopher Dykes [Fri, 7 Jul 2017 09:59:14 +0000 (02:59 -0700)]
Determine noexcept'ness of folly::Optional with std::is_nothrow_constructible

Summary: Because MSVC is not happy about how it's written now.

Reviewed By: yfeldblum

Differential Revision: D5378740

fbshipit-source-id: 8b77d1a05da75b331e0cb72bd0ad859b89e54b36

5 years agoDefine OPENSSL_NO_SSL2 under OpenSSL 1.1.0
Christopher Dykes [Thu, 6 Jul 2017 19:33:46 +0000 (12:33 -0700)]
Define OPENSSL_NO_SSL2 under OpenSSL 1.1.0

Summary: OpenSSL 1.1.0 drops support for SSLv2, and in doing so also removes the define that user-code used to guard on whether SSLv2 was supported. This adds the define to the portability header to indicate SSLv2 is not supported.

Reviewed By: anirudhvr

Differential Revision: D5376869

fbshipit-source-id: 04708db138dc13e7747cfff582f4cfed291648b3

5 years agolaunder
Phil Willoughby [Thu, 6 Jul 2017 07:09:18 +0000 (00:09 -0700)]

Summary: Backport C++17's `std::launder`.

Reviewed By: yfeldblum, ot

Differential Revision: D5370531

fbshipit-source-id: b7cc6701d082b6c4855fa77bb644e151ce882deb

5 years agofix double comparison in histogram test
Adam Simpkins [Wed, 5 Jul 2017 19:56:00 +0000 (12:56 -0700)]
fix double comparison in histogram test

The TestDoubleWidthTooBig test was performing an exact equality check on
two double values. This equality check fails when run on 32-bit

Replace the EXPECT_EQ() check with EXPECT_NEAR(), and simply check that
the two values do not differ by more than 1e-14.

Reviewed By: Orvid

Differential Revision: D652767

fbshipit-source-id: 7bf7ed560a4180a2e2d07a6050d1df18e18d1eea

5 years agologging: fix compiler compatibility for one more constexpr function
Adam Simpkins [Wed, 5 Jul 2017 17:48:49 +0000 (10:48 -0700)]
logging: fix compiler compatibility for one more constexpr function

Update LogLevel's operator+() to consist only of a single return statement.
This is required for pre-C++14 compiler support.

Reviewed By: yfeldblum

Differential Revision: D5368256

fbshipit-source-id: 9ecbcde5edd1d0b3e7580d6263ad926e44908219

5 years agoPromise<T>::makeEmpty() and Future<T>::makeEmpty()
Yedidya Feldblum [Wed, 5 Jul 2017 16:38:08 +0000 (09:38 -0700)]
Promise<T>::makeEmpty() and Future<T>::makeEmpty()

[Folly] `Promise<T>::makeEmpty()` and `Future<T>::makeEmpty()`.

These can currently be done by creating, and then moving away from, regular promises and futures. But that allocates; this is semantically equivalent but more efficient.

Differential Revision: D5368339

fbshipit-source-id: de054cfc75c701c5d39aac64d9a2949cd34b1896

5 years agofolly/futures/detail/Core.h: avoid FP from clang's -Wconditional-uninitialized
Jim Meyering [Wed, 5 Jul 2017 06:56:54 +0000 (23:56 -0700)]
folly/futures/detail/Core.h: avoid FP from clang's -Wconditional-uninitialized

Avoid this false positive from clang:

  folly/futures/detail/Core.h:369:15: error: variable 'priority' may be uninitialized when used here [-Werror,-Wconditional-uninitialized]

Reviewed By: yfeldblum

Differential Revision: D5369916

fbshipit-source-id: 49649417d1b799cc3945cba456b42ab438ad2ddc

5 years agoApply clang-format to folly/stats/
Yedidya Feldblum [Tue, 4 Jul 2017 05:28:37 +0000 (22:28 -0700)]
Apply clang-format to folly/stats/

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

Reviewed By: Orvid

Differential Revision: D5366745

fbshipit-source-id: 3b7419d4ab4c6203693603722cd8e707741d3953

5 years agoApply clang-format to folly/ssl/
Yedidya Feldblum [Tue, 4 Jul 2017 03:01:32 +0000 (20:01 -0700)]
Apply clang-format to folly/ssl/

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

Reviewed By: Orvid

Differential Revision: D5366760

fbshipit-source-id: ad4ec0570050f80d69c78626906e18b5892a999f

5 years agoApply clang-format to folly/concurrency/
Yedidya Feldblum [Tue, 4 Jul 2017 02:41:36 +0000 (19:41 -0700)]
Apply clang-format to folly/concurrency/

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

Reviewed By: Orvid

Differential Revision: D5366946

fbshipit-source-id: 2c9de7c4d8534e02c367fd235fb1ea943ba0539e

5 years agoExtract the namespace choice in FBString.h
Yedidya Feldblum [Tue, 4 Jul 2017 01:57:07 +0000 (18:57 -0700)]
Extract the namespace choice in FBString.h

[Folly] Extract the namespace choice in `FBString.h`.

The funny `namespace` bits confuse `clang-format`, so let us remove the confusion.

Reviewed By: ot, Orvid

Differential Revision: D5367299

fbshipit-source-id: efca65fecc70076829c14e31a835bc91f3efb4a4

5 years agoApply clang-format to folly/io/ (namespace)
Yedidya Feldblum [Tue, 4 Jul 2017 00:52:24 +0000 (17:52 -0700)]
Apply clang-format to folly/io/ (namespace)

Summary: [Folly] Apply `clang-format` to `folly/io/` (namespace).

Reviewed By: Orvid, terrelln

Differential Revision: D5366477

fbshipit-source-id: b4efcdc66c62885f5574b2940e5138590710deae

5 years agoFix tests in CMake build
Christopher Dykes [Tue, 4 Jul 2017 00:32:55 +0000 (17:32 -0700)]
Fix tests in CMake build

Summary: The fix for this didn't get made before the commit landed.

Reviewed By: yfeldblum

Differential Revision: D5367593

fbshipit-source-id: 4ed9c781121d1b23db11d75d0f8d017d1d8663d9

5 years agoFix build of SysUio portability header
Christopher Dykes [Mon, 3 Jul 2017 22:15:31 +0000 (15:15 -0700)]
Fix build of SysUio portability header

Summary: When I moved the change internally, I failed to add the `#include` that was required :(

Reviewed By: yfeldblum

Differential Revision: D5366037

fbshipit-source-id: 7ddf8fc0b7a0468d0831e886d8025c1893f7f8ae

5 years agoconstexpr the Unit comparison ops
Eric Niebler [Mon, 3 Jul 2017 21:13:27 +0000 (14:13 -0700)]
constexpr the Unit comparison ops

Summary: `constexpr` All The Things!

Reviewed By: Orvid

Differential Revision: D5364910

fbshipit-source-id: 11abeb8adc38aef3ac4f2596ecf0f533b9e74203

5 years agoFor futures::retrying, detect policy type using std::result_of
Yedidya Feldblum [Mon, 3 Jul 2017 20:20:29 +0000 (13:20 -0700)]
For futures::retrying, detect policy type using std::result_of

[Folly] For `futures::retrying`, detect policy type using `std::result_of`.

`FOLLY_CREATE_HAS_MEMBER_FN_TRAITS` does not work in all cases. For example, it does not work with inherited members.

And it is not really what we want, anyway, which is to dispatch based on the result type of invoking the policy with a particular set of arguments. We can do that more directly using `std::result_of`. And if we did not have `std::result_of`, then we could do that with SFINAE directly.

Reviewed By: WillerZ

Differential Revision: D5361808

fbshipit-source-id: 23f969dfd6dbaaa944dc2288e70c3ea11d3398f0

5 years agoContent-conversion constructors for Future
Phil Willoughby [Mon, 3 Jul 2017 12:55:21 +0000 (05:55 -0700)]
Content-conversion constructors for Future

Allows you to construct a `Future<A>` from a `Future<B>` if A can be constructed from `B&&`.

The constructor is `implicit` if and only if `B&&` is convertible to `A`.

This is the same philosophy as Optional, and has the same use-cases.

Reviewed By: yfeldblum

Differential Revision: D5264185

fbshipit-source-id: e2fae373ab549c186a69dc5f4e32481ef7b11bba

5 years agoReplace folly::asm_pause with folly::asm_volatile_pause v2017.07.03.00
Christopher Dykes [Mon, 3 Jul 2017 04:20:10 +0000 (21:20 -0700)]
Replace folly::asm_pause with folly::asm_volatile_pause

Summary: There is no difference, as the statements are already implicitly volatile.

Reviewed By: yfeldblum

Differential Revision: D5363491

fbshipit-source-id: ab5bb878f5ca72aa0de96f82e345213729c071e2

5 years agoIn-place construction for Try
Yedidya Feldblum [Sun, 2 Jul 2017 17:22:35 +0000 (10:22 -0700)]
In-place construction for Try

[Folly] In-place construction for `Try`.

Using `in_place` as the first argumenbt. Avoid move operations.

Reviewed By: Orvid

Differential Revision: D5362568

fbshipit-source-id: 5c2aaf5dba1253c59e384940add411f0f2b570b2

5 years agoIn-place construction for Optional
Yedidya Feldblum [Sun, 2 Jul 2017 17:22:33 +0000 (10:22 -0700)]
In-place construction for Optional

[Folly] In-place construction for `Optional`.

Using `in_place` as the first argument. Avoid move operations.

Reviewed By: Orvid, ot

Differential Revision: D5362563

fbshipit-source-id: 771db2556842d5dec35d1bf2ad6c23358a417d54

5 years agoMove in_place and friends to Utility.h
Yedidya Feldblum [Sun, 2 Jul 2017 17:22:31 +0000 (10:22 -0700)]
Move in_place and friends to Utility.h

[Folly] Move `in_place` and friends to `Utility.h`.

Document that they are backports from C++17.

Reviewed By: Orvid

Differential Revision: D5362364

fbshipit-source-id: 495cb7f339fc558f20d89100c141fc7a243239d5

5 years agoRemove construct_in_place
Yedidya Feldblum [Sun, 2 Jul 2017 17:22:29 +0000 (10:22 -0700)]
Remove construct_in_place

[Folly] Remove `construct_in_place`.

It is an alias for `in_place`, and unnecessary.

Reviewed By: Orvid

Differential Revision: D5362354

fbshipit-source-id: 39ce07bad87185e506fe7d780789b78060008182

5 years agoDisambiguate the various in_place overloads, following C++17
Yedidya Feldblum [Sun, 2 Jul 2017 17:22:27 +0000 (10:22 -0700)]
Disambiguate the various in_place overloads, following C++17

[Folly] Disambiguate the various `in_place` overloads, following C++17.

Forwarding `folly::in_place` is ambiguous because there are multiple overloads and we depend on deduction to choose the correct overload. For example:

enum struct Err {};
Expected<Expected<int, Err>, Err> val(in_place, in_place, 3); // fails to compile

So we must disambiguate the three overloads: the default, the typed, and the indexed.

C++17 defines `std::in_place`, `std::in_place_type<typename>`, and `std::in_place_index<std::size_t>`. Let us mimic that exactly, so that it becomes trivial to swap out our implementations for the standard implementations once we jump to C++17.

Reviewed By: Orvid

Differential Revision: D5362339

fbshipit-source-id: d4012b01796390e74d8c14cdf68af70102608039

5 years agoDon't attempt to lock the file descriptor in readv/writev if it's a socket
Christopher Dykes [Sun, 2 Jul 2017 06:50:37 +0000 (23:50 -0700)]
Don't attempt to lock the file descriptor in readv/writev if it's a socket

There is no way to lock a socket on Windows, so these calls will always fail. Just don't do the lock on Windows.
To do it properly with sockets, this should probably be forwarding to `sendmsg`/`recvmsg`, but this is good enough for now.

Reviewed By: simpkins

Differential Revision: D5307901

fbshipit-source-id: 9855274e932a3e2ec3cacae10363200187e0c01b

5 years agoEnable a missing test in the CMake build
Christopher Dykes [Sat, 1 Jul 2017 03:17:55 +0000 (20:17 -0700)]
Enable a missing test in the CMake build

Summary: This also silences a few warnings in the stl vector tests.

Reviewed By: yfeldblum

Differential Revision: D5350383

fbshipit-source-id: 84df2a7dbfbb23ebb3f15a09f0cb58080b3e06d6

5 years agoFix undefined warning errors
Nate Stedman [Sat, 1 Jul 2017 01:01:42 +0000 (18:01 -0700)]
Fix undefined warning errors

Summary: Xcode 9 is throwing errors because `-Wshadow-local` and `-Wshadow-compatible-local` are undefined in Clang.

Reviewed By: Orvid

Differential Revision: D5356476

fbshipit-source-id: 4cc9f48f796f66decb4beaa66d3e66f486449c19

5 years agoDrop std::max_align_t hack present for GCC 4.8
Christopher Dykes [Fri, 30 Jun 2017 23:20:37 +0000 (16:20 -0700)]
Drop std::max_align_t hack present for GCC 4.8

Summary: Folly no longer supports GCC 4.8, so this is no longer needed.

Reviewed By: yfeldblum

Differential Revision: D5354542

fbshipit-source-id: bd9a2732f22f2176f64f92f0af6f7d59dd59a8d9