6 years agofix FutexTest v2017.06.12.00
Tianjiao Yin [Sat, 10 Jun 2017 05:03:48 +0000 (22:03 -0700)]
fix FutexTest

Summary: 2_ms seems too short. I am not sure whether it's feasible to check whether thread is waiting for an address. We could wait for longer to reduce false alarm.

Reviewed By: nbronson

Differential Revision: D5220819

fbshipit-source-id: 42f31206e9cb7f9addaa049d0e7cd995f6735f6c

6 years agoLet SubprocessError inherit std::runtime_error
Yedidya Feldblum [Sat, 10 Jun 2017 03:19:01 +0000 (20:19 -0700)]
Let SubprocessError inherit std::runtime_error

[Folly] Let `SubprocessError` inherit `std::runtime_error`.

As an added bonus, this gives it `std::runtime_error`'s refcounted string for cheap copies.

Reviewed By: ericniebler

Differential Revision: D5216758

fbshipit-source-id: 43298e06f02cfd88abf2d73f7aa16117a6cb052b

6 years agoReorganize the stats directory
Christopher Dykes [Sat, 10 Jun 2017 02:48:51 +0000 (19:48 -0700)]
Reorganize the stats directory

Summary: The source and tests for the stats directory was spread across folly/detail and folly/test, move them into folly/stats directly instead.

Reviewed By: yfeldblum

Differential Revision: D5216810

fbshipit-source-id: 00a8bb95a4f7830d0bc46b3f914f256a37833b78

6 years agoapply clang-tidy modernize-use-override
Victor Gao [Fri, 9 Jun 2017 18:26:26 +0000 (11:26 -0700)]
apply clang-tidy modernize-use-override

Summary: Use clang-tidy to mechanically add missing `override` and remove redundant `virtual`.

Reviewed By: igorsugak

Differential Revision: D5211868

fbshipit-source-id: 6a85f7c4a543a4c9345ec5b0681a8853707343dc

6 years agoapply clang-tidy modernize-use-override
Victor Gao [Fri, 9 Jun 2017 18:23:25 +0000 (11:23 -0700)]
apply clang-tidy modernize-use-override

Summary: Use clang-tidy to mechanically add missing `override` and remove redundant `virtual`.

Reviewed By: igorsugak

Differential Revision: D5211868

fbshipit-source-id: 4118c4c72f8ec3485507f69679f7e852b3eaeb73

6 years agoSaner test exception in ExceptionWrapperTest.cpp
Yedidya Feldblum [Fri, 9 Jun 2017 06:45:51 +0000 (23:45 -0700)]
Saner test exception in ExceptionWrapperTest.cpp

[Folly] Saner test exception in `ExceptionWrapperTest.cpp`.

Make construction do the work and make `what()` free.

Reviewed By: andrewjcg

Differential Revision: D5216707

fbshipit-source-id: bfb4c2473a61ff7da7a3a01adc85facae30d6586

6 years agoSome more OpenSSL 1.1.0 compat APIs
Anirudh Ramachandran [Fri, 9 Jun 2017 06:06:24 +0000 (23:06 -0700)]
Some more OpenSSL 1.1.0 compat APIs

Summary: Add a few more compatibility wrappers for pre-1.1.0 APIs

Reviewed By: yfeldblum

Differential Revision: D5194164

fbshipit-source-id: ae8db08c31370eca729df2927798b6f4d99ee70c

6 years agoApply clang-format to folly/gen/ (template decls)
Yedidya Feldblum [Fri, 9 Jun 2017 05:34:09 +0000 (22:34 -0700)]
Apply clang-format to folly/gen/ (template decls)

Summary: [Folly] Apply `clang-format` to `folly/gen/` (template decls).

Reviewed By: Orvid

Differential Revision: D5216229

fbshipit-source-id: 1659f1944ccde4de39bccd189bb6490395cf29c2

6 years agoFix OpenSSLUtils to not include headers the wrong way
Christopher Dykes [Fri, 9 Jun 2017 04:15:44 +0000 (21:15 -0700)]
Fix OpenSSLUtils to not include headers the wrong way

Summary: This is entirely the wrong way to include these headers, and is being included within an anon namespace so just wrong.

Reviewed By: yfeldblum

Differential Revision: D5215065

fbshipit-source-id: 499df58c0202f7a1d4482eaa6a0e8b2e1535c763

6 years agoApply clang-format to folly/experimental/exception_tracer/ (headers)
Yedidya Feldblum [Fri, 9 Jun 2017 03:59:50 +0000 (20:59 -0700)]
Apply clang-format to folly/experimental/exception_tracer/ (headers)

[Folly] Apply `clang-format` to `folly/experimental/exception_tracer/` (headers).

With some manual rearrangement in the places where `clang-format` does awkward things, with the result that `clang-format` over the listed directory becomes a no-op.

Reviewed By: Orvid

Differential Revision: D5215212

fbshipit-source-id: 5570f02c238b1874adbc2ff4150f465c947ad0e6

6 years agoApply clang-format to folly/fibers/
Yedidya Feldblum [Thu, 8 Jun 2017 22:26:53 +0000 (15:26 -0700)]
Apply clang-format to folly/fibers/

[Folly] Apply `clang-format` to `folly/fibers/`

With some manual rearrangement in the places where `clang-format` does awkward things, with the result that `clang-format` over `folly/fibers/` becomes a no-op.

Reviewed By: igorsugak

Differential Revision: D5178118

fbshipit-source-id: ae65ff1902666ba9106e18f916bb1d10e6406bf4

6 years agoSwitch unguarded #pragmas to use portability macros
Christopher Dykes [Thu, 8 Jun 2017 21:50:17 +0000 (14:50 -0700)]
Switch unguarded #pragmas to use portability macros

Summary: Otherwise downstream Windows users have to explicitly disable MSVC's warnings about unknown pragmas.

Reviewed By: yfeldblum

Differential Revision: D5211415

fbshipit-source-id: 42871e03895010818c7e1cb6e57c1885970e98c2

6 years agoRefer to nullptr not NULL
Christopher Dykes [Thu, 8 Jun 2017 21:48:12 +0000 (14:48 -0700)]
Refer to nullptr not NULL

Folly is a C++ library not a C library, and (almost) universally uses `nullptr` everywhere, so refer to `nullptr` rather than `NULL`.
This also fixes the 1 place in our actual code where we were using `NULL` rather than `nullptr`.

Reviewed By: yfeldblum

Differential Revision: D5204766

fbshipit-source-id: 2a5d5011a28d7d5dd48789f60643a656f51b9732

6 years agoExtend the -Warray-bounds workaround in FixedString.h to gcc-5.
Eric Niebler [Thu, 8 Jun 2017 19:47:55 +0000 (12:47 -0700)]
Extend the -Warray-bounds workaround in FixedString.h to gcc-5.

Summary: FixedString.h has a workaround for a gcc bug regarding erroneous -Werror=array-bounds errors. This commit extends the workaround to the gcc-5 series, which sadly is still broken. Life gets better with gcc-6.

Reviewed By: luciang

