1. 03 May, 2017 3 commits
    • Christopher Dykes's avatar
      Fix a couple of issues with the CMake script · c2e28878
      Christopher Dykes authored
      Summary:
      The first issue is that I was missing a `G` in `LIBGFLAGS_INCLUDE_DIR` meaning that it always claimed it couldn't find gflags even though it did, and worked just fine anyways.
      The second issue is that it was passing `/permissive-` to MSVC 2015 builds, even though MSVC 2015 doesn't support the permissive flag.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4988813
      
      fbshipit-source-id: f1ea009226baee54032409ce7add3c41f1fe7a19
      c2e28878
    • Christopher Dykes's avatar
      Fix compiling with PThread support on Windows... Again... · 58a70372
      Christopher Dykes authored
      Summary: I was bad and didn't follow through on my previous test plan, and so didn't check that it completely fixed the issue, instead only fixing one of the two problems. This fixes the other one.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4988408
      
      fbshipit-source-id: 44389bc67bcb7d6db984075f3600948460fa8c5a
      58a70372
    • Christopher Dykes's avatar
      Fix ExceptionWrapper under MSVC 2015 Update 3 · 59c1b560
      Christopher Dykes authored
      Summary: Besides this code being utterly bizzare, it doesn't work under MSVC 2015 Update 3, so rather than doing a `static_cast<bool>(std::conjunction<>())` just do `std::conjunction<>::value`.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4988341
      
      fbshipit-source-id: ededdbf3f3d945d9e2f140f4e87643ec3c0d4239
      59c1b560
  2. 02 May, 2017 3 commits
    • Christopher Dykes's avatar
      Fix FBString in MSVC 2015 · 5e8852c8
      Christopher Dykes authored
      Summary: MSVC 2015 Update 3 is even worse in this particular case, and requires it to be explicitly referenced as being within the `folly` namespace >_>...
      
      Reviewed By: ot, yfeldblum
      
      Differential Revision: D4988025
      
      fbshipit-source-id: dea311dd42f40b442951b8df3c5f68cf70d13769
      5e8852c8
    • Christopher Dykes's avatar
      Fix the CMake build on Windows when using PThreads · 6a7b70f8
      Christopher Dykes authored
      Summary: I broke things, so now I have to fix them.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4981674
      
      fbshipit-source-id: 7df4d78cf4f984df158051a3a8b277a0bcad583b
      6a7b70f8
    • Christopher Dykes's avatar
      Fix FBString under MSVC · 24c892da
      Christopher Dykes authored
      Summary: MSVC requires the declaration to match a bit closer than GCC does.
      
      Reviewed By: yfeldblum, ot
      
      Differential Revision: D4981404
      
      fbshipit-source-id: 92ee40c40f66725c09a3087e49d99ebae222c2f2
      24c892da
  3. 01 May, 2017 2 commits
    • Andrii Grynenko's avatar
      Fix a race in Observable context destruction · 2642bd3d
      Andrii Grynenko authored
      Summary: In the subscribe callback It's possible that we lock the Context shared_ptr and while update is running, all other shared_ptr's are released. This will result in Context to be destroyed from the wrong thread (thread runnning subcribe callback), which is not desired.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4964605
      
      fbshipit-source-id: 285327a6873ccb7393fa3067ba7e612c29dbc454
      2642bd3d
    • Anirudh Ramachandran's avatar
      More OpenSSL 1.1.0 compatibility fixes · 79cb7776
      Anirudh Ramachandran authored
      Summary: A bunch of changes to make fbcode targets build with OpenSSL 1.1.0
      
      Reviewed By: ivmaykov
      
      Differential Revision: D4949822
      
      fbshipit-source-id: 35eda632d8335c4194352196264afeff69d87519
      79cb7776
  4. 30 Apr, 2017 1 commit
  5. 28 Apr, 2017 1 commit
    • Alexey Spiridonov's avatar
      Simplify BackgroundThreads, move them to folly/experimental/ThreadedRepeatingFunctionRunner · b7a0f26d
      Alexey Spiridonov authored
      Summary:
      - `FunctionScheduler` and `EventBase` are great for sharing one thread for many functions, but one-function-per-thread is messy.
      - Both of those implementations are complicated, but `FunctionThreads` is dead-simple.
      - I made it even simpler by eliminating the former `incrementalSleep` in favor of `std::future::wait_for`, which allows instant interruption without a tweakable param. h/t aru777 for suggesting `std::future` instead of `std::condition_variable`.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4742134
      
      fbshipit-source-id: b520bbcd5f218b2276200ffe8926722ae8a8d6ca
      b7a0f26d
  6. 27 Apr, 2017 6 commits
    • Giuseppe Ottaviano's avatar
      Fix a comment · d5a49339
      Giuseppe Ottaviano authored
      Reviewed By: yfeldblum
      
      Differential Revision: D4965608
      
      fbshipit-source-id: db8d67ca7174e0296fbd8da2e1fe90cbbcef9496
      d5a49339
    • Philipp Unterbrunner's avatar
      folly::rvalue_reference_wrapper for store&forward of rvalue references · 682dfa71
      Philipp Unterbrunner authored
      Summary:
      Class template that wraps a reference to an rvalue. Similar to std::reference_wrapper but with three important differences:
      1) folly::rvalue_reference_wrappers can only be moved, not copied;
      2) the get() function and the conversion-to-T operator are destructive and not const, they invalidate the wrapper;
      3) the constructor-from-T is explicit.
      These restrictions are designed to make it harder to accidentally create a a dangling rvalue reference, or to use an rvalue reference multiple times. (Using an rvalue reference typically implies invalidation of the target object, such as move-assignment to another object.)
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4931483
      
      fbshipit-source-id: 68453553bf4656ec41976699669a4491fcab79c9
      682dfa71
    • Philip Pronin's avatar
      fix silent eax clobbering in CpuId ctor · 95209f9d
      Philip Pronin authored
      Summary:
      `cpuid` uses all of `eax`, `ebx`, `ecx`, `edx` for output, but we
      aren't providing such information to GCC in a couple of cases, which might
      result in incorrect code being produced;
      
      GCC (unlike clang) doesn't allow the same register to appear both in input and
      clobber list, so put `eax` into output list where required.
      
      Reviewed By: ot, lbrandy
      
      Differential Revision: D4961841
      
      fbshipit-source-id: 07ca1977373496bfd794d3b0c8a4ba21333820e4
      95209f9d
    • Otto Ebeling's avatar
      Don't return a nullptr from IOBufQueue::split(0) · af5ed37b
      Otto Ebeling authored
      Summary: There's a gotcha case for IOBufQueue::split when  n==0, it will then return an unique_ptr wrapping a nullptr, which many call sites do not expect.
      
      Reviewed By: meyering
      
      Differential Revision: D4868228
      
      fbshipit-source-id: 418256dba8ca3bcfbae420b6099baa240055b9bb
      af5ed37b
    • Maged Michael's avatar
      Flat combining: Add lock holder with deferred option. Minor fixes. · b73507bb
      Maged Michael authored
      Summary: Added a lock holder with deferred option for cases where the caller may want to call try_lock() later.
      
      Reviewed By: djwatson
      
      Differential Revision: D4949736
      
      fbshipit-source-id: 31e0dc349dc3af9d04a33878e26cef1e48cce674
      b73507bb
    • Yedidya Feldblum's avatar
      Casing consistency for exception_wrapper::throw_exception · d2efd810
      Yedidya Feldblum authored
      Summary: [Folly] Casing consistency for `exception_wrapper::throw_exception`.
      
      Reviewed By: Orvid
      
      Differential Revision: D4944818
      
      fbshipit-source-id: 72056fb24ab6362e9a0319f73b5bbf8c92d658ca
      d2efd810
  7. 26 Apr, 2017 5 commits
    • Pavel Aslanov's avatar
      folly::overload and folly::variant_match · 7d06adb4
      Pavel Aslanov authored
      Summary: Pattern matching like functionality for boost::vairant. See unittests for usage examples.
      
      Reviewed By: yfeldblum, ericniebler
      
      Differential Revision: D4851133
      
      fbshipit-source-id: cda7dc766dac5870bcc4ab1859de0e4e7f0a6599
      7d06adb4
    • Nick Terrell's avatar
      small_vector improvements · 0ef8ce0d
      Nick Terrell authored
      Summary:
      1. `emplace_back()` is broken when there are at least two arguments and one is a reference to inside the vector. See the `ForwardingEmplaceInsideVector` test.
      2. Only `push_back(value_type&&)` did exponential growth, every other function grew linearly. The bug is hidden inside of facebook because `goodMallocSize()` grows fast enough to not be horribly slow. When not using jemalloc, it will grow one element at a time.
      3. `push_back(value_type const& t)` performed a copy and a move on `t` when `size() == capacity()`. Remove the extra move.
      
      Fixes https://github.com/facebook/folly/issues/541.
      
      Reviewed By: luciang
      
      Differential Revision: D4875084
      
      fbshipit-source-id: eefa76028c6bfd9d7c73af65e8bb9d4baf49b8cb
      0ef8ce0d
    • Dave Watson's avatar
      Make folly pass TSAN checks · a0c640e8
      Dave Watson authored
      Summary:
      Currently, contbuild has a blanket TSAN suppression for folly.
      Fix PicoSpinLock instead
      
      This should fix TSAN errors as an alternative to D4781776
      
      Some of the tests even had TSAN errors, fixed those.
      
      Reviewed By: davidtgoldblatt
      
      Differential Revision: D4795284
      
      fbshipit-source-id: 9f0fc6868399da2f86be355ce3c081990260a649
      a0c640e8
    • Dave Watson's avatar
      Fix virtual struct bug · 92f554a5
      Dave Watson authored
      Summary: virtual classes currently don't work in hazard pointers, and get incorrectly reclaimed.
      
      Reviewed By: magedm
      
      Differential Revision: D4951584
      
      fbshipit-source-id: 8200df6bb8d500af2e89086edf7835d4fb90b6a2
      92f554a5
    • Christopher Dykes's avatar
      Delete the non-char integeral forms of fbstring::operator= · ce979260
      Christopher Dykes authored
      Summary: They allow for assignments that make no sense, so make it impossible to do so.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4919606
      
      fbshipit-source-id: 24d8e036eff33a8c6def4672c0d098f0edd5c5b3
      ce979260
  8. 25 Apr, 2017 3 commits
    • Neel Goyal's avatar
      Guard SSLContext lock checks with init mutex and add setSSLLockTypesAndInitOpenSSL · 5699919f
      Neel Goyal authored
      Summary:
      Improve concurrency guards for `setSSLLockTypes` and `isSSLLockDisabled` by using initMutex.  Also verify that openssl has been initialized w/ DCHECK in isSSLLockDisabled.
      
      We also add a method to do the setting of locks and initialization in one shot.
      
      Reviewed By: knekritz
      
      Differential Revision: D4937242
      
      fbshipit-source-id: 308f516c17485281604d4322954c09beb58688e2
      5699919f
    • Andrii Grynenko's avatar
      Remove thread-safety comment from EventBaseLocal · 2c371199
      Andrii Grynenko authored
      Reviewed By: vitaut
      
      Differential Revision: D4940976
      
      fbshipit-source-id: 0c4ebf8f358e6f54a7b5e81f2e73649b030006c9
      2c371199
    • Christopher Dykes's avatar
      Shift the implementation of setThreadName out of the header · 6bfd09a8
      Christopher Dykes authored
      Summary:
      `folly::setThreadName` is neither performance critical, nor (after this diff) is it a template, so exposing the mess that is its implementation to the world isn't worth it.
      The implementation is expected to get even more messy as I add support for getting the current thread's name, and eventually also add support for Windows as well.
      
      This also required exposing whether the current platform supports setting the name of the current or other threads.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4942401
      
      fbshipit-source-id: 0e3be203995fa6ed667a5fd28dac7ba7fa49d683
      6bfd09a8
  9. 24 Apr, 2017 1 commit
    • Michael Lee's avatar
      Properly gate the wchar tests in FBStringTest · dee718a2
      Michael Lee authored
      Summary: Using `#ifndef __ANDROID__` does not necessarily handle all cases of gating the wchar tests
      
      Reviewed By: Orvid
      
      Differential Revision: D4938634
      
      fbshipit-source-id: a2184e20b8c382e5a34947c029f7e3746272b407
      dee718a2
  10. 22 Apr, 2017 2 commits
    • Neel Goyal's avatar
      Ignore setSSLLockTypes() calls after SSLContext is initialized. · 2d466553
      Neel Goyal authored
      Summary: We set the actual locks on initialization, so attempting to change locks after had no affect, other than making isSSLLockDisabled() report incorrect information.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4935475
      
      fbshipit-source-id: 7b80cd530801c925ade769163579b86b1a8f0027
      2d466553
    • Michael Lee's avatar
      Also exclude the wstring test · 3bdf6ef1
      Michael Lee authored
      Summary: ^^^
      
      Reviewed By: yangchi
      
      Differential Revision: D4934455
      
      fbshipit-source-id: babf56f4705ae06f46b694df3f2890d4b9506861
      3bdf6ef1
  11. 21 Apr, 2017 3 commits
    • Michael Lee's avatar
      Turn off failing FBString test for Android · 5b978faa
      Michael Lee authored
      Summary: The traitsLength call in the basic_fbstring constructor is returning a bad value.
      
      Reviewed By: Orvid
      
      Differential Revision: D4930106
      
      fbshipit-source-id: 556a61c4496c2af91cb70db6d62cdc7e915edd55
      5b978faa
    • Christopher Dykes's avatar
      Use std::nullptr_t in dynamic · 09887be9
      Christopher Dykes authored
      Summary: It was changed to a `void*` previously due to an ICE in GCC 4.7. GCC 4.7 hasn't been supported in quite a while, and newer versions of GCC don't crash, so it's time to switch it back to `nullptr_t`.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4917389
      
      fbshipit-source-id: fc48642026c7e3aaeadef27bb949f70648c2312c
      09887be9
    • Cameron Pickett's avatar
      Fix issue where compiler cannot determine address of ::free at compile time · 58006ffb
      Cameron Pickett authored
      Reviewed By: Orvid
      
      Differential Revision: D4921738
      
      fbshipit-source-id: 69848cda3638fca4ead73dcc9949af0f600f33bb
      58006ffb
  12. 20 Apr, 2017 2 commits
    • Andrii Grynenko's avatar
      EventBaseLocal cleanup · 7de5a995
      Andrii Grynenko authored
      Summary:
      1. Restrict EventBaseLocal API to only be used from EventBase thread to avoid extra locking.
      2. Make sure objects stored in EventBaseLocal are destroyed in EventBase thread.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4918282
      
      fbshipit-source-id: b7cb4c2b62fef85a9b1d796fa71af8af9087479d
      7de5a995
    • Nicholas Ormrod's avatar
      Remove unpackHack from smallVector · 049e3d99
      Nicholas Ormrod authored
      Summary:
      This change removes the unpackHack function from small_vector, which was blocking ##-Waddress-of-packed-member## from being enabled. The fix is split the pointer-getting non-const ##getCapacity## into a normal getter and setter.
      
      (lithium is flakey, according to continuous, and is push-blocking)
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4918188
      
      fbshipit-source-id: 435e030ad659f5dc9c42d90e9bfee9ca564a120a
      049e3d99
  13. 19 Apr, 2017 3 commits
    • Maxim's avatar
      Added pkg-config as required dependency · c6cf2b08
      Maxim authored
      Summary:
      Faced this problem on Ubuntu 14.04.4 LTS
      
      ```
      configure:16581: error: possibly undefined macro: AC_MSG_NOTICE
            If this token and others are legitimate, please use m4_pattern_allow.
            See the Autoconf documentation.
      autoreconf: /usr/bin/autoconf failed with exit status: 1
      ```
      Fixed with `apt-get install pkg-config`
      Closes https://github.com/facebook/folly/pull/579
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4886216
      
      Pulled By: Orvid
      
      fbshipit-source-id: 88159b70bfcf62d01bef502b3a5da6c9d81499bc
      c6cf2b08
    • Phil Willoughby's avatar
      Improve string comparisons · 5a122efc
      Phil Willoughby authored
      Summary:
      Any pair of read-compatible (same type, same traits) basic_strings (`basic_fbstring` or `std::basic_string`) can now be compared to each other with the `==`, `!=`, `<`, `>`, `<=`, and `>=` operators.
      
      If you have a C++14 environment this allows you to use the heterogeneous comparison lookup methods from N3657: you can query containers which store either string type with either string type efficiently.
      
      Reviewed By: yfeldblum, ot
      
      Differential Revision: D4905697
      
      fbshipit-source-id: 2ea976ebf40af45d64c1d8c1c08847feb3b9db68
      5a122efc
    • Andrew Krieger's avatar
      Include <strings.h> in portability/String.h · 14c1d806
      Andrew Krieger authored
      Summary:
      portabilty/String.h defines functions for Windows which
      are provided by <strings.h> on other platforms, but doesn't include
      <strings.h> in that case.
      
      Reviewed By: Orvid
      
      Differential Revision: D4908770
      
      fbshipit-source-id: b3326f78509c2aa1acb9c9279f01537b0a243400
      14c1d806
  14. 18 Apr, 2017 5 commits