1. 15 Jul, 2016 1 commit
    • Michael Lee's avatar
      Add a check for wchar support · ebcf92c2
      Michael Lee authored
      Summary:
      Not all libc's are the same. Some support wchar_t and some
      don't do a great job...
      
      Reviewed By: Orvid
      
      Differential Revision: D3565016
      
      fbshipit-source-id: 91da4f1332e30bdb20a93d0a26a0445d5eadd1b7
      ebcf92c2
  2. 14 Jul, 2016 6 commits
    • Saurabh Singh's avatar
      Adding std::unique_ptr definition for the ASN1_TIME type. · 81957665
      Saurabh Singh authored
      Summary:
      The ASN1_TIME is the typically used within OpenSSL for representing
      time. For example, it can be used to represent the NotBefore and NotAfter
      properties of a certificate to be verified. This diff introduces a
      ASN1TimeUniquePtr type to take care of the ownership of the ASN1_TIME.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3561274
      
      fbshipit-source-id: ca4d1431b33098cccd727253dd301e209d2561a5
      81957665
    • Vikas Kumar's avatar
      s/PortabilityTimeTest.cpp/TimeTest.cpp · 8ba9a001
      Vikas Kumar authored
      Summary:
      The test file in `../portability/test` is named `TimeTest.cpp`. Makefile refers to it as `PortabilityTimeTest.cpp`. Possibly a typo. Or the test file should be renamed to `PortabilityTimeTest.cpp`.
      Closes https://github.com/facebook/folly/pull/438
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3558452
      
      Pulled By: Orvid
      
      fbshipit-source-id: 0cee874b63e98e671153c507f42a7a3b9d8084c1
      8ba9a001
    • Tavian Barnes's avatar
      fbstring: Fix std::hash specializations for non-char types · 78890b3f
      Tavian Barnes authored
      Summary: Closes https://github.com/facebook/folly/pull/407
      
      Reviewed By: ot
      
      Differential Revision: D3428571
      
      Pulled By: Orvid
      
      fbshipit-source-id: 0b82afae2df24803250e8d6005e2e59bbc8348c9
      78890b3f
    • zhangkehong2brad's avatar
      Enable GroupVarint on Arm64 · 9be1d48f
      zhangkehong2brad authored
      Summary: Closes https://github.com/facebook/folly/pull/430
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3558454
      
      Pulled By: Orvid
      
      fbshipit-source-id: 8a69b4db31b73806b770fbcf15663411140a04f0
      9be1d48f
    • Christopher Dykes's avatar
      Switch away from things that are removed in C++17 · 048c5964
      Christopher Dykes authored
      Summary:
      That currently includes `std::binary_function`, `std::unary_function`, and `std::random_shuffle`.
      `std::{unary|binary}_function<T{, T2}, Ret>` changes to `std::function<Ret(T{, T2})>`.
      `std::random_shuffle` has no immediate equivalent, but `std::shuffle` while passing a specific RNG achieves the same effect.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3506405
      
      fbshipit-source-id: cdefc698a841eca762174eddd8ce636e2d8d26ef
      048c5964
    • Sven Over's avatar
      ManualExecutor: add clear method · a5f4fbe0
      Sven Over authored
      Summary:
      ManualExecutor::clear removes all waiting functions from the
      executor.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3555434
      
      fbshipit-source-id: 604c352f2299b0dada062e5f8287be98e2a5f72c
      a5f4fbe0
  3. 13 Jul, 2016 1 commit
  4. 12 Jul, 2016 7 commits
    • Yedidya Feldblum's avatar
      Fix Build: sorted_vector_types.h on GCC v4.8 · 6215a88d
      Yedidya Feldblum authored
      Summary:
      [Folly] Fix Build: `sorted_vector_types.h` on GCC v4.8.
      
      Problem: that compiler does not yet support `auto`-typed lambda parameters.
      
      Solution: specify the types of the lambda parameters.
      
      Reviewed By: mzlee, Orvid
      
      Differential Revision: D3551262
      
      fbshipit-source-id: 160d3245ec422060175ce59ee653d158954477ed
      6215a88d
    • Christopher Dykes's avatar
      Define TCPI_OPT_SYN_DATA if it isn't defined · 82142aa3
      Christopher Dykes authored
      Summary: Because it doesn't in a lot of our open-source builds.
      
      Differential Revision: D3551445
      
      fbshipit-source-id: 599f45f51d1cbecedd02cb2ca3ef611648986039
      82142aa3
    • Kevin Lewi's avatar
      Adding the ability to check for whether TCP fast open succeeded on a socket · 106a2a56
      Kevin Lewi authored
      Summary: Modifies AsyncSocket to check if TFO succeeded. Also added checks to AsyncSocketTest2 to check if TFO succeeded when it should.
      
      Reviewed By: siyengar
      
      Differential Revision: D3540330
      
      fbshipit-source-id: 8a4b64fdb040dea73ba264b8e3dfff4d717fd96f
      106a2a56
    • Christopher Dykes's avatar
      Improve folly/portability/Time.cpp OS X and Windows compatibility · a4657e89
      Christopher Dykes authored
      Summary:
      Folly currently contains wrappers to emulate
      `clock_gettime()` on platforms which don't support it.
      
      The OS X and Windows wrappers are missing a bit of functionality we
      need. In this diff, I:
      
      1. Bring the OS X and Windows wrappers closer to Linux's functionality
      2. Add unit tests
      
      Reviewed By: bmaurer, mzlee
      
      Differential Revision: D3418054
      
      fbshipit-source-id: 47eba871e844b4c3dccd7ab201ec82e1f6edf729
      a4657e89
    • Adam Simpkins's avatar
      add Synchronized::withLock() methods · b179601d
      Adam Simpkins authored
      Summary:
      Add withLock() and related methods for invoking a lambda function while the
      lock is held.  This is sometimes more convenient than opening a new scope and
      using lock().
      
      withLock() also retains some of the benefits of the SYNCHRONIZED macro in that
      it forces users to put their critical section code in a new scope, making the
      critical section more visibly distinct in the code.  This also encourages users
      to only put necessary work inside the critical section, and do to other work
      once the lock is released.
      
      This also adds a LockedGuardPtr class, which is a slightly cheaper version of
      LockedPtr.  The relationship between LockedGuardPtr and LockedPtr is very much
      like that between std::lock_guard and std::unique_lock.  It saves a branch in
      the destructor, and in the case of std::mutex it also saves a small amount of
      storage space (since LockedPtr is specialized for std::mutex to also store a
      std::unique_lock).
      
      Reviewed By: yfeldblum, djwatson
      
      Differential Revision: D3530368
      
      fbshipit-source-id: 72a4f457b3f18e8e8f4cc6713218f6882bb89818
      b179601d
    • Adam Simpkins's avatar
      improve Synchronized LockedPtr class, and add new lock() APIs · 50f4f92c
      Adam Simpkins authored
      Summary:
      This refactors the Synchronized::LockedPtr class, and adds new
      lock()/wlock()/rlock() APIs to Synchronized.
      
      The LockedPtr changes include:
      
      - Consolidate code so a single template class can be used for both const
        and non-const operation, rather than requiring separate class definitions.
        A LockPolicy template parameter controls if the lock should be acquired in
        exclusive or shared mode, and a SynchronizedType parameter controls whether
        or not the internal data is const or not.
      
      - Specialize LockedPtr for std::mutex, so it uses std::unique_lock<std::mutex>
        internally.  This requires slightly more storage space internally, but it
        allows Synchronized<T, std::mutex> to be used with std::condition_variable.
      
      - Implement operator*() to dereference the pointer and retrieve a reference to
        the locked data.
      
      - Implement operator!() and provide an isValid() method to check the validity
        of the LockedPtr.  These are needed to tell if a timed acquire operation
        succeeded or timed out.
      
      - Drop the LockedPtr copy constructor.  Previously the copy constructor
        acquired the lock a second time.  If anyone needs the ability to hold a
        shared lock a second time solely via a LockedPtr (and not via the original
        Synchronized object), I think we should add back a much more explicit API to
        do this.
      
      Furthermore, this adds lock(), wlock(), and rlock() methods to Synchronized to
      explicitly obtain a LockedPtr.  These APIs behave similar to operator->(), but
      are more explicit, and require the caller to make a concious choice about
      whether or not an exclusive or shared lock should be acquired.  The lock()
      method is present only on Synchronized instantiations using an exclusive mutex,
      and the wlock() and rlock() methods are present only on Synchronized
      instantiations that use a shared mutex.
      
      I plan to deprecate the existing Synchronized::operator->() method and the
      various SYNCHRONIZED macros in upcoming diffs.  For now this adds comments
      directing users to the new methods, but does not start any of the technical
      deprecation changes yet.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3526489
      
      fbshipit-source-id: 8a96a09b68656ff9215dcdfdf32ecd2bfbb1727f
      50f4f92c
    • Yedidya Feldblum's avatar
      Inline the lower_bound and upper_bound callbacks in sorted_vector_map · 594f18f7
      Yedidya Feldblum authored
      Summary:
      [Folly] Inline the `lower_bound` and `upper_bound` callbacks in `sorted_vector_map`.
      
      Avoids unnecessary use of legacy `boost::bind`, and allows the compiler to avoid the indirection it introduces. This way, we use templates instead of vtables.
      
      Reviewed By: Orvid
      
      Differential Revision: D3545939
      
      fbshipit-source-id: 277e9e4862beb71e99b94a62308783771071d2bc
      594f18f7
  5. 09 Jul, 2016 2 commits
    • Yedidya Feldblum's avatar
      Move IPAddress definitions to source files · c8f4d603
      Yedidya Feldblum authored
      Summary:
      [Folly] Move `IPAddress` definitions to source files.
      
      And to internal header files. Keeping headers lightweight can help with build times.
      
      Reviewed By: simpkins
      
      Differential Revision: D3514455
      
      fbshipit-source-id: de78f4ef9e70e7ddd7fb666348ed705c5228531c
      c8f4d603
    • Shayan Mohanty's avatar
      Folly::FutureDAG <-> Gossit · 2f9865aa
      Shayan Mohanty authored
      Summary:
      Implements remove(), state_clean(), and reset() functions in order to allow for static FutureDAGS that can be modified in place and executed multiple times.
      
      remove() removes the given handle from the nodes vector and cleans up all dependencies associated with it. Because of the way Handles are implemented, all Handles greater than the one removed are decremented (and therefore must be accounted for in the client-code). Current best-practice would be to remove nodes by most-recently added.
      
      state_clean() removes the sink/source nodes added by go().
      
      reset() removes all nodes but the top-level source node and resets dependency properties.
      
      Reviewed By: tjkswaine
      
      Differential Revision: D3486947
      
      fbshipit-source-id: c8b9db6a139ee5b36aae6e9366c9b338cc49ede1
      2f9865aa
  6. 08 Jul, 2016 1 commit
    • Adam Simpkins's avatar
      update LockTraitsBoost to handle arbitrary duration types · 804743d8
      Adam Simpkins authored
      Summary:
      Update the boost LockTraits classes to accept arbitrary std::chrono::duration
      types, rather than just std::chrono::milliseconds.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3533556
      
      fbshipit-source-id: e764cdf4dafa0b11cd7558c2d5bfb6f80dce88cf
      804743d8
  7. 07 Jul, 2016 2 commits
  8. 06 Jul, 2016 9 commits
    • Giuseppe Ottaviano's avatar
      Python-like enumerate() · d2549d03
      Giuseppe Ottaviano authored
      Summary:
      Range-based for cannot be used if the element index is needed along
      with the element. In these situations, it is often necessary to fall
      back to the standard for loop, which is easy to get wrong, or maintain
      an extra count variable, which is error-prone when control flow is
      nontrivial (for example in the presence of `continue`).
      
      This diff introduces a simple implementation of Python's
      `enumerate()`, with the same signature. Since in C++ tuple-unpacking
      is verbose, the iteration variable returned is a proxy object `it`
      where the iteration index can be retrieved with `it.idx`, and the
      value with `*it` or `it->...`, like a normal iterator.
      
      Differential Revision: D3477877
      
      fbshipit-source-id: 376af7f559e8b60f02a3f81f0c026a901e23ddcf
      d2549d03
    • Adam Simpkins's avatar
      various improvements to the Synchronized tests · 6b66499c
      Adam Simpkins authored
      Summary:
      Add a runParallel() helper function, to clean up logic that was copy-and-pasted
      through most of the test functions.  Additionally, clean up the tests to avoid
      unnecessary sleeps.  Also fix backwards arguments to EXPECT_EQ() calls--gtest
      assumes the first argument is the expected value, and the second argument is
      the value being checked.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3521565
      
      fbshipit-source-id: e4f007d52c114080cff1fd7a0a407fba39fa8b0e
      6b66499c
    • Adam Simpkins's avatar
      Remove LockTraitsBoost from Synchronized.h · a2b94586
      Adam Simpkins authored
      Summary:
      Update Synchronized.h to no longer include LockTraitsBoost.h
      Callers that want to use folly::Synchronized with a boost lock type will now
      need to explicitly include LockTraitsBoost.h on their own.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3521168
      
      fbshipit-source-id: 08f0041f51fe2e9566bde58e9f039a6d187b54e3
      a2b94586
    • Mohamed Amin JABRI's avatar
      Remove extra ';' from used macros in Traits.h · 6f7a1148
      Mohamed Amin JABRI authored
      Summary:
      Using folly on OSX using gcc-5.3 causes errors due to extra ';' in macro expansion in Traits.h.
      Closes https://github.com/facebook/folly/pull/394
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3205265
      
      Pulled By: elliottneilclark
      
      fbshipit-source-id: f49ab04add382660719b3bb83bce3c8dc303db8b
      6f7a1148
    • Michael Lee's avatar
      Clean up int128_t macro gating · 60699fef
      Michael Lee authored
      Summary: There is inconsistent use of `#ifdef` and `#if`. Cleaning this up
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3523561
      
      fbshipit-source-id: 23f62d632efeb1b9b137b3e3582c37aae591d901
      60699fef
    • Anirudh Ramachandran's avatar
      Cleanup of how we use BIO/BIO_METHODs · 57cdfdf7
      Anirudh Ramachandran authored
      Summary:
      AsyncSSLSocket's eorAwareBioWrite does some invasive stuff like
      reaching into a BIO and replacing its method (and the 'write' funcptr). This
      approach won't work with OpenSSL 1.1.0 or BoringSSL due to API changes and
      structs being made opaque. This diff adds a layer of wrappers for some BIO
      operations. Note that this is still only tested on 1.0.2
      
      Reviewed By: siyengar
      
      Differential Revision: D3338861
      
      fbshipit-source-id: 2ac9318b0df1709873511bfde0fa85d87c5dd29a
      57cdfdf7
    • Marcus Holland-Moritz's avatar
      Refactor folly::to<> · ad2f872b
      Marcus Holland-Moritz authored
      Summary:
      This is the main diff of the series. Its main purpose is to make
      the internals of folly::to<> propagate error codes instead of
      throwing exceptions. Along with this, it makes the following
      changes:
      
      - Move most of the string-to-int implementation out of the header file
      
      - Unify error/exception strings across conversion routines
      
      - Introduce a ConversionError class that derives from std::range_error
      
      - Capture an error code in ConversionError in addition to a string
      
      - Optimize tolower() calls in Conv.cpp
      
      - Introduce ConversionResult<>, which is used as the internal result wrapper
      
      - Get rid of all error checking macros
      
      There are quite a few benefits here.
      
      == Faster conversions ==
      
      For a large set of conversions, the performance is unchanged. I've removed
      all benchmarks that were unchanged from the table below for simplicity.
      
      A few things stand out:
      
      - `follyAtoiMeasure` is consistently faster, sometimes by quite a large margin
      
      - The cost of throwing exceptions is significantly reduced, as throwing them
        further down on the call stack will reduce the amount of stack unwinding
      
      - String-to-boolean and string-to-float conversions are significantly faster
        when passing in a string representation (e.g. "off" or "infinity") thanks
        to the optimized tolower_ascii() call (column `New+Ascii` in the table)
      
      - Conversions between int and float are significantly faster and almost back
        at the performance of before the undefined behaviour fix
      
      - All string-to-(int|float|bool) conversions are consistently faster
      
      The columns in the table are as follows:
      
        Original:  Original code before the undefined behaviour fix
        Fix UB:    Code with the undefined behaviour fix; this impacts mostly the
                   float <-> int conversions, but appears to have a small effect
                   on some other benchmarks
        New:       New code introduced by this diff, but without the tolower_ascii()
                   optimization
        New+Ascii: New code, including the tolower_ascii() optimization
      
        ===========================================================================================
                                                         Original   Fix UB     New        New+Ascii
        folly/test/ConvBenchmark.cpp                     time/iter  time/iter  time/iter  time/iter
        ===========================================================================================
        handwrittenAtoiMeasure(1)                           3.95ns     3.95ns     3.95ns     3.95ns
        follyAtoiMeasure(1)                                 6.08ns     6.08ns     3.95ns     3.95ns
        -------------------------------------------------------------------------------------------
        handwrittenAtoiMeasure(2)                           5.47ns     5.47ns     5.47ns     5.47ns
        follyAtoiMeasure(2)                                 5.77ns     5.77ns     3.95ns     3.95ns
        -------------------------------------------------------------------------------------------
        handwrittenAtoiMeasure(3)                           6.08ns     6.08ns     6.08ns     6.08ns
        follyAtoiMeasure(3)                                 6.08ns     6.08ns     4.25ns     4.25ns
        -------------------------------------------------------------------------------------------
        handwrittenAtoiMeasure(4)                           6.99ns     6.99ns     6.99ns     6.99ns
        follyAtoiMeasure(4)                                 6.99ns     6.99ns     4.56ns     4.56ns
        -------------------------------------------------------------------------------------------
        handwrittenAtoiMeasure(5)                           7.90ns     8.20ns     7.90ns     7.90ns
        follyAtoiMeasure(5)                                 7.29ns     7.29ns     4.86ns     4.86ns
        -------------------------------------------------------------------------------------------
        handwrittenAtoiMeasure(6)                           8.81ns     9.42ns     8.81ns     8.81ns
        follyAtoiMeasure(6)                                 7.29ns     7.29ns     4.86ns     4.86ns
        -------------------------------------------------------------------------------------------
        handwrittenAtoiMeasure(7)                           9.72ns    10.63ns     9.72ns     9.72ns
        follyAtoiMeasure(7)                                 7.60ns     7.60ns     5.16ns     5.16ns
        -------------------------------------------------------------------------------------------
        handwrittenAtoiMeasure(8)                          10.63ns    11.85ns    10.63ns    10.63ns
        follyAtoiMeasure(8)                                 8.51ns     8.51ns     6.08ns     6.08ns
        -------------------------------------------------------------------------------------------
        handwrittenAtoiMeasure(9)                          11.54ns    13.07ns    11.54ns    11.54ns
        follyAtoiMeasure(9)                                 8.81ns     8.81ns     6.08ns     6.08ns
        -------------------------------------------------------------------------------------------
        handwrittenAtoiMeasure(10)                         12.46ns    14.28ns    12.46ns    12.46ns
        follyAtoiMeasure(10)                                8.81ns     8.81ns     6.38ns     6.38ns
        -------------------------------------------------------------------------------------------
        handwrittenAtoiMeasure(11)                         13.37ns    15.50ns    13.37ns    13.37ns
        follyAtoiMeasure(11)                                9.12ns     9.12ns     6.38ns     6.38ns
        -------------------------------------------------------------------------------------------
        handwrittenAtoiMeasure(12)                         14.28ns    16.71ns    14.28ns    14.28ns
        follyAtoiMeasure(12)                               10.03ns    10.03ns     7.29ns     7.29ns
        -------------------------------------------------------------------------------------------
        handwrittenAtoiMeasure(13)                         15.19ns    17.92ns    15.19ns    15.19ns
        follyAtoiMeasure(13)                               10.33ns    10.33ns     7.60ns     7.60ns
        -------------------------------------------------------------------------------------------
        handwrittenAtoiMeasure(14)                         16.10ns    19.14ns    16.10ns    16.10ns
        follyAtoiMeasure(14)                               10.33ns    10.33ns     7.60ns     7.60ns
        -------------------------------------------------------------------------------------------
        handwrittenAtoiMeasure(15)                         17.01ns    20.36ns    17.01ns    17.01ns
        follyAtoiMeasure(15)                               10.63ns    10.63ns     7.90ns     7.90ns
        -------------------------------------------------------------------------------------------
        handwrittenAtoiMeasure(16)                         17.92ns    21.57ns    17.92ns    17.92ns
        follyAtoiMeasure(16)                               11.55ns    11.55ns     8.81ns     8.81ns
        -------------------------------------------------------------------------------------------
        handwrittenAtoiMeasure(17)                         18.84ns    22.79ns    18.84ns    18.84ns
        follyAtoiMeasure(17)                               11.85ns    11.85ns     8.81ns     8.81ns
        -------------------------------------------------------------------------------------------
        handwrittenAtoiMeasure(18)                         19.75ns    24.00ns    19.75ns    19.75ns
        follyAtoiMeasure(18)                               11.85ns    11.85ns     9.12ns     9.12ns
        -------------------------------------------------------------------------------------------
        handwrittenAtoiMeasure(19)                         20.66ns    25.22ns    20.66ns    20.66ns
        follyAtoiMeasure(19)                               12.16ns    12.16ns     9.11ns     9.11ns
        -------------------------------------------------------------------------------------------
        stringToBoolNumClassic                             12.76ns    12.76ns    11.96ns    12.15ns
        stringToBoolNumClassicError                         3.19us     3.18us     1.58us     1.58us
        stringToBoolStrClassic                             17.92ns    17.92ns    15.50ns     7.60ns
        stringToBoolStrClassicError                         3.21us     3.18us     1.57us     1.57us
        -------------------------------------------------------------------------------------------
        stringToFloatNumClassic                            32.96ns    32.81ns    32.10ns    31.12ns
        stringToFloatNumClassicError                        2.73us     2.69us     1.65us     1.66us
        stringToFloatStrClassic                            37.37ns    38.58ns    36.76ns    16.71ns
        stringToFloatStrClassicError                        2.87us     2.87us     1.60us     1.59us
        stringToDoubleNumClassic                           31.30ns    31.82ns    29.77ns    29.17ns
        stringToDoubleNumClassicError                       2.69us     2.66us     1.65us     1.66us
        stringToDoubleStrClassic                           37.67ns    37.67ns    35.84ns    16.71ns
        stringToDoubleStrClassicError                       2.87us     2.86us     1.58us     1.58us
        -------------------------------------------------------------------------------------------
        stringToCharSignedClassic                          16.71ns    18.08ns    15.49ns    14.59ns
        stringToCharSignedClassicError                      3.87us     3.82us     1.61us     1.61us
        stringToCharUnsignedClassic                        15.49ns    15.19ns    12.46ns    12.66ns
        stringToCharUnsignedClassicError                    2.73us     2.70us     1.62us     1.62us
        stringToIntSignedClassic                           21.26ns    19.44ns    17.92ns    18.40ns
        stringToIntSignedClassicError                       3.94us     3.89us     1.64us     1.64us
        stringToIntUnsignedClassic                         17.93ns    18.53ns    15.50ns    15.50ns
        stringToIntUnsignedClassicError                     2.72us     2.71us     1.62us     1.61us
        stringToLongLongSignedClassic                      34.63ns    30.58ns    27.04ns    27.04ns
        stringToLongLongSignedClassicError                  3.94us     3.90us     1.63us     1.63us
        stringToLongLongUnsignedClassic                    51.04ns    47.96ns    46.44ns    46.68ns
        stringToLongLongUnsignedClassicError                2.73us     2.71us     1.61us     1.61us
        -------------------------------------------------------------------------------------------
        ptrPairToCharSignedClassic                          5.16ns     5.16ns     3.34ns     3.65ns
        ptrPairToCharSignedClassicError                     3.56us     3.54us     1.61us     1.61us
        ptrPairToCharUnsignedClassic                        2.43ns     2.43ns     2.13ns     2.13ns
        ptrPairToCharUnsignedClassicError                   2.63us     2.63us     1.61us     1.61us
        ptrPairToIntSignedClassic                           6.99ns     6.99ns     5.16ns     5.16ns
        ptrPairToIntSignedClassicError                      4.08us     4.06us     1.61us     1.61us
        ptrPairToIntUnsignedClassic                         4.25ns     4.56ns     3.34ns     3.34ns
        ptrPairToIntUnsignedClassicError                    2.70us     2.70us     1.60us     1.60us
        ptrPairToLongLongSignedClassic                     12.16ns    12.16ns     9.72ns     9.72ns
        ptrPairToLongLongSignedClassicError                 4.06us     4.06us     1.61us     1.61us
        ptrPairToLongLongUnsignedClassic                   29.13ns    29.13ns    27.61ns    27.61ns
        ptrPairToLongLongUnsignedClassicError               2.71us     2.72us     1.63us     1.64us
        -------------------------------------------------------------------------------------------
        intToCharSignedClassic                            405.02ps   506.35ps   405.02ps   405.02ps
        intToCharSignedClassicError                         2.10us     2.09us     1.63us     1.64us
        intToCharUnsignedClassic                          303.79ps   303.78ps   303.77ps   303.77ps
        intToCharUnsignedClassicError                       2.10us     2.09us     1.63us     1.64us
        intToIntSignedClassic                             405.02ps   405.02ps   405.01ps   405.01ps
        intToIntSignedClassicError                          1.99us     1.98us     1.72us     1.72us
        intToIntUnsignedClassic                           405.03ps   405.03ps   379.71ps   379.71ps
        intToIntUnsignedClassicError                        2.09us     2.09us     1.63us     1.63us
        -------------------------------------------------------------------------------------------
        intToFloatClassic                                 545.11ps     3.34ns     1.23ns     1.23ns
        intToFloatClassicError                              1.67us     2.37us     1.73us     1.72us
        -------------------------------------------------------------------------------------------
        floatToFloatClassic                               759.47ps   759.47ps   759.45ps   759.45ps
        floatToFloatClassicError                            6.45us     6.44us     1.77us     1.77us
        -------------------------------------------------------------------------------------------
        floatToIntClassic                                 637.82ps     2.89ns     1.50ns     1.50ns
        floatToIntClassicError                              1.92us     2.61us     1.82us     1.83us
        ===========================================================================================
      
      == Improved build times ==
      
      I've checked this with gcc 4.9.3, and compile times for both ConvTest and
      ConvBenchmark are reduced by roughly 10%:
      
        ====================================
                          original  new code
        ------------------------------------
        ConvTest.o         14.788s   13.361s
        ConvBenchmark.o    16.148s   14.578s
        ====================================
      
      == Smaller binary size ==
      
      Again, checked with gcc 4.9.3, stripped binaries are slightly smaller with
      the new code:
      
        ====================================
                          original  new code
        ------------------------------------
        conv_test           761704    749384
        conv_benchmark      539632    510928
        ====================================
      
      == Ability to add new non-throwing interfaces ==
      
      This change sticks to the original API that will throw an exception in case
      of an error. A subsequent diff will introduce non-throwing interfaces with
      a minimum of additional code.
      
      Reviewed By: ericniebler
      
      Differential Revision: D3433856
      
      fbshipit-source-id: 9bc976ebc181fe2f172ae47c78edf407e9ee7bb0
      ad2f872b
    • Adam Simpkins's avatar
      update Synchronized to use LockTraits · c9fd5aed
      Adam Simpkins authored
      Summary:
      Update the Synchronized code to use the new LockTraits added in D3504625.
      This also removes the acquireRead*() and releaseRead*() adapter functions that
      had been defined for various other lock types, which are no longer needed.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3512310
      
      fbshipit-source-id: daedd47c0378aebd479dbfe7aba24978deb9cc05
      c9fd5aed
    • Adam Simpkins's avatar
      add LockTraits · 9276f2a5
      Adam Simpkins authored
      Summary:
      This adds a new LockTraits template class, for specifying how to use arbitrary
      custom mutex types.
      
      The goal of this new class is to replace the acquireRead(), acquireReadWrite(),
      releaseRead(), and releaseReadWrite() functions currently defined in
      Synchronized.h.  I have not replaced these functions yet in this diff, but will
      do so in a follow-up diff.
      
      LockTraits has a few advantages over the existing methods:
      * It provides mechanisms for telling if a given mutex supports shared access
        and timed access.
      * The default LockTraits implementation automatically figures out the correct
        behavior for classes that define lock(), unlock(), methods.  It automatically
        detects sharing and timed support based on the presence of lock_shared() and
        try_lock_for() methods.
      
      LockTraits can be specialized for custom lock types that do not conform with
      the lock method names used by the C++ standard.  This does differ slightly from
      the argument dependent lookup mechanism used by the acquireRead() functions.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3504625
      
      fbshipit-source-id: 40320997e9ae2147baecd10b70e8dc06a35e49e1
      9276f2a5
  9. 05 Jul, 2016 3 commits
    • Andrii Grynenko's avatar
      Disable PthreadKeyUnregister on iOS and MSVC · 7235d201
      Andrii Grynenko authored
      Summary: ~PthreadKeyUnregister logic is not safe if we can't guarantee that it has the maximum pririty (i.e. is the last to be run on shutdown).
      
      Reviewed By: ericniebler
      
      Differential Revision: D3517589
      
      fbshipit-source-id: 3340e2e19cf52973ee677288bc4ac6105f3f2543
      7235d201
    • Adam Simpkins's avatar
      fix flaky ConnectTFOTimeout and ConnectTFOFallbackTimeout tests · a3bd593a
      Adam Simpkins authored
      Summary:
      In the ConnectTFOTimeout and ConnectTFOFallbackTimeout tests in
      AsyncSSLSocketTest.cpp, the client runs for 1ms before timing out and quitting.
      It may end up shutting down the server thread before the server has even
      received the TCP connect callback.  If this happened it would cause the test to
      fail, since the server code checked to make sure the callback was invoked.
      
      This diff creates a new ConnectTimeoutCallback server-side callback for these
      tests to use, which doesn't care if it gets told about a new connection or not.
      
      Reviewed By: siyengar
      
      Differential Revision: D3512809
      
      fbshipit-source-id: ce77fe944fb06a38a84c1458356f161cec7387b3
      a3bd593a
    • Subodh Iyengar's avatar
      Add sa_len for sockaddr conversions · dc939388
      Subodh Iyengar authored
      Summary:
      Some platforms like Apple add a additional
      field to sockaddr called sa_len.
      
      This is not normally required by POSIX, so
      all posix methods work correctly when a sockaddr
      is passed in without a sa_len set.
      
      However other functions which are not defined
      by posix such as connectx require this field to
      operate correctly.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3514266
      
      fbshipit-source-id: f8e2941f337222486c81c911dbd06a2ce35e4f00
      dc939388
  10. 02 Jul, 2016 8 commits