Differential Revision: D5210633

fbshipit-source-id: 4fcf080d18ddc573636a3e58b61a97167a8c06ce

6 years agomake extent_hooks static.
Qi Wang [Thu, 8 Jun 2017 17:26:32 +0000 (10:26 -0700)]
make extent_hooks static.

Make extent hooks static and avoid calling arena_destroy, in case there are
alive allocations not freed yet.

Reviewed By: yfeldblum

Differential Revision: D5208102

fbshipit-source-id: 612c772347cd90227fa303fd0b059edbaeb7d4e2

6 years agoImplement __builtin_popcount under MSVC
Christopher Dykes [Wed, 7 Jun 2017 23:03:27 +0000 (16:03 -0700)]
Implement __builtin_popcount under MSVC

I thought I had already implemented this, but apparently I had only implemented the ll variable. Whoops.
This implements the 32-bit version which fixes the build on Windows.

Reviewed By: yfeldblum

Differential Revision: D5203680

fbshipit-source-id: 02b133db59e232cac586944b0ffc0e8bbf5f533a

6 years agoExclude experimental/hazptr/bench from the globs used in the CMake build
Christopher Dykes [Wed, 7 Jun 2017 23:01:52 +0000 (16:01 -0700)]
Exclude experimental/hazptr/bench from the globs used in the CMake build

Summary: The directory contains benchmarks and multiple `main`'s so shouldn't be included as part of the main folly library.

Reviewed By: yfeldblum

Differential Revision: D5204132

fbshipit-source-id: 7289cb9c2ec292c13df39c9e7b48eca4166ca951

6 years agoPass Try by rvalue ref in onError implementation
Yedidya Feldblum [Wed, 7 Jun 2017 21:39:54 +0000 (14:39 -0700)]
Pass Try by rvalue ref in onError implementation

[Folly] Pass `Try` by rvalue ref in `onError` implementation.

As is done in other overloads and in `thenImplementation`. For consistency.

Reviewed By: spacedentist

Differential Revision: D5199302

fbshipit-source-id: c78db0c36fc7a0b846ca5e44fc237422c9203a24

6 years agoUri: switch to std::string over fbstring take 2
Sonia Mar [Wed, 7 Jun 2017 18:30:55 +0000 (11:30 -0700)]
Uri: switch to std::string over fbstring take 2

Summary: Update tuple generated for hash/equal_to for `folly::Uri` to also use std::string

Reviewed By: Orvid

Differential Revision: D5199266

fbshipit-source-id: bcd619dae01ffbf82fbb5c8987b0e87103572452

6 years agoAdd OpenSSLCertUtils functions for DER encoding/decoding.
Kyle Nekritz [Wed, 7 Jun 2017 14:31:37 +0000 (07:31 -0700)]
Add OpenSSLCertUtils functions for DER encoding/decoding.

Reviewed By: anirudhvr

Differential Revision: D5193205

fbshipit-source-id: 5b427ee4f31008518078f5e54e85c0f0f2201da5

6 years agoShrink the implementations of then and onError
Yedidya Feldblum [Wed, 7 Jun 2017 09:33:31 +0000 (02:33 -0700)]
Shrink the implementations of then and onError

[Folly] Shrink the implementations of `then` and `onError`.

Just a small refactor.

Reviewed By: spacedentist

Differential Revision: D5180784

fbshipit-source-id: a399d18500a2b4c5d8f24dee54891cca802b4461

6 years agoTry::tryGetExceptionObject
Yedidya Feldblum [Wed, 7 Jun 2017 07:05:51 +0000 (00:05 -0700)]

[Folly] `Try::tryGetExceptionObject`.

If the `Try` has a `std::exception` for the non-template overload or a `From` where `is_convertible<From*, Ex*>` for the template overload parameterized by `typename Ex`, returns a pointer to it. Otherwise returns `nullptr`.

Reviewed By: spacedentist

Differential Revision: D5180848

fbshipit-source-id: b7593b7459259f9a1e1e78b36d548e55d086e722

6 years agoRemove exception_wrapper::throwException
Yedidya Feldblum [Wed, 7 Jun 2017 05:16:39 +0000 (22:16 -0700)]
Remove exception_wrapper::throwException

[Folly] Remove `exception_wrapper::throwException`.

It has been renamed to `throw_exception`.

Reviewed By: Orvid

Differential Revision: D5181005

fbshipit-source-id: 442b3fd9bdaa8170db504a81651cbb085ea50624

6 years agoAdd zlib/gzip streaming support
Nick Terrell [Wed, 7 Jun 2017 04:28:09 +0000 (21:28 -0700)]
Add zlib/gzip streaming support

Add streaming interface to the ZlibCodec.
Implement ZlibStreamCodec::doCompress() and ZlibStreamCodec::doUncompress() using the streaming interface. fbgs CodecType::ZLIB and check that no caller requires thread-safety.
I found one caller, but it was fixed in D5090855.

Reviewed By: yfeldblum

Differential Revision: D5169338

fbshipit-source-id: 40478e162143623ad28fd8bc937d0195521f13fe

6 years agoSwitch folly::Uri to use std::string rather than fbstring
Christopher Dykes [Wed, 7 Jun 2017 02:53:27 +0000 (19:53 -0700)]
Switch folly::Uri to use std::string rather than fbstring

Summary: Using fbstring directly is not really worthwhile in the vast majority of cases, especially when most places just convert it into an `std::string` immediately.

Reviewed By: yfeldblum

Differential Revision: D5187835

fbshipit-source-id: 6f7d71612d3765e8b501d2432cd6281369bfe0fa

6 years agoAdd a version of async_test using openssl 1.1.0
Anirudh Ramachandran [Wed, 7 Jun 2017 01:24:35 +0000 (18:24 -0700)]
Add a version of async_test using openssl 1.1.0

Now that it's possible, let's add some 1.1.0 tests to avoid regressing
1.1.0 support

Reviewed By: yfeldblum

Differential Revision: D5167246

fbshipit-source-id: ba12414504131697d4e0757c9c340a66f810acd4

6 years agoFix destruction order problem in getCoreAllocator
Giuseppe Ottaviano [Wed, 7 Jun 2017 00:32:12 +0000 (17:32 -0700)]
Fix destruction order problem in getCoreAllocator

Summary: We cannot guarantee the correct destruction order of the Meyers singleton owning the allocator, and the objects allocated with it, so we just leak it using `Indestructible`.

Reviewed By: djwatson

Differential Revision: D5196227

fbshipit-source-id: ec07ab1e21af7814194883b252d45aa36d2a04b1

6 years agoRename exception_wrapper::get_object to get_exception
Yedidya Feldblum [Tue, 6 Jun 2017 22:02:17 +0000 (15:02 -0700)]
Rename exception_wrapper::get_object to get_exception

[Folly] Rename `exception_wrapper::get_object` to `get_exception`.

This will be a template overload of the existing non-template member `get_exception`, but it should just work.

Reviewed By: spacedentist

Differential Revision: D5180845

fbshipit-source-id: 28e16e039ec6a7939b38f217b4ad5c6bc803f515

