1. 22 Jul, 2016 11 commits
    • Melanie Subbiah's avatar
      RequestContext changes to facilitate thread tracing · 6645b95d
      Melanie Subbiah authored
      Summary: In order to trigger trace points when a new thread begins/finishes executing, I added functionality to call onSet and onUnset methods on all RequestData objects whenever setContext is called. The main question: will this approach cost us too much overhead?
      
      Reviewed By: djwatson
      
      Differential Revision: D3604948
      
      fbshipit-source-id: 3b704ca0f2b713458427aa49be12f776939057f8
      6645b95d
    • Mark Isaacson's avatar
      Fix ASAN exposed heap-use-after-free · 066a868c
      Mark Isaacson authored
      Summary: This code very obviously wrote past the end of the buffer when the length was 1. Furthermore, it was just downright broken for all values. The author obviously meant to type * instead of +. I took the time to verify that the algorithm is actually correct, while I was working on this. My proof is in the test plan.
      
      Reviewed By: yfeldblum, meyering
      
      Differential Revision: D3603255
      
      fbshipit-source-id: 5f2a0011ff5401a70ba03993eab6e53e29d87c1c
      066a868c
    • Christopher Dykes's avatar
      Rename GetTickCount to GetClockTickCount · 0dacfa47
      Christopher Dykes authored
      Summary: Because Windows already defines a funtion named `GetTickCount` with a different signature.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3601877
      
      fbshipit-source-id: fa0fb422156a3dc71e149e02a000ccdf3479eea5
      0dacfa47
    • Christopher Dykes's avatar
      Update FB_ONE_OR_NONE in Preproc.h to work with MSVC · ccb2bd7f
      Christopher Dykes authored
      Summary: There was an MSVC section, but it's much simpler to just use the glue to solve the issue instead.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3601184
      
      fbshipit-source-id: f95bd3dfc4b244e1bce21997f44de2970575ad7f
      ccb2bd7f
    • Christopher Dykes's avatar
      Always use the 64-bit conversion function in ConvBenchmark.cpp · 38b106f1
      Christopher Dykes authored
      Summary: A `long` on MSVC is only 4 bytes, so the `static_assert` will fail. Remove the static assert and use the `long long` version instead. Do the same for the unsigned version.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3601064
      
      fbshipit-source-id: 70c5f4bca597ba05c3729f5d15feeea3cc8fde57
      38b106f1
    • Christopher Dykes's avatar
      Include the Builtins portability header in Bits.h · eeb9d4e9
      Christopher Dykes authored
      Summary: Because we need it for MSVC.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3601138
      
      fbshipit-source-id: 4d2ba3f9c972717745289686b025d2763f9ef30d
      eeb9d4e9
    • Christopher Dykes's avatar
      Include the sys/types.h portability header · c2cea839
      Christopher Dykes authored
      Summary: As the comment in the file says, this has to be included in a weird order due to issues on Windows.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3601008
      
      fbshipit-source-id: fca4b6d906eb0d1f001c28197987165cd075752d
      c2cea839
    • Christopher Dykes's avatar
      Use decltype to get the type of a non-static local · 7b8c8076
      Christopher Dykes authored
      Summary: As the `sizeof()` is being evaluated in a static context, MSVC doesn't let you reference non-static locals. Solve the issue by getting the type of the local via `decltype` instead.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3600845
      
      fbshipit-source-id: 825d93ced8f09d9f4bf0dcf02142f47a0ec32605
      7b8c8076
    • Christopher Dykes's avatar
      Don't typedef types to the same name in different namespaces · 9b2bbca7
      Christopher Dykes authored
      Summary:
      This was causing MSVC to complain due to `DSched` already being declared in `BatonTestHelpers.h` as `::folly::DSched`, but it's then typedef'd again in `BatonTest.cpp`, this time as `::DSched`. MSVC complains about the duplicate definitions even though they resolve to the same type, so kill the one in the source file and keep the one in the header.
      The same is the case with `GroupVarint32Decoder` and `GroupVarint64Decoder`, which are both declared in `GroupVarint.h` and then again, this time in an anon namespace, in `GroupVarintTest.cpp`.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3600948
      
      fbshipit-source-id: 401790aa918289fe4a34dd5af683f8c6ca50d847
      9b2bbca7
    • Wez Furlong's avatar
      folly: fixup folly::Random FixedSeed test expectations on macOS · 138f44b3
      Wez Furlong authored
      Summary:
      uniform_int_distribution is implemented differently on this system and
      always returns the generated number from our constant random number generator.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3585418
      
      fbshipit-source-id: 754076599ba77b49c17f03bb0c92264a3bed4ab0
      138f44b3
    • Christopher Dykes's avatar
      Don't use ?: · c2691bc6
      Christopher Dykes authored
      Summary:
      Because it doesn't exist in the C++ standard.
      
      This switches them to the explicitly expanded form, which is in the spec.
      It also removes a few that were doing absolutely nothing. (MSVC still complained about the division by zero)
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3479260
      
      fbshipit-source-id: 5386e27057beeb4b228f5d6be4e1cf9941cf3176
      c2691bc6
  2. 21 Jul, 2016 3 commits
    • Christopher Dykes's avatar
      Support StlVectorTest for MSVC · bfe4b109
      Christopher Dykes authored
      Summary:
      Sure, it's big, but it compiles.
      
      There are a few different changes to make this happen, the first is to deal with quite a few places where MSVC was complaining about the implicit coersion of template and noexcept parameters to bool.
      Next, the gating that disabled this for 4.7 is now gone.
      MSVC's runtime expected `difference_type` to be defined on our custom allocator, so it now is.
      `ReadTSC()` was changed to use MSVC's intrinsic for this.
      And finally, the named variadic parameters to macros were switched to normal variadic macro params, as MSVC doesn't support named ones.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3479761
      
      fbshipit-source-id: 703a5ef942ffc9b63381d13fc3960ac6f2780aa0
      bfe4b109
    • Christopher Dykes's avatar
      Mark a couple of local constants as static constexpr · cbef1e2d
      Christopher Dykes authored
      Summary: Because they aren't captured, and thus aren't accessible, in the callback used further on in the function.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3600874
      
      fbshipit-source-id: 699b3d4caa0a310b1ccc7810d670671850f4366b
      cbef1e2d
    • Christopher Dykes's avatar
      Disable a test of ThreadLocal across forks for Windows · e21b7273
      Christopher Dykes authored
      Summary: We don't have `fork()` to begin with, so disable the test and the includes it required if we're compiling on Windows.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3600600
      
      fbshipit-source-id: 5399705753b456139105f4ac757190e1ba1765f2
      e21b7273
  3. 20 Jul, 2016 3 commits
    • Yedidya Feldblum's avatar
      allocate_sys_buffer · e28213bf
      Yedidya Feldblum authored
      Summary:
      [Folly] `allocate_sys_buffer`.
      
      For when a `malloc`'d buffer is required, with an associated deleter that calls `free`.
      
      Reviewed By: JonCoens
      
      Differential Revision: D3590516
      
      fbshipit-source-id: 644f4b5d5e8f19dbc8f29efe3e93517fba0ad72f
      e28213bf
    • Mingtian Yin's avatar
      Record whether cached certificate was used · df8ec793
      Mingtian Yin authored
      Summary: Record whether cached certificate was used
      
      Reviewed By: anirudhvr
      
      Differential Revision: D3582807
      
      fbshipit-source-id: 246107ce383ff31718ee7dcccf8bbea459b559a8
      df8ec793
    • Wez Furlong's avatar
      folly: allow folly::init to build on systems without the symbolizer (macOS) · 8cf0c3e0
      Wez Furlong authored
      Summary:
      This makes folly/init/Init.cpp compile on macOS by leveraging
      equivalent functionality in the glog library when the folly symbolizer is not
      available.  This is true for macOS and also for Windows.  I haven't done
      anything to handle Windows in this diff.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3585509
      
      fbshipit-source-id: 2e0c29520a53826acbf656a7a02659b4e905802f
      8cf0c3e0
  4. 19 Jul, 2016 9 commits
    • Christopher Dykes's avatar
      Wrappers folly::chrono::clock_gettime and clock_gettime_ns · 5ab482b1
      Christopher Dykes authored
      Summary:
      On Linux hosts, the fast path to get the current time in
      nanoseconds without doing a syscall to the kernel is available via the
      VDSO kernel-runtime interface.
      
      In this diff, I:
      
      1. Expose portability wrappers `folly::chrono::clock_gettime()` and
      `folly::chrono::clock_gettime_ns()`
      2. Implement a VDSO wrapper on Linux hosts to implement those without
      a round-trip to the kernel
      
      Depends On D3418054
      
      Reviewed By: bmaurer
      
      Differential Revision: D3418087
      
      fbshipit-source-id: 3fb99f0dd946f19ba29d0d52a1038dad3556bafd
      5ab482b1
    • Steve Muir's avatar
      Generate a pkg-config file for Folly · 4786b768
      Steve Muir authored
      Summary: First cut at autoconf rules for generating a pkg-config file for Folly. The only interesting part is that we want to handle packages that provide their own .pc files as dependencies rather than just stuffing them into the list of libraries required from packages that don't provide .pc.
      
      Reviewed By: simpkins
      
      Differential Revision: D3556611
      
      fbshipit-source-id: d1c5f89416d1d96d2cdf5ccdc5bd7117fb822a82
      4786b768
    • Christopher Dykes's avatar
      Handle small_vectors with 0 inline capacity correctly · 6a3ea696
      Christopher Dykes authored
      Summary: It is an error to attempt to get the size of a zero length array, such as `unsigned char[0]`, which is what you get if `MaxInline` has been passed in as 0. We can work around this by simply defining `InlineStorageType` to be `void*` if the size is exactly 0, which will result in the capacity correctly being stored out of line.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3572898
      
      fbshipit-source-id: c96bb7cc6a890044bb74b0f6d5238c503552ee25
      6a3ea696
    • Elliott Clark's avatar
      Correctly use iters_ in ProducerConsumerQueueBenchmark · 26b139fc
      Elliott Clark authored
      Summary: iters was only being used on one side of the producer/consumer.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3588593
      
      fbshipit-source-id: 5e9a8a02bb9addbd6f936b8cc411d58cdf82b6e2
      26b139fc
    • Yedidya Feldblum's avatar
      Make the mprotect variant of asymmetricHeavyBarrier work when mlock fails · c17a113e
      Yedidya Feldblum authored
      Summary: [Folly] Make the `mprotect` variant of `asymmetricHeavyBarrier` work when `mlock` fails.
      
      Reviewed By: djwatson
      
      Differential Revision: D3585948
      
      fbshipit-source-id: c3a46884434b7f9da9caa9cf203573f9e3ce7444
      c17a113e
    • Michael Lee's avatar
      Fix macro check in SysMembarrier · 7dd33144
      Michael Lee authored
      Summary:
      FOLLY_X64 is usually defined, so check whehter it is defined
      to 0 or 1.  In addition, memory barriers are not necessarily widely
      available on the mobile platforms. What leads me to believe this is
      that, at least for older ndk's, atomics are not guaranteed to work for
      multicore platforms.
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D3586806
      
      fbshipit-source-id: 3ac8c4b74cac09e41bc3cb65c8adc2732b8b2256
      7dd33144
    • Wez Furlong's avatar
      folly: unconditionally include boost mutex definitions on macOS · 06064ddf
      Wez Furlong authored
      Summary:
      macOS doesn't have timedwait functionality and this header file was
      gating including the boost headers on that check which caused dependent modules
      to fail to compile because `boost::mutex` and `boost::recursive_mutex` were not
      known to the compiler.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3585470
      
      fbshipit-source-id: 7f8d9603e95ce01328103c7c6ac0bc75a35ddf4d
      06064ddf
    • Christopher Dykes's avatar
      Make sure to return from atomicHashArrayInsertRaceThread · 9dbb52ab
      Christopher Dykes authored
      Summary: Because, unfortunately, `pthread_exit` is not marked as noreturn in the pthread library primarily used on Windows, we need to return something to avoid errors.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3571465
      
      fbshipit-source-id: 4713b2364d6584ae255fb83cd21406fdc33ee299
      9dbb52ab
    • Andrii Grynenko's avatar
      Use membarrier in TLRefCount · 3f0064f6
      Andrii Grynenko authored
      Summary: membarrier guarantees that there's at most one update to thread-local counter, which collecting thread may not see.
      
      Reviewed By: djwatson
      
      Differential Revision: D3532952
      
      fbshipit-source-id: 6106bfe87c70c5f864573a424662778e20423bbb
      3f0064f6
  5. 18 Jul, 2016 5 commits
    • Wez Furlong's avatar
      folly: improve setThreadName for macOS · cf21fddd
      Wez Furlong authored
      Summary:
      Since OS X 10.6 it is possible to set the name of the current thread.
      This diff adjusts our setThreadName routine to do this, partially fixing
      the associated test case.  Even though this doesn't completely cover
      all cases it is still a valid improvement: most callers are
      threads setting their own name.
      
      I've amended the tests so that they can accomodate systems that cannot
      set the names of other threads.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3576281
      
      fbshipit-source-id: 13caf0dca6496aa2da897631e8d7327a6ee452bb
      cf21fddd
    • Andrii Grynenko's avatar
      Fix mocking to support multiple overrides · 46763a64
      Andrii Grynenko authored
      Summary: When installing the mock, we should make sure to remove singleton from the creation_order list.
      
      Differential Revision: D3580725
      
      fbshipit-source-id: dfb489de1be860ab639380644eab0b45a07a1450
      46763a64
    • Christopher Dykes's avatar
      Always pack small_vector · 71b5c881
      Christopher Dykes authored
      Summary:
      The check was overly restrictive, the conditional packing was originally used to limit it to GCC only (as it used the `__attribute__` directly), but that restriction is no longer needed as `FOLLY_PACK_*` will be defined appropriately for whatever platform we are currently on.
      
      This just switches it to unconditionally use the `FOLLY_PACK_*` macros rather than defining it's own `FB_PACK_*` macros.
      
      See https://github.com/facebook/folly/commit/aafd8ff9151615a8de09682d41d1c29966e4c8fe for where the `FB_PACK_*` macros could originally have been removed.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3373779
      
      fbshipit-source-id: 9e41b0836f8ba12de4f37aba58c51f841be08b41
      71b5c881
    • Christopher Dykes's avatar
      Make static analysis happy about the length of patternBuf · 9c4ce90b
      Christopher Dykes authored
      Summary: The static analysis doesn't quite understand that we are assigning a NUL to, at most, `patternBuf[MAX_PATH + 1]` so increase the buffer size slightly to make it happy.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3571923
      
      fbshipit-source-id: c027e2b253dc3e56d13e9a15a0e960a6aa3a0e6c
      9c4ce90b
    • Christopher Dykes's avatar
      Add an Atomic portability header · 9d4e8129
      Christopher Dykes authored
      Summary: Because there are situations where we need to do an atomic write to a plain pointer, rather than an atomic value. Unfortunately, there is no support in the standard library for this, so different compilers implement the primitives differently. This specifically implements an `int64_t` overload for `__sync_fetch_and_add` for use in the atomic hash map test.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3571830
      
      fbshipit-source-id: c27d8d2a5238bbc9aba6a9e48e4b3412a199288f
      9d4e8129
  6. 17 Jul, 2016 1 commit
    • Wez Furlong's avatar
      folly: fix initialization for CLOCK_PROCESS_CPUTIME_ID emulation on macOS · 4592f5e8
      Wez Furlong authored
      Summary:
      this fixes TimeTest on macOS.
      
      The problem was that `task_info_count` is an in/out parameter and it wasn't correctly initialized due to a typo.  The lack of initialization meant that the `task_info()` call would fail at runtime.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3576262
      
      fbshipit-source-id: 8388fa3c5020309d64a0fa7e01fd6cea80200219
      4592f5e8
  7. 16 Jul, 2016 4 commits
    • Wez Furlong's avatar
      folly: fix constexpr methods in RandomTest on macos · 92fd1080
      Wez Furlong authored
      Summary:
      the RNG max and min methods must be marked constexpr in order to
      compile.  The macos compiler doesn't know to propagate the constexpr-ness from
      numeric_limits::max on its own, so we have to be explicit (this also matches
      the annotations in ThreadLocalPRNG in Random.h)
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3576189
      
      fbshipit-source-id: e4eeb3361d1c48f582dad5a52e35cae133f007a1
      92fd1080
    • Wez Furlong's avatar
      folly: fixup CompressionTest compilation on macos · 95fb46db
      Wez Furlong authored
      Summary:
      The compiler on macos is pedantic about the size of the 9UL not
      matching the size of the type returned by `oneBasedMsbPos`.  Cast it to
      the appropriate size.
      
      Reviewed By: meyering
      
      Differential Revision: D3576183
      
      fbshipit-source-id: 41e9afc78eed2994e34238da119774e9bf6b7cea
      95fb46db
    • Qinfan Wu's avatar
      Fix FBStringTest build failure and hash computation for wchar · 77cf88a7
      Qinfan Wu authored
      Summary:
      Getting some build errors when doing `buck test folly/...`. This seems to be fixing it.
      
        folly/test/FBStringTest.cpp:1290:23: error: unknown type name 'basic_fbstring'; did you mean 'basic_fstream'?
          using u16fbstring = basic_fbstring<char16_t>;
                              ^~~~~~~~~~~~~~
                              basic_fstream
      
      Also the test `testHashChar16` was failing because only part of the string is used when computing hash.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3575858
      
      fbshipit-source-id: cdd5bdb9653d50beaf0ec82b659d31354b345441
      77cf88a7
    • Tom Jackson's avatar
      get_or_throw(map, key) returns references · 6871c5cc
      Tom Jackson authored
      Differential Revision: D3572671
      
      fbshipit-source-id: a80390921b41e47ed2794d48d943a9e4060c7135
      6871c5cc
  8. 15 Jul, 2016 4 commits