folly.git
6 years agoFix constexpr_min after D5739715 v2017.09.04.00
Yedidya Feldblum [Sat, 2 Sep 2017 09:11:34 +0000 (02:11 -0700)]
Fix constexpr_min after D5739715

Summary:
[Folly] Fix `constexpr_min` after {D5739715} (facebook/folly@6d7c6d55f0f4b7b75607608ef9037db58083368f).

Add new unit-tests for `constexpr_min` and `constexpr_max` to avoid silly mistakes like this in the future.

It was defined recursively in terms of `constexpr_max` rather than, as intended, in terns of `constexpr_min`. HT Mandar12.

Reviewed By: Orvid

Differential Revision: D5761831

fbshipit-source-id: 2dad5833e05679232b3c529d33325a0205c2e4e4

6 years agoincrease stack size when TSAN is enabled
Igor Sugak [Fri, 1 Sep 2017 20:23:11 +0000 (13:23 -0700)]
increase stack size when TSAN is enabled

Reviewed By: meyering

Differential Revision: D5757469

fbshipit-source-id: ad70c47251993c79a502d30f312534e28c9241d4

6 years agoDeflake some AsyncSSLSocket tests.
Kyle Nekritz [Fri, 1 Sep 2017 16:13:58 +0000 (09:13 -0700)]
Deflake some AsyncSSLSocket tests.

Summary: Fulfilling starts destroying the evb in another thread which races with the socket closing on the evb.

Reviewed By: siyengar, ngoyal

Differential Revision: D5755271

fbshipit-source-id: ace37eee63e684c97ca0fe503293eee83514e0ac

6 years agoAdd a comment on File.h
Aravind Anbudurai [Thu, 31 Aug 2017 23:20:43 +0000 (16:20 -0700)]
Add a comment on File.h

Summary: title

Reviewed By: yfeldblum

Differential Revision: D5751299

fbshipit-source-id: d3967c2499da9a2c98c2862b9bdc9994c12edc76

6 years agoExtract non-portability constexpr math functions to new header
Yedidya Feldblum [Thu, 31 Aug 2017 02:26:32 +0000 (19:26 -0700)]
Extract non-portability constexpr math functions to new header

Summary:
[Folly] Extract non-portability `constexpr` math functions to new header.

This new header, `folly/ConstexprMath.h`, is specifically for compile-time-computable math functions. We start with `min`, `max`, `abs`, and `log2`.

Included substantive changes:
* Add new tests for `constexpr_strlen`, which remains in the portability header.
* Make `constexpr_min` and `constexpr_max` variadic.
* Make `constexpr_log2` tail-recursive, remove `const_log2` in `FixedString.h`, and move the related comment.

Reviewed By: Orvid

Differential Revision: D5739715

fbshipit-source-id: 29d3cc846ce98bb4bdddcc8b0fa80e4d32075fe0

6 years agoDon't use symbolizer on OSX
Philip Jameson [Thu, 31 Aug 2017 01:00:36 +0000 (18:00 -0700)]
Don't use symbolizer on OSX

Summary:
When trying to build with targets files on OSX, I couldn't use the symbolizer because it needs StackTrace, which requires libunwind and elf. This makes it so that we only build on linux for now. This also makes it so that we set FOLLY_USE_SYMBOLIZER in autoconf, since that wasn't set before.

Does a few things surrounding usage of the symbolizer library:
- Introduce FOLLY_USE_SYMBOLIZER in folly-config.h and USE_SYMBOLIZER as an AM definition
-- Filter some code out of init and some other random libs that optionally need the symbolizer
- Fix libdwarf detection. Previously on a fresh ubuntu container, we didn't find libdwarf/dwarf.h, so we stopped trying before looking at dwarf.h

Reviewed By: yfeldblum

Differential Revision: D5644352

fbshipit-source-id: f0a3580c41122e5e8fdfd17a9fdbb0921be21401

6 years agoInclude `<array>` for test
Michael Lee [Wed, 30 Aug 2017 23:16:27 +0000 (16:16 -0700)]
Include `<array>` for test

Summary: <array> is sometimes necessary for using `std::array`. Fix up

Reviewed By: aary

Differential Revision: D5740866

fbshipit-source-id: 13bafadd26fdd0f2eff3513115b43811682e7cda

6 years agoConditionally compiled for_each with constexpr
Aaryaman Sagar [Wed, 30 Aug 2017 21:36:25 +0000 (14:36 -0700)]
Conditionally compiled for_each with constexpr

Summary:
Code was breaking in versions of C++ where constexpr functions are
required to have one line bodies

Reviewed By: yfeldblum, mzlee

Differential Revision: D5739062

fbshipit-source-id: 6c509f1daf77751d33ce9c173a0d7f1d3bd2a006

6 years agoDynamic MPMCQueue: Eliminate cases of enqueue indefinite blocking and failure in...
Maged Michael [Wed, 30 Aug 2017 19:53:16 +0000 (12:53 -0700)]
Dynamic MPMCQueue: Eliminate cases of enqueue indefinite blocking and failure in the extensible version that impossible under the default pre-allocated version

Summary:
Currently under the extensible version (Dynamic == true), some enqueue operations may block indefinitely or fail (return false) even though such outcomes are impossible under the default (Dynamic == false) pre-allocated version.

This diff eliminates such cases by changing the algorithms for the extensible version. Some of the high-level changes:
- The offset formula for an expansion guarantees that no enqueue operation left behind in a closed array does not have an existing dequeue operation that unblocks it. The old formula was 1 + max(head, tail). The new formula is max(head, current offset) + current capacity.
- Conditional operations validate state after the success of CAS.

Reviewed By: djwatson

Differential Revision: D5701013

fbshipit-source-id: 4917c5b35b7e2a2fddfd2e11fb5aeb478502137c

6 years agoconstexpr_log2
Yedidya Feldblum [Wed, 30 Aug 2017 18:39:43 +0000 (11:39 -0700)]
constexpr_log2

Summary:
[Folly] `constexpr_log2`.

Useful for anything that needs to compute log2 at compile time.

Reviewed By: eduardo-elizondo

Differential Revision: D5734727

fbshipit-source-id: 8eab7991eea2104570eecd8e84ede6160bb0b549

