1. 09 Aug, 2016 3 commits
    • Yedidya Feldblum's avatar
      constexpr_abs · cf93e807
      Yedidya Feldblum authored
      Summary:
      [Folly] `constexpr_abs`.
      
      Is `constexpr`.
      
      Works over integral and floating types.
      
      If given an integral type, the return type is the usigned version of that integral type, thereby avoiding the undefined behavior of `std::abs(std::numeric_limits<int>::min())`.
      
      Reviewed By: simpkins
      
      Differential Revision: D3654072
      
      fbshipit-source-id: 24fefc0c3b055f78ba3e07472c38fb9c550e0f31
      cf93e807
    • Aaryaman Sagar's avatar
      Removing noexcept specifications in constructors for Synchronized that call... · b26ef8ac
      Aaryaman Sagar authored
      Removing noexcept specifications in constructors for Synchronized that call contextualLock() and contextualRLock()
      
      Summary:
      Most mutex lock() functions do not have a noexcept guarantee, saying that the
      constructor for Synchronized based on whether the underlying constructor for
      the type stored is not enough.  Although this will *rarely* cause bugs, it
      probably can be fixed
      
      Reviewed By: simpkins
      
      Differential Revision: D3682974
      
      fbshipit-source-id: ec0bb701d0af41ffc79128fe8db7935a5f19bc70
      b26ef8ac
    • Subodh Iyengar's avatar
      Add MSG_NOSIGNAL to AsyncSSLSocket · 6b554b1e
      Subodh Iyengar authored
      Summary:
      We are definitely not prepared to handle
      SIGPIPEs, so add MSG_NOSIGNAL to sendmsg
      of AsyncSSLSocket.
      
      This is a problem which exists in openssl
      as well which calls send with flags = 0.
      We recently made a change to move the send
      into our control, so we can now supply the
      flag
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3686679
      
      fbshipit-source-id: ff8fe662e62923c25876bdfd516352639505dca6
      6b554b1e
  2. 08 Aug, 2016 3 commits
    • Adam Simpkins's avatar
      Update documentation for Synchronized · 218a45f5
      Adam Simpkins authored
      Summary:
      Update the documentation for Synchronized to remove references to the
      various SYNCHRONIZED macros, and document the lock() and withLock() APIs
      instead.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3618871
      
      fbshipit-source-id: e970f9a23e45831d62232eea2ba133a55e5a4a49
      218a45f5
    • Michael Lee's avatar
      Include sys/syscall.h to SysMembarrier · b8c8b1f8
      Michael Lee authored
      Summary: It calls syscall, but does not include the header.
      
      Reviewed By: knekritz
      
      Differential Revision: D3586636
      
      fbshipit-source-id: 2ef05fc4b88f236a84b79afa708e98fe21529685
      b8c8b1f8
    • Maged Michael's avatar
      Methodology for using DeterministicSchedule support for auxiliary data and global invariants · 58ecc903
      Maged Michael authored
      Summary:
      Depends on D3648195
      
      This test example is intended to demonstrate the methodology for using DeterministicSchedule support for auxiliary data and global invariants.
      The main goal is fine-grained invariant checking, ideally after every shared update.
      The secondary goals are:
      - Minimize intrusion in the original code. In this proposed methodology, it is adding a friend.
      - Minimize duplication of original tested code. Unfortunately, depending on the original code, it seems that significant duplication may be unavoidable if we don't want to change the original code.
      
      This diff is primarily about the methodology for testing already developed code. I plan to apply what we agree on through this diff to the dynamic MPMCQueue code (D3462592).
      
      A future goal to keep in mind is creating a methodology for developing new code with hooks for DSched aux. data and invariant checking integrated in it, in order to minimize or eliminate duplication of tested code.  In past projects, I used non-standard source code (basically algorithm code) that is automatically translatable through scripts and macros to input to a DSched-like tool as well as to compilable code. The main challenge for such a methodology is to allow the original source code to be standard readable C++ code.
      
      Reviewed By: djwatson
      
      Differential Revision: D3675447
      
      fbshipit-source-id: aae2c9f0550af88dc3a5dcbe53318a75a86b6e2b
      58ecc903
  3. 05 Aug, 2016 7 commits
    • Christopher Dykes's avatar
      Use the socket portability layer when needed. · c98aec4e
      Christopher Dykes authored
      Summary: This switches the places in Folly that need to explicitly reference the socket portability implementation to do exactly that.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3299984
      
      fbshipit-source-id: 57cd8ebe66c9055aba66581a8c0fcf6c125d96f9
      c98aec4e
    • Dave Watson's avatar
      Upper level tests · f3d9a55f
      Dave Watson authored
      Summary:
      Add some tests to test the other levels of the timer wheel.
      
      They are slow by necessity.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3637132
      
      fbshipit-source-id: badf8d37d726dbeb5a8220d50c60b8efdaee7989
      f3d9a55f
    • Dave Watson's avatar
      remove catchupEveryN · 07b497a7
      Dave Watson authored
      Summary: This feature doesn't make sense when wheeltimer doesn't constantly tick - we always have to get the current clock time.  On the plus side, we'll only be grabbing the clock on timer schedule or timeout, never for individual ticks.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3637088
      
      fbshipit-source-id: ed8fe52419259332a14b6dc1d357979dcf258a20
      07b497a7
    • Christopher Dykes's avatar
      Handle creating the default crypto context if it doesn't already exist · cf7b6169
      Christopher Dykes authored
      Summary: It's perfectly possible that the default crypto context simply hasn't been created yet, so try to create it if the initial acquisition fails.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3673138
      
      fbshipit-source-id: 122955df04055ff4f99513b182375d4388dd0305
      cf7b6169
    • Christopher Dykes's avatar
      Don't throw in the Watchdog destructor · 86b83461
      Christopher Dykes authored
      Summary: As-of C++11, destructors are assumed to be `noexcept` unless explicitly marked otherwise. `Watchdog`'s destructor throws, so switch it to a `LOG(FATAL)` instead.
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D3672621
      
      fbshipit-source-id: 5224ecf85d101462e02e12da257e033bab4db1a1
      86b83461
    • Aaryaman Sagar's avatar
      Adding policies for all the upgrade and downgrade mutex transitions that are... · 7dd2b580
      Aaryaman Sagar authored
      Adding policies for all the upgrade and downgrade mutex transitions that are going to be supported by Synchronized
      
      Summary:
      This diff contains the lock policies that will be used by Synchronized to
      implement mutex transitions by means of heterogenous RAII mutex wrappers
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3665020
      
      fbshipit-source-id: a5509dfd58a1dd6cd60a7d3afe929d0da860926d
      7dd2b580
    • Aaryaman Sagar's avatar
      Adding support for upgradable mutexes to LockTraits · 84f24236
      Aaryaman Sagar authored
      Summary:
      This diff adds support for upgradable mutexes to the LockTraits
      abstraction used by folly::Synchronized
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3645453
      
      fbshipit-source-id: 30f16eb3fbebc687a4136256f1103962c0e4c465
      84f24236
  4. 04 Aug, 2016 19 commits
    • Christopher Dykes's avatar
      Use std::max_align_t rather than __attribute__((__aligned__)) to get max alignment · b22e53e0
      Christopher Dykes authored
      Summary: Because the former is standardized, and the latter is a syntax error under MSVC.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3672667
      
      fbshipit-source-id: c0149b11367e36ba5574625240c41a167348199f
      b22e53e0
    • Melanie Subbiah's avatar
      Create trace points for thread events · 14410cc6
      Melanie Subbiah authored
      Summary: RequestContext update.
      
      Reviewed By: mibpl
      
      Differential Revision: D3604937
      
      fbshipit-source-id: 07b315fe22a6dba40f0bab53c8092f35c172ae85
      14410cc6
    • 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
  5. 03 Aug, 2016 8 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