Permalink
Commits on May 28, 2017
  1. Fix tryTo to support conversion to enumerations

    Summary:
    [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
    wqfish committed with facebook-github-bot May 28, 2017
  2. folly/portability/Memory.cpp: restructure preprocessor conditionals s…

    …o includes are at top level
    
    Summary:
    `#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
    yiding committed with facebook-github-bot May 28, 2017
  3. Moving DestructorCheck from proxygen library to folly.

    Summary:
    allow-large-files
    Moving DestructorCheck from proxygen library to folly.
    
    Reviewed By: djwatson
    
    Differential Revision: D5110897
    
    fbshipit-source-id: 02a6cf6336000e8c36484e75d2da820588baf2df
    maxgeorg committed with facebook-github-bot May 28, 2017
  4. 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
    Orvid committed with facebook-github-bot May 28, 2017
Commits on May 27, 2017
  1. Added folly::hint_emplace_iterator to folly/Iterator.h

    Summary:
    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
    philippu committed with facebook-github-bot May 27, 2017
Commits on May 26, 2017
  1. Fix build with Ninja generator

    Summary:
    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.
    
    Closes: #604
    
    Reviewed By: yfeldblum
    
    Differential Revision: D5134585
    
    fbshipit-source-id: 3816e53774f7963b9b4fd8ddf68b83ff7afdefe1
    Orvid committed with facebook-github-bot May 26, 2017
Commits on May 25, 2017
  1. Fix reliance on the sign of char in fnv32 and fnv64

    Summary:
    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
    Orvid committed with facebook-github-bot May 25, 2017
  2. Replace FOLLY_WARN_UNUSED_RESULT with FOLLY_NODISCARD everywhere

    Summary: `[[nodiscard]]` is the future. Let's start now.
    
    Reviewed By: yfeldblum
    
    Differential Revision: D5108297
    
    fbshipit-source-id: c98f44af9e282616af92f9171516b6ea18e68c6d
    Eric Niebler committed with facebook-github-bot May 25, 2017
Commits on May 24, 2017
  1. Add zstd streaming interface

    Summary:
    * Add streaming interface to the `ZstdCodec`
    * Implement `ZstdCodec::doCompress()` and `ZstdCodec::doUncompress()` using the streaming interface.
      [fbgs CodecType::ZSTD](https://fburl.com/pr8chg64) and check that no caller requires thread-safety.
    
    Reviewed By: yfeldblum
    
    Differential Revision: D5026558
    
    fbshipit-source-id: 61faa25c71f5aef06ca2d7e0700f43214353c650
    terrelln committed with facebook-github-bot May 24, 2017
  2. Add streaming API

    Summary:
    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
    terrelln committed with facebook-github-bot May 24, 2017
  3. apply clang-tidy modernize-use-override

    Summary:
    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
    Victor Gao committed with facebook-github-bot May 24, 2017
  4. A core-cached shared_ptr

    Summary:
    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
    ot committed with facebook-github-bot May 24, 2017
  5. Heterogeneous comparisons

    Summary:
    `std::optional` allows heterogeneous comparisons, so `folly::Optional` should as well.
    This allows numerical comparisons between different types, like `size_t` and `uint64_t`.
    
    Fixes #602.
    
    Reviewed By: AsyncDBConnMarkedDownDBException
    
    Differential Revision: D5110651
    
    fbshipit-source-id: 34f3368283953033fbb2423ab30b04e38b5b7974
    terrelln committed with facebook-github-bot May 24, 2017
  6. RFC: Embed exception_wrapper directly into Try

    Summary:
    [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
    yfeldblum committed with facebook-github-bot May 24, 2017
Commits on May 23, 2017
  1. Fix some old license headers

    Summary: [Folly] Fix some old license headers.
    
    Reviewed By: meyering
    
    Differential Revision: D5110463
    
    fbshipit-source-id: c7bb57194e0d33fbe1c6ddaa7d94437833b0cb0d
    yfeldblum committed with facebook-github-bot May 23, 2017
  2. 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
    Eric Niebler committed with facebook-github-bot May 23, 2017
  3. 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
    Orvid committed with facebook-github-bot May 22, 2017
Commits on May 22, 2017
  1. 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
    Orvid committed with facebook-github-bot May 22, 2017
  2. Shift the job of defining NOMINMAX into source rather than the build …

    …system
    
    Summary:
    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
    Orvid committed with facebook-github-bot May 22, 2017
  3. Add LOCK_SHAREDMUTEX SSLLockType.

    Summary: To take advantage of read locks.
    
    Reviewed By: siyengar
    
    Differential Revision: D5106090
    
    fbshipit-source-id: a32afd698e9204196aa3d23f21a7d41803b2eb66
    knekritz committed with facebook-github-bot May 22, 2017
Commits on May 20, 2017
  1. Refactor folly/gen/test/StringTest.cpp

    Summary:
    [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
    yfeldblum committed with facebook-github-bot May 20, 2017
  2. 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
    Song Zhou committed with facebook-github-bot May 20, 2017
  3. fix PicoSpinLock for aarch64 and allow PackedSyncPtr to compile for a…

    …arch64
    
    Summary:
    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
    Stephen Chen committed with facebook-github-bot May 20, 2017
  4. 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
    Orvid committed with facebook-github-bot May 20, 2017
  5. 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
    Orvid committed with facebook-github-bot May 20, 2017
  6. 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
    Orvid committed with facebook-github-bot May 20, 2017
  7. Work around a compiler crash in VS 2017.3 Preview 1

    Summary:
    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: https://developercommunity.visualstudio.com/content/problem/59614/compiler-crash-when-constexpr-constructing-stdchro.html
    
    Reviewed By: yfeldblum
    
    Differential Revision: D5099876
    
    fbshipit-source-id: 64d5573d78b14339ff3177dd910a22787463ccd2
    Orvid committed with facebook-github-bot May 20, 2017
Commits on May 19, 2017
  1. 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
    Orvid committed with facebook-github-bot May 19, 2017
  2. Remove FOLLY_SKIP_LIBCPP_4000_THROW_BACKPORTS

    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
    smeenai committed with facebook-github-bot May 19, 2017
  3. StampedPtr: use async-signal-safe assert

    Summary: Use SafeAssert instead of assert.
    
    Reviewed By: nbronson
    
    Differential Revision: D5085575
    
    fbshipit-source-id: daeff427b9b1fc5dff6ea986d16a70364acd2dd7
    shixiao committed with facebook-github-bot May 19, 2017
Commits on May 17, 2017
  1. 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
    snarkmaster committed with facebook-github-bot May 17, 2017
  2. Tweak basic_fbstring construction from std types

    Summary:
    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
    WillerZ committed with facebook-github-bot May 17, 2017
Commits on May 16, 2017
  1. Simplify ThreadedRepeatingFunctionRunner by requiring classes that co…

    …ntain 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
    snarkmaster committed with facebook-github-bot May 16, 2017
  2. gate sse42 implementation of checksum for x86 only

    Summary:
    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
    Stephen Chen committed with facebook-github-bot May 16, 2017
  3. Fix violations of unused-lambda-capture

    Summary: [Folly] Fix violations of `unused-lambda-capture`.
    
    Reviewed By: Orvid
    
    Differential Revision: D5060391
    
    fbshipit-source-id: 34aabc847719603d13da8f2b52a7ec187d803a4a
    yfeldblum committed with facebook-github-bot May 16, 2017