1. 16 Dec, 2016 8 commits
    • Yinghai Lu's avatar
      Add BEXTR instruction support · 9660cdb0
      Yinghai Lu authored
      Summary: BEXTR is an instruction in BMI set, which extract given number of bits from a 64 bit register starting from a given position. The position and size of extracted bits are packed into a one 64bit integer.
      
      Reviewed By: Orvid
      
      Differential Revision: D4316516
      
      fbshipit-source-id: 3f752388763b0e26c506d7d49cf6c05cf28271c0
      9660cdb0
    • Christopher Dykes's avatar
      Revert D4310312: [Folly] Enable -Wunreachable-code · eac2f407
      Christopher Dykes authored
      Summary: This reverts commit 8178dacc9268e1001efc5f803a35ef49e23d692a
      
      Differential Revision: D4310312
      
      fbshipit-source-id: 7c4b90e834f1a95e51524e1e82ac5294e5ba2dc5
      eac2f407
    • Yedidya Feldblum's avatar
      Always use an EventBaseManager with ScopedEventBaseThread · 536bac28
      Yedidya Feldblum authored
      Summary: [Folly] Always use an `EventBaseManager` with `ScopedEventBaseThread`.
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D4336412
      
      fbshipit-source-id: 459a679f8fda0db1ca0a9fdca2f852bb00c5231e
      536bac28
    • Christopher Dykes's avatar
      Enable -Wunreachable-code · a83ba29c
      Christopher Dykes authored
      Summary:
      Because it finds dead code.
      This also removes the dead code found.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4310312
      
      fbshipit-source-id: 8178dacc9268e1001efc5f803a35ef49e23d692a
      a83ba29c
    • Christopher Dykes's avatar
      Allow folly to compile cleanly with most of the rest of MSVC's sign mismatch warnings · d7d91eb1
      Christopher Dykes authored
      Summary:
      This allows folly to compile with warnings 4245, 4287 and 4365 enabled, all of which are sign mismatch warnings.
      This is labeled as 'mostly' because I'll probably have to clean up a few more of these.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4263259
      
      fbshipit-source-id: 0db618f0405817503a63094edd75b24ec1e5c9ad
      d7d91eb1
    • Christopher Dykes's avatar
      More implicit truncation warning fixes · 1c098e27
      Christopher Dykes authored
      Summary:
      This makes the changes required to compile Folly cleanly with the rest of MSVC's truncation warnings, 4244 & 4267.
      Only another 2800 sign mismatch warnings left to go.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4257094
      
      fbshipit-source-id: 1651eca875a31f53774d36c682f5e2745ddfcda5
      1c098e27
    • Christopher Dykes's avatar
      Refactor stats to use the same type for indexes · 654cce1e
      Christopher Dykes authored
      Summary:
      This refactors folly/stats/* to use a single type for indexes rather than `size_t`, `int`, `unsigned int`, `uint64_t` and `int64_t` depending on where you looked.
      This also has the result of getting MSVC to not complain about implicit sign conversions and implicit truncations.
      
      Reviewed By: simpkins
      
      Differential Revision: D4282174
      
      fbshipit-source-id: 8529be34dce8ad18bc64395330bbdf2cd7305be4
      654cce1e
    • Christopher Dykes's avatar
      Include <cassert> when using assert · 16c6735f
      Christopher Dykes authored
      Summary:
      We were using `assert` without including anything that defines it.
      
      Closes https://github.com/facebook/folly/issues/530
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4337047
      
      fbshipit-source-id: 327d19a685e7a4cc1e1eb6e471a6457fe9dee6c7
      16c6735f
  2. 15 Dec, 2016 5 commits
    • Yedidya Feldblum's avatar
      Check the baton waits in the ScopedEventBaseThread tests · b1cc5501
      Yedidya Feldblum authored
      Summary:
      [Folly] Check the baton waits in the `ScopedEventBaseThread` tests.
      
      Also:
      * `Baton<T>::timed_wait` can take a `duration`, not just a `time_point`.
      * Allow a bit more time for waiting, just in case the machine running the tests is under load.
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D4330126
      
      fbshipit-source-id: 55878577b1deeb260686647e5f22a81d6fb9e06d
      b1cc5501
    • Andrii Grynenko's avatar
      Require runBeforeLoop callbacks to be canceled prior to EventBase destruction · e3f67e10
      Andrii Grynenko authored
      Summary: This makes it similar to other other events registered with EventBase.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4331277
      
      fbshipit-source-id: 5d728d4ae5faff1a72ed724b4e2a6c0dd6c3b02d
      e3f67e10
    • Wez Furlong's avatar
      add folly::init to libfolly for OSS build · 8d0d6318
      Wez Furlong authored
      Summary:
      We use this in eden and this avoids needing to patch the homebrew recipe.
      
      I've also made the use of the folly symbolizer specific to the facebook
      internal build of folly, because it fails to compile in the Linux OSS build
      too.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4292166
      
      fbshipit-source-id: b69153be8ab9cc461bc7f456248e73972ba7f461
      8d0d6318
    • Andrii Grynenko's avatar
      Make FunctionLoopCallback available outside of EventBase.cpp · 489524aa
      Andrii Grynenko authored
      Reviewed By: yfeldblum
      
      Differential Revision: D4331194
      
      fbshipit-source-id: 1e1579e3b775b1b4e329aa28aae11a2b54294697
      489524aa
    • Andrii Grynenko's avatar
      Make SingletonVault state use ReadPriority mutex · 4092256e
      Andrii Grynenko authored
      Summary: This fixes a deadlock possible when singleton chain is created concurrently with destroyInstances().
      
      Reviewed By: lbrandy, yfeldblum
      
      Differential Revision: D4329028
      
      fbshipit-source-id: a11b3ff42d164ead2f8e3e77e0e17be43a8ad306
      4092256e
  3. 14 Dec, 2016 4 commits
    • Eric Niebler's avatar
      work around GCC#61971 (spurious -Warray-bounds warnings) in folly::FixedString · 6ed9b4c6
      Eric Niebler authored
      Summary:
      GCC has the temerity to insinuate that my code has out-of-array-bounds access. After cross-checking with clang and ubsan, reviewing the code, and running constexpr tests (for which out-of-range errors are caught at compile time), I can say with pretty high confidence that this is an instance of GCC#61971 (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61971). Basically, the gcc-4 series is known to issue spurious -Warray-bounds warnings. The "fix" is to route internal accesses to some helper functions, for which -Warray-bounds has been suppressed.
      
      User code that accesses elements with operator[] will still warn on out-of-bounds access. If this is a problem in practice, we can suppress the warning there, too. Trying this for now since it is less likely to hide real problems.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4317305
      
      fbshipit-source-id: 7bf92f993ac1a29631463c582c1b64d76f755181
      6ed9b4c6
    • Nathan Bronson's avatar
      fix ExceptionTracerTest build · 56ef367e
      Nathan Bronson authored
      Summary:
      A recent diff added [[noreturn]] annotations that cause buck
      build to fail for ExceptionTracerTest.cpp, due to our use of -Werror
      and -Wunreachable-code-return.  This diff removes the unreachable return
      statement.
      
      Differential Revision: D4326888
      
      fbshipit-source-id: 7863c163eedcf2a7e19730c1de194f05c544a2c0
      56ef367e
    • Christopher Dykes's avatar
      Allow building with -Wmissing-noreturn · f3f4bcfb
      Christopher Dykes authored
      Summary: If your function doesn't return you should be explicit about it.
      
      Reviewed By: meyering
      
      Differential Revision: D4309893
      
      fbshipit-source-id: ce275ec8f42e2cb3253a1e40e263934649f09d9e
      f3f4bcfb
    • Andrii Grynenko's avatar
      Update fibers GDB docs · f2203c94
      Andrii Grynenko authored
      Reviewed By: yfeldblum
      
      Differential Revision: D4323918
      
      fbshipit-source-id: 8dcd4ef3629fff061a9f149093ef1fe087f1c7e2
      f2203c94
  4. 13 Dec, 2016 6 commits
    • Michael Lee's avatar
      Find and remove unused headers · 4017bdbd
      Michael Lee authored
      Summary: Find and remove a couple of unnecessary includes
      
      Reviewed By: matbd
      
      Differential Revision: D4322316
      
      fbshipit-source-id: 7b55119bd7566fd62762ace5e35aa536489fafad
      4017bdbd
    • Andrii Grynenko's avatar
      Move GDB scripts for fibers into folly · 8753361e
      Andrii Grynenko authored
      Reviewed By: igorsugak
      
      Differential Revision: D4320762
      
      fbshipit-source-id: 2028de6ccc6fb129381b03d694b88677a5aa50d6
      8753361e
    • Neel Goyal's avatar
      Add evb change callback to SSL Socket · 168487dc
      Neel Goyal authored
      Summary: Allow observers to be notified when AsyncSocket attaches and detaches from EVB
      
      Reviewed By: siyengar
      
      Differential Revision: D4256175
      
      fbshipit-source-id: a3ff96811f885e508f20cf11ce52e0f00e5ee461
      168487dc
    • Christopher Dykes's avatar
      Enable -Wunreachable-code-return · 4824fb83
      Christopher Dykes authored
      Summary: The most common place this happened was in tests where it was being used to force the return type of a lambda, but there were a couple of places in the main code that triggered this as well.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4310187
      
      fbshipit-source-id: e3701cff9827eacaf3be8d28296441466eb2fa11
      4824fb83
    • Philip Pronin's avatar
      move JemallocNodumpAllocator to folly/experimental · ab1bf671
      Philip Pronin authored
      Summary:
      Moving russoue's `JemallocNodumpAllocator` (D3147173) from
      `mcrouter` codebase to `folly`, so we can use it in a few other services
      that suffer from a huge core dump problem.
      
      Reviewed By: russoue, jmswen, luciang
      
      Differential Revision: D4311394
      
      fbshipit-source-id: 6a13c478b939bd411e0fd37e655125f62434c366
      ab1bf671
    • Igor Zinkovsky's avatar
      allow run-once callbacks · 0dd7a9a6
      Igor Zinkovsky authored
      Summary: Adding new `addFunctionOnce` method that executes provided callback only once.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4315635
      
      fbshipit-source-id: 4819ec30b4f2e4ab3185a37158404e1c7a96758a
      0dd7a9a6
  5. 12 Dec, 2016 4 commits
    • Christopher Dykes's avatar
      Allow building with -Wshift-sign-overflow · 344088dc
      Christopher Dykes authored
      Summary: Prior to C++14 these shifts are undefined behavior, but the unsigned version is not, so do the shifts on unsigned values before converting to the final type.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4309311
      
      fbshipit-source-id: 914b207bac2f77a96c07a8a5df81980c672aa677
      344088dc
    • Christopher Dykes's avatar
      Allow building with -Wgnu-conditional-omitted-operand · 0d6a706b
      Christopher Dykes authored
      Summary: Which warns about the use of a ternary statement with the first operand omitted. This is a GCC extension and MSVC does not support it, so eliminate the last use of it.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4309989
      
      fbshipit-source-id: 04c968708e47f8cb707fd0892e8780bc676df0de
      0d6a706b
    • Christopher Dykes's avatar
      Don't declare a variable for exceptions we discard · 811bad8a
      Christopher Dykes authored
      Summary: They aren't needed and they count as initialized but unused variables.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4308844
      
      fbshipit-source-id: a6833dbf434ebdefff0b375729a4e62495463ac0
      811bad8a
    • Christopher Dykes's avatar
      Fix some implicit truncation and sign coersion in the networking APIs · b4a27a03
      Christopher Dykes authored
      Summary: Split out of an earlier pair of diffs, this focuses exclusively on Folly's networking APIs and works to eliminate places where values were being implicitly truncated.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4288042
      
      fbshipit-source-id: dd6e19acd319296a45c29c8050dc62f06571e1e6
      b4a27a03
  6. 10 Dec, 2016 2 commits
    • Christopher Dykes's avatar
      Enable -Wunreachable-code-break · 4168732c
      Christopher Dykes authored
      Summary: Because the `break;` can be dead, and sometimes is indicitive of a different type of error.
      
      Reviewed By: meyering
      
      Differential Revision: D4310056
      
      fbshipit-source-id: ad215eb9b2e5bb4d5c703582203efce893b26a76
      4168732c
    • Kyle Nekritz's avatar
      Log supported versions extension in AsyncSSLSocket. · 38442e01
      Kyle Nekritz authored
      Summary: To monitor client support of TLS 1.3.
      
      Reviewed By: ngoyal
      
      Differential Revision: D4308473
      
      fbshipit-source-id: cb6fb444c8b7ced39e6655a0f63b18523c2fb9c5
      38442e01
  7. 09 Dec, 2016 6 commits
    • Nathan Bronson's avatar
      folly/io/async/tests: always detach event base in tests, fixes UBSAN tests · c80831a5
      Nathan Bronson authored
      Summary:
      In AsyncSSLSocket tests the shared_ptr structure means that the
      AsyncSSLSocket-s outlive the stack-allocated EventBase on which they were
      created.  Previously there were scattered calls to detachEventBase on the
      last interesting callback, but several calls were missing.  This diff
      switches to a model where the SSLServerAcceptCallbackBase is responsible
      for detaching the sockets.
      
      This diff also fixes a low-firing race between shutdown
      of the TestSSLAsyncCacheServer Main thread and a call to
      EmptyReadCallback::readEOF.  Most uses of EmptyReadCallback don't attach
      the TCP socket, so they can't actually tolerate a call to readError
      or readEOF.
      
      These use-after-destruction problems were discovered by UBSAN.
      
      Reviewed By: djwatson
      
      Differential Revision: D4301416
      
      fbshipit-source-id: 127fb5e506d0694c5ca81d7a38c704d69f4ab3eb
      c80831a5
    • Christopher Dykes's avatar
      Enable -Wextra-semi · 10847386
      Christopher Dykes authored
      Summary:
      Because the extra semicolons are useless and all typos...
      GCC doesn't have this warning. Neither does MSVC, but that won't stop me.
      
      Reviewed By: igorsugak
      
      Differential Revision: D4304218
      
      fbshipit-source-id: a06586edc6b9bafd5dd074e9fd4e0ed152181abc
      10847386
    • Christopher Dykes's avatar
      Don't shadow locals, parameters or fields · d5c1c794
      Christopher Dykes authored
      Summary:
      This accounts for the places that were triggering warnings 4456, 4457, and 4458, which are all related to shadowing names, be they locals, parameters, or even types.
      This doesn't deal with 4459, which is specifically for shadowing global variables, because folly/gen defines globals by the name of `count`, `min`, `max` and a few other similar names.
      
      Reviewed By: meyering
      
      Differential Revision: D4296781
      
      fbshipit-source-id: a2e625095e2c65a53a9226b000aaf0ca95a3a393
      d5c1c794
    • David Goldblatt's avatar
      Fix SimpleBarrier · 43d3a315
      David Goldblatt authored
      Summary:
      Do the barrier completion test in a loop. (std::condition_variable has pthreads-style spurious wakeups).
      
      (Sorry for missing this in review).
      
      Reviewed By: djwatson
      
      Differential Revision: D4302035
      
      fbshipit-source-id: 3322d6a0ffba8c47c46bafb1d88034e1a0a9c652
      43d3a315
    • Dave Watson's avatar
      update small locks benchmark · efc07505
      Dave Watson authored
      Summary: Add fairness benchmark, contended benchmark
      
      Reviewed By: davidtgoldblatt
      
      Differential Revision: D3706680
      
      fbshipit-source-id: 01814fcd6b0cc3dd12815a2b2c248abc6a3771ec
      efc07505
    • Qinfan Wu's avatar
      Fix sorted_vector_set::erase · eab8d3c3
      Qinfan Wu authored
      Summary: It deletes things even when input isn't in the container.
      
      Reviewed By: luciang
      
      Differential Revision: D4298340
      
      fbshipit-source-id: 3e8fc04c2c21eb231dcaf82239ac5f6d25e49e2c
      eab8d3c3
  8. 07 Dec, 2016 5 commits
    • David Lam's avatar
      Fix Synchronized.md documentation to use correct condition_variable::wait call · 65fc07b5
      David Lam authored
      Summary:
      `condition_variable::wait_for` takes as second param `std::chrono::duration`
      and not a predicate; what we want is `condition_variable::wait`.
      
      Reviewed By: simpkins
      
      Differential Revision: D4295305
      
      fbshipit-source-id: 05f735fe6e7ecb9d8f42cb38a2985b9ce9dad984
      65fc07b5
    • Christopher Dykes's avatar
      Fix some implicit truncations in the interaction with OpenSSL APIs · 68112fa0
      Christopher Dykes authored
      Summary: MSVC has the ability to warn about implicit truncations and places where implicit sign coercions are occuring, so do some cleanup to make it possible to compile with the warnings enabled.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4288028
      
      fbshipit-source-id: f8330c62b2dcb76f696dfc47888f0e3e1eefc21a
      68112fa0
    • Yedidya Feldblum's avatar
      Cut some includes from Executor.h · c9fc2e32
      Yedidya Feldblum authored
      Summary: [Folly] Cut some includes from `Executor.h`.
      
      Reviewed By: mzlee
      
      Differential Revision: D4256618
      
      fbshipit-source-id: 1728f48b3c0ec4e0c4c84c44bd8afb583d438129
      c9fc2e32
    • Wez Furlong's avatar
      USE_JEMALLOC in the OSS build if we have jemalloc · e44d8a62
      Wez Furlong authored
      Summary:
      Nothing defines USE_JEMALLOC in the OSS build today and that causes
      some portability problems.
      
      Specifically, the homebrew recipe will make libjemalloc available and our
      configure script will detect it and add it to the library flags.
      
      Our subsequent check for `malloc_usable_size` then finds this function in
      libjemalloc.
      
      When later attempting to build wangle against the homebrew folly we get
      compilation failures because the prototype for `malloc_usable_size` is only
      available in the jemalloc headers and nothing in the saved configuration for
      folly is set up for this to be pulled in as it it guarded by `USE_JEMALLOC`.
      
      This attempts to resolve the situation by forcing on `USE_JEMALLOC` when
      we detect the library in configure.
      
      This is made a little more complicated because we cannot set `USE_JEMALLOC`
      in the OSS build; it gets rewritten to have a `FOLLY_` prefix.  Since we
      have code outside of folly that requires that this symbol be `USE_JEMALLOC`,
      I've changed the conditional to check for both flavors of the symbol, with
      and without the prefix.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4289176
      
      fbshipit-source-id: 756bc815c3ef1fac454e603feb72155d98c5aadd
      e44d8a62
    • Eric Niebler's avatar
      add folly::FixedString, a constexpr-usable string with a fixed-size internal buffer · 77d5e547
      Eric Niebler authored
      Summary: Inspired by http://wg21.link/p0259, folly::BasicFixedString is a std::string replacement that is usable in constexpr contexts. It uses an internal fixed-size buffer to store up to N characters, where N is a template parameter.
      
      Reviewed By: luciang
      
      Differential Revision: D4249529
      
      fbshipit-source-id: 10f12ea2510a8d21ec60a07a8f15ecc3e35c5431
      77d5e547