6 years agoadditional minor cleanup to the TimeUtil code
Adam Simpkins [Tue, 6 Jun 2017 21:09:41 +0000 (14:09 -0700)]
additional minor cleanup to the TimeUtil code

- Fix TimePoint to use steady_clock rather than system_clock
- Use nanoseconds instead of milliseconds in most locations

This code should probably also be moved into a folly::testing namespace or
something.  This class is pretty specific to unit tests, and `folly::TimePoint`
seems like too generic of a name for it.  However, just to keep things simple
I'm not doing that as part of this diff yet.

Reviewed By: yfeldblum

Differential Revision: D5175630

fbshipit-source-id: 26490fc7ff1b25fb86f09309e81108828cd0f091

6 years agoupdate TimeUtil to use getOSThreadID()
Adam Simpkins [Tue, 6 Jun 2017 21:09:40 +0000 (14:09 -0700)]
update TimeUtil to use getOSThreadID()

Use the newly introduced getOSThreadID() function to get a thread ID for
determining thread scheduling information on Linux.

Reviewed By: yfeldblum

Differential Revision: D5173596

fbshipit-source-id: 3e6fa352c3774986b0ac1f93bd6c7e4a29e08471

6 years agofix timeWaiting computation in TimeUtil
Adam Simpkins [Tue, 6 Jun 2017 21:09:39 +0000 (14:09 -0700)]
fix timeWaiting computation in TimeUtil

Some of the code in TimeUtil.cpp computes how long the current thread has spent
waiting to be schedule on the CPU, so we can discount this time when testing
timeout behavior.

It appears that this code has been broken for a fairly long time.  Older Linux
kernels reported values in /proc/<pid>/schedstat using jiffies.  However, it
appears that this was changed in Linux 2.6.23 to report values using
nanoseconds.  (It looks to me like this was changed in commit 425e0968a25f,
which purports to simply be moving code from sched.c to sched_stats.h,
but it appears to also have also changed this behavior.)

This updates TimeUtil.cpp to compute the value correctly in modern Linux

Reviewed By: yfeldblum

Differential Revision: D5173598

fbshipit-source-id: 98436d3a687400bf68661156ffce93eea7232632

6 years agoCore-local allocator
Dave Watson [Tue, 6 Jun 2017 21:06:53 +0000 (14:06 -0700)]
Core-local allocator

Adds a core-local allocator to CacheLocality.  Multiple objects using
cache locality may share the same allocator, and allocate things less than
cacheline sized, without incurring additional false-sharing overhead.

Reviewed By: nbronson, ot

Differential Revision: D5139886

fbshipit-source-id: a9804662d6339829a12e0791f418dabd9678f1bf

6 years agoFix the build of MallctlHelperTest without JEMalloc
Christopher Dykes [Tue, 6 Jun 2017 20:30:54 +0000 (13:30 -0700)]
Fix the build of MallctlHelperTest without JEMalloc

`kDecayCmd` was guarded such that it wasn't being defined at all if JEMalloc wasn't available.


Reviewed By: interwq

Differential Revision: D5193721

fbshipit-source-id: 1a2666de70e90eac1e9f2e130d0452b01b3239fa

6 years agoAdd element construction/destruction hooks to IndexedMemPool
Victor Zverovich [Tue, 6 Jun 2017 20:10:49 +0000 (13:10 -0700)]
Add element construction/destruction hooks to IndexedMemPool

Summary: This diff adds a Traits template parameter to IndexedMemPool that allows more control over the lifetime management of individual elements, including mixes of lazy and eager recycle semantics (or colocation of different classes of data inside a single element). It also arranges that an index is not reported as isAllocated() until it has been passed to Traits::initialize and passed to Traits::onAllocate at least once, so code that is traversing valid indexes doesn't need to deal with the post-initialize but pre-onAllocate state (it must still deal with indexes that reported isAllocated() as true but have since been passed to onRecycle). The default behavior is unchanged.

Reviewed By: nbronson

Differential Revision: D5177462

fbshipit-source-id: e7d22c860ab6bf25083977dfb5a63955641c9cfb

6 years agoDrop a dead include of FBString.h from MemoryMapping.h
Christopher Dykes [Tue, 6 Jun 2017 18:00:02 +0000 (11:00 -0700)]
Drop a dead include of FBString.h from MemoryMapping.h

Summary: MemoryMapping doesn't use fbstring directly at all, so this include isn't needed.

Reviewed By: yfeldblum

Differential Revision: D5188209

fbshipit-source-id: d86b876a96343c830295bea1162580215a340815

6 years agoadd missing include to ThreadId.h
Adam Simpkins [Tue, 6 Jun 2017 17:22:59 +0000 (10:22 -0700)]
add missing include to ThreadId.h

The syscall() function is defined in <unistd.h>
<sys/syscall.h> apparently only defines IDs to be used with syscall(), but does
not define the syscall() function itself.

This caused build failures for files that included ThreadId.h before unistd.h

Reviewed By: Orvid

Differential Revision: D5189658

fbshipit-source-id: 2ec8ea1d58f3fc14cf458a53ecaa811978527398

6 years agoUninitializedMemoryHacks
Nathan Bronson [Tue, 6 Jun 2017 16:08:51 +0000 (09:08 -0700)]

This diff adds helper functions that can resize std::string or std::vector
without constructing or initializing new elements.  They are designed
for retroactively optimizing code where touching every element twice
(or touching never-used elements once) shows up in profiling, and where
restructuring the code to use fixed-length arrays or IOBuf-s would
be difficult.

Implementations are provided for 5 string implementations (pre-c++11
libstdc++, libstdc++ with SSO, libc++, std::basic_fbstring, and MSVC)
and 3 vector implementations (libstdc++, libc++, and MSVC).  On an
unsupported platform you will hopefully get a #warn if you include
UninitializedMemoryHacks.h followed by a linker error if you actually
use it.

Reviewed By: yfeldblum

Differential Revision: D5102679

fbshipit-source-id: 536c00eabae4cdb8a0affe3e919a372f4dc51ac5

6 years agoUpdate MallctlHelperTest with jemalloc 5 APIs.
Qi Wang [Tue, 6 Jun 2017 06:06:11 +0000 (23:06 -0700)]
Update MallctlHelperTest with jemalloc 5 APIs.

Summary: Update decay time API to be jemalloc 4 & 5 compatible.

Reviewed By: yfeldblum

Differential Revision: D5188574

fbshipit-source-id: 8e3c26c8b6431efdd0ec7ff492a065bddb816b4b

6 years agoadd getOSThreadID()
Adam Simpkins [Tue, 6 Jun 2017 02:07:36 +0000 (19:07 -0700)]
add getOSThreadID()

Add a getOSThreadID() call.  This is similar to getCurrentThreadID(), but
returns the OS-level thread ID.

Reviewed By: yfeldblum

Differential Revision: D5173627

fbshipit-source-id: 0e8695ecfc1e382d12526c1b7d1717be114c9f4a

