1. 04 Aug, 2016 17 commits
    • Christopher Dykes's avatar
      Don't attempt to mmap an anonymous shared piece of memory · b837180a
      Christopher Dykes authored
      Summary: The portability implementation of `mmap` for Windows doesn't currently support anonymous shared allocations, as they are non-trivial to manage, and the places this is being used doesn't actually need the memory to be allocated as shared, so allocate it as private instead.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3671495
      
      fbshipit-source-id: e74d4fd925363fef16c1bf8445da1ff32bf8266d
      b837180a
    • Christopher Dykes's avatar
      Use std::thread rather than pthreads in AtomicHashMapTest · 114e32af
      Christopher Dykes authored
      Summary: The tests aren't dependent on it being pthread, so use standardized stuff instead.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3665698
      
      fbshipit-source-id: ad91facb75a9c5d7a90bfa294cc98bb07629de1b
      114e32af
    • Christopher Dykes's avatar
      Fix compilation errors when attempting to compile Folly without WIN32_LEAN_AND_MEAN defined · 5beef6c2
      Christopher Dykes authored
      Summary: Without `WIN32_LEAN_AND_MEAN` defined, including `Windows.h` includes a massive number of extra headers. There are situations that need things that are defined in those headers, so keep folly working even when it isn't defined.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3671350
      
      fbshipit-source-id: 0de986e17cdd4be386be8a9eeb0075b4af44024d
      5beef6c2
    • Christopher Dykes's avatar
      Add a couple more things to the socket portability layer · 242e3da1
      Christopher Dykes authored
      Summary: To make it possible for things to actually compile, this adds `socketpair` and the `sockaddr_un` struct, and also removes the `FOLLY_HAVE_UNIX_SOCKETS` define, as it is no longer needed.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3671158
      
      fbshipit-source-id: 7333470f2e85c24edb935be5e1b94b4edc6e7267
      242e3da1
    • Christopher Dykes's avatar
      Disable the use of direct TLS in ThreadLocalDetail under MSVC · ce9e2df3
      Christopher Dykes authored
      Summary: The comment tells the truth: StaticMeta doesn't mix well with MSVC's TLS implementation.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3671274
      
      fbshipit-source-id: 293eb32699ad5cee59965f24f985ec7099c90136
      ce9e2df3
    • Christopher Dykes's avatar
      Fix a pair of non-ascii quotes that made their way into AsyncSocket · 6ed8b542
      Christopher Dykes authored
      Summary: Because the lint error was annoying me.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3671252
      
      fbshipit-source-id: 2962db7616077f531e64c6f2b26ad708c7adf6ed
      6ed8b542
    • Christopher Dykes's avatar
      Eliminate the atomic porability header's dependence on Windows.h · 13310f28
      Christopher Dykes authored
      Summary:
      This is done by using the intrinsic directly instead.
      This also marks the input parameter as `volatile`, to make it more clear that that's how it is handled by `_InterlockedExchangeAdd64`.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3671320
      
      fbshipit-source-id: 6010085ec3b6952a3eb1e952965ec6ad87566db2
      13310f28
    • Christopher Dykes's avatar
      Don't assume boost::path contains narrow characters · db33d307
      Christopher Dykes authored
      Summary: Because it contains `wchar_t`'s on Windows.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3672098
      
      fbshipit-source-id: b49db642dedf48bf7379cf339130c93f52a22f9a
      db33d307
    • Christopher Dykes's avatar
      Don't try to ignore the SIGPIPE signal if it isn't defined · d449fce2
      Christopher Dykes authored
      Summary: Which is the case when compiling under MSVC.
      
      Reviewed By: pixelb
      
      Differential Revision: D3671357
      
      fbshipit-source-id: b7e51479cae44933c3f1caa21d45775a32f294a3
      d449fce2
    • Christopher Dykes's avatar
      Assume p is not nullptr in storeUnaligned · 41db9753
      Christopher Dykes authored
      Summary:
      Because we're constructing the value with a placement new, which has some of C++'s most unhelpful behavior ever put into the spec: If `p` is `nullptr` and we are not compiling in C++14 mode, where the restriction was changed, then the placement new will do absolutely nothing at all. By adding the assumption that `p` is not `nullptr`, we'll trip a segfault in release mode rather than failing silently.
      Note that MSVC would generate the nullptr check regardless of which mode it's in, so this assume forces the removal of the check.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3651116
      
      fbshipit-source-id: ee15a38f85ce4e3cb3186fda0b7bcca39acda27a
      41db9753
    • Mirek Klimos's avatar
      RequestContext::create should call onUnset callback · d89b4d34
      Mirek Klimos authored
      Summary: melaniesubbiah introduced onSet / onUnset callbacks on RequestData in D3604948; we need unset() to be called when an RC is overriden with RequestContext::create() so that things work as expected. Also, change the order of calling onSet / onUnset - from RequestData perspective, it shouldn't look like there are two contexts set at the same time
      
      Reviewed By: palmtenor
      
      Differential Revision: D3667017
      
      fbshipit-source-id: b9bfb858fe65ffb11de8e6d6f13b8f4cf6266bc9
      d89b4d34
    • Christopher Dykes's avatar
      Include the fcntl.h portability header where it's needed · 156f7033
      Christopher Dykes authored
      Summary: There are a few places that need this, so make it so.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3667234
      
      fbshipit-source-id: 84c16e1b036d9c2afddf03aa84c43210c5672f0a
      156f7033
    • Christopher Dykes's avatar
      Support TimeUtil under MSVC · 6edcf484
      Christopher Dykes authored
      Summary: Well, make it compile anyways. There's no simple equivelant for Windows, so just return 0 instead.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3667474
      
      fbshipit-source-id: 02224c6666dfcfdec237bfbbd4714170407a952a
      6edcf484
    • Christopher Dykes's avatar
      Fix the Windows portability implementations of mmap and munmap · 59bcc452
      Christopher Dykes authored
      Summary: Because they simply didn't work before.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3666894
      
      fbshipit-source-id: 7a34073b2bbc43c489ad963c28fac24dcbb187f2
      59bcc452
    • Nick Terrell's avatar
      Fix Enumerate C++17 Support · 5f92025e
      Nick Terrell authored
      Summary: `RangeEnumerator`s `begin()` and `end()` could return different values, but `Enumerator`s `operator ==` didn't support comparision with different types.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3662576
      
      fbshipit-source-id: cfd10fffd220c70191ce0ac2ed78edd35daf5538
      5f92025e
    • Christopher Dykes's avatar
      Don't use a macro for no reason · 381f8e28
      Christopher Dykes authored
      Summary: There is no reason at all for this to be a macro, so get rid of the macro.
      
      Reviewed By: igorsugak, yfeldblum
      
      Differential Revision: D3666339
      
      fbshipit-source-id: cf131fd4182fe89c5ce0c981edf9bd7fb46158a9
      381f8e28
    • Christopher Dykes's avatar
      Don't name a member small · cf1c637d
      Christopher Dykes authored
      Summary:
      Because, if you aren't compiling with `WIN32_LEAN_AND_MEAN`, including `WinSock2.h` will result in `small` being `#define`'d as `char`. The best way to work around the issue is to simply change the name of the member to something else.
      It would also have been possible to solve the problem by adding a section to `folly/portability/Windows.h`, but that would have required including that header in `folly/Function.h`, which there really is no reason to do.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3666417
      
      fbshipit-source-id: 21c0363a4b77bb01e4ec20b2fc625c40729879c3
      cf1c637d
  2. 03 Aug, 2016 9 commits
    • Christopher Dykes's avatar
      Fix the mode being used in the implementation of open in the Fcntl portability header · a0f8eed7
      Christopher Dykes authored
      Summary: The mode parameter to `open` under MSVC is not the same as the mode parameter everywhere else, so we need to do a bit of translation.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3651218
      
      fbshipit-source-id: 80df1e15f34b8d66533256107d8c9218f757fde2
      a0f8eed7
    • Christopher Dykes's avatar
      Force the overflow in BitVectorCoding::skipTo to be 64-bit · abb963a0
      Christopher Dykes authored
      Summary: This code was relying on the `- 1` overflowing as a 64-bit value, but MSVC (correctly in my opinion) was overflowing this as a 32-bit value, resulting in a segfault when trying to run the bitvector and eliasfano tests on MSVC.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3652343
      
      fbshipit-source-id: 38a22abfc0d05ab2f070c450eebfa69af07d26af
      abb963a0
    • Mirek Klimos's avatar
      Unset RequestContext properly in EventBase::runLoopCallbacks · 6e8fcd16
      Mirek Klimos authored
      Summary: We need to make sure RequestContext is unset properly for correct attribution of events to requests in BPF. djwatson, is there a reason not to set RequestContext when running runLoopCallbacks() from EventBase destructor?
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3640289
      
      fbshipit-source-id: bc48e936618adb1a1619de004b8479f58d3b683d
      6e8fcd16
    • lpathy's avatar
      Added DiscriminatedPtr support to arm64 · 0376a848
      lpathy authored
      Summary: Closes https://github.com/facebook/folly/pull/429
      
      Reviewed By: mzlee
      
      Differential Revision: D3649806
      
      Pulled By: Orvid
      
      fbshipit-source-id: 77288e0a1aedf15a18f558e18fbc1dc3a56e5fd6
      0376a848
    • Christopher Dykes's avatar
      Fix a typo in PicoSpinLock · 0ce4e4c6
      Christopher Dykes authored
      Summary:
      Because I fail at typing underscores apparently.
      This also switches the shifts over to using `kLockBitMask_` instead, which was already defined for us.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3652483
      
      fbshipit-source-id: 6bd527beeb90bea8ee7632c0a3bfbbb9e0a7e2e7
      0ce4e4c6
    • Alexander Stocko's avatar
      Add libfollytestmain.la to mallctl's LDADD · a1e9df40
      Alexander Stocko authored
      Summary:
      Fixes make check problem for MallctlHelperTest.
      
      Previous make check output:
      
      MallctlHelperTest.o: In function `MallctlHelperTest_valid_read_Test::TestBody()':
      MallctlHelperTest.cpp:(.text+0x25): undefined reference to `testing::internal::AlwaysTrue()'
      MallctlHelperTest.cpp:(.text+0x2e): undefined reference to `testing::internal::AlwaysTrue()'
      MallctlHelperTest.cpp:(.text+0x51): undefined reference to `testing::Message::Message()'
      MallctlHelperTest.cpp:(.text+0x72): undefined reference to `testing::internal::AssertHelper::AssertHelper(testing::TestPartResult::Type, char const*, int, char const*)'
      MallctlHelperTest.cpp:(.text+0x85): undefined reference to `testing::internal::AssertHelper::operator=(testing::Message const&) const'
      MallctlHelperTest.cpp:(.text+0x91): undefined reference to `testing::internal::AssertHelper::~AssertHelper()'
      MallctlHelperTest.cpp:(.text+0xe4): undefined reference to `testing::Message::Message()'
      MallctlHelperTest.cpp:(.text+0x111): undefined reference to `testing::inte
      Closes https://github.com/facebook/folly/pull/448
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3659427
      
      Pulled By: Orvid
      
      fbshipit-source-id: c1445b881bbebdace4defc02024a5184fd821ed6
      a1e9df40
    • Yuri Putivsky's avatar
      folly AsyncPipeReader supports IOBuf · 2bee060d
      Yuri Putivsky authored
      Summary: folly AsyncPipeReader takes a callback of type AsyncReader::ReadCallback. Now AsyncReader::ReadCallback class supports IOBuf as a buffer for transfer read bytes. Need to extend AsyncPipeReader class to support IOBuf as well
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3650893
      
      fbshipit-source-id: e2142341c8b8b0b2ef248c1f13a8caba9d50ba67
      2bee060d
    • Maged Michael's avatar
      Test of DeterministicSchedule support for global invariants and auxiliary vari · 832479bd
      Maged Michael authored
      Summary:
      Depends on D3648146
      
      Atomic counter test with:
      - Buggy path triggered by an env var
      - Auxiliary data
      - A global invariant
      - A function to be called with shared accesses to update auxiliary data and check the global invariant.
      
      Reviewed By: djwatson
      
      Differential Revision: D3648195
      
      fbshipit-source-id: 18620a887f114abf31ba1261c38287139a1591a7
      832479bd
    • Gustavo Serra Scalet's avatar
      Fix compiler warnings · 40857a36
      Gustavo Serra Scalet authored
      Summary:
      - unused variables
      - suppressing "warning: variable length array ‘vec’ is used [-Wvla]"
      Closes https://github.com/facebook/folly/pull/443
      
      Reviewed By: djwatson
      
      Differential Revision: D3641928
      
      Pulled By: Orvid
      
      fbshipit-source-id: 0bd58a75f8948f28cc2d232c03bd443734d9657d
      40857a36
  3. 02 Aug, 2016 5 commits
    • Maged Michael's avatar
      DeterministicSchedule support for global invariants and auxiliary variables · 61d53283
      Maged Michael authored
      Summary:
      Support for user-defined auxiliary variables and global invariants.
      - Add two fields to DSched:
        -- tls_aux: static FOLLY_TLS std::function<void(uint64_t, bool)>*. User-defined auxiliary function with parameters: count of synchronization steps, and boolean indicator of the success of the current step.
        -- step_: uint64_t. Count of shared accesses that correspond to user synchronization steps (atomic accesses for now).
      - Add two static functions to DSched:
        -- void setAux(std::function<void(uint64_t, bool)>*).
        -- void callAux(bool success). Calls the aux function with the step count and the bool success argument.
      - Add a version of afterSharedAccess(bool) that takes a bool success parameter and calls callAux(success). This version is used in every atomic operation of DeterministicAtomic.
      - Add direct load interface to  DeterministicAtomic for use by auxiliary functions.
      
      Note: This the base of a stacked diff with:
      - Test the new capabilities in DeterministicScheduleTest.h
      Next steps:
      - Use the new capabilities to test dynamic MPMCQueue
      Other possible additions:
      - Change the implementation of DeterministicMutex to allow inspecting its internal state.
      - Test the new capabilities for mutexes and semaphores in DeterministicScheduleTest.h
      - Performance optimization: e.g., user-space context switching, using regular variables to implements atomics.
      
      Reviewed By: djwatson
      
      Differential Revision: D3648146
      
      fbshipit-source-id: 4f838ff7cfd41ab71cfdf22bb67def3221948311
      61d53283
    • Sahil Jain's avatar
      Update folly/futures README · 1ddb975d
      Sahil Jain authored
      Summary: Regenerate README after updating dex_export.php
      
      Reviewed By: fugalh
      
      Differential Revision: D3654216
      
      fbshipit-source-id: aaae04803c480e2ecaf9b3cb8794c8d8f7df560b
      1ddb975d
    • Dave Watson's avatar
      Ensure getVia(eventbase) does not busy wait · 62cc0672
      Dave Watson authored
      Summary:
      Currently, getVia(eventbase) will busy wait if no work is scheduled on the event base.
      
      Tweak the DrivableExecutor API a bit to support sleeping/wakeups.
      There was already a similar fix for the only other existing DrivableExecutor, the ManualExecutor, in
      D2906858.
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D3613954
      
      fbshipit-source-id: 9ff9f2e010040d9886fdf51a665e3afabbff57c0
      62cc0672
    • Aravind Anbudurai's avatar
      readFile to take in fd · 4bd3e568
      Aravind Anbudurai authored
      Summary:
      I want to be able to read from an fd into an std::string and this diffs helps
      with that.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3654709
      
      fbshipit-source-id: d48e8001a50f90c66cbe5b4a3b536c7b0074c39d
      4bd3e568
    • Igor Sugak's avatar
      folly: remove template argument to std::abs to fix build with libc++ · 42cd3696
      Igor Sugak authored
      Summary:
      libc++ doesn't implement `std::abs` as template.
      
      ```lang=bash
      ./../folly/fibers/Fiber.h:68:34: error: unexpected type name 'intptr_t': expected
            expression
          const size_t size = std::abs<intptr_t>(
                                       ^
      ```
      
      Reviewed By: markisaa
      
      Differential Revision: D3645584
      
      fbshipit-source-id: a2d672137f110b975412a94ae4c6d00da0bd0d43
      42cd3696
  4. 01 Aug, 2016 6 commits
    • Yedidya Feldblum's avatar
      Remove the glog header include from Assume.h · a251c84f
      Yedidya Feldblum authored
      Summary:
      [Folly] Remove the glog header include from `Assume.h`.
      
      Better to avoid unnecessary includes.
      
      Reviewed By: Orvid
      
      Differential Revision: D3652651
      
      fbshipit-source-id: 3fa6256e9571539c692b9c50c1c215b31eef394a
      a251c84f
    • Christopher Dykes's avatar
      Fix the ffs builtins under MSVC · fcd39524
      Christopher Dykes authored
      Summary: I was off by one in my implementation.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3651183
      
      fbshipit-source-id: 4d6a6d08c06bce332a00088920bf604a10c942e7
      fcd39524
    • Christopher Dykes's avatar
      Don't disable the shadowing warning just for a parameter name · 0b400104
      Christopher Dykes authored
      Summary: Just rename the parameter instead, it's not worth it.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3651065
      
      fbshipit-source-id: ce11c35a7923ab7e10868cedb49c47c0b427fd0c
      0b400104
    • Christopher Dykes's avatar
      Fix nextPowTwo for 64-bit values under MSVC · 8fdd5f1b
      Christopher Dykes authored
      Summary: A `long` is only 32-bits on MSVC, so this is simply wrong. Shift a `T` left instead.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3651139
      
      fbshipit-source-id: 3bbfd18ed0c372287c4ec6cbcc543f6f1fcc4139
      8fdd5f1b
    • Christopher Dykes's avatar
      Switch some assertions to std::thread rather than pthread · 800802c8
      Christopher Dykes authored
      Summary: Because the check macros attempt to pipe the values to the error stream, but we can't do that with the Windows implementation. Switch to `std::this_thread::get_id()` instead because it's standard and can be piped.
      
      Reviewed By: djwatson
      
      Differential Revision: D3650362
      
      fbshipit-source-id: 8af65448a33949f310abc818d95bac843214b685
      800802c8
    • David Wilemski's avatar
      fix HHWheelTimer comment typo · 27945a69
      David Wilemski authored
      Summary: Noticed this while reading the code.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3648565
      
      fbshipit-source-id: c00940e5ce91fbc7e5cc6c42e35c5deee3e0bf65
      27945a69
  5. 30 Jul, 2016 1 commit
    • Aaryaman Sagar's avatar
      Added initlist_construct_t tag for explicit initializer list · 912d191d
      Aaryaman Sagar authored
      Summary:
      Initializer list construction can often have conflictingly similar
      syntax as uniform initialization.  As a result APIs and classes often either
      avoid using `std::initializer_list`s or deprecate construction with
      `std::initializer_list`s.  This change provides a tag similar to
      `std::piecewise_construct_t` to help out.
      
      Reviewed By: simpkins
      
      Differential Revision: D3617276
      
      fbshipit-source-id: 3c74802f946a22e1a4ee52eca0f89df4a028eb22
      912d191d
  6. 29 Jul, 2016 2 commits
    • Dave Watson's avatar
      More tests · 24e91815
      Dave Watson authored
      Summary:
      Test timers where we need to reschedule the wheel timer next tick.
      
      This wasn't tested before, since we were always ticking, and never needed to reschedule.
      
      Differential Revision: D3637103
      
      fbshipit-source-id: cb80e7b790bb6aac68bdb5f60f8aa00caa2e5b69
      24e91815
    • Giuseppe Ottaviano's avatar
      Limit symbol length in demangle() · acd8ed50
      Giuseppe Ottaviano authored
      Summary:
      GCC's `__cxa_demangle()` uses on-stack data structures for the parser
      state which are linear in the number of components of the symbol. For
      extremely long symbols, this can cause a stack overflow.
      
      This diff introduces an arbitrary symbol length limit above which we
      just return the mangled name.
      
      Reviewed By: philippv
      
      Differential Revision: D3641115
      
      fbshipit-source-id: ec360bb20ca499fd0eaf3a06c5bbcbd1e936d845
      acd8ed50