1. 14 Jul, 2014 5 commits
    • Elizabeth Smith's avatar
      Small changes for cygwin build · 0e2b9093
      Elizabeth Smith authored
      Summary:
      Folly is almost "out of the box" working with cygwin
      
      This has the proper ifdefs to include cygwin in two areas and a workaround for a cygwin bug when including headers
      
      Test Plan: fbconfig -r folly && fbmake runtests
      
      Reviewed By: delong.j@fb.com
      
      FB internal diff: D1413303
      0e2b9093
    • Elizabeth Smith's avatar
      MSVC includes for inet/sockets · a303e3e4
      Elizabeth Smith authored
      Summary:
      MSVC has all the sockets and internet functionality required except for one missing item - which can safely be defined to a windows specific type
      But it requires a different set of headers than on *nix systems
      
      Test Plan: fbconfig -r folly && fbmake runtests
      
      Reviewed By: delong.j@fb.com
      
      FB internal diff: D1413265
      a303e3e4
    • Elizabeth Smith's avatar
      MSVC intrinsics for bits and cpuid · 5ed20b59
      Elizabeth Smith authored
      Summary: Use msvc intrinsics for cpuid, popcount, byteswap, and bit scan functionality
      
      Test Plan: fbconfig -r folly && fbmake runtests
      
      Reviewed By: delong.j@fb.com
      
      FB internal diff: D1413254
      5ed20b59
    • Elizabeth Smith's avatar
      Expression SFINAE issue in base.h · 1f1ba906
      Elizabeth Smith authored
      Summary:
      MSVC 14 is still broken with expression sfinae - and the things that break are often strange
      Moving this out into two expr templates solves the compilation issue
      
      Test Plan: fbconfig -r folly && fbmake runtests
      
      Reviewed By: tjackson@fb.com
      
      FB internal diff: D1413297
      1f1ba906
    • Wez Furlong's avatar
      use recursive_mutex to protect State · d7f1adb6
      Wez Furlong authored
      Summary:
      maelstrom destructs a Promise during an indirect call from
      maybeCallback and deadlocks on itself unless we use a recursive mutex.
      
      There may be a smarter way to proceed but at the moment I can't build
      and deploy a package from trunk because the service is non-functional
      :-/
      
      Test Plan:
      run
      
      ```
      fbconfig -r folly/wangle messaging/maelstrom
      fbmake runtests
      ```
      
      Reviewed By: hannesr@fb.com
      
      Subscribers: fugalh, fsilva
      
      FB internal diff: D1428504
      d7f1adb6
  2. 09 Jul, 2014 10 commits
    • Tudor Bosman's avatar
      Remove unnecessary and broken hash specializations · df377ed2
      Tudor Bosman authored
      Summary:
      No need to specialize std::hash for std::basic_string; the STL already does
      this. Plus, the specializations were broken in multiple ways:
      
      1. std::hash does not treat const char* specially, so it just hashes the
      pointer value (contrasting the old __gnu_cxx::hash, which hashed a C-string)
      
      2. Either way, using __gnu_cxx::hash<const char*> for std::string is broken,
      as it won't hash anything past the first null byte.
      
      Also, make sure fbstring gets the same (full) specializations as std::string
      does in the standard.
      
      Test Plan: fbconfig -r folly && fbmake runtests_opt, also tests in tupperware/agent which is still using __gnu_cxx::hash_map with string keys.
      
      Reviewed By: pgriess@fb.com, andrei.alexandrescu@fb.com
      
      Subscribers: njormrod, jhj, kma, lesha
      
      FB internal diff: D1426479
      df377ed2
    • Gunjan Sharma's avatar
      Fix race in Notification Queue · ed684e76
      Gunjan Sharma authored
      Summary: When we are changing value of numActiveConsumers_ with setActive from handlerReady at the SCOPE_EXIT we have a race with reading of the same variable in putMessageImpl.
      
      Test Plan: Had a local race which works fine now.
      
      Reviewed By: davejwatson@fb.com
      
      Subscribers: trunkagent
      
      FB internal diff: D1424674
      ed684e76
    • Tudor Bosman's avatar
      Simplify pipe2 / O_CLOEXEC handling in Subprocess.cpp · fca9fccb
      Tudor Bosman authored
      Summary: per @rockyliu's suggestions
      
      Test Plan: subprocess_test
      
      Reviewed By: rockyliu4@fb.com
      
      Subscribers: rockyliu, jhj, lesha, kma
      
      FB internal diff: D1423157
      fca9fccb
    • Paul Tarjan's avatar
      Revert "make `folly::Formatter` extendible" · 2c378ec8
      Paul Tarjan authored
      Summary:
      This reverts commit 5ea0eb0c705224b82a5c284dc5f7722e1f71199f.
      
      This breaks the HHVM clang build test.
      
      Test Plan: clang will pass now
      
      Reviewed By: smith@fb.com
      
      Subscribers: dmitrys
      
      FB internal diff: D1426399
      
      Tasks: 4667712
      2c378ec8
    • Tyler MacDonald's avatar
      make `folly::Formatter` extendible · 664e121a
      Tyler MacDonald authored
      Summary:
      on advice of @tudorb, move most of `folly::Formatter` into `folly::BaseFormatter` so that we can use compile-time polymorphism to provide different types of Formatters.
      
      I wasn't able to get the recursive formatter to be polymorphic -- whenever I tried to convert `class FormatValue<Formatter<containerMode, Args...>, void>` into `class FormatValue<BaseFormatter...`, `FormatTest.cpp:Test(Format, Nested)` wouldn't compile because it couldn't find the template. @tudorb, if you have an easy fix for this, lmk, otherwise I'm (reluctantly) okay with requiring that `Formatter`s define their own nesting `FormatValue`.
      
      phew. the last time I did this sort of metaprogramming was over 5 years ago in perl. Doing it in C++ is... interesting.
      
      Test Plan: `fbconfig -r thrift folly cold_storage && fbmake dbg && fbmake runtests`
      
      Reviewed By: tudorb@fb.com
      
      Subscribers: tudorb, dgp
      
      FB internal diff: D1422343
      
      Tasks: 4624268
      664e121a
    • Tudor Bosman's avatar
      Fix libc++ build errors · eaed5551
      Tudor Bosman authored
      Summary:
      Reported externally:
      
      https://github.com/facebook/folly/issues/70
      https://github.com/facebook/folly/issues/71
      https://github.com/facebook/folly/issues/72
      https://github.com/facebook/folly/issues/73
      
      Note that I can't test on libc++ myself, but the reports suggested fixes which
      sounded good.
      
      Test Plan: fbconfig -r folly && fbmake runtests_opt
      
      Reviewed By: marcelo.juchem@fb.com
      
      Subscribers: jhj, ntv, lesha, kma, fugalh, jdelong
      
      FB internal diff: D1421029
      eaed5551
    • Tudor Bosman's avatar
      Use pipe2 in Subprocess; platform-specific config · 217e88e6
      Tudor Bosman authored
      Summary:
      We've wanted to use pipe2 in Subprocess for a while, but that's not supported
      on glibc 2.5.1. This is not a problem in OSS (autoconf can solve this),
      but, internally, we don't run autoconf; add an internal platform include file
      with such per-platform differences.
      
      Test Plan: fbconfig -r folly && fbmake runtests_opt
      
      Reviewed By: meyering@fb.com
      
      Subscribers: jhj, lesha, kma, agallagher
      
      FB internal diff: D1422128
      217e88e6
    • Tom Jackson's avatar
      stride() · 2015ae71
      Tom Jackson authored
      Summary: thatwaseasy
      
      Test Plan: iloveunittests
      
      Reviewed By: lucian@fb.com
      
      Subscribers: philipp
      
      FB internal diff: D1419848
      
      Tasks: 4636617
      2015ae71
    • Brian Pane's avatar
      Move the branchless, parallel ASCII toLower into folly · db66e2f4
      Brian Pane authored
      Summary:
      * Moved the fast toLower code into folly
      * Updated the name to emphasize that it's ASCII-only
      
      Test Plan: * Unit tests and benchmarks included.
      
      Reviewed By: tudorb@fb.com
      
      Subscribers: ruibalp, bmatheny
      
      FB internal diff: D1421056
      db66e2f4
    • Hans Fugal's avatar
      (wangle) fix shadow · a0d5122f
      Hans Fugal authored
      Summary: Not sure why this shadow error didn't turn up in my tests, but whatevs
      
      Test Plan: traffic manager builds without warning-errors
      
      Reviewed By: suhas@fb.com
      
      Subscribers: hannesr, net-systems@, fugalh, exa
      
      FB internal diff: D1421495
      
      Tasks: 4653938
      a0d5122f
  3. 07 Jul, 2014 10 commits
    • Tudor Bosman's avatar
      fix Makefile.am · 3454265d
      Tudor Bosman authored
      Summary: wangle/detail.h -> wangle/detail/State.h
      
      Test Plan: OSS build
      
      Reviewed By: meyering@fb.com
      
      Subscribers: fugalh, lesha
      
      FB internal diff: D1421490
      3454265d
    • Tudor Bosman's avatar
      gflags now likes namespace gflags, not google · f6a8fe63
      Tudor Bosman authored
      Summary:
      Use namespace gflags going forward, import namespace google into it if
      backward.
      
      Also added a few "checking for..." messages in autoconf.
      
      Test Plan: fbconfig -r folly && fbmake runtests_opt, OSS build
      
      Reviewed By: meyering@fb.com
      
      Subscribers: fjargsto, ntv, jhj, lesha, kma, davejwatson
      
      FB internal diff: D1420575
      f6a8fe63
    • Hans Fugal's avatar
      (wangle) cold via · 73e3273b
      Hans Fugal authored
      Summary:
      Instead of returning a Later, `via` returns a cold future.
      This works without keeping a backreference like Later does, because an inactive Future will always activate on destruction. Alternatively we could have an extra Promise, a la Later, and pass that along like Later does, and require launch() at the end (though, implicit launching on destruction would be an option there too).
      
      If you think this approach is viable I'll clean it up on Wednesday: make sure all the calling sites work, etc.
      
      Test Plan:
      new unit test
      This may fail in contbuild, I haven't done the codemod for calling sites, if there are any.
      
      Reviewed By: hannesr@fb.com
      
      Subscribers: jsedgwick, net-systems@, fugalh, exa
      
      FB internal diff: D1412499
      
      Tasks: 4480567
      73e3273b
    • Hans Fugal's avatar
      (wangle) Future/Promise detachment · 03f41278
      Hans Fugal authored
      Summary:
      Bring a bit more sanity to the lifetime. Now Future and Promise detach by calling the respective methods on State, and they do it during their destruction only. State manages its own lifetime.
      
      Besides being cleaner, this also sets the stage for cancellation (where we'll need Future to hang on to its reference to State after setting the callback), and for folding in Later (we will have a bool for whether the future is hot and hold off executing the callback if it isn't).
      
      Also cleans up various things I noticed while auditing the code for usages of `state_`.
      
      Test Plan:
      All the unit tests still pass.
      Ran with ASAN (and found I had introduced a bug, then fixed it. yay)
      
      Reviewed By: hannesr@fb.com
      
      Subscribers: jsedgwick, net-systems@, fugalh, exa
      
      FB internal diff: D1412038
      
      Tasks: 4618297
      03f41278
    • Hannes Roth's avatar
      (Folly/FBString) Enum class for category · 7609a2fb
      Hannes Roth authored
      Summary: Suggested by @aalexandre.
      
      Test Plan: Compile.
      
      Reviewed By: andrei.alexandrescu@fb.com
      
      Subscribers: folly@lists, njormrod, aalexandre
      
      FB internal diff: D1246180
      7609a2fb
    • Lucian Grijincu's avatar
      folly: StringPiece: add skipWhitespace · 38fb7acd
      Lucian Grijincu authored
      Test Plan: copied from folly::json
      
      Reviewed By: philipp@fb.com, soren@fb.com
      
      FB internal diff: D1417992
      
      Tasks: 4527315
      38fb7acd
    • Hans Fugal's avatar
      s/setCallback_/setCallback/ for detail::State · 368266c3
      Hans Fugal authored
      Summary: This isn't really an internal-to-this-class method. :-/
      
      Test Plan: builds
      
      Reviewed By: hannesr@fb.com
      
      Subscribers: jsedgwick, net-systems@, fugalh, exa
      
      FB internal diff: D1412008
      368266c3
    • Hans Fugal's avatar
      (wangle) s/continuation_/callback/ (missed some) · 82ab3bae
      Hans Fugal authored
      Summary: In the spirit of D1406753
      
      Test Plan: still builds and tests pass
      
      Reviewed By: hannesr@fb.com
      
      Subscribers: jsedgwick, net-systems@, fugalh, exa
      
      FB internal diff: D1412002
      82ab3bae
    • Hans Fugal's avatar
      (wangle) s/FutureObject/detail::State/ · 1d42dc0b
      Hans Fugal authored
      Summary:
      codemod
      I never was satisfied with this name. `State` feels a little better. More descriptive. But still pretty generic, so I'm open to alternative ideas.
      
      Test Plan: It still builds and tests pass.
      
      Reviewed By: hannesr@fb.com
      
      Subscribers: jsedgwick, net-systems@, fugalh, exa
      
      FB internal diff: D1411506
      1d42dc0b
    • Kevin Chou's avatar
      Fix string split when last part is shorter than delimiter · 02a9ec75
      Kevin Chou authored
      Summary: The bug is when ignoreEmpty is true, we use the wrong token size, which will be 0 when last token is shorter than delimiter.
      
      Test Plan:
      1. Add unit test
      2. fbconfig -r folly && fbmake runtests
      
      Reviewed By: philipp@fb.com
      
      Subscribers: maxime, xiaol
      
      FB internal diff: D1415803
      02a9ec75
  4. 02 Jul, 2014 1 commit
  5. 01 Jul, 2014 4 commits
    • Dave Watson's avatar
      update make check targets · d175e4ac
      Dave Watson authored
      Summary:
      Update targets so that gtest isn't required unless you run 'make check'.
      
      Simply make everything that uses gtest a 'check_PROGRAM' instead of a 'noinst_PROGRAM'
      
      Test Plan: build folly with 'make -j32', gtest isn't required.
      
      Reviewed By: andrewjcg@fb.com
      
      Subscribers: pavlo, doug
      
      FB internal diff: D1408288
      d175e4ac
    • Tudor Bosman's avatar
      Simplify include path, make sure .. is in it · 4bfe9433
      Tudor Bosman authored
      Summary: so #include <folly/File.h> works
      
      Test Plan: built OSS folly, make check, built tiny program out of tree
      
      Reviewed By: davejwatson@fb.com
      
      FB internal diff: D1412123
      4bfe9433
    • Tudor Bosman's avatar
      Codemod: use #include angle brackets in folly and thrift · ce64f0f6
      Tudor Bosman authored
      Summary: Also changed the thrift compilers to emit code with <...>.
      
      Test Plan: fbconfig -r folly thrift && fbmake opt && fbmake runtests_opt
      
      Reviewed By: davejwatson@fb.com
      
      Subscribers: ruibalp, nli, shilin, tjackson, fugalh, alandau, bmatheny, njormrod
      
      FB internal diff: D1411225
      ce64f0f6
    • Philip Pronin's avatar
      fix AsyncIO::doWait · c6bdae86
      Philip Pronin authored
      Summary:
      As it turns out, `io_getevents` may actually return less than
      `min_nr` events.  According to the aio logic
      (https://github.com/torvalds/linux/blob/10b5b5361a3c2a7fff9dbfa0f127adc2531e7732/fs/aio.c#L1634),
      there may be a couple of rounds required to get at least `nr_min` events, and
      if interrupted after the first one, incomplete results would be returned
      
      Test Plan:
      fbconfig -r folly/experimental/io/test && fbmake runtests_opt -32
      
      and was no longer able to repro #4609062
      
      Reviewed By: soren@fb.com
      
      FB internal diff: D1410389
      
      Tasks: 4609062
      c6bdae86
  6. 27 Jun, 2014 10 commits
    • Joel Marcey's avatar
      Be explicit about what we're passing to Endian::big · 09a81a96
      Joel Marcey authored
      Summary:
      This prevents a linker error on OSX:
      ```
      Undefined symbols for architecture x86_64:
      "folly::detail::EndianIntBase::swap(unsigned long)",
      referenced from:
      __GLOBAL__sub_I_MacAddress.cpp in libfolly.a(MacAddress.cpp.o)
      ld: symbol(s) not found for architecture x86_64
      ```
      
      We need folly and third-party changes in order to land a pull request for HHVM
      that starts to get FastCGI running on OSX.
      
      See the checklist of the HHVM pull request here: https://github.com/facebook/hhvm/pull/2944#issuecomment-47281003
      
      Closes #68
      
      GitHub Author: Daniel Sloof <goapsychadelic@gmail.com>
      
      @override-unit-failures
      
      Test Plan: fbmake runtests 100%
      
      Reviewed By: pt@fb.com, njormrod@fb.com
      
      FB internal diff: D1407426
      09a81a96
    • Joel Marcey's avatar
      Fix folly on OSX and BSD in prep for FastCGI on HHVM · 75f93a66
      Joel Marcey authored
      Summary:
      A recent change in folly/MemoryMapping.cpp uses MAP_ANONYMOUS, which is
      named MAP_ANON on OSX/BSD.
      
      We need folly and third-party changes in order to land a pull request for HHVM
      that starts to get FastCGI running on OSX.
      
      See the checklist of the HHVM pull request here: https://github.com/facebook/hhvm/pull/2944#issuecomment-47281003
      
      Closes #67
      
      GitHub Author: Daniel Sloof <goapsychadelic@gmail.com>
      
      @override-unit-failures
      
      Test Plan: fbmake runtests 100%
      
      Reviewed By: pt@fb.com, njormrod@fb.com
      
      FB internal diff: D1407393
      75f93a66
    • Hans Fugal's avatar
      (wangle) Return a Later from Future::via · a181fa04
      Hans Fugal authored
      Summary: Stroke of brilliance, Hannes.
      
      Test Plan:
      unit tests, including a new one
      Looked through `fbgs 'via('` and all the extant `via`s are attached to `Later`s already so it shouldn't break anything. But check contbuild before commit.
      
      Reviewed By: hannesr@fb.com
      
      Subscribers: net-systems@, fugalh, exa
      
      FB internal diff: D1406976
      
      Tasks: 4480567
      a181fa04
    • Jim Meyering's avatar
      folly: futexWaitUntilImpl: avoid abort triggered via tao/queues tests · b27ed0f6
      Jim Meyering authored
      Summary:
      * folly/test/DeterministicSchedule.cpp (folly): Tao/queues tests exposed
      an unhandled case in this code: when (futex->data == expected) happens,
      we would call futexErrnoToFutexResult with a futexErrno value of 0,
      which would cause an abort (unhandled valued in switch).
      Here's a stack trace from the abort: https://phabricator.fb.com/P12558008
      showing the invalid futexErrno value in frame #4.
      
      Test Plan:
      fbconfig -r --platform-all=gcc-4.8.1-glibc-2.17 --sanitize=address tao/queues:TimeoutWorkQueueTests
      _bin/tao/queues/WorkQueueTests -fbunit_test_regexp '^mt\_stress\_deterministic$'
      
      Reviewed By: mssarang@fb.com
      
      FB internal diff: D1404572
      
      Tasks: 4494871
      b27ed0f6
    • Sarang Masti's avatar
      Fix use-after-free in futexWaitUntilImpl · 8ee3ba54
      Sarang Masti authored
      Summary: Handle wake-ups correctly in futexWaitUntilImpl.
      
      Test Plan:
      -- ran all folly unit tests
      -- ran TimeoutWorkQueue test under tao/queues
      
      Reviewed By: ngbronson@fb.com, meyering@fb.com
      
      FB internal diff: D1406845
      
      Tasks: 4494871
      8ee3ba54
    • Hans Fugal's avatar
      (wangle) noexcept move constructor · 0498579d
      Hans Fugal authored
      Summary: to make lint happy
      
      Test Plan: builds
      
      Reviewed By: hannesr@fb.com
      
      Subscribers: net-systems@, fugalh, exa
      
      FB internal diff: D1406766
      
      Tasks: 4480567
      0498579d
    • Hans Fugal's avatar
      (wangle) s/continuation/callback · b20a9545
      Hans Fugal authored
      Summary: The word "continuation" is too ambiguous. Prefer callback (except where we are actually talking about CSP continuations in the README).
      
      Test Plan: Still builds. Nothing external is or should be calling `setContinuation`. But I'll wait for contbuild anyway.
      
      Reviewed By: hannesr@fb.com
      
      Subscribers: net-systems@, fugalh, exa
      
      FB internal diff: D1406753
      
      Tasks: 4480567
      b20a9545
    • Hans Fugal's avatar
      nuke executeWith · ad710a56
      Hans Fugal authored
      Summary: Removing this crufty API. The only callsite for `executeWith` was `Later::via` so I just folded it in there.
      
      Test Plan:
      unit tests
      contbuild
      
      Reviewed By: hannesr@fb.com
      
      Subscribers: net-systems@, fugalh, exa
      
      FB internal diff: D1406592
      
      Tasks: 4480567
      ad710a56
    • Hans Fugal's avatar
      Fix bizarre optimization · 57a00d50
      Hans Fugal authored
      Summary:
      I have no idea why the compiler is gettings its britches in a bunch because a unit test has a predictable output. Really, gcc?!
      
      But whatever, avoiding inlining by putting it in the cpp file solves it.
      
      Test Plan: fbmake runtests_opt
      
      Reviewed By: davejwatson@fb.com
      
      Subscribers: net-systems@, fugalh, exa
      
      FB internal diff: D1405811
      
      Tasks: 4591823
      57a00d50
    • Hans Fugal's avatar
      (folly) QueuedImmediateExecutor · 339a9d37
      Hans Fugal authored
      Summary: Add the `QueuedImmediateExecutor` which behaves like `InlineExecutor` but with different (and usually better) ordering semantics for nested calls.
      @override-unit-failures
      
      Test Plan: unit tests
      
      Reviewed By: davejwatson@fb.com
      
      Subscribers: folly@lists, net-systems@, fugalh, exa
      
      FB internal diff: D1364904
      
      Tasks: 3789661
      339a9d37