6 years agoShrink MicroSpinLock.h transitive includes and inline methods
Yedidya Feldblum [Wed, 30 Aug 2017 03:28:59 +0000 (20:28 -0700)]
Shrink MicroSpinLock.h transitive includes and inline methods

Summary: [Folly] Shrink `MicroSpinLock.h` transitive includes and inline methods.

Reviewed By: meyering

Differential Revision: D5732693

fbshipit-source-id: 386816f0d97c145ff8a4180d41c8a682694aa6cb

6 years agorm old comment on HHWheelTimer::UniquePtr
Xiao Shi [Wed, 30 Aug 2017 03:05:38 +0000 (20:05 -0700)]
rm old comment on HHWheelTimer::UniquePtr

Summary: This comment is outdated.

Reviewed By: yfeldblum

Differential Revision: D5730049

fbshipit-source-id: f6088c4354210fafb019656cdf8246abf90fbc06

6 years agoUse weak_ptr to hold future context in timekeeper to allow clean up when future complete
Richard Meng [Tue, 29 Aug 2017 17:18:29 +0000 (10:18 -0700)]
Use weak_ptr to hold future context in timekeeper to allow clean up when future complete

Summary:
Before this change, future context will not be cleaned up until timekeeper times out. These objects has been occupying memory when more shorter future tasks are registered.
Switch to use weak ptr to hold context, so that context objects are deallocated as soon as the future completes (or times out)

Reviewed By: yfeldblum

Differential Revision: D5692040

fbshipit-source-id: b3b74a29b2ccafef6c4a06011699b069feb3a847

6 years agoAllow forcing value for FOLLY_FUTURE_USING_FIBER in folly-config.h
Andrew Krieger [Tue, 29 Aug 2017 05:36:16 +0000 (22:36 -0700)]
Allow forcing value for FOLLY_FUTURE_USING_FIBER in folly-config.h

Summary:
Let clients choose whether to use fibers or not, but default
to the same autodetected setting as prior logic.

Reviewed By: yfeldblum

Differential Revision: D5585605

fbshipit-source-id: 9a4bf9f9bc23b4e15601f30c40602f21798c9685

6 years agoFix potentially uninitialized struct used on MSVC
Andrew Krieger [Tue, 29 Aug 2017 05:34:42 +0000 (22:34 -0700)]
Fix potentially uninitialized struct used on MSVC

Summary:
MSVC warns this might be used but uninitialized. Force
the struct to be zero initialized.

Reviewed By: yfeldblum

Differential Revision: D5585320

fbshipit-source-id: 9454a2a4a66c7689f42b1eb211dc57f5d3b88fea

6 years agoFix portability opendir() behavior on paths without trailing slashes
Andrew Krieger [Tue, 29 Aug 2017 05:33:44 +0000 (22:33 -0700)]
Fix portability opendir() behavior on paths without trailing slashes

Summary:
Off-by-one error in DIR::open() would result in paths not
ending in a trailing separator to fail to open. Fix the arithmetic.

Reviewed By: Orvid

Differential Revision: D5579657

fbshipit-source-id: 79507bc398549033eb26b2ffa788d66241deb623

6 years agoImplement folly::launder for MSVC
Andrew Krieger [Tue, 29 Aug 2017 05:30:39 +0000 (22:30 -0700)]
Implement folly::launder for MSVC

Summary:
This implementation should suffice for MSVC. _ReadWriteBarrier()
generates no instructions but instructs the compiler not to reorder accesses
around it, and we have to rely on MSVC not currently having any other
optimizations for const members to worry about.

Reviewed By: yfeldblum

Differential Revision: D5723782

fbshipit-source-id: a68caa4673a5c410b326c1d2e3c0752bd945f4a6

6 years agoApply clang-format to folly/experimental/exception_tracer/
Yedidya Feldblum [Tue, 29 Aug 2017 02:59:43 +0000 (19:59 -0700)]
Apply clang-format to folly/experimental/exception_tracer/

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

Reviewed By: Orvid

Differential Revision: D5722994

fbshipit-source-id: 2e52c920119ba58d123aaffd59491d7561c37c17

6 years agoRevert D5714883: [Folly] Shrink MicroSpinLock.h transitive includes and inline methods
Christopher Dykes [Tue, 29 Aug 2017 01:06:22 +0000 (18:06 -0700)]
Revert D5714883: [Folly] Shrink MicroSpinLock.h transitive includes and inline methods

Summary:
This reverts commit 1744685ff9fa8d3620aef2545c8fe3ebc481df06

bypass-lint

Differential Revision: D5714883

fbshipit-source-id: 0cdb5f2cac095a9202cb1310ff8e75e75b4afd74

6 years agoEnable auto-deps in all of Folly
Christopher Dykes [Mon, 28 Aug 2017 22:13:58 +0000 (15:13 -0700)]
Enable auto-deps in all of Folly

Summary: This enables the last of the magic internally.

Reviewed By: yfeldblum

Differential Revision: D5719795

fbshipit-source-id: fb59a0d7873e9a9f3b73f556b42b647091ca7e67

6 years agoShrink MicroSpinLock.h transitive includes and inline methods
Yedidya Feldblum [Mon, 28 Aug 2017 08:29:16 +0000 (01:29 -0700)]
Shrink MicroSpinLock.h transitive includes and inline methods

Summary: [Folly] Shrink `MicroSpinLock.h` transitive includes and inline methods.

Reviewed By: Orvid

Differential Revision: D5714883

fbshipit-source-id: 1744685ff9fa8d3620aef2545c8fe3ebc481df06

6 years agoMake cancelling and rescheduling of functions O(1) v2017.08.28.00
Patryk Zaryjewski [Mon, 28 Aug 2017 06:35:38 +0000 (23:35 -0700)]
Make cancelling and rescheduling of functions O(1)

Summary: Currently FunctionScheduler calls that cancel/restart timer for a function of particular id are O(n). By introducing hashmap that translate id to pointer of particular RepeatFunc, we make it O(1).

Reviewed By: simpkins

Differential Revision: D5668557

fbshipit-source-id: e5e8bf9bd75b6d5d42f0bfa398d476703e5801fa

6 years agogcc 6.2 was not accepting the current definition of void_t
Aaryaman Sagar [Fri, 25 Aug 2017 23:08:18 +0000 (16:08 -0700)]
gcc 6.2 was not accepting the current definition of void_t

