1. 04 Mar, 2019 1 commit
    • Lewis Baker's avatar
      Fix property_set_insert_t metafunction in pushmi · 8d53d77b
      Lewis Baker authored
      Summary: The property_set_insert_t<PS1, PS2> template metafunction had a bug that meant that it would fail to replace elements in the base set that had the same category as elements from the set being inserted.
      
      Reviewed By: ericniebler, kirkshoop
      
      Differential Revision: D14268145
      
      fbshipit-source-id: ccc64e455bc6ff2073229e028a19d64dc7050092
      8d53d77b
  2. 02 Mar, 2019 2 commits
    • Yedidya Feldblum's avatar
      Mark BitIterator with the category of the base · 973c5bb8
      Yedidya Feldblum authored
      Summary:
      [Folly] Mark `BitIterator<BaseIterator>` with the iterator category of `BitIterator`.
      
      As one benefit, using `std::distance` to find the distance between two `BitIterator`s gotten from a random access container such as `std::vector` is now constant-time.
      
      Fixes #1026.
      
      Reviewed By: ot
      
      Differential Revision: D14294852
      
      fbshipit-source-id: 2345bc73dec169803ae41b9391687e89ad77207b
      973c5bb8
    • Yedidya Feldblum's avatar
      Support C++11 in folly/IPAddress.h w.r.t. aligned_union · 40df9484
      Yedidya Feldblum authored
      Summary: [Folly] Support C++11 in `folly/IPAddress.h` w.r.t. `aligned_union` by avoiding `aligned_union_t`, which is C++14.
      
      Reviewed By: spalamarchuk, mengz0
      
      Differential Revision: D14278604
      
      fbshipit-source-id: 474ac0aa0110f4939d1042d334b69feb6b2644cb
      40df9484
  3. 01 Mar, 2019 9 commits
    • Rick Ratmansky's avatar
      Revert D14114164: [Folly] Remove include of glog from Range.h · a99a9d37
      Rick Ratmansky authored
      Differential Revision:
      D14114164
      
      Original commit changeset: e227609e9214
      
      fbshipit-source-id: 99d0fde58e512224915d7a00893ddf15c547dfba
      a99a9d37
    • Yedidya Feldblum's avatar
      Remove include of glog from Range.h · 1c841a35
      Yedidya Feldblum authored
      Summary: [Folly] Remove include of `glog` from `Range.h`.
      
      Reviewed By: lbrandy, Orvid
      
      Differential Revision: D14114164
      
      fbshipit-source-id: e227609e9214ab39ff272e44519d34f3047fe025
      1c841a35
    • Ilya Maykov's avatar
      fix comments in experimental/crypto/Blake2xb.h · 20a8a095
      Ilya Maykov authored
      Summary: The reinit() method was removed but some comments mentioning it remained. Remove them.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D14277614
      
      fbshipit-source-id: 389ef3e2afe1fdc60f37aaec2f8a48dfa0b1436c
      20a8a095
    • Yedidya Feldblum's avatar
      Make EventBase enqueue noexcept · 8dc220b9
      Yedidya Feldblum authored
      Summary:
      [Folly] Make `EventBase` enqueue `noexcept`.
      
      It cannot really fail anyway in correct usage besides allocation failure, unless in the `EventBase` destructor and while draining and the `AlwaysEnqueue` variant is called.
      
      Theoretically if a caller attempts to enqueue concurrently with `EventBase` dtor while in `consumeUntilDrained`, but either *not* in the `EventBase` thread or in the `EventBase` thread and using the `AlwaysEnqueue` variant, there is a race which can lead to termination.
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D14114678
      
      fbshipit-source-id: 9a0128d207f86ca34eb8a1d417766c095ed5e137
      8dc220b9
    • Joe Loser's avatar
      Inline TypeError special member functions (#1034) · baeb381c
      Joe Loser authored
      Summary:
      The `TypeError` special member functions - copy and move constructors and assignment operators - were outlined to reduce inline code size of `throw TypeError(...);` statements. This is no longer necessary, since these sites have been replaced by `folly::throw_exception<TypeError>(...);` statements, which have minimal inline code size. As a benefit, the special member functions may all now be declared as defaulted within the class body, and the conditional `noexcept` calculations are no longer required to be written - the compiler will do them. (Note: as of the libstdc++ which ships with GCC 5, library exception special member functions are `noexcept`; previously, they are not.)
      
      Pull Request resolved: https://github.com/facebook/folly/pull/1034
      
      Reviewed By: nbronson
      
      Differential Revision: D14255166
      
      Pulled By: yfeldblum
      
      fbshipit-source-id: 2f795a2b937fee58f243a9d374fc01829c674fe6
      baeb381c
    • Yedidya Feldblum's avatar
      Avoid explicit memset in IPAddress storage union · 61c3151a
      Yedidya Feldblum authored
      Summary: [Folly] Avoid explicit `memset` in `IPAddress` storage union by having an explicit storage field and value-initializing it in the default constructor.
      
      Reviewed By: stevegury
      
      Differential Revision: D14270246
      
      fbshipit-source-id: f1f135f20709d8225e984ee3d6b397d4b04e0d76
      61c3151a
    • Ilya Maykov's avatar
      Implemented LtHash in folly/experimental/crypto · a0e3a745
      Ilya Maykov authored
      Summary:
      Added LtHash, a cryptographic homomorphic hash, to folly/experimental/crypto.
      This has a soft dependency on libsodium and the code will not be compiled if libsodium is not detected by cmake.
      
      Reviewed By: djwatson
      
      Differential Revision: D13390825
      
      fbshipit-source-id: f7597ced7bcc7b403e8bbaa733837b795128f1b3
      a0e3a745
    • Ilya Maykov's avatar
      make blake2xb compatible w/ libsodium 1.0.17+ · f42dd787
      Ilya Maykov authored
      Summary: struct crypto_generichash_blake2b_state was made opaque in libsodium 1.0.17. This change is needed to make blake2xb code compile.
      
      Reviewed By: djwatson
      
      Differential Revision: D14141454
      
      fbshipit-source-id: eee887e8300229ff568d12ef19b46472edfc56d2
      f42dd787
    • Ilya Maykov's avatar
      Implemented the Blake2xb XOF (extendable output function) · 6880b411
      Ilya Maykov authored
      Summary: Implemented the Blake2xb XOF. See the specification at https://blake2.net/blake2x.pdf.
      
      Reviewed By: djwatson
      
      Differential Revision: D13403920
      
      fbshipit-source-id: 38afd6d3b782c2f6649365d01ca3d83b55c90c4b
      6880b411
  4. 28 Feb, 2019 8 commits
    • Orvid King's avatar
      Quick fix for OpenSSL 1.1.0 on Windows · 95478cc4
      Orvid King authored
      Summary:
      This was treating a socket as a file descriptor, so make it explicitly be a file descriptor instead.
      The full fix for this requires a *lot* of refactoring and splitting of a lot of concepts within Folly, so this short-term fix should be good enough for now.
      
      Reviewed By: boguscoder
      
      Differential Revision: D14266198
      
      fbshipit-source-id: bafb3a403ab8555f865f4541323c5d0ad81f5052
      95478cc4
    • Meng Zhang's avatar
      Back out "[folly][PR] Allow trivially move constructible types to be relocatable" · 3f7a734c
      Meng Zhang authored
      Summary: Original commit changeset: 1e15d312d1a8
      
      Reviewed By: Orvid
      
      Differential Revision: D14265880
      
      fbshipit-source-id: 8c2ad3e15334015dadc19bf77b061f66086adcd6
      3f7a734c
    • Orvid King's avatar
      Remove the fd overload of AsyncSocket::newSocket · cee1964d
      Orvid King authored
      Summary: It's dead.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D14192000
      
      fbshipit-source-id: 3cecbc8e9f656080a023d676883de9943e7d0004
      cee1964d
    • Orvid King's avatar
      Shift calls of the file descriptor overload of AsyncSocket::AsyncSocket() to... · 3938ebc1
      Orvid King authored
      Shift calls of the file descriptor overload of AsyncSocket::AsyncSocket() to the NetworkSocket overload
      
      Summary: The file descriptor overload will be going away.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D13998628
      
      fbshipit-source-id: 7a1d3bae03d4742d874e1e7d733f7733b5a1c110
      3938ebc1
    • Lee Howes's avatar
      Deprecate futures::sleepUnsafe · ad001a22
      Lee Howes authored
      Summary: Deprecate sleepUnsafe to avoid use growing and to clearly communicate the change.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D14255404
      
      fbshipit-source-id: cb2116910a15b9835fef9bf4273242457a5e96bd
      ad001a22
    • Aaryaman Sagar's avatar
      InlineFunctionRef for inline FunctionRef storage · a703ff28
      Aaryaman Sagar authored
      Summary:
      InlineFunctionRef is a semantically the same as folly::FunctionRef but has the
      additional benefit of being able to store the function it was instantiated
      with inline in a buffer of the given capacity.  If there is not enough in-situ
      capacity for the callable, this has the same semantics as FunctionRef.
      
      This helps give a perf boost in the case where the data gets separated from
      the point of invocation.  If, for example, at the point of invocation, the
      InlineFunctionRef object is not cached, a remote memory/cache read might be
      required to invoke the original callable.  Customizable inline storage helps
      tune storage so we can store a type-erased callable with better performance
      and locality.  A real-life example of this might be a folly::FunctionRef with
      a function pointer.  The folly::FunctionRef would point to the function
      pointer object in a remote location.  This causes a double-indirection at the
      point of invocation, and if that memory is dirty, or not cached, it would
      cause additional cache misses.  On the other hand with InlineFunctionRef,
      inline storage would store the value of the function pointer, avoiding the
      need to do a remote lookup to fetch the value of the function pointer.
      
      To prevent misuse, InlineFunctionRef disallows construction from an lvalue
      callable.  This is to prevent usage where a user relies on the callable's
      state after invocation through InlineFunctionRef.  This has the potential to
      copy the callable into inline storage when the callable is small, so we might
      not use the same function when invoking, but rather a copy of it.
      
      Also note that InlineFunctionRef will always invoke the const qualified
      version of the call operator for any callable that is passed.  Regardless of
      whether it has a non-const version.  This is done to enforce the logical
      constraint of function state being immutable.
      
      This class is always trivially-copyable (and therefore
      trivially-destructible), making it suitable for use in a union without
      requiring manual destruction.
      
      Reviewed By: yfeldblum, ot
      
      Differential Revision: D14029799
      
      fbshipit-source-id: 2cff3ce27d564f3d524095189f847c14911f9402
      a703ff28
    • Chad Austin's avatar
      fix folly:memory build on macOS · a255f1ff
      Chad Austin authored
      Summary:
      Don't assume a jemalloc target exists (even if it would be a no-op, as
      in on macOS). Instead compute the correct set of external_deps in
      jemalloc.bzl.
      
      This fixes the folly build on mode/mac after D14179337.
      
      Reviewed By: andrewjcg
      
      Differential Revision: D14235815
      
      fbshipit-source-id: d1bfbb91897de9557524bbb4b5736ca7b03cbf9b
      a255f1ff
    • Joe Loser's avatar
      Allow trivially move constructible types to be relocatable (#1035) · bb19b301
      Joe Loser authored
      Summary:
      - If a type is not marked explicitly with `IsRelocatable`
        as `std::true_type`, we infer its relocability only based on the
        property of whether the type is trivially copyable.
      - Extend the default relocability to also be true for trivially move
        constructible types.
      Pull Request resolved: https://github.com/facebook/folly/pull/1035
      
      Reviewed By: Orvid
      
      Differential Revision: D14240127
      
      Pulled By: yfeldblum
      
      fbshipit-source-id: 1e15d312d1a8340417bba2beb1db30ce4c543b26
      bb19b301
  5. 27 Feb, 2019 8 commits
    • Orvid King's avatar
      Remove AsyncServerSocket.getSockets() · 01354e23
      Orvid King authored
      Summary: It is dead
      
      Reviewed By: yfeldblum
      
      Differential Revision: D14235873
      
      fbshipit-source-id: bafc323898f2a17aedf6644f9c2dd7319b8e6420
      01354e23
    • Andrii Grynenko's avatar
      Simplify observable state · f3a00610
      Andrii Grynenko authored
      Summary: Merge two mutexes together and get rid of atomics.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D14236244
      
      fbshipit-source-id: 0b97d519e72322377e225a0cc8975e3a2a86ec31
      f3a00610
    • Orvid King's avatar
      Add a NetworkSocket overload for AsyncUDPServerSocket->getFD · 670768f1
      Orvid King authored
      Summary: I missed one of the functions that needs a NetworkSocket overload in past iterations.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D14237211
      
      fbshipit-source-id: 6d0bd151ff636206a44940c88a2d48c339aa67de
      670768f1
    • Lewis Baker's avatar
      Move decay_rvalue_reference_t metafunction to folly/experimental/coro/detail/Traits.h · 3a129426
      Lewis Baker authored
      Summary:
      Make this metafunction available for use outside of the
      folly::coro::blockingWait() implementation.
      
      I plan to reuse this metafunction for other operators such as `when_all()`.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D13778687
      
      fbshipit-source-id: f766f93da21bf19e89262cd60048b0b7b1b76940
      3a129426
    • Joe Loser's avatar
      Cut disabling uninitialized warnings in folly/experimental/Bits.h (#1033) · a79183e4
      Joe Loser authored
      Summary:
      - `folly/experimental/Bits.h` has a section where we disable two
        uninitialized-flavors of warnings that were needed for GCC 4.8
      - Since we do not support GCC 4.8 anymore and GCC 5.1 does not have
        issues with this, do not disable the warnings anymore.
      Pull Request resolved: https://github.com/facebook/folly/pull/1033
      
      Reviewed By: Orvid
      
      Differential Revision: D14223285
      
      Pulled By: yfeldblum
      
      fbshipit-source-id: 0088341b13e26dff2dc90a768319cccc45e942da
      a79183e4
    • Yedidya Feldblum's avatar
      DefaultKeepAliveExecutor::reset · c971b9f7
      Yedidya Feldblum authored
      Summary: [Folly] `DefaultKeepAliveExecutor::reset` in case of restartable executors.
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D14236173
      
      fbshipit-source-id: 14f71af6bd54777770fdfe6036a4137af4e884bc
      c971b9f7
    • Yedidya Feldblum's avatar
      Cut deducible template arg in DefaultKeepAliveExecutor init · c2a61864
      Yedidya Feldblum authored
      Summary: [Folly] Cut deducible template arg in `DefaultKeepAliveExecutor` init - let it be deduced instead.
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D14236171
      
      fbshipit-source-id: 2de043efe541c13c59764715516b08d77efcb99b
      c2a61864
    • Andrii Grynenko's avatar
      Fix a race when a leaf update is missed · bde0b49f
      Andrii Grynenko authored
      Summary:
      If multiple leaves are updated at the same time (or a new observer is created concurrently that depends on the updated leaf) it's possible for refresh to be called concurrently with force=false which will not update the leaf value, but also ignore the refresh with force=true.
      This is fixed by making force to be the property of the leaf observer itself, which is set when the version is bumped.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D14222400
      
      fbshipit-source-id: 657c2c273002f576dbe48a232eaef2d530cea07d
      bde0b49f
  6. 26 Feb, 2019 4 commits
    • Ning Xu's avatar
      Surround code snippets with tildes (#1032) · 017cd274
      Ning Xu authored
      Summary:
      Angled brackets inside angled brackets is not displayed.
      This makes the document misleading.
      Pull Request resolved: https://github.com/facebook/folly/pull/1032
      
      Reviewed By: shixiao
      
      Differential Revision: D14207772
      
      Pulled By: yfeldblum
      
      fbshipit-source-id: 4f2e58145a5473a7b887ef1da4efbeb16d5330c6
      017cd274
    • Lee Howes's avatar
      Change return type of futures::sleep to SemiFuture · 75d20258
      Lee Howes authored
      Summary:
      futures::sleep returning a Future leads to continuations easily being run on
      the Timekeeper's callback. The goal is to change the return type so that
      futures::sleep returns a folly::SemiFuture.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D14069549
      
      fbshipit-source-id: b98e2c76ccbf0a80aed28f90a1f3c63f15eb2e5c
      75d20258
    • Joe Loser's avatar
      Remove disabling -Warray-bounds for GCC in FBString.h (#999) · 268ab2a1
      Joe Loser authored
      Summary:
      - Existing code disables `-Warray-bounds` warning for GCC due to a bug in
        GCC 4.9.
      - As seen in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59124, the bug
        has been resolved for GCC 5.1.
      - Since the bug has been resolved, we no longer need to disable the
        warning.
      
      yfeldblum I suspect that we have to hold off on this PR until the internal use cases relying on GCC 4.9 upgrade, but I figured it is better to have some of these cleanup opportunities ready for when the time arises.
      Pull Request resolved: https://github.com/facebook/folly/pull/999
      
      Reviewed By: ot, Orvid
      
      Differential Revision: D13729723
      
      Pulled By: yfeldblum
      
      fbshipit-source-id: da33704c2e2022c2dad0681e4d6152105a1cf54d
      268ab2a1
    • Yedidya Feldblum's avatar
      Address MSVC C4686 in folly/lang/Pretty.h · 6f14ffa5
      Yedidya Feldblum authored
      Summary:
      [Folly] Address MSVC C4686 in `folly/lang/Pretty.h`.
      
      Resolves:
      
      ```
      folly\lang\pretty.h(119): warning C4686: 'folly::detail::pretty_name_zarray<T>::zarray_': possible change in behavior, change in UDT return calling convention
      ```
      
      Reviewed By: Orvid
      
      Differential Revision: D14214290
      
      fbshipit-source-id: c5e0ebd7c100413737bdcba157ec8b5ce42895de
      6f14ffa5
  7. 25 Feb, 2019 8 commits
    • Marc Berenbach's avatar
      Fix unnecessary copy warnings found by Infer · 986a6124
      Marc Berenbach authored
      Summary:
      Infer AL has reported valid warnings on some folly and thrift code:
      
      ```
      fbcode/folly/io/async/AsyncUDPServerSocket.h:228:19:
      WARNING Extra Copy: Potentially unnecessary to copy var `client` at line 228, column 19. Use 'const auto&' or 'auto&' if possible.
      fbcode/folly/io/async/AsyncUDPServerSocket.h:230:19:
      WARNING Extra Copy: Potentially unnecessary to copy var `socket` at line 230, column 19. Use 'const auto&' or 'auto&' if possible.
      fbcode/thrift/lib/cpp/TProcessorEventHandler.h:148:15:
      WARNING Extra Copy: Potentially unnecessary to copy var `ew` at line 148, column 15. Use 'const auto&' or 'auto&' if possible.
      fbcode/thrift/lib/cpp2/server/ThriftServer.h:705:20:
      WARNING Extra Copy: Potentially unnecessary to copy var `sockets` at line 705, column 20. Use 'const auto&' or 'auto&' if possible.
      ```
      
      As these are transitively included in many services, they are fairly prevalent/annoying warnings. Let's fix them.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D14168260
      
      fbshipit-source-id: 12e537fe5aa73e653c15c4fef01ac618e51cd4d0
      986a6124
    • Joe Loser's avatar
      Add std::string_view specialization in F14Table.h (#1031) · 223aae6b
      Joe Loser authored
      Summary:
      - `F14Table.h`'s fallback when SIMD isn't used has template specializations
        to track which `std::hash` implementations are considered worth caching by
        `std::unordered_map`. This included `std::string` but was missing
        support for `std::string_view`. This commit adds support for marking
       `std::string_view` as not fast.
      Pull Request resolved: https://github.com/facebook/folly/pull/1031
      
      Reviewed By: nbronson
      
      Differential Revision: D14197661
      
      Pulled By: yfeldblum
      
      fbshipit-source-id: bd634b5755e2794891200c7f71e9d6874a60cc38
      223aae6b
    • Joe Loser's avatar
      Cut FOLLY_USE_CPP14_CONSTEXPR and FOLLY_CPP14_CONSTEXPR (#1029) · cd3b981a
      Joe Loser authored
      Summary:
      - `FOLLY_USE_CPP14_CONSTEXPR` macro is not needed as Folly requires a
        recent enough version of MSVC where its constexpr support is "good
        enough". For Clang and GCC, the min compiler versions supported would
        both evaluate the prior implementation of this macro to true in both
        cases. This is potentially slightly behavior changing since
        `FOLLY_USE_CPP14_CONSTEXPR` would be `inline` for ICC and I am not
        sure if its constexpr support is "good enough" for a min version of
        ICC we claim support for.
      - Replace `FOLLY_CPP14_CONSTEXPR` with `constexpr` in all call sites and
        remove the `FOLLY_CPP14_CONSTEXPR` macro.
      - Simplify how we define `FOLLY_STORAGE_CONSTEXPR` and
        `FOLLY_STORAGE_CPP14_CONSTEXPR` after cutting
        `FOLLY_USE_CPP14_CONSTEXPR`.
      Pull Request resolved: https://github.com/facebook/folly/pull/1029
      
      Reviewed By: Orvid
      
      Differential Revision: D14199538
      
      Pulled By: yfeldblum
      
      fbshipit-source-id: 99daecf7d7ad0c4bf6735e74247112a78923602a
      cd3b981a
    • Yedidya Feldblum's avatar
      Use pretty_name in F14TableStats · 02e56189
      Yedidya Feldblum authored
      Summary: [Folly] Use `pretty_name` in `F14TableStats`, which may not be exact in edge cases (e.g. function-local policy types) but which works without RTTI.
      
      Reviewed By: nbronson
      
      Differential Revision: D14129242
      
      fbshipit-source-id: 6f7a8e0b3af4d6b16673770228e98cd989ab0c3f
      02e56189
    • Lee Howes's avatar
      Make TimekeeperTest use thenError · d389009f
      Lee Howes authored
      Summary: Update to use thenError rather than onError.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D14209634
      
      fbshipit-source-id: 5cbb66146b148654641a7a0a58717a31608a4ac7
      d389009f
    • Yedidya Feldblum's avatar
      Omit excess landing pads with StaticSingletonManager · c17964fd
      Yedidya Feldblum authored
      Summary:
      [Folly] Omit excess landing pads with `StaticSingletonManager` when the type of the global is nothrow-default-constructible.
      
      This changes behavior for nothrow-default-constructible types to terminate immediately if the process is out of memory while performing the bookkeeping around attempting to instantiate a global.
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D14203826
      
      fbshipit-source-id: 8c9becde3b245d6b027c97bd8541c48745727dff
      c17964fd
    • Joe Loser's avatar
      Add to_underlying_type to cast enum to underlying (#1028) · 83b597e5
      Joe Loser authored
      Summary:
      - It is verbose at the call sites to cast an enum or enum class to its
        underlying type.
      - Introduce `to_underlying_type`, which, given an enum or enum class,
        returns the value from static casting to the underlying type.
      Pull Request resolved: https://github.com/facebook/folly/pull/1028
      
      Reviewed By: stevegury
      
      Differential Revision: D14199619
      
      Pulled By: yfeldblum
      
      fbshipit-source-id: fde85b9be50945a390b18ba1448a0137f3d7b63e
      83b597e5
    • Orvid King's avatar
      Remove the fd overload of AsyncServerSocket::useExistingSockets · b66dfacb
      Orvid King authored
      Summary: Remove all uses and remove the overload.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D14194039
      
      fbshipit-source-id: c3b271747200b9219b734e5a0f19c6d5d4d135a2
      b66dfacb