6 years agoSwitch Bits.h to just use the popcount builtins directly
Christopher Dykes [Mon, 5 Jun 2017 23:38:24 +0000 (16:38 -0700)]
Switch Bits.h to just use the popcount builtins directly

These builtins are available on all platforms under GCC, using the instruction directly when available and a fallback implementation otherwise.
They are implemented in the builtins portability header for MSVC.

Reviewed By: yfeldblum

Differential Revision: D5185106

fbshipit-source-id: a58305a6b99eb49bd165876a4a60c512a259b225

6 years agoRename folly/detail/Malloc.h to folly/detail/MallocImpl.h
Christopher Dykes [Mon, 5 Jun 2017 23:09:11 +0000 (16:09 -0700)]
Rename folly/detail/Malloc.h to folly/detail/MallocImpl.h

Summary: This makes the name of the header match the source file.

Reviewed By: yfeldblum

Differential Revision: D5186193

fbshipit-source-id: b1f9041fb730eacb91ad167e500c25df8f8ba947

6 years agoLet map-related functions be templated over key types
Yedidya Feldblum [Mon, 5 Jun 2017 21:35:46 +0000 (14:35 -0700)]
Let map-related functions be templated over key types

[Folly] Let map-related functions be templated over key types.

This supports the case where map members like `find` may be overloaded or templated on types other than the map's `key_type const&`.

In C++14, standard library map types gain template overloads for `find` and for other members, permitting lookups without constructing `key_type` instances. This is useful primarily when `key_type` is expensive but another object type comparable with `key_type` is inexpensive. As a common example, a `key_type` of `std::string` is expensive in the general case because it allocates storage on the heap but `std::string_view` (C++17), when constructed with non-allocated `char const*, std::size_t`, would be inexpensive.

Reviewed By: terrelln

Differential Revision: D5145879

fbshipit-source-id: 979b75bfe55661aab11d5302da1bcd7830abd5af

6 years agoFixed documentation in folly/Random.h
Peter Goldsborough [Mon, 5 Jun 2017 21:17:02 +0000 (14:17 -0700)]
Fixed documentation in folly/Random.h

The docs give `ThreadLocalPRNG rng = Random::threadLocalPRNG()` as an example
of creating a thread local PRNG, but `Random::threadLocalPRNG()` does not/no longer
exist. I think it's just `folly::ThreadLocalPRNG` right now.

Reviewed By: yfeldblum

Differential Revision: D5184992

fbshipit-source-id: 63a9ef62b32fca42088abec419ae53531910cc82

6 years agoFix JemallocNodumpAllocator destructor w/ jemalloc 5.0.
Qi Wang [Mon, 5 Jun 2017 19:45:43 +0000 (12:45 -0700)]
Fix JemallocNodumpAllocator destructor w/ jemalloc 5.0.

Summary: Destroy created arena which has extent_hooks linked.

Reviewed By: jasone

Differential Revision: D5177535

fbshipit-source-id: 7d75f4276fc174c4d4ce1102dfb8ec8c27c1f56d

6 years agoMake StringKeyed* more complete
Phil Willoughby [Mon, 5 Jun 2017 17:58:29 +0000 (10:58 -0700)]
Make StringKeyed* more complete

Summary: Add `count()` and `swap()` methods. Ensure that `operator==` works.

Reviewed By: yfeldblum

Differential Revision: D5169393

fbshipit-source-id: a8025f6fdf251e38b0d2f27733d18967a55c6a15

6 years agoDon't explicitly disable the C++1y-extensions warning in ForEach-inl and WhenN-inl v2017.06.05.00
Christopher Dykes [Sun, 4 Jun 2017 19:04:28 +0000 (12:04 -0700)]
Don't explicitly disable the C++1y-extensions warning in ForEach-inl and WhenN-inl

Summary: We are fully on C++14 now, so these warnings should never be firing.

Reviewed By: yfeldblum

Differential Revision: D5179124

fbshipit-source-id: 31c6ddbce5c45b60fe73990f49d65ac95d17fe87

6 years agoResolve the circular dependency between folly/futures/detail/Core.h and Future.h...
Christopher Dykes [Sun, 4 Jun 2017 18:35:40 +0000 (11:35 -0700)]
Resolve the circular dependency between folly/futures/detail/Core.h and Future.h and Promise.h

Summary: Do this by moving the two helpers that need to refer to them into `folly/futures/helpers.h`.

Reviewed By: yfeldblum

Differential Revision: D5179109

fbshipit-source-id: bdb319ff3432d3629a955c1390dc8bf6f27f4ce6

6 years agoDon't use folly::shellify in StaticTracepointTest
Christopher Dykes [Sun, 4 Jun 2017 03:10:38 +0000 (20:10 -0700)]
Don't use folly::shellify in StaticTracepointTest

Summary: It's deprecated, so use the non-deprecated form instead.

Reviewed By: yfeldblum

Differential Revision: D5179133

fbshipit-source-id: 91440bc3768ee68d2aada2299fbfbcdd852f946c

6 years agoApply clang-format to folly/gen/ (partial: namespace)
Yedidya Feldblum [Sat, 3 Jun 2017 00:51:28 +0000 (17:51 -0700)]
Apply clang-format to folly/gen/ (partial: namespace)

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

With some manual rearrangement in the places where `clang-format` does awkward things, with the result that clang-format over `folly/gen/` becomes a no-op.

Reviewed By: Orvid

Differential Revision: D5177428

fbshipit-source-id: 17f51d00454a7be7f29dcf1a2ff3d0eaf1de72ab

6 years agoApply clang-format to folly/portability/
Yedidya Feldblum [Fri, 2 Jun 2017 22:34:42 +0000 (15:34 -0700)]
Apply clang-format to folly/portability/

[Folly] Apply `clang-format` to `folly/portability/`.

With some manual rearrangement in the places where `clang-format` does awkward things, with the result that `clang-format` over `folly/portability/` becomes a no-op.

Reviewed By: igorsugak

Differential Revision: D5170107

fbshipit-source-id: ceadd96740b4877cbae947846f0e738e6aaf5ed1

6 years agoFix JemallocNodumpAllocator extent_hooks API.
Qi Wang [Fri, 2 Jun 2017 19:32:01 +0000 (12:32 -0700)]
Fix JemallocNodumpAllocator extent_hooks API.

Summary: Using extent_hooks mallctl to update hooks.

Reviewed By: jasone

Differential Revision: D5174623

fbshipit-source-id: 9313ee9ae55c85d973736077727e54a5825f4c3d

6 years agoHazard pointers: Optimize memory order, add bulk reclamation control, add stats,...
Maged Michael [Fri, 2 Jun 2017 18:16:04 +0000 (11:16 -0700)]
Hazard pointers: Optimize memory order, add bulk reclamation control, add stats, add implementation switches, add benchmarks.

Summary: Make the implementation partially performant by optimizing memory order and using asymmetric memory barrier for full fences. Also added more control for bulk reclamation implementation, stats, and quality of implementation switches.

Reviewed By: djwatson

Differential Revision: D5129614

fbshipit-source-id: c597edf711fdc8f16f80523bd8cae42c51fbe140