Summary:
The current definition of void_t was leading to errors because unused
template parameters are ignored and SFINAE SFIAEs

Reviewed By: yfeldblum

Differential Revision: D5700825

fbshipit-source-id: d23336070c217e8594980d6db710cb417b014236

6 years agoAdded a flag FOLLY_FORCE_EXCEPTION_COUNT_USE_STD
Marko Novakovic [Fri, 25 Aug 2017 22:23:42 +0000 (15:23 -0700)]
Added a flag FOLLY_FORCE_EXCEPTION_COUNT_USE_STD

Summary:
The flag FOLLY_FORCE_EXCEPTION_COUNT_USE_STD forces
the usage of std:uncaught_exceptions() for folly's
implementation of uncaught_exceptions()

Reviewed By: yfeldblum

Differential Revision: D5542302

fbshipit-source-id: 2c2f507ab9dde916a160a9c370a267cdcfd7203a

6 years agoEnforce forward progress with StreamCodec
Stella Lau [Fri, 25 Aug 2017 16:23:46 +0000 (09:23 -0700)]
Enforce forward progress with StreamCodec

Summary:
- Throw exception if no forward progress was made with `StreamCodec.compress()` and `StreamCodec.uncompress()`
- Prevents infinite looping behavior when no forward progress was made
- Update tests

Reviewed By: terrelln

Differential Revision: D5685690

fbshipit-source-id: 969393896b74f51250f0e0ce3af0cd4fedcab49a

6 years agoFix typo in Function.h
Qinfan Wu [Fri, 25 Aug 2017 10:05:04 +0000 (03:05 -0700)]
Fix typo in Function.h

Summary: [Folly] Fix typo in `Function.h`.

Reviewed By: yfeldblum

Differential Revision: D5703550

fbshipit-source-id: 9dc09697fd09db6c65b1a4f2d8bdf44451b4aab2

6 years agoadd public kSlotSize to IndexedMemPool
Greg Nisbet [Fri, 25 Aug 2017 00:53:08 +0000 (17:53 -0700)]
add public kSlotSize to IndexedMemPool

