1. 04 Jun, 2017 3 commits
  2. 03 Jun, 2017 1 commit
    • Yedidya Feldblum's avatar
      Apply clang-format to folly/gen/ (partial: namespace) · bbc51806
      Yedidya Feldblum authored
      Summary:
      [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
      bbc51806
  3. 02 Jun, 2017 4 commits
    • Yedidya Feldblum's avatar
      Apply clang-format to folly/portability/ · 1b67e9aa
      Yedidya Feldblum authored
      Summary:
      [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
      1b67e9aa
    • Qi Wang's avatar
      Fix JemallocNodumpAllocator extent_hooks API. · 5fc76bd2
      Qi Wang authored
      Summary: Using extent_hooks mallctl to update hooks.
      
      Reviewed By: jasone
      
      Differential Revision: D5174623
      
      fbshipit-source-id: 9313ee9ae55c85d973736077727e54a5825f4c3d
      5fc76bd2
    • Maged Michael's avatar
      Hazard pointers: Optimize memory order, add bulk reclamation control, add... · 3c118217
      Maged Michael authored
      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
      3c118217
    • Qi Wang's avatar
      Update folly/JemallocNodumpAllocator to jemalloc 4 & 5 compatible. · a88d0d72
      Qi Wang authored
      Summary:
      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
      a88d0d72
  4. 01 Jun, 2017 6 commits
    • Christopher Dykes's avatar
      Remove InlineExecutor.cpp · 49399f7c
      Christopher Dykes authored
      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
      49399f7c
    • Tom Jackson's avatar
      Rephrase Optional usage to quite warnings · 4ae89dde
      Tom Jackson authored
      Reviewed By: yfeldblum
      
      Differential Revision: D5105818
      
      fbshipit-source-id: e3926a0c70a68855e0180bdd44cb0ec76e66bb94
      4ae89dde
    • Phil Willoughby's avatar
      Docs for SingletonThreadLocal · e51e7780
      Phil Willoughby authored
      Summary:
      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
      e51e7780
    • Tom Jackson's avatar
      Fix UB in folly/experimental/Bits.h · a1d62691
      Tom Jackson authored
      Summary:
      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
      a1d62691
    • Christopher Dykes's avatar
      Remove FiberManagerFuture.h as it's dead · d53c91d0
      Christopher Dykes authored
      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
      d53c91d0
    • Yedidya Feldblum's avatar
      Destroy promise/future callback functions before waking waiters · 8e110a76
      Yedidya Feldblum authored
      Summary:
      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.
      
      ```lang=c++
      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
      8e110a76
  5. 31 May, 2017 4 commits
    • Christopher Dykes's avatar
      Refactor the CMake file to work with CMake 3.8.2 · 3a4a9694
      Christopher Dykes authored
      Summary:
      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
      3a4a9694
    • Sven Over's avatar
      Future: some fixes re: handling of universal references · 8401bbaf
      Sven Over authored
      Summary:
      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
      8401bbaf
    • Jon Maltiel Swenson's avatar
      Add non-throwing alternative to decodeVarint · ba9034b9
      Jon Maltiel Swenson authored
      Summary:
      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
      ba9034b9
    • Bi Xue's avatar
      add equals interface for Range class. · da541af3
      Bi Xue authored
      Summary:
      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
      da541af3
  6. 28 May, 2017 4 commits
    • Qinfan Wu's avatar
      Fix tryTo to support conversion to enumerations · e49575d4
      Qinfan Wu authored
      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
      e49575d4
    • Yiding Jia's avatar
      folly/portability/Memory.cpp: restructure preprocessor conditionals so includes are at top level · 3a78d442
      Yiding Jia authored
      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
      3a78d442
    • Maxim Georgiev's avatar
      Moving DestructorCheck from proxygen library to folly. · c1a1a5e6
      Maxim Georgiev authored
      Summary:
      allow-large-files
      Moving DestructorCheck from proxygen library to folly.
      
      Reviewed By: djwatson
      
      Differential Revision: D5110897
      
      fbshipit-source-id: 02a6cf6336000e8c36484e75d2da820588baf2df
      c1a1a5e6
    • Christopher Dykes's avatar
      Clarify in the docs what belongs in portability/ · 314c43c4
      Christopher Dykes authored
      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
      314c43c4
  7. 27 May, 2017 1 commit
    • Philipp Unterbrunner's avatar
      Added folly::hint_emplace_iterator to folly/Iterator.h · 719b2df9
      Philipp Unterbrunner authored
      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
      719b2df9
  8. 26 May, 2017 1 commit
    • Christopher Dykes's avatar
      Fix build with Ninja generator · a7001e5c
      Christopher Dykes authored
      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: https://github.com/facebook/folly/issues/604
      
      Reviewed By: yfeldblum
      
      Differential Revision: D5134585
      
      fbshipit-source-id: 3816e53774f7963b9b4fd8ddf68b83ff7afdefe1
      a7001e5c
  9. 25 May, 2017 2 commits
    • Christopher Dykes's avatar
      Fix reliance on the sign of char in fnv32 and fnv64 · 22d531a8
      Christopher Dykes authored
      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
      22d531a8
    • Eric Niebler's avatar
      Replace FOLLY_WARN_UNUSED_RESULT with FOLLY_NODISCARD everywhere · 713e4298
      Eric Niebler authored
      Summary: `[[nodiscard]]` is the future. Let's start now.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D5108297
      
      fbshipit-source-id: c98f44af9e282616af92f9171516b6ea18e68c6d
      713e4298
  10. 24 May, 2017 6 commits
    • Nick Terrell's avatar
      Add zstd streaming interface · e1d2ddd5
      Nick Terrell authored
      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
      e1d2ddd5
    • Nick Terrell's avatar
      Add streaming API · 74560278
      Nick Terrell authored
      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
      74560278
    • Victor Gao's avatar
      apply clang-tidy modernize-use-override · e70058f4
      Victor Gao authored
      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
      e70058f4
    • Giuseppe Ottaviano's avatar
      A core-cached shared_ptr · b1eb5b68
      Giuseppe Ottaviano authored
      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
      b1eb5b68
    • Nick Terrell's avatar
      Heterogeneous comparisons · 8bca2fb2
      Nick Terrell authored
      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 https://github.com/facebook/folly/issues/602.
      
      Reviewed By: AsyncDBConnMarkedDownDBException
      
      Differential Revision: D5110651
      
      fbshipit-source-id: 34f3368283953033fbb2423ab30b04e38b5b7974
      8bca2fb2
    • Yedidya Feldblum's avatar
      RFC: Embed exception_wrapper directly into Try · 790b68ac
      Yedidya Feldblum authored
      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
      790b68ac
  11. 23 May, 2017 3 commits
    • Yedidya Feldblum's avatar
      Fix some old license headers · 27249d44
      Yedidya Feldblum authored
      Summary: [Folly] Fix some old license headers.
      
      Reviewed By: meyering
      
      Differential Revision: D5110463
      
      fbshipit-source-id: c7bb57194e0d33fbe1c6ddaa7d94437833b0cb0d
      27249d44
    • Eric Niebler's avatar
      Add FOLLY_NODISCARD for [[nodiscard]] attribute when it exists,... · 576710ca
      Eric Niebler authored
      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
      576710ca
    • Christopher Dykes's avatar
      Make a few implicit truncations either explicit, or not truncate · 3e0ea102
      Christopher Dykes authored
      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
      3e0ea102
  12. 22 May, 2017 3 commits
    • Christopher Dykes's avatar
      Enable -Wimplicit-fallthrough · 523ca7d7
      Christopher Dykes authored
      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
      523ca7d7
    • Christopher Dykes's avatar
      Shift the job of defining NOMINMAX into source rather than the build system · 887367ca
      Christopher Dykes authored
      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
      887367ca
    • Kyle Nekritz's avatar
      Add LOCK_SHAREDMUTEX SSLLockType. · c32f067b
      Kyle Nekritz authored
      Summary: To take advantage of read locks.
      
      Reviewed By: siyengar
      
      Differential Revision: D5106090
      
      fbshipit-source-id: a32afd698e9204196aa3d23f21a7d41803b2eb66
      c32f067b
  13. 20 May, 2017 2 commits
    • Yedidya Feldblum's avatar
      Refactor folly/gen/test/StringTest.cpp · b3e1ea38
      Yedidya Feldblum authored
      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
      b3e1ea38
    • Song Zhou's avatar
      Added a new variant of byLine to keep the delimiter · 98889326
      Song Zhou authored
      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
      98889326