1. 02 Apr, 2016 1 commit
    • Sven Over's avatar
      folly::Function: fix swap function and put in correct namespace · 12d273d2
      Sven Over authored
      Summary:The swap function belongs in the same namespace as Function: folly.
      Also, to avoid amibiguities with a generic swap function in
      <algorithm>, we need two variants: one for identical types of
      folly::Function, and one for folly::Functions with different
      configurations.
      
      Reviewed By: ericniebler
      
      Differential Revision: D3106429
      
      fb-gh-sync-id: 11b04e9bc709d52016ac94c078278410f5ee43c6
      fbshipit-source-id: 11b04e9bc709d52016ac94c078278410f5ee43c6
      12d273d2
  2. 01 Apr, 2016 8 commits
    • Adam Simpkins's avatar
      update SocketAddress::setFromPath() to take a StringPiece · 4e995b4d
      Adam Simpkins authored
      Summary:Update setFromPath() to accept a StringPiece rather than just std::string
      or a plain const char*.
      
      Also fix two other minor issues:
      - Leave the old address untouched on failure.  Previously it could leave the
        SocketAddress in a partially updated state.
      - Don't assume the input is nul terminated.  Previously the input code read
        one past the specified input length, and copied this into the address,
        assuming it was a nul terminator.  The new code explicitly writes a 0 byte.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3119882
      
      fb-gh-sync-id: 3e2258f42034b4f470ade0a23ea085e132a3dd0f
      fbshipit-source-id: 3e2258f42034b4f470ade0a23ea085e132a3dd0f
      4e995b4d
    • Christopher Dykes's avatar
      Create the Builtins portability header · 98d33bb5
      Christopher Dykes authored
      Summary: Because we don't have these builtins under MSVC, and not having to deal with the differences in API in the places that use these builtins is good.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D2984842
      
      fb-gh-sync-id: 34db7455debf81e4abffe57c154eb731ae097ff6
      fbshipit-source-id: 34db7455debf81e4abffe57c154eb731ae097ff6
      98d33bb5
    • Christopher Dykes's avatar
      Create the dirent.h portability header · ad4df4af
      Christopher Dykes authored
      Summary: We don't have dirent.h on Windows, but we can emulate its behavior.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D2978570
      
      fb-gh-sync-id: af5ade0ea64ba22900440250e7125aa039a77f62
      fbshipit-source-id: af5ade0ea64ba22900440250e7125aa039a77f62
      ad4df4af
    • Christopher Dykes's avatar
      Create the pthread.h portability header · c63fe6c3
      Christopher Dykes authored
      Summary: The primary issue is that the pthread implementation we use for Windows defines `pthread_t` as a struct (yes, it is allowed to do this), which breaks a lot of things.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D2862671
      
      fb-gh-sync-id: 551569b6a9e2e374cf77e186e148b6b397f8f25f
      fbshipit-source-id: 551569b6a9e2e374cf77e186e148b6b397f8f25f
      c63fe6c3
    • Michael Lee's avatar
      `strndup` is defined on modern OSX · 9ab69bc7
      Michael Lee authored
      Summary: `strndup` is defined on modern versions of OSX
      
      Reviewed By: Orvid, grp
      
      Differential Revision: D3122635
      
      fb-gh-sync-id: 678792765addf2fb226e835d3b7a67e155ed6dc5
      fbshipit-source-id: 678792765addf2fb226e835d3b7a67e155ed6dc5
      9ab69bc7
    • Sven Over's avatar
      folly: replace old-style header guards with "pragma once" · dee8a518
      Sven Over authored
      Summary:Most header files in folly already used "#pragma once" to
      protect against multiple inclusion. This diff removes old-style
      ifndef/define/endif header guards and replaces them with
      pragma once.
      
      In some cases the defined symbol is tested in other header
      files. In those cases the "#define" is kept.
      
      Reviewed By: igorsugak
      
      Differential Revision: D3054492
      
      fb-gh-sync-id: 20aa0b9b926a30dd021e4b8f5440e8888874681c
      fbshipit-source-id: 20aa0b9b926a30dd021e4b8f5440e8888874681c
      dee8a518
    • Sven Over's avatar
      folly/docs: add documentation about folly::Function · 94070f19
      Sven Over authored
      Summary: This diff adds folly/docs/Function.md
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3120617
      
      fb-gh-sync-id: fecc0e507e05016aaac43ba981eab49431229bd7
      fbshipit-source-id: fecc0e507e05016aaac43ba981eab49431229bd7
      94070f19
    • Andrii Grynenko's avatar
      Implement GDB pretty-printers for folly::fibers · b1e45251
      Andrii Grynenko authored
      Summary:This adds basic print functions for FiberManager, Fiber and FiberManager map.
      It also adds a global list of fibers to FiberManager. Fibers are only removed from that list on Fiber object destruction, so it shouldn't have any perf impact.
      
      Inspired by tao/server/scripts/fiber_bt.gdb
      
      FiberManager map example:
        (gdb) print_folly_fiber_manager_map
          Global FiberManager map has 2 entries.
            (folly::EventBase*)0x7fffffffdb60 -> (folly::fibers::FiberManager*)0x7ffff5b58480
            (folly::EventBase*)0x7fffffffd930 -> (folly::fibers::FiberManager*)0x7ffff5b58300
      
      FiberManager example:
        (gdb) print_folly_fiber_manager &manager
          (folly::fibers::FiberManager*)0x7fffffffdbe0
      
          Fibers active: 3
          Fibers allocated: 3
          Fibers pool size: 0
          Active fiber: (folly::fibers::Fiber*)(nil)
          Current fiber: (folly::fibers::Fiber*)(nil)
      
          Active fibers:
            (folly::fibers::Fiber*)0x7ffff5b5b000   State: Awaiting
            (folly::fibers::Fiber*)0x7ffff5b5b300   State: Awaiting
            (folly::fibers::Fiber*)0x7ffff5b5b600   State: Awaiting
      
      Fiber example: P56244621
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3119616
      
      fb-gh-sync-id: defa27b84aafbd4333b2ca301f07c226f0386f44
      fbshipit-source-id: defa27b84aafbd4333b2ca301f07c226f0386f44
      b1e45251
  3. 31 Mar, 2016 10 commits
    • Nicholas Ormrod's avatar
      New strings no longer relocatable · 9a781ed4
      Nicholas Ormrod authored
      Summary:gcc-5.0 introduced non-relocatable strings in libgcc. Only treat gcc < 5 strings as relocatable. Enable relocation for fbstrings via typedef.
      
      Re https://github.com/facebook/folly/issues/316, thanks tomhughes for reporting this.
      
      Reviewed By: snarkmaster, ot
      
      Differential Revision: D3115580
      
      fb-gh-sync-id: d8aff947d55a0a0c57f6b997f651a190e05f2779
      fbshipit-source-id: d8aff947d55a0a0c57f6b997f651a190e05f2779
      9a781ed4
    • Giuseppe Ottaviano's avatar
      Simplify fbstring::insertImpl · 8ddc5992
      Giuseppe Ottaviano authored
      Summary:The current implementation of `insertImpl` assumes that
      `expand_noinit` does not reallocate if the `size() + delta <=
      capacity()`, but D3114022 makes this assumption invalid when compiling
      with ASan. It also doesn't guarantee exponential growth, so repeated
      inserting at the end could trigger quadratic behavior.
      
      The new implementation fixes the problems above, and it's much
      simpler.
      
      Reviewed By: yfeldblum, Orvid
      
      Differential Revision: D3119813
      
      fb-gh-sync-id: 946ebeeaf924a531f7f03fb7e79c75e352a50c58
      fbshipit-source-id: 946ebeeaf924a531f7f03fb7e79c75e352a50c58
      8ddc5992
    • Kyle Nekritz's avatar
      Log SSL alerts received on the server. · 2cf0e317
      Kyle Nekritz authored
      Summary: Alerts may be sent by clients, potentially letting us know why connections fail.
      
      Reviewed By: siyengar
      
      Differential Revision: D3117395
      
      fb-gh-sync-id: bddf51f2399eb9e7e397981d5440adb3e815d6d2
      fbshipit-source-id: bddf51f2399eb9e7e397981d5440adb3e815d6d2
      2cf0e317
    • Christopher Dykes's avatar
      Create the sys/resource.h portability header · f30ed164
      Christopher Dykes authored
      Summary: Windows doesn't have it, so be nice and at least stub it out.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D2984232
      
      fb-gh-sync-id: 3e8871ab78c5d7c8785a52af24548245f842f19b
      fbshipit-source-id: 3e8871ab78c5d7c8785a52af24548245f842f19b
      f30ed164
    • Christopher Dykes's avatar
      Create a malloc.h portability header · 86017162
      Christopher Dykes authored
      Summary:Let's break OSX!
      
      Alright, maybe not. Neither OSX nor Windows define malloc_usable_size, so we implement them based on what is available on the respective platforms.
      This moves the implementation for OSX out of Portability.h and into the new header, so it likely breaks something on OSX, although I'm not sure what.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3019938
      
      fb-gh-sync-id: df95faef09535098fb73b7b3479d7a73f6b49712
      fbshipit-source-id: df95faef09535098fb73b7b3479d7a73f6b49712
      86017162
    • Andrii Grynenko's avatar
      Add create-move-invoke benchmark for folly::Function · 7f38b123
      Andrii Grynenko authored
      Summary: Adding a benchmark for one the most common scenarios (used in Futures, EventBase, fibers etc).
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3106365
      
      fb-gh-sync-id: 8cb55959b3803e8836ab5a5bdf43fdfc1db02d4c
      fbshipit-source-id: 8cb55959b3803e8836ab5a5bdf43fdfc1db02d4c
      7f38b123
    • Christopher Dykes's avatar
      Fix the portability implementation of strndup · e3774034
      Christopher Dykes authored
      Summary:It was mistakenly assuming the length passed in included the null terminator.
      This also makes the portability implementation of `strndup` available to OSX and FreeBSD, where they weren't present, and where HHVM had a wrapper for them.
      This also removes the extra pair of conditions around `memrchr`, as the main define should always be getting set.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3116467
      
      fb-gh-sync-id: 243dd4dace219efab2c2bf2f383202e70fbec4de
      fbshipit-source-id: 243dd4dace219efab2c2bf2f383202e70fbec4de
      e3774034
    • Christopher Dykes's avatar
      Support SSE 4.2 qfind under MSVC · 10001685
      Christopher Dykes authored
      Summary:MSVC has support in the compiler for the intrinsics required, but both refuses to tell us that, and also gives them proper names.
      The code already checks for runtime support, this just enables compiling the SSE 4.2 version in the first place.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3104296
      
      fb-gh-sync-id: 9143240bede9b756817691fdd86818001267dac1
      fbshipit-source-id: 9143240bede9b756817691fdd86818001267dac1
      10001685
    • Neel Goyal's avatar
      include glog for CHECK_EQ · 06fe0874
      Neel Goyal authored
      Summary: OpenSSLPtrTypes.h uses CHECK_EQ which is included in glog/logging.
      
      Reviewed By: knekritz
      
      Differential Revision: D3118577
      
      fb-gh-sync-id: f8a00aa5a523bf88a3f783433c6699d555799225
      fbshipit-source-id: f8a00aa5a523bf88a3f783433c6699d555799225
      06fe0874
    • Christopher Dykes's avatar
      Update the sys/syscall.h portability header for Windows · c330a7dd
      Christopher Dykes authored
      Summary: This adds Windows support to the portability header for sys/syscall.h, which was previously named portability/Syscall.h, which is inconsistent with the naming of the other headers, so it's now also been renamed to SysSyscall.h, and the one place that used it updated to reflect the new name.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D2984383
      
      fb-gh-sync-id: c0e4ce55c7bc2aa6db9b084e09d9762ba587002d
      fbshipit-source-id: c0e4ce55c7bc2aa6db9b084e09d9762ba587002d
      c330a7dd
  4. 30 Mar, 2016 3 commits
    • Giuseppe Ottaviano's avatar
      Do not use small category in fbstring when in ASan mode · ef01f57b
      Giuseppe Ottaviano authored
      Summary:`fbstring`'s small string optimization prevents ASan to catch invalid
      accesses to the data of a destroyed string, for example if a
      `StringPiece` is initialized from a temporary string.
      
      This diff disables building a string with the small category when
      compiled with ASan: small strings will be constructed as
      `Medium`-category strings and heap-allocated. This is done by only
      changing the behavior of construction and resizing, so that the ABI is
      preserved and it is still possible to link an ASan-enabled object file
      with a library that wasn't compiled with ASan.
      
      The diff also fixes a blind spot in `fbstring_core`'s constructor,
      which disabled ASan altogether in order to allow fast word-aligned
      copy of small strings. Since small string construction is now disabled
      under ASan, we don't need to disable it anymore.
      
      Lastly, it always clears moved-from strings, even when they are small.
      This improves the performance of the move constructor (no more conditional
      needed) and it uncovers another class of potential bugs.
      
      Reviewed By: luciang
      
      Differential Revision: D3114022
      
      fb-gh-sync-id: 4e180fbf2b8aced3b977afc985d26fdf244d9598
      fbshipit-source-id: 4e180fbf2b8aced3b977afc985d26fdf244d9598
      ef01f57b
    • Yang Chi's avatar
      use unit64_t for numElements in HHWheelTimer · ebf930ca
      Yang Chi authored
      Summary: Some compiler will complain about this when calling std::min with a size_t and a uint64_t. So use unit64_t for numElements in HHWheelTimer.
      
      Reviewed By: mzlee
      
      Differential Revision: D3116346
      
      fb-gh-sync-id: 67a9eebf4f9e8fe0e732a7292af55122be04163b
      fbshipit-source-id: 67a9eebf4f9e8fe0e732a7292af55122be04163b
      ebf930ca
    • Misha Shneerson's avatar
      fix stack usage in HHWhileTimer · abf66230
      Misha Shneerson authored
      Summary:We should be able to use HHWheelTimer in fibers. So it should use way less stack.
      
      Alternative solution to D3112305
      
      Reviewed By: haijunz
      
      Differential Revision: D3112558
      
      fb-gh-sync-id: 3a52a37d9f9347639005fdf84524f7f8c3041918
      fbshipit-source-id: 3a52a37d9f9347639005fdf84524f7f8c3041918
      abf66230
  5. 29 Mar, 2016 4 commits
    • Yedidya Feldblum's avatar
      IPAddressV[46]::validate · 6644b370
      Yedidya Feldblum authored
      Summary:[Folly] `IPAddressV[46]::validate(StringPiece)`.
      
      Just perform the check without allocations or throws.
      
      Reviewed By: meyering
      
      Differential Revision: D3103545
      
      fb-gh-sync-id: 2918c1398935738f597b9045cf7dadbe42da2527
      fbshipit-source-id: 2918c1398935738f597b9045cf7dadbe42da2527
      6644b370
    • Neel Goyal's avatar
      Change SSLContext to use a ThreadLocalPRNG · 03afacaf
      Neel Goyal authored
      Summary:Use a ThreadLocalPRNG insteaad of a per context RNG.  This avoids
      calls to Random::seed on context creation which can get expensive
      when many are created in an application.
      
      Reviewed By: siyengar
      
      Differential Revision: D3105501
      
      fb-gh-sync-id: 92d987c27a1f190a98035ca25c23b994ca915007
      fbshipit-source-id: 92d987c27a1f190a98035ca25c23b994ca915007
      03afacaf
    • Nicholas Ormrod's avatar
      Make FBVector faster · 8063649a
      Nicholas Ormrod authored
      Summary:Per https://github.com/facebook/folly/issues/379, github user pmalek determined that fbvector's insert function was a lot slower than std::vector's. While insert is often imagined to be a second-class vector function (if you're inserting in the middle, don't use a vector!), it is the correct function to use when inserting multiple elements at the back of an array (since the standard lacks an ##append(multiple-elements)## function). The code, therefore, required optimization.
      
      There are three things that were slowing down fbvector:
      - Excessive asserts. The fbvector code contains internal asserts that ensure proper calling of private methods. These are mostly unnecessary, given the extensive test suite that batters fbvector, in addition to fbvector's battle tested history. I have removed these.
      - Internal data checks. When inserting into a vector, the elements being inserted may not reference the contents of the vector in question. If the client supplies internal references, then the standard allows for undefined behavior. An old design decision for fbvector was to be forgiving of this error; we check for internal data before performing internal data moves. This is expensive. Further, it is unnecessary when the insertion point is at the end of the vector (which is the valid case we are optimizing) or if the vector is being reallocated. I've rearchitected the insert macros to only perform the internal-data-check when it is absolutely necessary. While rearchitecting the checks, I also reorganized the n==0 base case checking.
      - The 'window' function is pretty expensive when called with the end() iterator. It is effectively a no-op, but the function (and some of its called functions) are too big to inline, so the call overhead is non-trivial. I've put window calls behind a conditional to save this overhead.
      
      I added a benchmark test to FBVectorTestBenchmark.cpp.h, but the particular pattern in that file caused the results to be completely optimized away, voiding the test. Oh well.
      
      Running the github benchmarks show a 4x speedup for inserting a single element on the back, bringing it quite close to that of std::vector. The multi-insert function got a bit faster, though the exact number of iterations seems to be having an effect on the numbers (running the tests 10,000 times, intead of only 1,000 times, yields results that are 90% as fast as std::vector, instead of 75%). Both of these cases are now looking quite a bit better.
      
      I resurrected the old StlVectorTest suite, since I was mucking with the complicated insert code. The suite had one latent compilation error (caught with newer compiler warnings - fortunately this particular case was benign). The test suite caught an error in shrink_to_fit, where a clean-slate optimization for empty vectors (see D2696314) that trampled the vector's allocator. I have fixed that small bug in this diff, too.
      
      Reviewed By: ot
      
      Differential Revision: D3105962
      
      fb-gh-sync-id: ac9fa9d7ca79335cf0ff6bb9010af1ed8bd7916b
      fbshipit-source-id: ac9fa9d7ca79335cf0ff6bb9010af1ed8bd7916b
      8063649a
    • Sven Over's avatar
      folly/futures: use folly::Function to store callback · 3f2140ea
      Sven Over authored
      Summary:This diff makes it possible to pass callables (such as lambdas) to
      folly::Future::then that are not copy-constructible. As a consequence, move-only
      types (such as folly::Promise or std::unique_ptr) can now be captured in lambdas
      passed to folly::Future::then.
      
      Using C++14 notation, the following is now possible:
        Future<Unit>().then([promise = std::move(promise)]() mutable {
          promise.setValue(123);
        });
      See folly/futures/test/NonCopyableLambdaTest.cpp for more examples.
      
      folly::Future uses std::function to store callback functions. (More precisely,
      the callback function is stored in a std::function in folly::detail::Core.)
      std::function is a copy-constructible type and it requires that the callable
      that it stores is copy constructible as well.
      
      This diff changes the implementation of folly::detail::Core to use
      folly::Function instead of std::function. It also simplifies the code in
      folly::detail::Core a little bit: Core had a reserved space of size
      8*sizeof(void*) to store callbacks in-place. Only larger callbacks (capturing
      more data) would be stored in the std::function, which puts those on the heap.
      folly::Function has a template parameter to set the size of the in-place
      callable storage. In Core, it is set to 8*sizeof(void*), so all callbacks that
      used to be stored in-place inside Core, are now stored in-place inside
      folly::Function. This even reduces the size of a Core object: the
      folly::Function object occupies 80 bytes, which is 16 bytes less than what was
      used before for a std::function (32 bytes) and the callback storage (64
      bytes). The resulting size of a Core<Unit> goes down from 192 to 176 bytes (on
      x86_64).
      
      Reviewed By: fugalh
      
      Differential Revision: D2884868
      
      fb-gh-sync-id: 35548890c392f80e6c680676b0f98e711bc03ca3
      fbshipit-source-id: 35548890c392f80e6c680676b0f98e711bc03ca3
      3f2140ea
  6. 28 Mar, 2016 6 commits
    • Subodh Iyengar's avatar
      Fix cases of overwriting errno · 6f068498
      Subodh Iyengar authored
      Summary:AsyncSocket has a few cases where
      we might overwrite errno, with another function
      call that is done during use.
      
      For example withAddr could cause an EBADF if the fd
      was bad.
      
      This fixes these cases by copying errno, before doing
      anything else
      
      Reviewed By: afrind
      
      Differential Revision: D3101932
      
      fb-gh-sync-id: 73d4810314c90cb987936a0a3a9dc977af07243a
      fbshipit-source-id: 73d4810314c90cb987936a0a3a9dc977af07243a
      6f068498
    • Yedidya Feldblum's avatar
      s/MAX_STATIC_CONSTRUCTOR_PRIORITY/FOLLY_STATIC_CTOR_PRIORITY_MAX/g · 03343ccb
      Yedidya Feldblum authored
      Summary:[Folly] `s/MAX_STATIC_CONSTRUCTOR_PRIORITY/FOLLY_STATIC_CTOR_PRIORITY_MAX/g`.
      
      Namespace it with a `FOLLY_` prefix - when Folly introduces its own symbols, it is best when they are namespaced.
      
      And stick `_MAX` at the end. Reads a bit more hierarchically to me that way.
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D3095964
      
      fb-gh-sync-id: 4ac8c00c03c8bd146fad9be96ce3849830504d96
      fbshipit-source-id: 4ac8c00c03c8bd146fad9be96ce3849830504d96
      03343ccb
    • Andrii Grynenko's avatar
      Allocate stacks with guard pages by default · efdf2270
      Andrii Grynenko authored
      Summary: This was on for mcrouter for very long time. We should make it default for everyone.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3023133
      
      fb-gh-sync-id: 6401f86df754e9490d46beb5fd9d0cf4b3675208
      fbshipit-source-id: 6401f86df754e9490d46beb5fd9d0cf4b3675208
      efdf2270
    • Sven Over's avatar
      folly::fibers: do not move out of lvalue references · 6f323462
      Sven Over authored
      Summary:If you pass an lvalue to folly::fibers::Fiber::setFunction or
      setFunctionFinally, you do not expect that those methods move
      the function out of your lvalue.
      
      This diff uses std::forward for perfect forwarding, so if an lvalue
      is passed, a copy is made.
      
      If and when when start using folly::Function for storing the
      functions in the Fiber object, passing an lvalue will trigger a
      compiler error because folly::Function is not copyable. That is
      a good thing, as it enforces calling setFunction with std::move
      if you use a named object, making clear that the named object
      gets moved out of. Often people will pass temporary objects
      (like a lambda defined i- place), which a rvalues anyway, so
      this will not be a problem anyway.
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D3102685
      
      fb-gh-sync-id: 87bf3135f7f6630766f97be351599ff488e4b796
      fbshipit-source-id: 87bf3135f7f6630766f97be351599ff488e4b796
      6f323462
    • Christopher Dykes's avatar
      Create the string.h portability header · 8ff7c8b8
      Christopher Dykes authored
      Summary: Windows has it, but some things aren't there, and some have different names.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D2990475
      
      fb-gh-sync-id: 3f30e084eb7789c13b3981ec0fbf5b7b642c3367
      fbshipit-source-id: 3f30e084eb7789c13b3981ec0fbf5b7b642c3367
      8ff7c8b8
    • Christopher Dykes's avatar
      Move asm portability to an Asm portability header · fe33916f
      Christopher Dykes authored
      Summary: Portabilty.h is just a mashup of everything that was needed up-to now, however, with the Windows port significantly expanding the scope of portability in Folly, it no longer needs to be a massive mashup, so start things by splitting out the asm stubs.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3007018
      
      fb-gh-sync-id: f32913f74660aaa8889a553ae5d6f7182a4f5789
      fbshipit-source-id: f32913f74660aaa8889a553ae5d6f7182a4f5789
      fe33916f
  7. 27 Mar, 2016 1 commit
    • Haijun Zhu's avatar
      Move event_base_new out of critical region · a103b7e7
      Haijun Zhu authored
      Summary:event_base_new does not change the global current_base so no need to
      call it with the mutex held.
      
      Reviewed By: chadparry
      
      Differential Revision: D3055963
      
      fb-gh-sync-id: df420b189ef0d7d56eda5ad6c32e03b195804e6b
      fbshipit-source-id: df420b189ef0d7d56eda5ad6c32e03b195804e6b
      a103b7e7
  8. 26 Mar, 2016 2 commits
    • Sven Over's avatar
      folly::Function: improve conversion of return types · ecf14e67
      Sven Over authored
      Summary:Treat any return type as convertible to void:
      
      As of C++17, std::function<void(Args...)> can be set to callables
      returning non-void types when called with parameters Args....
      This diff adds that capability to folly::Function. It also adds
      unit tests, not only for ignoring return types, but also for
      correctly converting between the return type of the embedded
      callabled and the return type of the encapsulating folly::Function.
      
      Allow conversion of one folly::Function type to another one which
      declares a return type the original one can be converted to:
      
      E.g. allow to construct a Function<double()> from a
      Function<int()> or a Function<Base*()> from a
      Function<Derived*()>.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3095583
      
      fb-gh-sync-id: 6d924dc6e97f759d8109db4200e1cb9333a98d31
      fbshipit-source-id: 6d924dc6e97f759d8109db4200e1cb9333a98d31
      ecf14e67
    • Bert Maher's avatar
      Fix portability/Time.h on OSX · b6ed6b39
      Bert Maher authored
      Summary: It needs stdint to define uint8_t
      
      Reviewed By: yfeldblum, mzlee
      
      Differential Revision: D3101140
      
      fb-gh-sync-id: 308507af1ccd81e2eb389a400376556a6cc597b2
      fbshipit-source-id: 308507af1ccd81e2eb389a400376556a6cc597b2
      b6ed6b39
  9. 24 Mar, 2016 2 commits
    • Kevin McCray's avatar
      folly: avoid using atomic operations android can't handle · 61e0e4d9
      Kevin McCray authored
      Summary:On Android, clang 3.8 + libstdc++ doesn't support the full
      range of atomic operations.  This diff fixes up the ones we
      ran into when building fb4a.
      
      Reviewed By: mzlee
      
      Differential Revision: D3092352
      
      fb-gh-sync-id: 7fea8513e23425fc37050ad14d82aabaceb00352
      shipit-source-id: 7fea8513e23425fc37050ad14d82aabaceb00352
      61e0e4d9
    • Yedidya Feldblum's avatar
      Fix Build: folly after replacing FOLLY_NORETURN · 7ea8b939
      Yedidya Feldblum authored
      Summary:[Folly] Fix Build: `folly` after replacing `FOLLY_NORETURN`.
      
      Problem 1:
      * Clang does not treat `[[noreturn]]` and `__attribute__((__noreturn__))` as the same attribute. When a function is declared twice with the noreturn attribute, both declarations must use either the one syntax or the other; Clang fails if the two declarations mix-and-match. When both `folly/detail/FunctionalExcept.h` and gcc49's `bits/functexcept.h` are both included from the same source, they (now) mix-and-match the attribute syntaxes and Clang emits an error.
      * `folly/detail/FunctionalExcept.h` should be included only when `bits/functexcept.h` is unavailable - somehow, both headers were being included.
      
      We fix the latter problem and keep our `[[noreturn]]` syntax.
      
      Found from WDT build failures in Travis CI.
      
      Reviewed By: ldemailly
      
      Differential Revision: D3089987
      
      fb-gh-sync-id: 705a087fc2a9629739d6cedd8315d56111204e6d
      shipit-source-id: 705a087fc2a9629739d6cedd8315d56111204e6d
      7ea8b939
  10. 23 Mar, 2016 2 commits
    • Yedidya Feldblum's avatar
      Use C++'s standardized [[noreturn]] attribute · 9895ee08
      Yedidya Feldblum authored
      Summary:Use C++'s standardized `[[noreturn]]` attribute.
      
      All supported compilers (and some unsupported compilers) also support the standardized syntax.
      
      GCC >= 4.8, Clang >= 3.0, and MSVC >= 2015 have direct support for the C++'s standardized way of writing the attribute.
      
      Clang - http://goo.gl/ftJGVM
      GCC 4.8.2 - http://goo.gl/ORCVOD
      ICC 13.0.1 - http://goo.gl/I5tn5I
      MSVC 2015 - https://msdn.microsoft.com/en-us/library/hh567368.aspx
      
      (Regardling Clang, earlier versions may support it. 3.0 was the earliest Clang version listed at godbolt.com, so that's as far back as I went.)
      
      Therefore, we no longer need to use the compiler-specific syntaxes, or use preprocessor macros with per-compiler definitions:
      
          __attribute__((__noreturn__))
          __attribute__((noreturn))
          __declspec(noreturn)
      
      Reviewed By: Orvid
      
      Differential Revision: D3073621
      
      fb-gh-sync-id: 32d4771d1bf1974693b8574fa2d39c9559872945
      shipit-source-id: 32d4771d1bf1974693b8574fa2d39c9559872945
      9895ee08
    • Christopher Dykes's avatar
      Move the clock details over to the Time.h portability header · dec14727
      Christopher Dykes authored
      Summary: Because things belong places.
      
      Reviewed By: mzlee
      
      Differential Revision: D3077737
      
      fb-gh-sync-id: 966f37df722ae737481d776ff1c9b0d5132b7a58
      shipit-source-id: 966f37df722ae737481d776ff1c9b0d5132b7a58
      dec14727
  11. 22 Mar, 2016 1 commit
    • Michael Lee's avatar
      Add APPLE to portability/Config · 67859615
      Michael Lee authored
      Summary: And use that to guard the use of posix_memalign.
      
      Reviewed By: benyl
      
      Differential Revision: D3081743
      
      fb-gh-sync-id: 2c71d9cbeeaeb59d1600d486cccfc2109699ba6b
      shipit-source-id: 2c71d9cbeeaeb59d1600d486cccfc2109699ba6b
      67859615