1. 28 Aug, 2013 31 commits
    • Tudor Bosman's avatar
      Expand the range where uninitialized warnings are ignored · 2b356118
      Tudor Bosman authored
      Summary: gcc 4.8 is picky
      
      Test Plan: folly tests, compiled unicorn with gcc 4.8
      
      Reviewed By: andrei.alexandrescu@fb.com
      
      FB internal diff: D945336
      2b356118
    • Jim Meyering's avatar
      folly: adjust more headers to be -Wshadow-clean · 820c91a0
      Jim Meyering authored
      Summary:
      This is part of what's required to make mcrouter compile warning-free
      with gcc -Wshadow.  In case it's not obvious why this is worth doing,
      see t2719164.
      
      I've used two techniques:
      rename one of the shadowed variables
      bracket offending code with #pragma directives to disable the warning there.
      
      * folly/Bits.h (BitIterator): Guard this function with #pragma
      to avoid a warning about its member-shadowing "bitOffset" parameter.
      * folly/Memory.h (StlAllocator): Rename parameter in trivial, one-line
      function definition, s/alloc/a/, to avoid shadowing the member function.
      Let me know if you'd prefer #pragma directives instead.
      * folly/io/Cursor.h (pull,skip,clone): Rename parameter, s/length/len/,
      not to shadow the member function name.
      
      Test Plan:
      build and run tests of a few tools that use these headers
      
      Reviewed By: jon.coens@fb.com
      
      FB internal diff: D940493
      820c91a0
    • Tudor Bosman's avatar
      unbreak build · cf0e5923
      Tudor Bosman authored
      Test Plan: built producer_consumer_queue_test with gcc 4.7.1
      @override-unit-failures
      
      Reviewed By: chip@fb.com
      
      FB internal diff: D942465
      cf0e5923
    • Sara Golemon's avatar
      Use boost:has_trivial_destructor instead of std::... · 573d6149
      Sara Golemon authored
      Summary: Boost's version is 4.8 safe.  std's version changes name
      
      Test Plan: hhvm builds
      
      Reviewed By: andrei.alexandrescu@fb.com
      
      FB internal diff: D883508
      573d6149
    • Tudor Bosman's avatar
      std::map and std::set are not relocatable · 0950060f
      Tudor Bosman authored
      Summary: https://github.com/facebook/folly/issues/35
      
      @override-unit-failures
      hphp tests independently broken
      
      Test Plan: test added
      
      Reviewed By: delong.j@fb.com
      
      FB internal diff: D939323
      0950060f
    • Lucian Grijincu's avatar
      folly: improve Subprocess::enforce() error message · 01f69815
      Lucian Grijincu authored
      Summary: Previous implementation only printed the desired state, not the actual runtime state. Fix that.
      
      Test Plan: n/a
      
      Reviewed By: tudorb@fb.com
      
      FB internal diff: D936279
      01f69815
    • Philip Pronin's avatar
      make StringGen clang-compatible · 5ab723e5
      Philip Pronin authored
      Test Plan:
      fbconfig -r folly/test && fbmake opt -j32
      
      Reviewed By: tjackson@fb.com
      
      FB internal diff: D935182
      5ab723e5
    • Philip Pronin's avatar
      retry flock() if interrupted (EINTR) · 257ff9ff
      Philip Pronin authored
      Test Plan: fbconfig folly/test:file_test && fbmake runtests_opt
      
      Reviewed By: soren@fb.com
      
      FB internal diff: D932782
      257ff9ff
    • Tudor Bosman's avatar
      Fix overeager assertion · 07ed0a72
      Tudor Bosman authored
      Summary: Also important spelling mistakes.
      @override-unit-failures
      
      Test Plan: string_test
      
      Reviewed By: tjackson@fb.com
      
      FB internal diff: D930037
      07ed0a72
    • Tudor Bosman's avatar
      Add Varint-length-prefixed flavor of LZ4 · d71636e2
      Tudor Bosman authored
      Test Plan: test added
      
      Reviewed By: alandau@fb.com
      
      FB internal diff: D928836
      d71636e2
    • Tudor Bosman's avatar
      Varint in folly · 0558d398
      Tudor Bosman authored
      Test Plan: test added
      
      Reviewed By: alandau@fb.com
      
      FB internal diff: D928835
      0558d398
    • Jordan DeLong's avatar
      Fix a ThreadLocal bug: hold the meta lock when resizing the element vector · c55ca702
      Jordan DeLong authored
      Summary:
      There appears to be a race here.  leizha reported issues with
      a heavily recycled AtomicHashMap (ThreadCachedInt inside).  It looks
      like what's happening is this:
      
      - Thread A: ~ThreadCachedInt from an AHM
      - meta lock is taken, and the ThreadElement list is iterated
      - all entries are zerod, and the id is marked free
      - then releases the lock
      - Thread B: someone is calling get() on an unrelated id
      - hit reserve: rallocm on the pointer or unsynchronized memcpy from
      the element vector
      - waits on the lock
      - when it gets the lock, it stores back the value that it read that
      was zero'd by A.
      
      Later, someone reuses the id from the freelist, and reuses the
      previously freed pointer, and eventually double-freeing it.  (nullptr
      is the signifier for "this thread doesn't have an instance of the
      threadlocal yet").
      
      Test Plan:
      leizha's test case doesn't segv after this diff---it was
      reliably breaking with corruption in malloc before it.  I'm working on
      making that test case into a unit test to add to this diff, but I'm
      putting it up early in case there's something wrong with the theory
      above or in case someone has an idea for a better fix.
      
      Reviewed By: tudorb@fb.com
      
      FB internal diff: D928534
      c55ca702
    • Jim Meyering's avatar
      folly: attribute-aligned-arg must now be constant (not enum) · 21effa23
      Jim Meyering authored
      Summary:
      With gcc-4.8.[01], the argument to __attribute__((__aligned__(...)))
      must be a literal;  using an enum member evokes this:
      
      ./folly/MPMCQueue.h:341:63: error: requested alignment is not an \
      integer constant
      size_t capacity_ FOLLY_ON_NEXT_CACHE_LINE;
      
      Changing the enum member to this made no difference:
      
      static constexpr size_t kFalseSharingRange = 64;
      
      Test Plan: compile tao and run test suite
      
      Reviewed By: andrei.alexandrescu@fb.com
      
      FB internal diff: D926221
      
      @override-unit-failures
      21effa23
    • Andrew Gallagher's avatar
      folly/Conv.h: remove unused local typedef · 6d5d48ac
      Andrew Gallagher authored
      Test Plan: compiled using gcc-4.8
      
      Reviewed By: meyering@fb.com
      
      FB internal diff: D923895
      6d5d48ac
    • Jim Meyering's avatar
      folly: avoid use of has_trivial_destructor in FBVector.h · 7c94b139
      Jim Meyering authored
      Summary:
      This is required for gcc-4.8.x.
      Use boost::has_trivial_destructor, not std::has_trivial_destructor.
      The latter was never standard, and the now-std name (and the only one
      supported in gcc-4.8.0) is std::is_trivially_destructible.
      
      Test Plan:
      fbmake runtests and then
      run_unit_tests.sh with -r and again with -d
      
      Reviewed By: njormrod@fb.com
      
      FB internal diff: D923359
      
      @override-unit-failures
      7c94b139
    • Tudor Bosman's avatar
      IOBuf compression · 797870ec
      Tudor Bosman authored
      Summary: davejwatson: you asked
      
      Test Plan: test added
      
      Reviewed By: davejwatson@fb.com
      
      FB internal diff: D917336
      797870ec
    • Andrew Gallagher's avatar
      Revert "[clang support] removed superfluous declarations from header files" · fa664ed9
      Andrew Gallagher authored
      Summary: This reverts commit 49b197dfd02443e958906bac45059cea460e4e10.
      
      Test Plan: contbuild
      
      Reviewed By: akhilravidas@fb.com
      
      FB internal diff: D915386
      
      @override-unit-failures
      fa664ed9
    • Bob Haarman's avatar
      removed superfluous declarations from header files · c8cbdd5f
      Bob Haarman authored
      Summary:
      Clang doesn't like the same member of a class being defined more than once,
      or default argument values being defined more than once. This diff removes some
      instances.
      
      @override-unit-failures
      
      Test Plan: Compiled the code with Clang and GCC
      
      Reviewed By: andrewjcg@fb.com
      
      FB internal diff: D913226
      c8cbdd5f
    • Tom Jackson's avatar
      dereference · ca7e6f1b
      Tom Jackson authored
      Summary:
      For dealing with sequences of pointers. Works with pointer wrappers,
      and filters out nullptrs, see tests.
      
      Test Plan: Unit tests
      
      Reviewed By: tulloch@fb.com
      
      FB internal diff: D914069
      ca7e6f1b
    • Tom Jackson's avatar
      Fixing Until, Take · 52479853
      Tom Jackson authored
      Summary:
      `apply()` returns false if and only if the handler it was //directly//
      passed returned false. `Take` didn't do this right, and `Until` was just broken.
      
      Test Plan: More thorough unit tests.
      
      Reviewed By: kittipat@fb.com
      
      FB internal diff: D913185
      52479853
    • Philip Pronin's avatar
      make folly/Bits.h clang-compatible · d82103b8
      Philip Pronin authored
      Summary: In clang (as of 3.2) intrinsics aren't `constexpr`.
      
      Test Plan:
      fbconfig folly/test:bits_test && fbmake opt -j32
      fbconfig --clang folly/test:bits_test && fbmake opt -j32
      
      Reviewed By: lucian@fb.com
      
      FB internal diff: D910310
      d82103b8
    • Kittipat Virochsiri's avatar
      Batch · 634f30b5
      Kittipat Virochsiri authored
      Summary: Convert stream of elements to stream of fixed-sized vectors.
      
      Test Plan: unit tests
      
      Reviewed By: tjackson@fb.com
      
      FB internal diff: D912290
      634f30b5
    • Dave Watson's avatar
      Update build for Ubuntu 12.10. 12.04 seems to no longer compile · 5b065dbe
      Dave Watson authored
      Summary: Dave Watson put this in github a few months ago.
      
      Test Plan: None
      
      Reviewed By: delong.j@fb.com
      
      FB internal diff: D912681
      5b065dbe
    • Tudor Bosman's avatar
      Make ThreadLocalPtr behave sanely around fork() · 88ae9ac7
      Tudor Bosman authored
      Summary:
      Threads and fork still don't mix, but we shouldn't help you shoot yourself in
      the foot if you decide to do it.
      
      Test Plan: test added
      
      Reviewed By: mshneer@fb.com
      
      FB internal diff: D911224
      88ae9ac7
    • Tom Jackson's avatar
      Cycle · 206a0372
      Tom Jackson authored
      Summary: For repeating a generator's values endlessly.
      
      Test Plan: Unit tests
      
      Reviewed By: kittipat@fb.com
      
      FB internal diff: D911178
      206a0372
    • Andrew Tulloch's avatar
      Fix build break for Clang builds. · af705b32
      Andrew Tulloch authored
      Summary:
      Complains about
      
      ```
      In file included from crypto/lib/cpp/CryptoException.cpp:1:
      In file included from crypto/lib/cpp/CryptoException.h:5:
      In file included from ./folly/Conv.h:30:
      ./folly/Range.h:573:19: error: redefinition of default argument
      Comp eq = Comp()) {
      ^    ~~~~~~
      ./folly/Range.h:55:26: note: previous definition is here
      Comp eq = Comp());
      ^    ~~~~~~
      ```
      
      Redefinition of default arguments is not allowed in C++.
      
      Test Plan:
      ```
      fbconfig --clang admarket/adpublisher && fbmake dbg
      ```
      
      contbuild, etc.
      
      Reviewed By: lucian@fb.com
      
      FB internal diff: D910800
      af705b32
    • Josh Metzler's avatar
      Use std::equal<> as qfind default comparator · 9ada53a9
      Josh Metzler authored
      Summary:
      qfind(haystack, needle) is templated, but used a non-templated
      default comparator that cast everything to char.  This works find for
      8-bit types, but not for others such as the uint32_t Ranges we are
      using.  Replace the default comparator with std::equal<> to use a
      working comparator for whatever type is being searched.
      
      Test Plan:
      Compiles, unit tests (including a new one that fails with the
      old code) pass.  Not sure how to test other users of this, or measure
      performance impact. :(
      
      Reviewed By: andrei.alexandrescu@fb.com
      
      FB internal diff: D906311
      9ada53a9
    • Sean Cannella's avatar
      fix folly Range compilation on FreeBSD · b22d95e4
      Sean Cannella authored
      Summary: - memrchr is GNU + Linux specific, it turns out
      
      Test Plan: - compiled on FreeBSD, contbuild
      
      Reviewed By: delong.j@fb.com
      
      FB internal diff: D900935
      b22d95e4
    • Sean Cannella's avatar
      fix folly compilation on FreeBSD · ea2da05c
      Sean Cannella authored
      Summary:
      - fix folly compilation on FreeBSD
      
      Github Author: Martin Matuska <martin@matuska.org>
      
      Test Plan: - compiled
      
      Reviewed By: tudorb@fb.com
      
      FB internal diff: D896747
      ea2da05c
    • Tudor Bosman's avatar
      Multi-Producer, Multi-Consumer pipeline · 5f4c6672
      Tudor Bosman authored
      Summary:
      A bunch of MPMCQueues linked together. Stage i produces exactly Ki (default 1)
      outputs for each input. Ordering is preserved, even though stages might
      produce (intermediate or final) results in parallel and in any order; we do
      this by abusing the enqueueing mechanism in MPMCQueue. (Read the code for
      details)
      
      Test Plan: test added, more tests to be written before commit
      
      Reviewed By: ngbronson@fb.com
      
      FB internal diff: D892388
      5f4c6672
    • Nathan Bronson's avatar
      folly/MPMCQueue sizeGuess should return a signed int · ff1046b8
      Nathan Bronson authored
      Summary:
      Like size(), sizeGuess() is allowed to return a negative value,
      so it should be ssize_t instead of uint64_t.
      
      Test Plan: fbmake, wait for contbuild
      
      Reviewed By: tudorb@fb.com
      
      FB internal diff: D893075
      ff1046b8
  2. 18 Jul, 2013 8 commits
    • Hans Fugal's avatar
      folly/Hash.h add a test to ensure different hashes · 8035fc11
      Hans Fugal authored
      Summary:
      "Wouldn't this test case still pass if the hash function didn't depend on the value?
      
      It would be nice to verify that different tuple values produce different hash values (or maybe there's another test that verifies that), especially since this is a tricky thing to get right."
      
      I think there's not much chance of this failing since it's just leveraging hash_combine and that's already tested. But it's easy to add another sanity check, so here we are.
      
      Test Plan: runtests
      
      Reviewed By: tulloch@fb.com
      
      FB internal diff: D890448
      
      Blame Revision: D888796
      8035fc11
    • Hans Fugal's avatar
      tuple hashing · b71e31a5
      Hans Fugal authored
      Summary:
      Add hash support for std::tuple.
      See also D490478 (where a first attempt was made) and D543586 (where that attempt was deemed broken and removed).
      
      Test Plan: unit test
      
      Reviewed By: chip@fb.com
      
      FB internal diff: D888796
      b71e31a5
    • Sean Cannella's avatar
      OSX compat fixes · 982acaae
      Sean Cannella authored
      Summary:
      fix OSX compat issues
      
      Github Author: Daniel Sloof <goapsychadelic@gmail.com>
      
      Test Plan: - compiled
      
      Reviewed By: pt@fb.com
      
      FB internal diff: D877309
      982acaae
    • Chip Turner's avatar
      Add initializer_list support to folly::join · de064c41
      Chip Turner authored
      Summary:
      Apparently the templates don't like to match the initlializer
      list, so this needed to be added.  This allows for things like:
      
      auto s = join(":", {val1, val2, val3, val4, val4});
      
      Test Plan: run tests
      
      Reviewed By: andrei.alexandrescu@fb.com
      
      FB internal diff: D878032
      de064c41
    • Tom Jackson's avatar
      guard<Exception>() (redo) · b5a0a9f7
      Tom Jackson authored
      Summary:
      For handling exceptions from downstream operations.
      
      Now with cleaner build.
      
      Test Plan: Unit tests, including those outside `folly`.
      
      Reviewed By: marcelo.juchem@fb.com
      
      FB internal diff: D877795
      
      Blame Revision: https://phabricator.fb.com/D872581
      b5a0a9f7
    • Chip Turner's avatar
      Fix folly/FBString.h build error · acd305a3
      Chip Turner authored
      Summary:
      Looks like D880140 left off this part when it was committed.
      
      This fixes the build.
      
      Test Plan: runtests
      
      Reviewed By: vini@fb.com
      
      FB internal diff: D881445
      acd305a3
    • Andrei Alexandrescu's avatar
      Fix build breakage in hphp · 2302d45a
      Andrei Alexandrescu authored
      Summary:
      This should fix the build breakage in hphp caused by the latest fbstring changes (after being ported to engshare). Note that I'm flying blind here; I couldn't test with the hphp build because I don't have write access to engshare. @agallagher could you please make sure that this works after the fix?
      
      fbconfig -r hphp && fbmake dbg
      
      Test Plan: tested on folly
      
      Reviewed By: tudorb@fb.com
      
      FB internal diff: D880140
      2302d45a
    • Andrei Alexandrescu's avatar
      fbstring::shrink_to_fit · af1b0a8b
      Andrei Alexandrescu authored
      Summary: Adds the eponymous C++11 capability to fbstring.
      
      Test Plan: fbstring runtests
      
      Reviewed By: tudorb@fb.com
      
      FB internal diff: D867995
      af1b0a8b
  3. 09 Jul, 2013 1 commit
    • Tom Jackson's avatar
      Allowing trailing comma in folly::parseJson · ea72b037
      Tom Jackson authored
      Summary:
      Introduced a new serialization option, `allow_trailing_comma`, which allows trailing commas to be included in strings when they are parsed. This isn't strictly allowed by RFC 4627, but we're allowing more than that anyway.
      
      I've run into this dozens of times, especially while using SMC.
      
      Test Plan: Unit tests
      
      Reviewed By: delong.j@fb.com
      
      FB internal diff: D872581
      ea72b037