1. 09 Mar, 2019 1 commit
  2. 08 Mar, 2019 5 commits
    • Matthew Glazar's avatar
      Don't clobber CXXFLAGS/CMAKE_CXX_FLAGS (#1046) · 15fff7c1
      Matthew Glazar authored
      Summary:
      CMake allows the user to add additional compilation options using
      CXXFLAGS= or -DCMAKE_CXX_FLAGS=. For example, each of the following
      commands would enable GCC security features in generated code:
      
          $ CXXFLAGS=-fstack-protector-strong cmake .
          $ cmake -DCMAKE_CXX_FLAGS=-fstack-protector-strong .
      
      Unfortunately, this doesn't work with folly's build system; CXXFLAGS and
      CMAKE_CXX_FLAGS are ignored. This makes it harder for package managers
      to tweak folly's compilation.
      
      Teach folly to respect user-supplied compiler flags instead of
      overriding them.
      Pull Request resolved: https://github.com/facebook/folly/pull/1046
      
      Reviewed By: wez
      
      Differential Revision: D14383310
      
      Pulled By: yfeldblum
      
      fbshipit-source-id: a6c527fa1659b93bb88a4e0be617a5d9022489dd
      15fff7c1
    • Matt Joras's avatar
      Print si_code even if there's no string decoding available. · 2d22dfe3
      Matt Joras authored
      Summary: We are getting SIGILLs that end up not printing a code because it's not in the cases in `signal_reason`, which isn't particularly helpful. Additionally, the check for kernel-sourced si_codes is incorrect. Any code > 0 is from the kernel. This causes folly to log nonsense PIDs and UIDs.
      
      Differential Revision: D14388102
      
      fbshipit-source-id: 3201a16bbe9eb9038ebc5601044406f5333ec9e9
      2d22dfe3
    • Tyler John Smith's avatar
      Fix ordering issue with folly dynamic subtraction and division · 01323e31
      Tyler John Smith authored
      Summary:
      folly dynamic "double / int" (division, same goes for subtraction) results in the operands switching places (always becomes "int / double") due to int and non-int checking logic.
      
      Same applies to addition and multiplication, but order doesn't matter for those.
      
      If both dynamics are doubles or both are ints, then the problematic logic is bypassed.
      
      So this is only when you have one int and one double, and the int comes second, and the operand is subtraction or division.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D14379896
      
      fbshipit-source-id: e76f1fe677fc4ea69856649ab046a5080a902b0d
      01323e31
    • Phil Willoughby's avatar
      expose share count of IOBuf · 3a0d4ce4
      Phil Willoughby authored
      Summary: Exposing this counter allows us to fairly divide the memory usage of shared IOBuf buffers among all the owners in memory-usage tracking code.
      
      Reviewed By: simpkins
      
      Differential Revision: D14361976
      
      fbshipit-source-id: 73c63c473b117198786143b421c6fcb8aed684d5
      3a0d4ce4
    • Orvid King's avatar
      AsyncUDPSocket->getFD to AsyncUDPSocket->getNetworkSocket() · f988642d
      Orvid King authored
      Summary: The file descriptor backed version will be going away.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D14235700
      
      fbshipit-source-id: 990b0276b085e6bb88bf3bdb83cdeba332f75ac6
      f988642d
  3. 07 Mar, 2019 2 commits
    • Ilya Maykov's avatar
      add missing experimental/crypto tests to CMakeLists.txt · c0fc7af5
      Ilya Maykov authored
      Summary: The tests were accidentally checked in without the cmake build rules to build them.
      
      Reviewed By: kevinlewi
      
      Differential Revision: D14277667
      
      fbshipit-source-id: 5e0ff305341772232579bbde2dfc60477b4f1937
      c0fc7af5
    • Chad Austin's avatar
      build folly/experimental/symbolizer:stack_trace on mac · 6eb906e6
      Chad Austin authored
      Summary:
      ssize_t is not standard, so include <sys/types.h>. (I considered
      switching to intptr_t but decided against it.)
      
      Also, on macOS, the function appears to be called backtrace, not
      unw_backtrace.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D14307252
      
      fbshipit-source-id: d919bd37fea8f68b5d610e771e577c8ce385f6ec
      6eb906e6
  4. 06 Mar, 2019 5 commits
    • Orvid King's avatar
      Remove the fd overloads of AsyncSSLSocket::AsyncSSLSocket() · 7a5aa125
      Orvid King authored
      Summary: They are dead.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D14192072
      
      fbshipit-source-id: dcb95be39614d9968db9d63cd9f06396f4779a0a
      7a5aa125
    • Joe Loser's avatar
      Update Ubuntu build scripts to work with CMake build (#1042) · 82336a72
      Joe Loser authored
      Summary:
      - Update Ubuntu 14.04 build script to use CMake instead of Autotools.
      - Rename Ubuntu 14.04 build script to use hyphens rather than underscores to match POSIX standard for bash scripts.
      - The Ubuntu 14.04 build script is now meant to be run from the top-level rather than from inside the `folly` source tree.
      - Remove the Ubuntu 12.04 build scripts. It was previously only needed for Travis CI, but Travis CI isn't using it anymore.
      Pull Request resolved: https://github.com/facebook/folly/pull/1042
      
      Reviewed By: Orvid
      
      Differential Revision: D14298995
      
      Pulled By: yfeldblum
      
      fbshipit-source-id: e3151620c0f0fa73147ab258b8750480c868c44a
      82336a72
    • Lewis Baker's avatar
      Add folly::coro::semi_await_result_t<T> · 0cf8295c
      Lewis Baker authored
      Summary:
      - Change folly::coro::co_viaIfAsync to be a customization-point object.
      - Modify co_viaIfAsync() to call a .viaIfAsync() member function if one exists.
        Otherwise it calls the co_viaIfAsync() function found by ADL.
      - Add FOLLY_DEFINE_CPO() helper macro to folly/Portability.h
        Borrows some techniques from range-v3 to support CPOs in different
        compilers and C++ versions.
      - Redefined co_viaIfAsync() CPO in terms of this macro.
        This allows it to be callable as folly::coro::co_viaIfAsync() while
        still allowing other types in folly::coro namespace to define friend
        functions that customise the behaviour of this customisation point
        without causing conflicts.
      - Add folly::coro::is_semi_awaitable<T> metafunction.
      - Add folly::coro::semi_await_result_t<T> metafunction.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D14016389
      
      fbshipit-source-id: 63998993b2fa8560700f81666a910dee31f3ba72
      0cf8295c
    • Erik Hortsch's avatar
      Standardize fiber baton behavior across threads and fibers · 12f18243
      Erik Hortsch authored
      Summary:
      The behavior of fiber Baton is currently inconsistent around posting of a timed out baton, and subsequent calls to try_wait().  As stated in the post, only when the waiter is a thread will a post overwrite a timeout internally, and this is observable externally because try_wait returns true only if a baton is in the POSTED state, but not the timed out state.  Example code:
      
      ```
      folly::fibers::Baton b;
      
      b.try_wait_for(std::chrono::milliseconds(1));
      b.try_wait(); // returns false
      
      b.post();
      b.try_wait(); // Returns true on threads, false on fibers
      ```
      
      Other options we could consider for the fix:
       * Update postThread to leave baton in a timeout state, and have waitThread move the baton into the timeout state on a failed wait.
       * Update try_wait() to return true if the state is either POSTED or TIMEOUT.
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D14324532
      
      fbshipit-source-id: 51b993a6153cba0fc3cf5701f765fff8ad1c8e3c
      12f18243
    • Nick Terrell's avatar
      Allow counters to be disabled · 49a54a71
      Nick Terrell authored
      Summary:
      Some codecs may not want counters enabled. Right now that will
      `std::terminate`. Allow disabled counters, and add a test.
      
      Reviewed By: felixhandte
      
      Differential Revision: D14327170
      
      fbshipit-source-id: 37858518c80e192e351e8578e088b59732d2a0cb
      49a54a71
  5. 05 Mar, 2019 3 commits
    • Joe Loser's avatar
      Replace some bool_constant with constexpr bool in FBVector (#1039) · 8ef7d7f1
      Joe Loser authored
      Summary:
      - Some constant expressions are wrapped in a type carrying a bool, but
        are only used in value contexts. Remove the type wrapper
        (bool_constant) use and just use `constexpr bool` directly. This makes the
        usages not have to use `::value` everywhere.
      Pull Request resolved: https://github.com/facebook/folly/pull/1039
      
      Reviewed By: Orvid
      
      Differential Revision: D14293828
      
      Pulled By: yfeldblum
      
      fbshipit-source-id: 78399e4fb401ab680a4f1ecef63fb4c2a82927c2
      8ef7d7f1
    • Yedidya Feldblum's avatar
      Remove extraneous uses of keyword typename in fibers collectN · 0217f5e2
      Yedidya Feldblum authored
      Summary: [Folly] Remove extraneous uses of keyword `typename` in fibers `collectN`.
      
      Reviewed By: ericniebler
      
      Differential Revision: D14317102
      
      fbshipit-source-id: 1ae04081258bf2398865a1cc5461618648623158
      0217f5e2
    • Yedidya Feldblum's avatar
      Canonical SFINAE in fibers · ddc11d67
      Yedidya Feldblum authored
      Summary: [Folly] Canonical SFINAE in fibers, where the `enable_if` is on the outside.
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D14294993
      
      fbshipit-source-id: 498c9bfcd346edb5e4b5b65941e2a09c93e870b6
      ddc11d67
  6. 04 Mar, 2019 2 commits
    • Joe Loser's avatar
      Fix to handle empty CMAKE_SYSTEM_ARCHITECTURE (#1040) · 1cb1ad79
      Joe Loser authored
      Summary:
      - On some platforms, `CMAKE_SYSTEM_ARCHITECTURE` may resolve to an empty
        string.
      - When this value is used without quotes to the `string` command, it is
        ill-formed with error:
      
      ```
        CMake Error at CMakeLists.txt:174 (string):
        string sub-command FIND requires 3 or 4 parameters.
      ```
      
      - Explicitly wrap the value to the `string` operation in quotes to treat
        `CMAKE_SYSTEM_ARCHITECTURE` as a string, which is allowed to be empty.
        The result is that the `string` operation will not result in a hard
        error.
      Pull Request resolved: https://github.com/facebook/folly/pull/1040
      
      Reviewed By: calebmarchent
      
      Differential Revision: D14293784
      
      Pulled By: yfeldblum
      
      fbshipit-source-id: cd5924fa62277aa07e930c7b088197ef596be977
      1cb1ad79
    • 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
  7. 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
  8. 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
  9. 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
  10. 27 Feb, 2019 3 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