Summary:
add public kSlotSize to IndexedMemPool,
needed to support getting the approximate memory footprint of the pool
(since a Slot has two atomic uint32_t's more than a bare Elem)

Reviewed By: yfeldblum

Differential Revision: D5690225

fbshipit-source-id: 667da6b67b339038b92b0e5acde17219fe1c85c5

6 years agoAdded rvalue and const rvalue overloads to Try
Aaryaman Sagar [Thu, 24 Aug 2017 21:46:17 +0000 (14:46 -0700)]
Added rvalue and const rvalue overloads to Try

Summary:
Try was missing some important-ish overloads that help it behave well
in rvalue contexts

Reviewed By: yfeldblum

Differential Revision: D5692021

fbshipit-source-id: c34627b56eb52dceaeb1f00ae930ee3bc6e00306

6 years agounwrapTryTuple only accepted rvalue tuple types
Aaryaman Sagar [Thu, 24 Aug 2017 21:42:53 +0000 (14:42 -0700)]
unwrapTryTuple only accepted rvalue tuple types

Summary:
unwrapTryTuple only accepted rvalue tuple types, this diff fixes that
to work with forwarding reference tuple types.

Also reduces the number of template instantiations

Reviewed By: yfeldblum

Differential Revision: D5682996

fbshipit-source-id: ee6dd2c20d8dfca33e769a98a6ca56fa96c73b72

6 years agoCreate generic method to extract mac address from EUI-64 constructed addresses
Andrii Kryzhyk [Thu, 24 Aug 2017 19:08:18 +0000 (12:08 -0700)]
Create generic method to extract mac address from EUI-64 constructed addresses

Summary: Link local is not the only type of address that is based on mac address, therefore create generic function to extract mac address from EUI-64 autoconfigured addresses using the same logic as for getMacAddressFromLinkLocal

Reviewed By: pallotron

Differential Revision: D5697781

fbshipit-source-id: 4d69085a1d8f08e06496b8a9b638ac7ff31c6c3a

6 years agoImprove formatting of scripts and test files
Peter DeLong [Thu, 24 Aug 2017 17:16:37 +0000 (10:16 -0700)]
Improve formatting of scripts and test files

Summary: Reformatted the scripts and test files to look better and also to avoid lint warnings in the future

Reviewed By: andriigrynenko

Differential Revision: D5673856

fbshipit-source-id: 5818625ec14d18ef3b9b804df53949afefc3b98f

6 years agoAdd LZMA streaming interface
Stella Lau [Thu, 24 Aug 2017 16:26:59 +0000 (09:26 -0700)]
Add LZMA streaming interface

Summary:
- Replace LZMA2Codec with LZMA2StreamCodec
- Update tests to reflect LZMA2_VARINT_SIZE requiring data length

Reviewed By: terrelln

Differential Revision: D5625388

fbshipit-source-id: 3303c6dda5d41f40615c87504a46923815b0b716

6 years agoTry::exception overload for Try&&
Yedidya Feldblum [Thu, 24 Aug 2017 07:42:16 +0000 (00:42 -0700)]
Try::exception overload for Try&&

Summary:
[Folly] `Try::exception` overload for `Try&&`.

For consistency with `Try::value`.

Reviewed By: WillerZ

Differential Revision: D5691758

fbshipit-source-id: 9904b2a5c90f4575a3c09dc012658d359d11fdd9

6 years agoRename FOLLY_A64 to FOLLY_AARCH64
Christopher Dykes [Thu, 24 Aug 2017 05:51:43 +0000 (22:51 -0700)]
Rename FOLLY_A64 to FOLLY_AARCH64

Summary:
`FOLLY_AARCH64` is more descriptive.
(searching for A64 tells you nothing, searching for aarch64 tells you a lot)

Reviewed By: yfeldblum, andrewjcg

Differential Revision: D5663075

fbshipit-source-id: 8f31fde4aa394f5452305929541af6d38e4d8a37

6 years agoupdate README for ubuntu 16.04 LTS + custom boost installation details
shane [Thu, 24 Aug 2017 00:40:02 +0000 (17:40 -0700)]
update README for ubuntu 16.04 LTS + custom boost installation details

Summary:
the README didn't have explicit instructions for ubuntu 16.04 LTS...  now it does.

i also added a section for how to handle building folly w/a custom boost installation.
Closes https://github.com/facebook/folly/pull/664

Reviewed By: eduardo-elizondo

Differential Revision: D5694143

Pulled By: yfeldblum

fbshipit-source-id: e2786d045c3459cac49c8b052d90ca24d10f7922

6 years agomacro to enable scoped trace section functionality
Alison Tsai [Wed, 23 Aug 2017 23:50:28 +0000 (16:50 -0700)]
macro to enable scoped trace section functionality

Summary: Add a macro to enable optional scoped trace section functionality (user-defined). This macro will have no effect unless configured to do so. This change means that if proxygen is being upgraded, folly must also be updated.

Reviewed By: mzlee

Differential Revision: D5635123

fbshipit-source-id: 7db17f6ae8c0d1484cf9fad043eb42717279bd0a

6 years agoUse simple exception_wrapper ctor in the Promise::setException test
Yedidya Feldblum [Tue, 22 Aug 2017 22:51:49 +0000 (15:51 -0700)]
Use simple exception_wrapper ctor in the Promise::setException test

Summary:
[Folly] Use simple `exception_wrapper` ctor in the `Promise::setException` test.

And add a new case testing with `exception_ptr`.

Reviewed By: andrewjcg

Differential Revision: D5683035

fbshipit-source-id: e8276166dacbe09a9a745271d636db44c593058c

6 years agoAdded a for_each function to iterate through ranges
Aaryaman Sagar [Tue, 22 Aug 2017 17:54:11 +0000 (10:54 -0700)]
Added a for_each function to iterate through ranges

Summary:
Adding a for_each function that allows generalized indexed and breakable iteration through ranges, these can either be runtime ranges (i.e. entities for which std::begin and std::end work) or compile time ranges (as deemed by the presence of a std::tuple_length<>, get<> (ADL resolved) functions)

The function is made to provide a convenient library based solution to the proposal p0589r0, which aims to generalize the range based for loop even further to work with compile time ranges

A drawback of using range based for loops is that sometimes you do not have access to the index within the range.  This provides easy access to that, even with compile time ranges.

Further this also provides a good way to break out of a loop without any overhead when that is not used.

A simple use case would be when using futures, if the user was doing calls to n servers then they would accept the callback with the futures like this

   auto vec = std::vector<std::future<int>>{request_one(), ...};
   when_all(vec.begin(), vec.end()).then([](auto futures) {
     folly::for_each(futures, [](auto& fut) { ... });
   });

Now when this code switches to use tuples instead of the runtime std::vector, then the loop does not need to change, the code will still work just fine

   when_all(future_one, future_two, future_three).then([](auto futures) {
     folly::for_each(futures, [](auto& fut) { ... });
   });

Reviewed By: yfeldblum

Differential Revision: D5557336

fbshipit-source-id: 79fcbafa7e1671f8856f0dcb7bf7996435dadeaa

6 years agoExplicitly initialize AsyncSocket in MockAsyncSSLSocket
Mingtao Yang [Tue, 22 Aug 2017 17:36:32 +0000 (10:36 -0700)]
Explicitly initialize AsyncSocket in MockAsyncSSLSocket

Summary:
Even though MockAsyncSSLSocket's initializes AsyncSSLSocket, which should
initialize AsyncSocket, this does not actually happen because AsyncSSLSocket
virtually inherits from AsyncSocket.

Because of this, prior to this diff, the MockAsyncSSLSocket was not properly
setting its EventBase.

Reviewed By: knekritz

Differential Revision: D5676596

fbshipit-source-id: 5f3c0e848179cb5eb4d2dc4921a11e7c04d7c0e0

6 years agoUse exception_wrapper::from_exception_ptr in Try and Promise
Yedidya Feldblum [Tue, 22 Aug 2017 04:10:34 +0000 (21:10 -0700)]
Use exception_wrapper::from_exception_ptr in Try and Promise

Summary:
[Folly] Use `exception_wrapper::from_exception_ptr` in `Try` and `Promise`.

It does just what we need; DRY.

Reviewed By: andrewjcg

Differential Revision: D5674663

fbshipit-source-id: 73e46df62c06736c4eaf013d05dfea819cbec515

6 years agoAdd zlib-specific codec initialization
Stella Lau [Tue, 22 Aug 2017 01:15:27 +0000 (18:15 -0700)]
Add zlib-specific codec initialization

Summary:
- Create interface to initialize zlib codec using specific parameters
- This enables the raw inflate/deflate and auto inflate options
- Add tests for option initialization

Reviewed By: terrelln, yfeldblum

Differential Revision: D5649980

fbshipit-source-id: fd36e8edc0e8c528cd6c9d8f39e8ef839b6acfef

6 years agoexception_wrapper::from_exception_ptr
Yedidya Feldblum [Mon, 21 Aug 2017 18:38:39 +0000 (11:38 -0700)]
exception_wrapper::from_exception_ptr

Summary:
[Folly] `exception_wrapper::from_exception_ptr`.

A handry helper for converting from `std::exception_ptr` to `folly::exception_wrapper`.

Reviewed By: ericniebler

Differential Revision: D5668179

fbshipit-source-id: a81a60cb22a2a697714268e027af62dd8825d2c3

6 years agoSynchronizedPtr
Phil Willoughby [Mon, 21 Aug 2017 12:07:57 +0000 (05:07 -0700)]
SynchronizedPtr

Summary: Fairly minimal API to start with. Refer to the comments for the rationale/usage.

Reviewed By: yfeldblum

Differential Revision: D5554854

fbshipit-source-id: 173bf7c40e70b55bf6afb8c4bc9e83d48f90b6ee

6 years agoRecommended cipher list for server side. v2017.08.21.00
Xiangyu Bu [Fri, 18 Aug 2017 23:59:18 +0000 (16:59 -0700)]
Recommended cipher list for server side.

Summary: A SSLOptions recommended for cipher use.

Reviewed By: yfeldblum

Differential Revision: D5614280

fbshipit-source-id: a6b1adfa8d168f35c7bc7d4088c4073c3f4084a5

6 years agoLet SSLContext::setCipherList accept generic container type.
Xiangyu Bu [Fri, 18 Aug 2017 23:35:27 +0000 (16:35 -0700)]
Let SSLContext::setCipherList accept generic container type.

Summary:
Make SSLContext::setCipherList() and SSLContext::setSignatureAlgorithms()
accept std::array besides std::vector so that cipher lists in SSLOptions
can be initialized POD.

Reviewed By: yfeldblum

Differential Revision: D5578758

fbshipit-source-id: 7e5c2e9a75600e93c89e7b13a9042434a4189384

6 years agoDrop jemalloc specific smartRealloc integration
Dave Watson [Fri, 18 Aug 2017 15:45:44 +0000 (08:45 -0700)]
Drop jemalloc specific smartRealloc integration

Summary:
This was added several jemalloc versions ago, and is no longer a win.

From microbenches in folly/test, this codepath is successful less than .5% of the time.

There are a handful of other places directly using this (fbvector, IOBuf, ThreadLocal),
but should probably change them individually.

Reviewed By: interwq

Differential Revision: D5596678

fbshipit-source-id: 354d7204f61df0eace4d98d930d0f6e06a90ffde

6 years agoRemove outdated comments referencing removed TAsyncSSLServerSocket
David Lam [Fri, 18 Aug 2017 05:59:58 +0000 (22:59 -0700)]
Remove outdated comments referencing removed TAsyncSSLServerSocket

Summary:
TAsyncSSLServerSocket was deleted in D1806807, so we should remove
these comments.

Reviewed By: yfeldblum

Differential Revision: D5657431

fbshipit-source-id: ca875293737ad8ba0a8c028c9bfa5651f4a6065f

6 years agoFix incorrect format in Overview markdown
darrenl [Fri, 18 Aug 2017 05:41:29 +0000 (22:41 -0700)]
Fix incorrect format in Overview markdown

Summary:
The format is incorrect in [Overview.md](https://github.com/facebook/folly/blob/master/folly/docs/Overview.md)
Closes https://github.com/facebook/folly/pull/661

Reviewed By: eduardo-elizondo

Differential Revision: D5657083

Pulled By: yfeldblum

fbshipit-source-id: a9cedb413cbb3d455f4c1e5f785d05a33f8182c8

6 years agoFix undefined behavior when decoding varint
Stella Lau [Thu, 17 Aug 2017 23:34:56 +0000 (16:34 -0700)]
Fix undefined behavior when decoding varint

Summary: Left shifting `0x7f` by `63` is undefined behavior (i.e. when decoding `0xFFFF...`)

Reviewed By: yfeldblum, terrelln

Differential Revision: D5653353

fbshipit-source-id: c74c9f43a9bc82d15a2223df853dc533cea1478b

6 years agoAdd getSSLContext() to AsyncSSLSocket
Mingtao Yang [Thu, 17 Aug 2017 20:54:11 +0000 (13:54 -0700)]
Add getSSLContext() to AsyncSSLSocket

Reviewed By: knekritz

Differential Revision: D5632201

fbshipit-source-id: 5db380379ab6cb608922c77dd716bfc4410b2cd8

6 years agoChange AsyncSSLSocket getSecurityProtocol to handle unencrypted mode
Neel Goyal [Thu, 17 Aug 2017 17:59:06 +0000 (10:59 -0700)]
Change AsyncSSLSocket getSecurityProtocol to handle unencrypted mode

Summary: Return empty string for `getSecurityProtocol` if the socket is good and the handshake failed, otherwise "TLS"

Reviewed By: knekritz

Differential Revision: D5647637

fbshipit-source-id: b95cbf39e4bb7f89b1ebcbc0238c2becba7ad42a

6 years agoRemove a use of SFINAE in the Range constructor.
Phil Willoughby [Thu, 17 Aug 2017 08:27:07 +0000 (01:27 -0700)]
Remove a use of SFINAE in the Range constructor.

Summary:
Specifically, the constructor `implicit Range(Iter)` is now declared and defined for all `Range` specializations. It is an error to use it, and we `static_assert`, unless `Iter` is `char const *` or `char *`.

Performance effect
 ---
Measuring compilation-time on a file that just make ~40k StringPieces, compiled with -O3. All compilers produced identical code before/after this change.

* clang-trunk: 4% improvement
* gcc-5: no change
* gcc-4.9: 11% improvement
* gcc-7.1: 5% improvement

Could this possibly break any existing code?
 ---
Yes. If you have a function that's overloaded for both `Range<char const*>` and `Range<X>` and your input object is not `char const*` and is implicitly convertible to both `char const*` and `X`: that is now ambiguous whereas before it would unambiguously pick the `Range<char const*>` overload. I don't consider this scenario likely.

Why should this work?
 ---
Using SFINAE is more expensive at compile time (with some compilation environments) than not using it. It's necessary to use SFINAE when there is an alternative function which will be used in preference when the substitution fails, but when that is not the case it is on average cheaper to make the function always exist and use static_assert to disallow the bad uses of it. A bonus is that the caller gets a more comprehensible error message.

Reviewed By: nbronson

Differential Revision: D5639502

fbshipit-source-id: 13469f2995a487398734f86108087fdc8e32ad71

6 years agoOptionally run autoconf
Philip Jameson [Thu, 17 Aug 2017 00:46:52 +0000 (17:46 -0700)]
Optionally run autoconf

Summary:
This makes it so that the //folly:config rule can run autoconf to create folly-config

- Uses cxx_genrule get compiler settings and paths to dependent libraries
- Goes around a couple of oddities in the way that buck exports some of its macros
- While it uses buck_cxx_library, that's okay to use outside of facebook's internal repos.

Reviewed By: meyering

Differential Revision: D5620729

fbshipit-source-id: 0d2d8e3bda92182dcdcd3e80cb12a3756b3816ac

6 years agoAdd prepareSkipTo() method to EliasFanoReader
Rushy Panchal [Thu, 17 Aug 2017 00:19:03 +0000 (17:19 -0700)]
Add prepareSkipTo() method to EliasFanoReader

Summary:
`prepareSkipTo(x`) allows the client of EliasFanoReader to "hint" that
`skipTo(x)` will be called in the near future. The primary benefit of doing so
is that memory which is needed for `skipTo(x)` can be prefetched to minimize
cache misses incurred when calling `skipTo(x)`.

Reviewed By: ot, philippv

Differential Revision: D5508995

fbshipit-source-id: 4876b566256849f76193db3dc0404768aeeeb30d

6 years agoAdd ConcurrentHashMap installable
Shu Zhang [Wed, 16 Aug 2017 20:17:13 +0000 (13:17 -0700)]
Add ConcurrentHashMap installable

Summary:
ConcurrentHashMap is a newly added feature and we wanted to test it in our enviornment, making it installable.

Built & Installed on ubuntu 14 env.
Closes https://github.com/facebook/folly/pull/659

Reviewed By: djwatson

Differential Revision: D5629159

Pulled By: yfeldblum

fbshipit-source-id: 8a40e768f3db7918a3b284059f2efa0b7ecb9aca

6 years agofolly::ElfFile - add support to iterate over program headers
Mirek Klimos [Wed, 16 Aug 2017 04:04:27 +0000 (21:04 -0700)]
folly::ElfFile - add support to iterate over program headers

Summary: Adding iterateProgramHeaders, similar to iterateSections, just iterates over program headers instead of section headers. I want this to get the size of the first PT_LOAD header.

Differential Revision: D5602575

fbshipit-source-id: f73989cade20214f884571c1099761ecaa4841f7

6 years agoFix destruction order
Maged Michael [Wed, 16 Aug 2017 01:01:19 +0000 (18:01 -0700)]
Fix destruction order

Summary:
- Added `hazptr.cpp` and `memory_resource.cpp`. Moved singleton code to source.
  - Changed the singleton for the default `hazptr_domain` to a global.
  - Changed hazptr_stats singleton to a global.
  - Moved the thread caching calls from the hazptr_domain functions to the constructor/destructor of hazptr_holder.
  - Changed the TLS singletons to TLS globals.
  - Changed some inlining directives.
  - Leak the hazptr_rec-s in the default domain

Reviewed By: davidtgoldblatt, djwatson

Differential Revision: D5553753

fbshipit-source-id: da69eecec55c0f78fb8ef5591f9aeffee99ff3fa

6 years agotry to fix folly, wangle, etc open-source build
Alexey Spiridonov [Tue, 15 Aug 2017 17:52:45 +0000 (10:52 -0700)]
try to fix folly, wangle, etc open-source build

Summary: add missing source files to Makefile

Reviewed By: andriigrynenko

Differential Revision: D5630758

fbshipit-source-id: 0f04c11b65fd3a6f4f33e34ae57c0fcba8671e97

6 years agoAdd hooks to track which threads belong to which thread pools
Peter DeLong [Mon, 14 Aug 2017 23:40:47 +0000 (16:40 -0700)]
Add hooks to track which threads belong to which thread pools

Summary:
Keep track of which threads belong to which thread pools for use when debugging.
This will be paired with a gdb script that associates threads with their thread pools

Reviewed By: andriigrynenko

Differential Revision: D5514729

fbshipit-source-id: 57ada4dd1aaaec5d7026e4eee05b0ec4e7434c77

6 years agoallow comparing Optional<T> with none
Nick Wolchko [Mon, 14 Aug 2017 19:49:06 +0000 (12:49 -0700)]
allow comparing Optional<T> with none

Summary:
`std::optional` supports comparing with `std::nullopt`, so
`folly::Optional` should do the same with `folly::none`.
This also involves marking hasValue() noexcept to be the same as `std::optional`.

Reviewed By: yfeldblum, WillerZ

Differential Revision: D5617825

fbshipit-source-id: a4b863dd61c3a86223fb21a5b7759e7c295fd272

6 years agoAsyncSSLSocket::get/setClientCertValidationResult API.
Xiangyu Bu [Mon, 14 Aug 2017 17:13:58 +0000 (10:13 -0700)]
AsyncSSLSocket::get/setClientCertValidationResult API.

Summary:
The added API will be used for storing and retrieving validation result of client cert.

At some point we may change "client" to "peer" to make it generic.

Reviewed By: anirudhvr

Differential Revision: D5610404

fbshipit-source-id: 2feb03abc0594af4c68db33d8885ea214867148a

6 years agosmall_vector default constructor shouldn't be explicit v2017.08.14.00
Nathan Bronson [Thu, 10 Aug 2017 19:35:20 +0000 (12:35 -0700)]
small_vector default constructor shouldn't be explicit

Summary:
Containers should not tag their default constructor explicit,
because it means that you can't return an empty one with "return {};".
This diff removes the explicit tag from small_vector's default
constructor.

Reviewed By: meyering

Differential Revision: D5602749

fbshipit-source-id: 2a4a356134c69d01e3b040719dc6ffca0fe97e75

6 years agofix sorted_vector_{set,map} bulk_insert deduplication
Nick Jiang [Wed, 9 Aug 2017 22:23:24 +0000 (15:23 -0700)]
fix sorted_vector_{set,map} bulk_insert deduplication

Summary: this fixes the case where bulk inserting a range where the smallest element is equal to the largest element of the current set/map fails to deduplicate that element.

Reviewed By: mlogan, yfeldblum

Differential Revision: D5593284

fbshipit-source-id: 487500ee7a5e33f27c24321ad4a3c07a669fc26c

6 years agoExplicitly handle gcc in FOLLY_MAYBE_UNUSED
Yedidya Feldblum [Wed, 9 Aug 2017 21:55:17 +0000 (14:55 -0700)]
Explicitly handle gcc in FOLLY_MAYBE_UNUSED

Summary:
[Folly] Explicitly handle gcc in `FOLLY_MAYBE_UNUSED`.

Fixes build break from {D5562220}.

Reviewed By: Orvid

Differential Revision: D5594288

fbshipit-source-id: 5aa2dcb6133d53a0eb20d34b67c8e4407dd2b7ca

6 years agoCut unnecessary parens in IPAddress.h
Yedidya Feldblum [Wed, 9 Aug 2017 18:21:38 +0000 (11:21 -0700)]
Cut unnecessary parens in IPAddress.h

Summary: [Folly] Cut unnecessary parens in `IPAddress.h`.

Reviewed By: meyering

Differential Revision: D5589756

fbshipit-source-id: 6499e0db2aeb232356e2808fc59a35869b5dad0a

6 years agoLet IPAddressV4::bitCount and IPAddressV6::bitCount be constexpr
Yedidya Feldblum [Wed, 9 Aug 2017 03:27:39 +0000 (20:27 -0700)]
Let IPAddressV4::bitCount and IPAddressV6::bitCount be constexpr

Summary: [Folly] Let `IPAddressV4::bitCount` and `IPAddressV6::bitCount` be `constexpr`.

Reviewed By: meyering

Differential Revision: D5589954

fbshipit-source-id: f4208efd62e71f47a7c87bdc8ddd421f93413c29

6 years agoApply clang-format to folly/**/*Address*.*
Yedidya Feldblum [Tue, 8 Aug 2017 21:40:04 +0000 (14:40 -0700)]
Apply clang-format to folly/**/*Address*.*

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

Reviewed By: Orvid

Differential Revision: D5581523

fbshipit-source-id: 97b5270e43e279e7deb9606524d5fee844a50649

6 years agoAdd a UDL suffix to define a StringPiece
Phil Willoughby [Tue, 8 Aug 2017 10:19:16 +0000 (03:19 -0700)]
Add a UDL suffix to define a StringPiece

Summary:
Use it like this:
```
using namespace folly::string_piece_literals;
StringPiece p = "A literal string"_sp;
```

In some compilation environments it can be more efficient than the implicit
conversion from `char const *` to `StringPiece`.

Reviewed By: yfeldblum

Differential Revision: D5562782

fbshipit-source-id: ce715edc65b1510761e127bf89a6936370253a68

6 years agoDon't allow Future::onError([](exception_wrapper&){}) to compile
Sargun Vohra [Mon, 7 Aug 2017 20:29:40 +0000 (13:29 -0700)]
Don't allow Future::onError([](exception_wrapper&){}) to compile

Summary: `Future::onError` does not work with a function that takes `exception_wrapper&`, so it should not compile. `exception_wrapper`, `const exception_wrapper&`, and `exception_wrapper&&` are unaffected.

Reviewed By: yfeldblum

Differential Revision: D5556083

fbshipit-source-id: 45d096d9fee00322eeec6b9b9b1dcbef55cced03

6 years agoConsistent use of sformat in address-related files v2017.08.07.00
Yedidya Feldblum [Sun, 6 Aug 2017 05:09:13 +0000 (22:09 -0700)]
Consistent use of sformat in address-related files

Summary:
[Folly] Consistent use of `sformat` in address-related files.

V.s. `format(/*...*/).str()` and v.s. `to<std::string>`.

Reviewed By: meyering

Differential Revision: D5570334

fbshipit-source-id: 83aedf9a694721fb209e62e94f1a5c5ecd355e81

6 years agoApply clang-format to folly/**/*Range*.*
Yedidya Feldblum [Sun, 6 Aug 2017 05:00:20 +0000 (22:00 -0700)]
Apply clang-format to folly/**/*Range*.*

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

Reviewed By: meyering

Differential Revision: D5570553

fbshipit-source-id: 230aa8557c2d402d741aaa541f96f4634dd13d3b

6 years agoTest server-side getPeerCert().
Xiangyu Bu [Fri, 4 Aug 2017 21:32:14 +0000 (14:32 -0700)]
Test server-side getPeerCert().

Summary: Make sure server can get client cert using AsyncSSLSocket::getPeerCert() call.

Reviewed By: anirudhvr

Differential Revision: D5557303

fbshipit-source-id: d95696f592e3b3f67acba9f92add32b91c29a000

6 years agoClang-format AsyncSSLSocketTest.cpp.
Xiangyu Bu [Fri, 4 Aug 2017 17:54:29 +0000 (10:54 -0700)]
Clang-format AsyncSSLSocketTest.cpp.

Summary: ... as titled.

Reviewed By: yfeldblum

Differential Revision: D5558742

fbshipit-source-id: b63b121cde8db93de4cabc80563539297611d600

6 years agoReplacing instances of __CLANG__ with __clang__
Marko Novakovic [Fri, 4 Aug 2017 06:02:17 +0000 (23:02 -0700)]
Replacing instances of __CLANG__ with __clang__

Summary:
Clang compiler does not define `__CLANG__` macro and
only defines `__clang__`, but we use `__CLANG__` in a
few places in the code which was probably done by mistake.
This should make the code behave in the intended way.

Reviewed By: yfeldblum

Differential Revision: D5542162

fbshipit-source-id: 74d24ba9464d8faec160d73e6c582967d3c80c19

6 years agoAdd X509_EXTENSION unique pointer
Alex Guzman [Thu, 3 Aug 2017 21:18:34 +0000 (14:18 -0700)]
Add X509_EXTENSION unique pointer

Summary: Adds unique pointer type for X509_EXTENSION

Reviewed By: knekritz

Differential Revision: D5556504

fbshipit-source-id: b84190f20dd0a2ee9f5f07f197caf53a9a063af7

6 years agoReduce Code Duplication In NotificationQueue With Universal Reference
Adam Norton [Thu, 3 Aug 2017 17:08:17 +0000 (10:08 -0700)]
Reduce Code Duplication In NotificationQueue With Universal Reference

Summary: Remove a bunch of identical code that only exists to provide interfaces for both `const MessageT&` and `MessageT&&` arguments.

Reviewed By: ot

Differential Revision: D5540560

fbshipit-source-id: ae7b9345b64130fc748033be2e0587c4f83345a7

6 years agoFix error in comment.
Martin Martin [Wed, 2 Aug 2017 18:25:45 +0000 (11:25 -0700)]
Fix error in comment.

Summary: Speaking of errors...

Reviewed By: philippv

Differential Revision: D5545916

fbshipit-source-id: cc8471c2f0fc3cefaa9f8493d9b976098f896176

6 years agoFix for building with icc.
Greg Bentley [Wed, 2 Aug 2017 02:15:32 +0000 (19:15 -0700)]
Fix for building with icc.

Summary: Closes https://github.com/facebook/folly/pull/649

Reviewed By: Orvid

Differential Revision: D5535534

Pulled By: yfeldblum

fbshipit-source-id: 641186d6171479755bd9471a484b8b3c2ab62418

6 years agoCreate X509_STORE ptr type
Alex Guzman [Tue, 1 Aug 2017 23:23:36 +0000 (16:23 -0700)]
Create X509_STORE ptr type

Summary: What it says on tin

Reviewed By: knekritz

Differential Revision: D5533819

fbshipit-source-id: e3ba89f02d20d171fbcb8ed2853267d37bd86756

6 years agoCut debugging code from SocketAddress
Yedidya Feldblum [Tue, 1 Aug 2017 22:53:15 +0000 (15:53 -0700)]
Cut debugging code from SocketAddress

Summary:
[Folly] Cut debugging code from `SocketAddress`.

Specifically from its `ExternalUnixAddr` helper class, which is probably not broken.

Reviewed By: simpkins

Differential Revision: D5530685

fbshipit-source-id: adfc46ec1c1a142e9914051e8a97b39f41d71630

6 years agoC++11 support for Replaceable
Phil Willoughby [Tue, 1 Aug 2017 19:20:30 +0000 (12:20 -0700)]
C++11 support for Replaceable

Summary: Also add tests for the `is_replaceable` trait.

Reviewed By: yfeldblum

Differential Revision: D5526317

fbshipit-source-id: 92559d55fbb8d115856ef9e8f86b42e327f74e56

6 years agoAdd TLS 1.2+ version for contexts
Neel Goyal [Tue, 1 Aug 2017 19:18:25 +0000 (12:18 -0700)]
Add TLS 1.2+ version for contexts

Summary: Add an SSL Version that specifies only TLS 1.2 and up.  This prevents any client with less than TLS 1.2 from connecting.

Reviewed By: knekritz

Differential Revision: D5537423

fbshipit-source-id: 131f5b124af379eaa2b443052be9b43290c41820

6 years agoChange AsyncUDP's readCallback to be protected.
Neel Goyal [Tue, 1 Aug 2017 15:37:13 +0000 (08:37 -0700)]
Change AsyncUDP's readCallback to be protected.

Summary: Change AsyncUDPSocket's ReadCallback to be protected so that subclasses can have access to it.

Reviewed By: yangchi

Differential Revision: D5376012

fbshipit-source-id: 7ec21d9bfe6bde525253adea7abf5dea15fb7fa0

6 years agoDRY some methods in IPAddress
Yedidya Feldblum [Tue, 1 Aug 2017 02:42:53 +0000 (19:42 -0700)]
DRY some methods in IPAddress

Summary:
[Folly] DRY some methods in `IPAddress`.

Specifically, the ones which just delegate to either `asV4()` or to `asV6()`.

Reviewed By: mzlee

Differential Revision: D5529797

fbshipit-source-id: 4dd3dc893ab19281325700b85400c1c1aadfd77f

6 years agoMake sendmsg in AsyncUDPSocket overridable
Yang Chi [Mon, 31 Jul 2017 20:48:23 +0000 (13:48 -0700)]
Make sendmsg in AsyncUDPSocket overridable

Summary: Add a protected virtual sendmsg method to AsyncUDPSocket. And make it default to call the system sendmsg function. This enables subclasses of AsyncUDPSocket to be able to override the behavior of sendmseg, also makes AsyncUDPSocket easier to mock and test.

Reviewed By: afrind

Differential Revision: D5459745

fbshipit-source-id: b0227bf7503b1096cb1f0bfc8b9c784db2f2e45d

6 years agoNo need for strncpy in passwordCallback
Yedidya Feldblum [Mon, 31 Jul 2017 19:04:10 +0000 (12:04 -0700)]
No need for strncpy in passwordCallback

Summary:
[Folly] No need for `strncpy` in `passwordCallback`.

Careful reading of the documentation:

> The pem_passwd_cb must write the password into the provided buffer `buf` which is of size `size`.
>
> https://wiki.openssl.org/index.php?title=Manual:SSL_CTX_set_default_passwd_cb(3)&oldid=761

No mention is made of a requirement on the password being written into `buf` that it be null-terminated.

Reviewed By: knekritz, meyering

Differential Revision: D5524814

fbshipit-source-id: 6cfc588cdf3675281ffe39e6af376f3f0631d1b0

6 years agoRemove template helper constants
Phil Willoughby [Mon, 31 Jul 2017 08:35:58 +0000 (01:35 -0700)]
Remove template helper constants

Summary: Not supported by some environments.

Reviewed By: yfeldblum

Differential Revision: D5526180

fbshipit-source-id: 2c2b6f7627860c5f896532b90601c817530e6b69

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

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

Reviewed By: Orvid

Differential Revision: D5524744

fbshipit-source-id: ced4dd2398ed6baa3ad5b68b74eee6a5d6b2b103

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

Summary: [Folly] Formatting for template parameters.

Reviewed By: Orvid

Differential Revision: D5525123

fbshipit-source-id: 4feb772300cfdd6ae3168fe9f59f5a951fb85d0e

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

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

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

Reviewed By: Orvid

Differential Revision: D5525144

fbshipit-source-id: bc27f112ed0d9b55befe9dabe08c4d345a402435

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

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

Reviewed By: Orvid

Differential Revision: D5523933

fbshipit-source-id: 371c9ecc707e48dcc05fa4aab4fd326111466161

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

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

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

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

Reviewed By: Orvid

Differential Revision: D5524229

fbshipit-source-id: 21d6938e20cd675e65499a5b64d2af934f980222

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

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

Reviewed By: andrewjcg

Differential Revision: D5524869

fbshipit-source-id: 53e4b6cbda10d5b63bafbd535794a8b7ae01a8e0

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

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

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

Reviewed By: andrewjcg

Differential Revision: D5524792

fbshipit-source-id: 6614eecf384bf3e3ccc2f0cc7c5334a0cb9c76af

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

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

They did not need to be implicit.

Reviewed By: andrewjcg

Differential Revision: D5524798

fbshipit-source-id: a50bc6bfc9da2642891faf0aa38a19f46e75b9da

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

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

Reviewed By: andrewjcg

Differential Revision: D5524248

fbshipit-source-id: 5f5f2acd6e9cfd6dfd148cc7d95bda720bf81ee9

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

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

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

Reviewed By: andrewjcg

Differential Revision: D5524267

fbshipit-source-id: e128c69c7da38663f19d0ccd73edaae36c3f469a

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

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

Reviewed By: ericniebler

Differential Revision: D5522791

fbshipit-source-id: 545185bc580ea8628075b9ecae46c2f19308e937

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

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

Reviewed By: WillerZ

Differential Revision: D5524197

fbshipit-source-id: ebeeab28304bff4f6150cf76216d170908e62aa4

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

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

Reviewed By: yfeldblum

Differential Revision: D5516628

fbshipit-source-id: 3e688c34f061511df5b68243111fecb83483d79d