6 years agoUpdate folly/JemallocNodumpAllocator to jemalloc 4 & 5 compatible.
Qi Wang [Fri, 2 Jun 2017 17:17:40 +0000 (10:17 -0700)]
Update folly/JemallocNodumpAllocator to jemalloc 4 & 5 compatible.

jemalloc 5.0 comes replaced chunks with extents APIs. Make the API compatible
with both jemalloc 4 and 5.

Reviewed By: yfeldblum

Differential Revision: D5170925

fbshipit-source-id: ce25723975729b0b63371f89a96842a1b2e3b3cc

6 years agoRemove InlineExecutor.cpp
Christopher Dykes [Thu, 1 Jun 2017 18:37:08 +0000 (11:37 -0700)]
Remove InlineExecutor.cpp

Summary: It is nothing but a file with the license header in it and has been since it was introduced nearly 4 years ago.

Reviewed By: yfeldblum

Differential Revision: D5163176

fbshipit-source-id: f510411cbb3d9d4c90d68c9b8d1f04d9f97fcb89

6 years agoRephrase Optional usage to quite warnings
Tom Jackson [Thu, 1 Jun 2017 15:44:32 +0000 (08:44 -0700)]
Rephrase Optional usage to quite warnings

Reviewed By: yfeldblum

Differential Revision: D5105818

fbshipit-source-id: e3926a0c70a68855e0180bdd44cb0ec76e66bb94

6 years agoDocs for SingletonThreadLocal
Phil Willoughby [Thu, 1 Jun 2017 15:43:35 +0000 (08:43 -0700)]
Docs for SingletonThreadLocal

Add a few keywords people search for when looking for this that won't otherwise
find this file.

Add a reference to the usage notes for Singleton which are a good description
of how you should operate SingletoThreadLocal as well.

Reviewed By: nbronson

Differential Revision: D5094598

fbshipit-source-id: 9980850805e1564e5c394af713e2fa17fe8844fe

6 years agoFix UB in folly/experimental/Bits.h
Tom Jackson [Thu, 1 Jun 2017 15:33:55 +0000 (08:33 -0700)]
Fix UB in folly/experimental/Bits.h

Test output before the fix is applied:
folly/experimental/Bits.h:247:59: runtime error: signed integer overflow: -2147483648 - 1 cannot be represented in type 'int'
     #0 folly/experimental/Bits.h:247 folly::Bits<...>::set(int*, unsigned long, unsigned long, int)
     #1 folly/experimental/test/BitsTest.cpp:228 std::enable_if<...>::type (anonymous namespace)::testSet<...>(unsigned char*, unsigned long, unsigned long, int)
     #2 folly/experimental/test/BitsTest.cpp:263 Bits_Boundaries_Test::TestBody()
    #17 folly/experimental/test/BitsTest.cpp:381 main

Reviewed By: philippv

Differential Revision: D5160789

fbshipit-source-id: 43f1926d58f1a5c019d4f8794d10a7a80a5c4749

6 years agoRemove FiberManagerFuture.h as it's dead
Christopher Dykes [Thu, 1 Jun 2017 07:23:48 +0000 (00:23 -0700)]
Remove FiberManagerFuture.h as it's dead

Summary: All functions in this file are defined in `folly/fibers/FiberManager-inl.h`. There are no remaining references to this file.

Reviewed By: yfeldblum

Differential Revision: D5163160

fbshipit-source-id: 2fcb782a4de78f5c067610c876d0cf98f3b69e63

6 years agoDestroy promise/future callback functions before waking waiters
Yedidya Feldblum [Thu, 1 Jun 2017 05:41:16 +0000 (22:41 -0700)]
Destroy promise/future callback functions before waking waiters

Code may pass a callback which captures an object with a destructor which mutates through a stored reference, triggering heap-use-after-free or stack-use-after-scope.

