1. 20 May, 2014 5 commits
    • Elizabeth Smith's avatar
      msvc packed attribute translation · aafd8ff9
      Elizabeth Smith authored
      Summary:
      Provide translations for gcc packed
      
      MSVC has a very very ugly syntax for packing using pragmas which is very different from the gcc attribute
      this makes it very hard to macro around, but lots of ifdefs are also painful - cleanest of the hackery is to simply have push, pop, and attribute macros for packed that define properly depending on the compiler
      
      Test Plan: fbmake runtests
      
      Reviewed By: njormrod@fb.com
      
      FB internal diff: D1279966
      aafd8ff9
    • Andrii Grynenko's avatar
      Future API for CacheClientCommon · b7ccdf65
      Andrii Grynenko authored
      Summary:
      Allow mutable functors in Promise::fulfil.
      
      Facebook:
      Works both with EventBase and without it (thanks to wangle::Future thread-safety). CacheClientImpl lifetime is guaranteed using shared_ptr.
      
      Test Plan: unit test
      
      Reviewed By: stepan@fb.com
      
      FB internal diff: D1291024
      b7ccdf65
    • Adam Simpkins's avatar
      fix off-by-one error in IPAddress::longestCommonPrefix() · dea4e166
      Adam Simpkins authored
      Summary:
      Fix an off-by-one error causing an ASAN abort.  When calling
      longestCommonPrefix() with a full mask, it would compare one byte past
      the end of the address data, and would end up writing past the end of
      the ba array on the stack.
      
      Test Plan:
      Built with ASAN, ran the unit tests, and verified the ASAN failure was
      gone.
      
      Reviewed By: jasmeetbagga@fb.com
      
      FB internal diff: D1284750
      dea4e166
    • Anton Likhtarov's avatar
      Move common/network/IPAddress.h and related to folly/ · dced19f5
      Anton Likhtarov authored
      Summary:
      Moving our internal IP/Mac address libraries to folly/
      
      Facebook:
      We want to get rid of common/ dependencies in Mcrouter since we're going to open source it. Also looking at the original commit, seems like it's been the intention all along, so I just did it.
      
      I tried to keep dependencies intact as much as possible. Changing projects to use this directly should be in separate diffs.
      
      Test Plan:
      Run folly/network and common/network unit tests.
      
      Generate the list of targets with:
      
      ```
      fbgs /$FILE.h | cut -f1 -d: | xargs -L1 dirname | cut -f2- -d/ | sort | uniq
      ```
      
      Then fbconfig + fbmake. Will fix contbuild failures.
      
      Revert Plan:
      
      Reviewed By: simpkins@fb.com
      
      FB internal diff: D1261089
      dced19f5
    • Peter Griess's avatar
      Fix type mismatch in IOBuf::getIov() · fbdb6012
      Peter Griess authored
      Summary: - On iOS, iovec::iov_len is a size_t, which is a uint32_t; convert
      
      Test Plan:
      - fbconfig -r folly && fbmake runtests
      - Builds in fbobjc
      
      Reviewed By: simpkins@fb.com
      
      FB internal diff: D1284931
      fbdb6012
  2. 18 Apr, 2014 23 commits
    • Nicholas Ormrod's avatar
      Fix header ordering lint failures · b215baa2
      Nicholas Ormrod authored
      Summary:
      Headers whose includes are not sufficient cause problems when included
      from other files. An easy way to prevent this is to include the header
      first in its associated cpp file. In fact, we have a lint rule for this.
      However, there are places where this rule is ignored. This diff fixes
      many of them.
      
      Note that a few top-level directories were excluded.
      
      Reviewed By: robbert@fb.com
      
      FB internal diff: D1281032
      b215baa2
    • Elizabeth Smith's avatar
      x64 detection missing an include · b7433faa
      Elizabeth Smith authored
      Summary: rwspinlock.h was missing the portability.h header which made the x64 detection go wonky, but only shows up when used with isolated rwspinlock use
      
      Test Plan: fbmake runtests
      
      Reviewed By: andrei.alexandrescu@fb.com
      
      FB internal diff: D1284387
      
      Blame Revision: D1282140
      b7433faa
    • Elizabeth Smith's avatar
      macro for cross platform x64 detection · 779cbf35
      Elizabeth Smith authored
      Summary: Another cross platform fun macro - this one detects x64 status and requires some portability.h includes (which should only define portability stuff and not actually include anything)
      
      Test Plan: fbmake runtests
      
      Reviewed By: delong.j@fb.com
      
      FB internal diff: D1282140
      779cbf35
    • Bryan Alger's avatar
      Fix flag naming · d8662420
      Bryan Alger authored
      Summary: doh
      @override-unit-failures
      
      Test Plan: compiled under android
      
      Reviewed By: subodh@fb.com
      
      FB internal diff: D1283177
      d8662420
    • Elizabeth Smith's avatar
      fbstring likely/unlikley ifdef for stuff that doesn't support it · c9b41e27
      Elizabeth Smith authored
      Summary: the fbstring specific unlikely/likely defs were missing the ifdef blocks to avoid breaking things without builtin_expect
      
      Test Plan: fbmake runtests
      
      Reviewed By: njormrod@fb.com
      
      FB internal diff: D1282166
      c9b41e27
    • Hannes Roth's avatar
      (Folly/Gen) Make ranges and sequences take a stepping functor · 8cd97e5f
      Hannes Roth authored
      Summary:
      The functor allows to create ranges and sequences that advance the
      iterator by more than 1 per iteration.
      
      Test Plan: Unit test.
      
      Reviewed By: tjackson@fb.com
      
      FB internal diff: D1228065
      8cd97e5f
    • Hannes Roth's avatar
      (Folly/Gen) Fix compilation with clang · d456b584
      Hannes Roth authored
      Summary:
      Clang chokes because it tries to instantiate both versions of `from<const int*>`, one of which calls `std::begin(const int*)`, which doesn't work. By casting the intializer list to the right type, it can pick the overload.
      
      Clang, because it makes debugging these templates so much better.
      
      Test Plan: `fbconfig --clang folly/gen/test && fbmake runtests_dbg`
      
      Reviewed By: tjackson@fb.com
      
      FB internal diff: D1280888
      d456b584
    • Elizabeth Smith's avatar
      abstract thread_local support · ec06f66c
      Elizabeth Smith authored
      Summary:
      change from using __thread to using FOLLY_THREAD_LOCAL macro, this will allow abstraction over gcc and msvc implementations of thread local (__thread and __declspec(thread)) which have the same semantices and will also allow drop in replacement of thread_local when compiler support for the feature is complete  This doesn't do anything about apple, however, which still has broken __thread support
      
      This doesn't actually change any implementation for now, simply allows for correct compilation
      
      Test Plan: fbmake runtests
      
      Reviewed By: delong.j@fb.com
      
      FB internal diff: D1278726
      ec06f66c
    • Elizabeth Smith's avatar
      Add missing includes for msvc · f585e98a
      Elizabeth Smith authored
      Summary: MSVC is a stricter compiler and needs additional includes explicitly declared
      
      Test Plan: fbmake runtests
      
      Reviewed By: njormrod@fb.com
      
      FB internal diff: D1277004
      f585e98a
    • Tom Jackson's avatar
      parallel(pipeline) · d3cc50e0
      Tom Jackson authored
      Summary:
      Adding `... | parallel(my | pipe | line) | ...` for parallelizing a portion of a generator pipeline.
      
      ```lang=cpp
      auto factored = from(values)
      | parallel(filter(isEven) | map(square) | sub(count))
      | sum;
      ```
      
      Work is divided evenly among a fixed number of threads using a `MPMCQueue`.
      
      Test Plan: Unit tests and benchmarks testing for a variety of workloads and performance characteristics, including sub-linear (blocking) workloads, linear (mostly math) workloads, and superlinear (sleeping) workloads to simulate real-world use.
      
      Reviewed By: lucian@fb.com
      
      FB internal diff: D638551
      d3cc50e0
    • Marc Celani's avatar
      Introduce LifoSem · 7fbec719
      Marc Celani authored
      Summary: A LIFO semaphore is useful for building a thread pool because we can keep cpu caches warmer by continually reusing the last used thread. This diff introduces a LIFO semaphore to folly.
      
      Test Plan: unit tests
      
      Reviewed By: davejwatson@fb.com
      
      FB internal diff: D1280405
      7fbec719
    • Jun LI's avatar
      Fix folly Uri::host() return value for IPv6 address · 59c7c8ea
      Jun LI authored
      Summary: folly Uri::host() returns leading and trailing brackets for IPv6 host, for example, for URI "http:://[::1]:8080/index.html", host() method returns "[::1]". But square brackets are not part of host in fact, this diff is going to remove brackets for IPv6 host.
      
      Test Plan: fbconfig -r folly/test && fbmake runtests_dbg
      
      Reviewed By: chip@fb.com
      
      FB internal diff: D1276513
      59c7c8ea
    • Elizabeth Smith's avatar
      MSVC translation of noreturn attribute · 934a0b06
      Elizabeth Smith authored
      Summary:
      Provide translations for gcc noreturn attribute
      
      __attribute__((noreturn)) is gcc specific, clang understands it on nix systems, but for msvc __declspec(noreturn) is the compiler specific version, which clang will imitate/use on windows.  There was already a FOLLY_NORETURN in portability.h, however because of __declspec limitations it must prefix the declaration, not postfix.  The gcc noreturn attribute does not have this limitation and will work prefixed OR postfixed, so to keep from turning code into spaghetti nonsense, the macro was moved to the front of declations where it is currently used.  This will allow it to work with the proper definitions on clang, clang on windows, gcc, and msvc
      
      Test Plan: fbmake runtests
      
      Reviewed By: delong.j@fb.com
      
      FB internal diff: D1279466
      934a0b06
    • Elizabeth Smith's avatar
      MSVC always_inline and noinline __attributes__ translation · 2c2e0f6e
      Elizabeth Smith authored
      Summary:
      Provide translations for gcc always_inline and noinline attribute
      
      Change to using a macro from portability.h for attributes for using always_inline and noinline for cross platform support
      
      Test Plan: fbmake runtests
      
      Reviewed By: delong.j@fb.com
      
      FB internal diff: D1279652
      2c2e0f6e
    • Victor Loh's avatar
      Use StringPiece instead of String · 30a71566
      Victor Loh authored
      Summary:
      Using StringPiece makes it easier than std::string
      
      Facebook: Motivation for this diff is found in D1253595
      
      Test Plan:
      Added new unittest
      
      fbconfig folly/io/test && fbmake runtests_opt
      
      Reviewed By: simpkins@fb.com
      
      FB internal diff: D1276185
      30a71566
    • Elizabeth Smith's avatar
      uint isn't portable and makes some compilers angry, change to unsigned int · 32d518c3
      Elizabeth Smith authored
      Summary: As part of the windows port, uint is not defined as a type and is not standard, it makes msvc choke, a simple change to unsigned int fixes the issue
      
      Test Plan: fbmake runtests
      
      Reviewed By: delong.j@fb.com
      
      FB internal diff: D1278487
      32d518c3
    • Tudor Bosman's avatar
      Add non-const operator[] to TypedIOBuf · 0c8631dc
      Tudor Bosman authored
      Test Plan: used it
      
      Reviewed By: lucian@fb.com
      
      FB internal diff: D1277063
      
      @override-unit-failures
      0c8631dc
    • Lucian Grijincu's avatar
      folly: improve ProducerConsumerQueueBenchmark (misplaced doNotOptimizeAway) · e39dfd9d
      Lucian Grijincu authored
      Summary:
      as per discussion from https://phabricator.fb.com/D1274352
      
      After changing the queue length to be a small value (100) I didn't see
      improvement from cache alignment of atomics (too much noise). Dropping
      that and just fixing the benchmark.
      
      Test Plan: n/a
      
      Reviewed By: ngbronson@fb.com
      
      FB internal diff: D1276591
      e39dfd9d
    • Nicholas Ormrod's avatar
      Fix apparent race in SubprocessTest · 1321eef0
      Nicholas Ormrod authored
      Summary:
      The code originally contained the line
      
      EXPECT_EQ((rcount == lineCount), r); // EOF iff at lineCount
      
      Which asserted that, on the last iteration, EOF was being read (and thus
      r was true).
      
      This line has been causing errors in contbuild. There seem to be two
      issues at play.
      
      First, the left hand side of the EXPECT_EQ is always false. rcount is
      incremented three lines down, and the (implicit) loop ends when rcount
      equals lineCount. This means that, on the last iteration, rcount is
      actually one less than lineCount. Hence the check is effectively
      asserting that r is false.
      
      The second issue is that r is rarely true. Empirically, a necessary but
      not sufficient condition is that there be lots of other processes
      running at the same time (such as when running fbconfig -r folly &&
      fbmake runtests_opt). This would explain why the test passes during
      development but fails in contbuild.
      
      I am guessing that, when there are few processes running, Subprocess is
      predictably ceasing to read before whichever other process yields EOF,
      and that this does not always happen when there is resource contention.
      
      As an immediate fix, I am asserting that r may only be true on the last
      iteration. Could someone (cc @tudorb) who is more familiar with the
      intricacies of Subprocess please check to see if this is an idiosyncrasy
      of the test, or if there is actually an underlying bug.
      
      Test Plan:
      Before the change, run fbconfig -r folly && fbmake runtests_opt
      repeatedly. Notice that most of the iterations yield an error from line
      376 (which is consistent with contbuild error logs).
      
      After the change, notice that the error disappears.
      
      Reviewed By: andrewjcg@fb.com
      
      FB internal diff: D1269124
      1321eef0
    • Lucian Grijincu's avatar
      folly: gen: pmap: parallel version of map · 89c3562e
      Lucian Grijincu authored
      Summary:
      same as map, but runs it's argument in parallel over a number of threads.
      
      @override-unit-failures
      
      Test Plan: added test
      
      Reviewed By: tjackson@fb.com
      
      FB internal diff: D1258364
      89c3562e
    • Alexey Spiridonov's avatar
      Change child's working directory · 188e13f3
      Alexey Spiridonov authored
      Summary: Changing the parent's WD is prone to race conditions of various sorts, and needlessly alters parent state. Python's subprocess also has this feature.
      
      Test Plan: fbmake dbg _bin/folly/test/subprocess_test ; ../_bin/folly/test/subprocess_test
      
      Reviewed By: agoder@fb.com
      
      FB internal diff: D1269526
      188e13f3
    • Jim Meyering's avatar
      folly: allow to build with clang.dev (flex arrays vs. lambda) · a6e257a5
      Jim Meyering authored
      Summary:
      * folly/test/CacheLocalityTest.cpp (contentionAtWidth): Work around
      clang's prohibition against using flexible arrays in a lambda.
      
      Test Plan:
      fbconfig --clang --with-project-version clang:dev folly/test \
      && fbmake runtests
      
      Reviewed By: ngbronson@fb.com
      
      FB internal diff: D1263620
      a6e257a5
    • Philip Pronin's avatar
      configurable alignment for Arena · 970c7961
      Philip Pronin authored
      Summary: Allow specifying custom alignment.
      
      Test Plan: fbconfig -r folly/test && fbmake opt -j32
      
      @override-unit-failures
      
      Reviewed By: lucian@fb.com
      
      FB internal diff: D1264851
      970c7961
  3. 09 Apr, 2014 11 commits
    • ptarjan's avatar
      Make header compatible with warp · 074bdb7f
      ptarjan authored
      074bdb7f
    • Philip Pronin's avatar
      fix ConcurrentSkipList::Recycler layout · d92b1b90
      Philip Pronin authored
      Summary:
      D1261546 introduced regression in `sizeof(ConcurrentSkipList)`.
      In case of `NodeAlloc = folly::SysAlloc`, size of an empty `NodeAlloc` struct
      is 1 byte, due to the alignment requirements of the next field, it got
      translated into wasting 8 bytes.
      
      Test Plan: fbconfig -r folly/test && fbmake opt -j32
      
      @override-unit-failures
      
      Reviewed By: lucian@fb.com
      
      FB internal diff: D1264730
      d92b1b90
    • Jim Meyering's avatar
      folly: accommodate fact that clang's strlen is not constexpr · bfdcbc20
      Jim Meyering authored
      Summary:
      * folly/folly-config.h (FOLLY_HAVE_CONSTEXPR_STRLEN): Define to
      zero when compiling with clang, since clang's strlen is not constexpr.
      
      Test Plan:
      Run this:
      fbconfig --clang --with-project-version clang:dev folly/test && fbconfig dbg
      and observe that the following no longer strikes:
      folly/test/RangeTest.cpp:304:25: error: constexpr variable 'hello1' must be initialized by a constant expression
      
      I also tried using clang-3.4 (the current default),
      fbconfig --clang folly/test && fbmake dbg
      with these results:
      https://phabricator.fb.com/P8583443
      
      Reviewed By: pgriess@fb.com
      
      FB internal diff: D1262840
      bfdcbc20
    • Dave Watson's avatar
      Fix make check · 8e82fd34
      Dave Watson authored
      Summary: Fix make check.  Benchmark.cpp was included twice, eventfd doesn't exist anymore.
      
      Test Plan: autoreconf -i; ./configure; make check on ubuntu
      
      Reviewed By: pgriess@fb.com
      
      FB internal diff: D1259706
      8e82fd34
    • Dave Watson's avatar
      fix automake · d666fcdb
      Dave Watson authored
      Summary:
      Automake complains there are two Malloc.cpp rules - rename one of them.
      
      Facebook: Actually this file doesn't even build in fbconfig - is it still necessary?
      
      Test Plan: autoreconf -i on ubuntu doens't fail
      
      Reviewed By: pgriess@fb.com
      
      FB internal diff: D1257372
      d666fcdb
    • Hans Fugal's avatar
      (wangle) codegen then() variant tests · 64d0f9a3
      Hans Fugal authored
      Summary:
      When all the variants I am dreaming of work, there's a little more than
      100 tests generated.
      
      Test Plan: fbmake runtests
      
      Reviewed By: hannesr@fb.com
      
      FB internal diff: D1258754
      64d0f9a3
    • Hannes Roth's avatar
      (Folly/FBString) Fix compilation time of test with opt · a71d861b
      Hannes Roth authored
      Summary: Now compiles in 18 seconds. Took two minutes before.
      
      Test Plan: `fbmake runtests_opt`
      
      Reviewed By: smith@fb.com
      
      FB internal diff: D1243689
      a71d861b
    • Philip Pronin's avatar
      configurable node allocator for ConcurrentSkipList · ac2aa280
      Philip Pronin authored
      Summary:
      Allow specifying `SimpleAllocator` to use for node allocation.
      Added optimizations for arena allocators.
      
      Test Plan: fbconfig -r folly/test && fbmake opt -j32
      
      Reviewed By: soren@fb.com
      
      FB internal diff: D1261546
      ac2aa280
    • Philip Pronin's avatar
      make ConcurrentSkipList ctor public · 0fd4f579
      Philip Pronin authored
      Summary:
      There is no reason to force heap allocation for
      `ConcurrentSkipList`.
      
      Test Plan: fbconfig -r unicorn/test && fbmake opt -j32
      
      @override-unit-failures
      
      Reviewed By: lucian@fb.com
      
      FB internal diff: D1261183
      0fd4f579
    • Tom Jackson's avatar
      Adding support for signed integers · ff03c3a8
      Tom Jackson authored
      Summary: For use with Thrift::Frozen, especially.
      
      Test Plan: Unit tests
      
      Reviewed By: philipp@fb.com
      
      FB internal diff: D1255257
      ff03c3a8
    • Nicholas Ormrod's avatar
      Bugfix in iterator emplace · 14e2c0f8
      Nicholas Ormrod authored
      Summary:
      Subtle bugfix to fbvector
      
      Reproduction requirements:
      - emplace into a vector at a non-end position
      - the vector has enough capacity for the extra elements
      - the value type's internal state is poisoned after a move
      
      What should happen, explained by picture:
      
      INITIAL SETUP
      
      abc1234XY____
      ^
      want to insert two elements here
      
      FIRST STEP: uninitialized move-construction
      x and y are initialized, but could be in an invalid state
      
      abc1234xyXY__
      
      SECOND STEP: move-assignment, in reverse order
      
      abc123xy4XY__
      abc12xy34XY__
      abc1xy234XY__
      abcxy1234XY__
      
      What actually happens:
      An indexing error causes the entire tail (##1234xy##) to be
      move-assigned, instead of the intended head of the tail (##1234##).
      
      If the data type's move operator does not invalidate its own data (i.e.
      move is essentially a copy, as is the case with atomic types) then the
      move assignment of ##y## onto ##Y## and ##x## onto ##X## is basically a
      no-op. However, for types that do invalidate their own data when being
      the source of a move (e.g. non-empty vectors and fbvectors), then the
      end result will have bad data in place of ##X## and ##Y##.
      
      Detection:
      This bug has lain dormant for a while.
      
      Very few people emplace into a vector, and those few who do could be
      saved by using a copy-movable type like int.
      
      The original test case did not use a data type which poisoned itself
      after being the source of a move, so the tests did not notice any
      oddities.
      
      A new testsuite, which does poison itself, did notice.
      
      Test Plan:
      re-enable the test/stl_test mega-test. Run it. All tests
      pass.
      
      fbconfig -r folly && fbmake runtests_opt
      
      Run fbvector through the new test suite (which initially caught the
      error). It now passes.
      
      Reviewed By: robbert@fb.com
      
      FB internal diff: D1257258
      14e2c0f8
  4. 04 Apr, 2014 1 commit
    • Hans Fugal's avatar
      A few missing includes · fbee7f6b
      Hans Fugal authored
      Summary: These were required to build folly on OSX.
      
      Test Plan: build
      
      Reviewed By: davejwatson@fb.com
      
      FB internal diff: D1256856
      fbee7f6b