void performDataRace() {
  auto number = std::make_unique<int>(0);
  auto guard = folly::makeGuard([&number] { *number = 1; });
  folly::via(getSomeExecutor(), [guard = std::move(guard)]() mutable {}).wait();
  // data race - we may wake and destruct number before guard is destructed on the
  // executor thread, which is both stack-use-after-scope and heap-use-after-free!

We can avoid this condition by always destructing the provided functor before setting any result on the promise.

Retry at {D4982969}.

Reviewed By: andriigrynenko

Differential Revision: D5058750

fbshipit-source-id: 4d1d878b4889e5e6474941187f03de5fa84d3061

6 years agoRefactor the CMake file to work with CMake 3.8.2
Christopher Dykes [Wed, 31 May 2017 22:12:02 +0000 (15:12 -0700)]
Refactor the CMake file to work with CMake 3.8.2

The dirty hack I was using to link `folly_base` into `folly` doesn't work in newer versions of CMake :(
This refactors the makefile to not need to dirty hack by using an object library rule instead. It also makes the compiler version detection more generic.

Reviewed By: yfeldblum

Differential Revision: D5158919

fbshipit-source-id: cd052a5f58ed3d88c377c68cca07ca8497ca0c7a

6 years agoFuture: some fixes re: handling of universal references
Sven Over [Wed, 31 May 2017 16:43:09 +0000 (09:43 -0700)]
Future: some fixes re: handling of universal references

Callables that are passed as rvalues to makeFutureWith should be
executed as rvalues.
Generally callables that get captured by value should be executed
as rvalues, to allow passing e.g. folly::Partial objects that contain
move-only objects like unique_ptr or folly::Promise.
`collect` would move out of parameters passed as lvalues.

Reviewed By: fugalh

Differential Revision: D5120420

fbshipit-source-id: 1633c6b7e3fbb562f4d31e21d28c98b053de9912

6 years agoAdd non-throwing alternative to decodeVarint
Jon Maltiel Swenson [Wed, 31 May 2017 15:20:51 +0000 (08:20 -0700)]
Add non-throwing alternative to decodeVarint

In mcrouter code, we would like a non-throwing alternative to `decodeVarint()`. There
are real, expected scenarios where only part of a serialized varint fits into a packet,
in which case mcrouter fails to decode the varint and throws.  In these scenarios,
throwing too many exceptions can lead to lock contention and degrade performance.

Reviewed By: yfeldblum

Differential Revision: D5153823

fbshipit-source-id: 138273af832903f0b04bee0bcacddd66b4274129

6 years agoadd equals interface for Range class.
Bi Xue [Wed, 31 May 2017 04:09:55 +0000 (21:09 -0700)]
add equals interface for Range class.

Add `equals` interface to StringPiece (Range class). To support following case insensitive compare case:
folly::StringPiece a("hello");
if (a.equals("HELLO", folly::AsciiCaseInsensitive())) {
  // Do something.

Reviewed By: ot

Differential Revision: D5150495

fbshipit-source-id: 26816820f93959678f550768396f55293b5588cb

6 years agoFix tryTo to support conversion to enumerations v2017.05.29.00
Qinfan Wu [Sun, 28 May 2017 20:49:28 +0000 (13:49 -0700)]
Fix tryTo to support conversion to enumerations

[Folly] Fix `tryTo` to support conversion to enumerations.

`tryTo` should return `Expected<Tgt, ConversionCode>` instead of `Tgt`.

Reviewed By: yfeldblum

Differential Revision: D5144706

fbshipit-source-id: cd23f3cf75de7c5a26bc569f3cb47fff360f6e2a

6 years agofolly/portability/Memory.cpp: restructure preprocessor conditionals so includes are...
Yiding Jia [Sun, 28 May 2017 18:51:10 +0000 (11:51 -0700)]
folly/portability/Memory.cpp: restructure preprocessor conditionals so includes are at top level

`#include` inside a namespace is disallowed when using clang modules. Here I
just unconditionally include them at top level, since they are available in all the
relevant platforms.

Reviewed By: yfeldblum, Orvid

Differential Revision: D5140355

fbshipit-source-id: bb87225c1d8f4ac64b90a7aff5f912c13e150e3a

6 years agoMoving DestructorCheck from proxygen library to folly.
Maxim Georgiev [Sun, 28 May 2017 14:25:17 +0000 (07:25 -0700)]
Moving DestructorCheck from proxygen library to folly.

Moving DestructorCheck from proxygen library to folly.

Reviewed By: djwatson

Differential Revision: D5110897

fbshipit-source-id: 02a6cf6336000e8c36484e75d2da820588baf2df

6 years agoClarify in the docs what belongs in portability/
Christopher Dykes [Sun, 28 May 2017 01:00:35 +0000 (18:00 -0700)]
Clarify in the docs what belongs in portability/

Summary: This has always been the design rule for what belongs in `folly/portability/`, but was never written down anywhere except in my head, so put it somewhere people can actually find it so I can free that space in my head for other things.

Reviewed By: yfeldblum

Differential Revision: D5140587

fbshipit-source-id: 1f09c17b7ccfff780e1825670a7ffaa75cd1b1d5

6 years agoAdded folly::hint_emplace_iterator to folly/Iterator.h
Philipp Unterbrunner [Sat, 27 May 2017 05:54:46 +0000 (22:54 -0700)]
Added folly::hint_emplace_iterator to folly/Iterator.h

In contrast to Container::insert(), for any STL container class, Container::emplace() does not have an overload that takes a Container::iterator as its first parameter. (The reason is to prevent ambiguity with respect to target class constructor parameters.) Instead, container classes have a separate emplace_hint() function.
Because of this separation, folly::emplace_iterator would fail to perform hinted emplacement in constructs where std::insert_iterator would perform hinted insertion.
This diff adds a new class, folly::hint_emplace_iterator(), and corresponding convenience function, folly::hint_emplacer(), which calls Container::emplace_hint() rather than Container::emplace().
It would have been trivial to copy&paste the existing folly::emplace_iterator class and simply replace the emplace() call with emplace_hint(), but I did not like the large amount of code repetition. So I decided to do some refactoring and move the emplace()/emplace_hint()/emplace_front()/emplace_back() calls into separate trait classes, and replace emplace_iterator()/hint_emplace_iterator()/front_emplace_iterator()/back_emplace_iterator() with suitable type aliases.

Reviewed By: yfeldblum

Differential Revision: D5097860

fbshipit-source-id: c0b733131a0d0d21fc0a8b08ad655142c6a41c19

6 years agoFix build with Ninja generator
Christopher Dykes [Fri, 26 May 2017 21:03:46 +0000 (14:03 -0700)]
Fix build with Ninja generator

We were hitting a bug in CMake's Ninja generator that was causing it to incorrectly attempt to escape the closing quote on `_HAS_AUTO_PTR_ETC=1`, so remove the quotes, as they aren't actually needed.
This also makes a few quality-of-life changes to make building Folly with Ninja slightly easier.


Reviewed By: yfeldblum

Differential Revision: D5134585

fbshipit-source-id: 3816e53774f7963b9b4fd8ddf68b83ff7afdefe1

6 years agoFix reliance on the sign of char in fnv32 and fnv64
Christopher Dykes [Thu, 25 May 2017 19:48:25 +0000 (12:48 -0700)]
Fix reliance on the sign of char in fnv32 and fnv64

Clearly someone noticed this was an issue before and fixed the other 2 overloads, but never fixed these :(

Specifically, ARM has unsigned chars, so this would be producing the wrong values there.

Reviewed By: yfeldblum, mzlee

Differential Revision: D5122992

fbshipit-source-id: eb71dea82c187c09c2c4496f1f7c99bd01db6dd0

6 years agoReplace FOLLY_WARN_UNUSED_RESULT with FOLLY_NODISCARD everywhere
Eric Niebler [Thu, 25 May 2017 03:29:37 +0000 (20:29 -0700)]

Summary: `[[nodiscard]]` is the future. Let's start now.

Reviewed By: yfeldblum

Differential Revision: D5108297

fbshipit-source-id: c98f44af9e282616af92f9171516b6ea18e68c6d

6 years agoAdd zstd streaming interface
Nick Terrell [Wed, 24 May 2017 21:59:42 +0000 (14:59 -0700)]
Add zstd streaming interface

* Add streaming interface to the `ZstdCodec`
* Implement `ZstdCodec::doCompress()` and `ZstdCodec::doUncompress()` using the streaming interface.
  [fbgs CodecType::ZSTD]( and check that no caller requires thread-safety.

Reviewed By: yfeldblum

Differential Revision: D5026558

fbshipit-source-id: 61faa25c71f5aef06ca2d7e0700f43214353c650

6 years agoAdd streaming API
Nick Terrell [Wed, 24 May 2017 21:59:41 +0000 (14:59 -0700)]
Add streaming API

Adds a C-style streaming API to `folly/io/Compression.h`, with a zlib-esque interface.
Stacked diffs will add streaming support to zstd, zlib, gzip, lzma, lz4_frame, and automatic codecs.
This interface is targeting advanced users who are building higher level interfaces.
They can use this as a common base so they don't have to reimplement the same code for every codec.

Reviewed By: yfeldblum

Differential Revision: D5026332

fbshipit-source-id: e3abf1767b493c2fef153b895858a3a81b67d989

6 years agoapply clang-tidy modernize-use-override
Victor Gao [Wed, 24 May 2017 18:03:04 +0000 (11:03 -0700)]
apply clang-tidy modernize-use-override

This is generated by applying clang-tidy -checks=modernize-use-override to all .cpp files under folly.
It enforces the use of the keywords virtual, override and final in a way compliant to the style guide.

Reviewed By: yfeldblum

Differential Revision: D5108973

fbshipit-source-id: 61c55aa372feebe3b3be12a2705a04879aae57a4

6 years agoA core-cached shared_ptr
Giuseppe Ottaviano [Wed, 24 May 2017 05:52:12 +0000 (22:52 -0700)]
A core-cached shared_ptr

This class serves a similar use case to `ReadMostlySharedPtr`, but with two differences:

- It returns actual `shared_ptr`s, so it can be used as a drop-in replacement.
- Its memory utilization is constant, independent of the number of threads that use it.

Also, the code is much simpler. On the other hand, it is about 4x slower (but it still scales linearly in the number of concurrent threads acquiring the reference).

Reviewed By: djwatson

Differential Revision: D5104730

fbshipit-source-id: 8c18b635e0390394b06417b6df8b790e4bd2d90d

6 years agoHeterogeneous comparisons
Nick Terrell [Wed, 24 May 2017 02:35:39 +0000 (19:35 -0700)]
Heterogeneous comparisons

`std::optional` allows heterogeneous comparisons, so `folly::Optional` should as well.
This allows numerical comparisons between different types, like `size_t` and `uint64_t`.


Reviewed By: AsyncDBConnMarkedDownDBException

Differential Revision: D5110651

fbshipit-source-id: 34f3368283953033fbb2423ab30b04e38b5b7974

6 years agoRFC: Embed exception_wrapper directly into Try
Yedidya Feldblum [Wed, 24 May 2017 02:18:12 +0000 (19:18 -0700)]
RFC: Embed exception_wrapper directly into Try

[Folly] RFC: Embed `exception_wrapper` directly into `Try`.

Rather than storing it elsewhere on the heap. With `exception_wrapper` at 24 bytes on x64, it may now be small enough. However, it will expand the size of `Try<T>` for `sizeof(T) <= 16`, giving `Try` a new minimum size of 32 bytes on x64 instead of 16.

Reviewed By: ericniebler

Differential Revision: D5051436

fbshipit-source-id: 10d59686d64382c88d54340c97567eafb3e2f682

6 years agoFix some old license headers
Yedidya Feldblum [Tue, 23 May 2017 19:59:17 +0000 (12:59 -0700)]
Fix some old license headers

Summary: [Folly] Fix some old license headers.

Reviewed By: meyering

Differential Revision: D5110463

fbshipit-source-id: c7bb57194e0d33fbe1c6ddaa7d94437833b0cb0d

6 years agoAdd FOLLY_NODISCARD for [[nodiscard]] attribute when it exists, FOLLY_WARN_UNUSED_RES...
Eric Niebler [Tue, 23 May 2017 16:01:31 +0000 (09:01 -0700)]
Add FOLLY_NODISCARD for [[nodiscard]] attribute when it exists, FOLLY_WARN_UNUSED_RESULT uses FOLLY_NODISCARD.

Summary: The `nodiscard` attribute was added to standard C++ in C++17. Prefer the standard formulation when it is available; otherwise, use `__attribute__((__warn_unused_result__))` on compilers that support the GNU extensions, and `_Check_return_` on MSVC. The old `FOLLY_WARN_UNUSED_RESULT` is now expands to `FOLLY_NODISCARD`.

Reviewed By: yfeldblum

Differential Revision: D5105137

fbshipit-source-id: 9aa22e81cd9f0b89f9343433aeae3ba365227ccb

6 years agoMake a few implicit truncations either explicit, or not truncate
Christopher Dykes [Mon, 22 May 2017 23:54:41 +0000 (16:54 -0700)]
Make a few implicit truncations either explicit, or not truncate

Summary: This silences a few warnings under MSVC, and gets Folly closer to being able to compile with `-Wconversion` enabled.

Reviewed By: yfeldblum

Differential Revision: D5100686

fbshipit-source-id: e5e04c7aa143597e151a56a4d1f90dda26d0033b

6 years agoEnable -Wimplicit-fallthrough
Christopher Dykes [Mon, 22 May 2017 22:33:12 +0000 (15:33 -0700)]
Enable -Wimplicit-fallthrough

Summary: Because just having a linter enforce it isn't good enough to catch everything.

Reviewed By: yfeldblum

Differential Revision: D5101828

fbshipit-source-id: a1bc482b37139a1eddeb93bc298596af950aa87d

6 years agoShift the job of defining NOMINMAX into source rather than the build system
Christopher Dykes [Mon, 22 May 2017 22:19:00 +0000 (15:19 -0700)]
Shift the job of defining NOMINMAX into source rather than the build system

This makes it easier to consume Folly from a non-cmake project.
Note that this also requires making libevent, which was previously categorized as a semi-portable header into a non-portable header, meaning it can't be referenced directly. (libevent includes `Windows.h` in one of its headers -_-....)

Reviewed By: yfeldblum

Differential Revision: D5106051

fbshipit-source-id: 5ce2d4188c9036d6ab206af3036c8fd4b09516a4

6 years agoAdd LOCK_SHAREDMUTEX SSLLockType.
Kyle Nekritz [Mon, 22 May 2017 21:36:33 +0000 (14:36 -0700)]

Summary: To take advantage of read locks.

Reviewed By: siyengar

Differential Revision: D5106090

fbshipit-source-id: a32afd698e9204196aa3d23f21a7d41803b2eb66

6 years agoRefactor folly/gen/test/StringTest.cpp v2017.05.22.00
Yedidya Feldblum [Sat, 20 May 2017 20:32:49 +0000 (13:32 -0700)]
Refactor folly/gen/test/StringTest.cpp

[Folly] Refactor `folly/gen/test/StringTest.cpp`.

Prefer to compare whole values once per test case, rather than sequentially comparing each part in turn.

Reviewed By: andrewjcg

Differential Revision: D5101467

fbshipit-source-id: 3d19d32bc6a5ecc5863bea76c4292935c775fe75

6 years agoAdded a new variant of byLine to keep the delimiter
Song Zhou [Sat, 20 May 2017 14:53:57 +0000 (07:53 -0700)]
Added a new variant of byLine to keep the delimiter

Summary: new method byLineFull will not trim the delimiter so that consumers can check if final line is ended up with delimiter or not.

Reviewed By: philippv, yfeldblum

Differential Revision: D5085371

fbshipit-source-id: 5045127ee11d008e3cd7d13d33bffad280fe0a7e

6 years agofix PicoSpinLock for aarch64 and allow PackedSyncPtr to compile for aarch64
Stephen Chen [Sat, 20 May 2017 03:59:15 +0000 (20:59 -0700)]
fix PicoSpinLock for aarch64 and allow PackedSyncPtr to compile for aarch64

Looks like we never tried to compile or run the PicoSpinLock under aarch64. There were two problems:

if sizeof(IntType) is 64, we try to do
  1 << 63
in lock and unlock. This doesn't compile because sizeof(1) is 32.

Also for try_lock, we were returning the data instead of checking for the locked bit.

Reviewed By: djwatson, yfeldblum

Differential Revision: D5091656

fbshipit-source-id: 4f81b8b32633e87b491548a1a24b9bcf20264063

6 years agoFix the linking of various tests against GMock
Christopher Dykes [Sat, 20 May 2017 03:57:10 +0000 (20:57 -0700)]
Fix the linking of various tests against GMock

Summary: A define was needed to be able to link when built against a shared-library version of gmock and gtest.

Reviewed By: yfeldblum

Differential Revision: D5100409

fbshipit-source-id: 9a4c9df20f682a25edde642c451476b2d1e1ae22

6 years agoMake a few adjustments to the compile config for the CMake build
Christopher Dykes [Sat, 20 May 2017 03:36:50 +0000 (20:36 -0700)]
Make a few adjustments to the compile config for the CMake build

Summary: This includes adding options to toggle `/std:c++latest`, and `WIN32_LEAN_AND_MEAN`, along with giving a nice drop-down selector to `MSVC_FAVORED_ARCHITECTURE` when configured via the GUI, dropping `_WINSOCK_DEPRECATED_NO_WARNINGS` as it wasn't needed, and re-enabling warnings 4365 and 4775 within the scope of the standard library.

Reviewed By: yfeldblum

Differential Revision: D5100586

fbshipit-source-id: 87b20c6415391d4f0c75837cad5bc312910bf49f

6 years agoMark constexpr values needed within non-implicitly-capturing lambdas as static
Christopher Dykes [Sat, 20 May 2017 03:33:41 +0000 (20:33 -0700)]
Mark constexpr values needed within non-implicitly-capturing lambdas as static

Summary: MSVC needs these to be marked as `static` in order to be accessible within the lambdas without capturing them.

Reviewed By: yfeldblum

Differential Revision: D5099607

fbshipit-source-id: 0270e2191d504f74b1902789b662e1766b2056c4

6 years agoWork around a compiler crash in VS 2017.3 Preview 1
Christopher Dykes [Sat, 20 May 2017 01:37:20 +0000 (18:37 -0700)]
Work around a compiler crash in VS 2017.3 Preview 1

MSVC is being grumpy, and I want to continue to work from the preview build, so commit the workaround, as there's no significant difference.
Upstream bug report:

Reviewed By: yfeldblum

Differential Revision: D5099876

fbshipit-source-id: 64d5573d78b14339ff3177dd910a22787463ccd2

6 years agoFix the header being included when trying to specialize std::hash
Christopher Dykes [Fri, 19 May 2017 23:42:25 +0000 (16:42 -0700)]
Fix the header being included when trying to specialize std::hash

Summary: `std::hash` lives in `<functional>`, not `<xstddef>`.

Reviewed By: yfeldblum

Differential Revision: D5097468

fbshipit-source-id: d0684491d1d4b0f83f07ad837a66a915ce2ec8a6

Shoaib Meenai [Fri, 19 May 2017 23:11:07 +0000 (16:11 -0700)]

Summary: 4.0 has been out for three months now, so it's pretty safe to remove them.

Reviewed By: Orvid, yfeldblum, mzlee

Differential Revision: D5096007

fbshipit-source-id: 595c3e86cd7cf1a1706f27f107fb0af8ab89a676

6 years agoStampedPtr: use async-signal-safe assert
Xiao Shi [Fri, 19 May 2017 14:23:29 +0000 (07:23 -0700)]
StampedPtr: use async-signal-safe assert

Summary: Use SafeAssert instead of assert.

Reviewed By: nbronson

Differential Revision: D5085575

fbshipit-source-id: daeff427b9b1fc5dff6ea986d16a70364acd2dd7

6 years agoThreadedRepeatingFunctionRunner: Name all the threads
Alexey Spiridonov [Wed, 17 May 2017 22:56:39 +0000 (15:56 -0700)]
ThreadedRepeatingFunctionRunner: Name all the threads

Summary: Name all repeating function threads for ease of debugging.

Reviewed By: yfeldblum

Differential Revision: D5065281

fbshipit-source-id: e875e654dfa644a265e44416baf5fbf23c9da434

6 years agoTweak basic_fbstring construction from std types
Phil Willoughby [Wed, 17 May 2017 11:05:52 +0000 (04:05 -0700)]
Tweak basic_fbstring construction from std types

Previously we defined an assignment from std::string on all basic_fbstring
specialisations, but we don't actually want to do that because it's nonsense to
construct a basic_fbstring<char16_t> from an std::string. Equally it's not
nonsense to construct one of those from an std::u16string but the previous code
didn't allow it.

We now permit basic_fbstring<C, T, A1, S> to be constructed or assigned-to from
std::basic_string<C, T, A2>. The character type and traits must match but the
allocator is permitted to vary.

Background on my determination that the allocator type was unimportant and
could be disregarded: In part this is because C++17 made the same choice for
basic_string_view. Another factor was C++17's std::pmr::string (it's a
std::string with a different allocator) which I thought should be convertible
to fbstring in the same way as std::string.

Reviewed By: Gownta

Differential Revision: D5060569

fbshipit-source-id: f8984c528b76356240970c67916c58995d3f228d

6 years agoSimplify ThreadedRepeatingFunctionRunner by requiring classes that contain it to...
Alexey Spiridonov [Tue, 16 May 2017 21:05:49 +0000 (14:05 -0700)]
Simplify ThreadedRepeatingFunctionRunner by requiring classes that contain it to be final

Summary: It is pretty confusing to inherit from classes that manage threads. See the docblocks in this diff.

Reviewed By: yfeldblum

Differential Revision: D4973498

fbshipit-source-id: 2fcf1ddf68ef46d4d78a9b40f304262064862715

6 years agogate sse42 implementation of checksum for x86 only
Stephen Chen [Tue, 16 May 2017 17:06:47 +0000 (10:06 -0700)]
gate sse42 implementation of checksum for x86 only

folly/detail/ChecksumDetail.h gets included in Checksum.h and it
unconditionally includes <immintrin.h>. This doesn't compile on
aarch64 platform. Add #ifdefs for this.

Reviewed By: yfeldblum

Differential Revision: D5048636

fbshipit-source-id: d2074eb1b01487b02d95f3e2eebe683237d918fe

6 years agoFix violations of unused-lambda-capture
Yedidya Feldblum [Tue, 16 May 2017 15:07:22 +0000 (08:07 -0700)]
Fix violations of unused-lambda-capture

Summary: [Folly] Fix violations of `unused-lambda-capture`.

Reviewed By: Orvid

Differential Revision: D5060391

fbshipit-source-id: 34aabc847719603d13da8f2b52a7ec187d803a4a

6 years agoSwitch implicit references of folly::make_unique to std::make_unique
Christopher Dykes [Tue, 16 May 2017 01:23:54 +0000 (18:23 -0700)]
Switch implicit references of folly::make_unique to std::make_unique

Summary: It's *almost* dead. This switches things to explicitly reference `std::make_unique` so that `folly::make_unique` can be marked as deprecated until mobile catches up and it can be killed completely.

Reviewed By: yfeldblum

Differential Revision: D5026584

fbshipit-source-id: aefc8cb3de84583fd3722fdb9dfea620884590c5

6 years agoDrop support for deprecated associative containers
Yedidya Feldblum [Mon, 15 May 2017 19:31:24 +0000 (12:31 -0700)]
Drop support for deprecated associative containers

[Folly] Drop support for deprecated associative containers.

Namely, `__gnu_cxx::hash_set` and `__gnu_cxx::hash_map`.

Reviewed By: wqfish

Differential Revision: D5058813

fbshipit-source-id: ebbcf10765f5d06776ee8f697cfb78614a3a566c