1. 26 Jun, 2013 3 commits
    • Jim Meyering's avatar
      folly: accommodate use of -Wshadow in other projects · 46de7098
      Jim Meyering authored
      Summary:
      Without this change, any folly-using project that attempts to enable
      gcc's -Wshadow option will be overwhelmed by warnings about violations
      in folly's class definitions.  Violations are often due to local
      variable or parameter names shadowed by a member function.
      
      Bracket offending content with directives like this:
      
      #pragma GCC diagnostic push
      #pragma GCC diagnostic ignored "-Wshadow"
      ...
      #pragma GCC diagnostic pop
      
      This set of modified files is the minimal set to allow tao
      to use -Wshadow with no folly-related warning.
      
      Test Plan:
      fbmake folly/test && fbmake opt
      
      Reviewed By: simpkins@fb.com
      
      FB internal diff: D848455
      46de7098
    • Adam Simpkins's avatar
      rework the Subprocess::communicate() API · 76ade918
      Adam Simpkins authored
      Summary:
      This eliminates the CommunicateFlags argument to communicate().  It now
      always reads from both stdout and stderr if they were set up a pipes.
      If a non-empty input buffer was supplied, it always writes that to
      stdin.
      
      This mimics the communicate() behavior of python's subprocess.py module.
      This also makes it impossible to have buffering deadlocks by forgetting
      to call communicate() with readStderr().
      
      Test Plan:
      Ran the existing subprocess tests, and also added a more complicated
      duplex test that requires communication on stdin, stdout, and stderr all
      at the same time.
      
      Also grepped for all existing users of Subprocess::communicate(), and
      made sure they will work correctly with the new behavior.
      
      Reviewed By: tudorb@fb.com
      
      FB internal diff: D814405
      76ade918
    • Todd Nowacki's avatar
      Folly Changes for Clang, revision 1 · 16d227a1
      Todd Nowacki authored
      Summary:
      Depends on D829162 and D830052
      
      A few changes are needed to get folly compiling with clang.
      There are likely more changes to compile all of folly
      
      ---folly/Bits.cpp
      +++folly/folly-config.h
      Moved ifunc check, and added an additional check for clang, instead of hard
      coding it to be 1
      
      ~~~folly/Range.cpp
      Moved the declaration of a function to get rid of clang's unused function
      warning.
      
      Test Plan:
      This bit of code was a dependency in another project.
      That code compiled as it needed to
      
      See other diff for more test details
      
      Reviewed By: oyamauchi@fb.com
      
      FB internal diff: D830075
      16d227a1
  2. 04 Jun, 2013 2 commits
    • Jordan DeLong's avatar
      Fix some issues in allocator_delete · a2d09ab3
      Jordan DeLong authored
      Summary:
      The unique_ptr implementation was getting confused about how
      to determine the pointer type, so just tell it.
      
      Facebook: Broke the fxl build; test plan included recompiling it.
      
      Test Plan: Built.
      
      Reviewed By: marcelo.juchem@fb.com
      
      FB internal diff: D834371
      a2d09ab3
    • Jordan DeLong's avatar
      Make folly::allocator_delete take advantage of EBO · 79345bbc
      Jordan DeLong authored
      Summary: It wasn't.
      
      Test Plan:
      I have a case using this that now passes a static_assert
      that it's the same size as the default_deleter version.  I didn't add
      a static_assert in folly's tests because right now
      is_simple_allocator<int,std::allocator<int>>::value is true (I think
      because the tested members come from a base class), which breaks easy
      test cases.
      
      Reviewed By: andrei.alexandrescu@fb.com
      
      FB internal diff: D833142
      79345bbc
  3. 03 Jun, 2013 12 commits
    • Paul Tarjan's avatar
      osx on folly take 2 · 1b68b53f
      Paul Tarjan authored
      Summary: using ULL broke everything. Lets try the case @danslo originally suggested.
      
      Test Plan: will check errors for this file
      
      Reviewed By: delong.j@fb.com
      
      FB internal diff: D832165
      1b68b53f
    • Paul Tarjan's avatar
      revert folly/Benchmark.cpp · 4591d3cd
      Paul Tarjan authored
      Summary: revert the breaking change
      
      Test Plan: none
      
      Reviewed By: delong.j@fb.com
      
      FB internal diff: D832143
      
      Blame Revision: D830883
      4591d3cd
    • Daniel Sloof's avatar
      make folly build on OSX · edf5a373
      Daniel Sloof authored
      Summary:
      A squash of https://github.com/danslo/folly/compare/master
      
      Github Author: danslo
      
      Test Plan: he said it compiles on OSX
      
      Reviewed By: oyamauchi@fb.com
      
      FB internal diff: D830883
      edf5a373
    • Owen Yamauchi's avatar
      add missing include · 93435568
      Owen Yamauchi authored
      Summary:
      Newer versions of boost fail without this. I guess mutex.hpp doesn't
      include lock_guard.hpp indirectly anymore, or something.
      
      Test Plan:
      built on OS X. This was part of what I had to do for my OS
      X-building attempts from a few weeks ago.
      
      Reviewed By: delong.j@fb.com
      
      FB internal diff: D830157
      93435568
    • Tom Jackson's avatar
      eachToTuple<Types...>() · db54a909
      Tom Jackson authored
      Summary: For parsing records. `eachToPair` might be a worthwhile specialization.
      
      Test Plan: Unit tests, benchmarks maybe?
      
      Reviewed By: antoine@fb.com
      
      FB internal diff: D827441
      db54a909
    • Mike Curtiss's avatar
      HACK: New Gen operators: zip, interleave · c1c28d91
      Mike Curtiss authored
      Summary:
      Zip: inspired by python's zip()
      o Combine a generator with the contents of a container to form
      a tuple.  Note that we combine with a container (and not
      another generator) because of a fundamental constraint
      in how control-flow in Generators works.  Containers give us 90%
      of the utility without all the hassle.  We could theoretically
      also add a version of zip where the extra source is generated
      concurrently in another thread.
      
      Interleave: similar to zip, but inspired by Clojure's interleave()
      o Instead of creating a tuple like zip, just flatten the values.
      
      Added some tuple creation/concatenation functions.  These are mostly
      meant as a way to enable zip'ing multiple containers together into an
      N-tuple. (My variadic-fu was not strong enough to get this working
      within a single Zip function).
      
      Test Plan: Added unit-tests
      
      Reviewed By: tjackson@fb.com
      
      FB internal diff: D740518
      c1c28d91
    • John Fremlin VII's avatar
      correct broken testcase · 22286705
      John Fremlin VII authored
      Summary:
      Turns out that phabricator and arc unit do not actually run
      tests in our internal repo and this one had a bunch of syntax errors.
      
      doh
      
      No test cases were changed, just fixing syntax.
      
      Test Plan:
      - fbconfig folly/test
      
      - fbmake runtests
      
      - saw all ok
      
      - _bin/folly/test/json_test
      
      [==========] Running 10 tests from 1 test case.
      [----------] Global test environment set-up.
      [----------] 10 tests from Json
      [ RUN      ] Json.Unicode
      [       OK ] Json.Unicode (0 ms)
      [ RUN      ] Json.Parse
      [       OK ] Json.Parse (1 ms)
      [ RUN      ] Json.JavascriptSafe
      [       OK ] Json.JavascriptSafe (0 ms)
      [ RUN      ] Json.Produce
      [       OK ] Json.Produce (0 ms)
      [ RUN      ] Json.JsonEscape
      [       OK ] Json.JsonEscape (0 ms)
      [ RUN      ] Json.JsonNonAsciiEncoding
      [       OK ] Json.JsonNonAsciiEncoding (0 ms)
      [ RUN      ] Json.UTF8Retention
      WARNING: Logging before InitGoogleLogging() is written to STDERR
      I0528 11:29:43.879976 17977 JsonTest.cpp:257] input:  => json: ""
      I0528 11:29:43.880077 17977 JsonTest.cpp:259] output:  => json: ""
      [       OK ] Json.UTF8Retention (1 ms)
      [ RUN      ] Json.UTF8EncodeNonAsciiRetention
      I0528 11:29:43.880122 17977 JsonTest.cpp:284] input:  => json: "\u2665"
      I0528 11:29:43.880131 17977 JsonTest.cpp:286] output:  => json: "\u2665"
      [       OK ] Json.UTF8EncodeNonAsciiRetention (0 ms)
      [ RUN      ] Json.UTF8Validation
      [       OK ] Json.UTF8Validation (0 ms)
      [ RUN      ] Json.ParseNonStringKeys
      [       OK ] Json.ParseNonStringKeys (0 ms)
      [----------] 10 tests from Json (2 ms total)
      
      [----------] Global test environment tear-down
      [==========] 10 tests from 1 test case ran. (2 ms total)
      [  PASSED  ] 10 tests.
      
      Reviewed By: delong.j@fb.com
      
      FB internal diff: D826413
      
      Blame Revision: D805218
      22286705
    • John Fremlin VII's avatar
      allow reading maps from number -> value · a4c90474
      John Fremlin VII authored
      Summary:
      The serialization of PHP values often uses integer -> value
      maps in JSON arrays. These are emitted by the standard stream <<
      operator on dynamics but cannot be read. This diff fixes that.
      
      Test Plan: - read in serialized value with array "bucketing":{"days_stale":{0:{2:null,1:14.01,0:"more_than_two_weeks_stale"}}}
      
      Reviewed By: delong.j@fb.com
      
      FB internal diff: D805218
      a4c90474
    • Tudor Bosman's avatar
      add openNoInt, truncateNoInt, ftruncateNoInt · a896ed39
      Tudor Bosman authored
      Test Plan: it compiles
      
      Reviewed By: soren@fb.com
      
      FB internal diff: D825286
      a896ed39
    • Tudor Bosman's avatar
      Add QueueAppender · 2ba26b05
      Tudor Bosman authored
      Summary:
      Add an Appender that appends to a IOBufQueue.  You can pass in the maximum
      append size if you know it, and it will throw on overflow, and will never
      allocate IOBufs larger than the remaining size.
      
      Test Plan: test added
      
      Reviewed By: davejwatson@fb.com
      
      FB internal diff: D820160
      2ba26b05
    • Xu Ning's avatar
      make folly:make_unique support customized deleter · 0781f3a8
      Xu Ning authored
      Summary: just follow the same template arguments as unique_ptr
      
      Test Plan: compile
      
      Reviewed By: marcelo.juchem@fb.com
      
      FB internal diff: D825025
      0781f3a8
    • Tom Jackson's avatar
      member(&Foo::getter), field(&Foo::field) · 5c507b28
      Tom Jackson authored
      Summary: For easily calling a getter on every item in a sequence.
      
      Test Plan: Unit tests, benchmarks
      
      Reviewed By: mmcurtiss@fb.com
      
      FB internal diff: D651206
      5c507b28
  4. 23 May, 2013 5 commits
    • Jordan DeLong's avatar
      Some documentation updates in lazy · 42eed265
      Jordan DeLong authored
      Summary: Per discussion after commit on the previous diff.
      
      Test Plan: Compiled.
      
      Reviewed By: tjackson@fb.com
      
      FB internal diff: D821985
      42eed265
    • Jordan DeLong's avatar
      Add folly::lazy · 12c8603d
      Jordan DeLong authored
      Summary:
      A thin wrapper around Optional for terse creation of
      lazily-initialized values.
      
      Test Plan: New tests, and a use case in hphp.
      
      Reviewed By: tjackson@fb.com
      
      FB internal diff: D817906
      12c8603d
    • Maxime Boucher's avatar
      Allow escapeString in folly/json.cpp to be called by other methods. · dc64a0e3
      Maxime Boucher authored
      Summary: See title.
      
      Test Plan:
      From fbocde, type:
      fbconfig folly/test; fbmake opt -j 32; fbmake runtests_opt -j 32
      
      Reviewed By: delong.j@fb.com
      
      FB internal diff: D818077
      dc64a0e3
    • Mike Curtiss's avatar
      Gen apply comment · b297ef2d
      Mike Curtiss authored
      Summary: Comment
      
      Test Plan: Builds
      
      Reviewed By: tjackson@fb.com
      
      FB internal diff: D814986
      b297ef2d
    • Paul Tarjan's avatar
      delete unused variable · efdfacee
      Paul Tarjan authored
      Test Plan: none
      
      Reviewed By: tjackson@fb.com
      
      FB internal diff: D818326
      efdfacee
  5. 20 May, 2013 18 commits
    • Mike Curtiss's avatar
      gen::sample · e8865049
      Mike Curtiss authored
      Summary:
      Take a random sample of size N from a range.  Clients
      can also pass in a custom random number generator.
      
      Test Plan: Added test and benchmark.
      
      Reviewed By: tjackson@fb.com
      
      FB internal diff: D811260
      e8865049
    • Adam Simpkins's avatar
      Update Subprocess to throw if exec() fails · 9cbe6594
      Adam Simpkins authored
      Summary:
      Add a new SubprocessSpawnError, and change the Subprocess constructor to
      throw this if the child process encounters an error before calling
      execve().  Error information is passed back to the parent process over a
      pipe.
      
      Previosly in this case the Subprocess constructor would fail, and
      clients would simply get a return code of 126 or 127 when waiting on the
      process.  There was no way to distinguish this from a successful
      execve() followed by the child process exiting with status 127.
      
      Test Plan:
      Added tests to check the exception behavior, and also to check for file
      descriptor leaks in the parent process.
      
      Reviewed By: tudorb@fb.com
      
      FB internal diff: D776273
      9cbe6594
    • Chip Turner's avatar
      Expose a human-readable type name for a dynamic · 94ddd29d
      Chip Turner authored
      Summary: Aids in debugging dynamic types, etc.
      
      Test Plan: unit tests
      
      Reviewed By: delong.j@fb.com
      
      FB internal diff: D812385
      94ddd29d
    • Mark Williams's avatar
      New feature support in folly::AtomicHash* · 7969353a
      Mark Williams authored
      Summary:
      AtomicHashMap/AtomicHashArray didn't support a custom equality
      function, and didnt support pointer keys. We only ever do
      compare-and-swap against the 3 "magic" keys, so as long as we're
      careful we can continue to do that, while using the equality
      function elsewhere.
      
      Also add a user-configurable growth rate, independent of
      maxLoadFactor.
      
      Test Plan: automated tests
      
      Reviewed By: delong.j@fb.com
      
      FB internal diff: D806936
      7969353a
    • Tudor Bosman's avatar
      Add fsyncNoInt, fdatasyncNoInt · aa0a6569
      Tudor Bosman authored
      Test Plan: compiled file_util_test
      
      Reviewed By: soren@fb.com
      
      FB internal diff: D809250
      aa0a6569
    • Maxime Boucher's avatar
      Replace CHECK in Range.h by throw std::out_of_range · c524e712
      Maxime Boucher authored
      Summary:
      Calling CHECK() in folly will force the program to abort in case of a failure.
      On the other hand, for range checking, the standard library throws std::out_of_range for many functions.
      
      Thus it could be a good idea to throw the same exception in folly so that errors can be handled using try {} catch (...) {} blocks.
      
      Test Plan:
      from fbcode, type:
      fbconfig -r folly; fbmake opt -j32; fbmake runtests_opt -j 32
      
      What other tests should I run?
      
      Reviewed By: tudorb@fb.com
      
      FB internal diff: D808204
      c524e712
    • Maxime Boucher's avatar
      Replace CHECK in Range.h by throw std::out_of_range · d327d57f
      Maxime Boucher authored
      Summary:
      Calling CHECK() in folly will force the program to abort in case of a failure.
      On the other hand, for range checking, the standard library throws std::out_of_range for many functions.
      
      Thus it could be a good idea to throw the same exception in folly so that errors can be handled using try {} catch (...) {} blocks.
      
      Test Plan:
      from fbcode, type:
      fbconfig -r folly; fbmake opt -j32; fbmake runtests_opt -j 32
      
      What other tests should I run?
      
      Reviewed By: tudorb@fb.com
      
      FB internal diff: D808204
      d327d57f
    • Tudor Bosman's avatar
      Unbreak build on glibc 2.5.1 · 9cdd19b7
      Tudor Bosman authored
      Summary:
      Also move manually-generated stuff away from folly-config.h and into
      Portability.h.  This should be only for things that differs between the
      various (compiler, library) pairs used internally at FB; everything else
      should be autoconf-ed and therefore go into folly-config.h.
      
      Test Plan: built and ran file_util_test on various platforms
      
      Reviewed By: delong.j@fb.com
      
      FB internal diff: D807067
      
      Blame Revision: D806781
      9cdd19b7
    • Tudor Bosman's avatar
      fix segfault on fb platform · 531568a6
      Tudor Bosman authored
      Summary: Strings can be moved around while the vector grows.
      
      Test Plan: file_util_test
      
      Reviewed By: lucian@fb.com
      
      FB internal diff: D806966
      
      Blame Revision: D806781
      531568a6
    • Tudor Bosman's avatar
      convert RecordIO to pwritev · 63b61817
      Tudor Bosman authored
      Summary: zero-copy
      
      Test Plan: record_io_test
      
      Reviewed By: lucian@fb.com
      
      FB internal diff: D806813
      63b61817
    • Tudor Bosman's avatar
      Add missing FileUtil functions (p?readvFull, p?writevFull) , add test · bfd3d062
      Tudor Bosman authored
      Summary:
      Testing incomplete reads / writes is hard, so I'm only testing the wrappers
      (template functions that take the underlying operation and retry it in
      case of incomplete operations).  Note the cute hack of using variadic
      templates to use the same wrapper for both file pointer- and explicit-position
      flavors of the functions (the offset argument becomes optional).
      
      Test Plan: test added
      
      Reviewed By: lucian@fb.com
      
      FB internal diff: D806781
      bfd3d062
    • Tudor Bosman's avatar
      Make folly::AsyncIO thread safe · d10b6508
      Tudor Bosman authored
      Summary:
      You can now submit to the same AsyncIO object from different threads, but you
      must still reap from only one thread at a time.
      
      Test Plan: async_io_test, added MT test
      
      Reviewed By: philipp@fb.com
      
      FB internal diff: D804914
      d10b6508
    • Owen Yamauchi's avatar
      Break dependency on endian.h · e49f2768
      Owen Yamauchi authored
      Summary:
      gcc and clang both give you these three macros pre-defined. I've found a
      reference on the interweb to this being broken
      (http://gcc.gnu.org/ml/gcc/2011-08/msg00152.html) but that was with gcc
      4.4. I've tested with 4.6, 4.7 and clang 3.2 and they all do the right
      thing on little-endian (internal build and OS X). Alas, I don't have a
      big-endian system handy to test with.
      
      Test Plan: fbconfig/fbmake runtests.
      
      Reviewed By: simpkins@fb.com
      
      FB internal diff: D799416
      e49f2768
    • Owen Yamauchi's avatar
      Break dependency on byteswap.h · 29ad1ec9
      Owen Yamauchi authored
      Summary:
      Unfortunately, this doesn't exist on all platforms. Fortunately, both
      gcc and clang support builtins that do the same thing as the bswap_*
      functions we were including byteswap.h for.
      
      I changed the test file to hardcode expected results for the swapping
      functions. Is that OK? It seemed a little silly to be testing the
      Endian::whatever functions by comparing them against the functions that
      they're implemented in terms of.
      
      Test Plan:
      fbconfig/fbmake runtests with gcc 4.6 and 4.7. Verified
      separately that clang supports these builtins.
      
      Reviewed By: simpkins@fb.com
      
      FB internal diff: D799244
      29ad1ec9
    • Owen Yamauchi's avatar
      Break dependency on features.h · ce4dec4c
      Owen Yamauchi authored
      Summary:
      It doesn't exist on some systems (at least Mac OS X). We're only using
      it for __GNUC_PREREQ, which is easy to provide our own definition for.
      
      I moved the definitions of FOLLY_FINAL and FOLLY_OVERRIDE into
      folly-config.h so we can autoconf them in the open-source build. The
      hardcoded stuff for the internal build is a little ugly, unfortunately.
      
      folly can't be built with gcc versions earlier than 4.6, so that check
      in ThreadLocal.h is pointless by now. (Plus we use noexcept without a
      macro wrapper all over the place.) That stuff was also not
      clang-friendly. clang has supported static_assert since 2.9 and noexcept
      since... I'm not sure but at least 3.0.
      
      Test Plan:
      fbconfig/fbmake runtests, with gcc 4.6 and 4.7. clang can't
      build folly right now, but I verified separately that it supports
      noexcept and static_assert.
      
      Reviewed By: simpkins@fb.com
      
      FB internal diff: D799143
      ce4dec4c
    • Hannes Roth's avatar
      (Folly) Remove unused variable according to -Wunused-variable · bbe8ee53
      Hannes Roth authored
      Summary:
      I am trying to move more code into a HPHP extension, and it's complaining about
      this.
      
      Test Plan: `fbconfig -r folly && fbmake runtests`
      
      Reviewed By: delong.j@fb.com
      
      FB internal diff: D799096
      bbe8ee53
    • Owen Yamauchi's avatar
      Fail the configure script if you don't have boost · 9345f46e
      Owen Yamauchi authored
      Summary:
      Discovered this while trying to build folly on OS X. It would print a
      warning about Boost being missing that got drowned out in the rest of
      the configure output, and then the build would fail. This makes the
      failure more friendly.
      
      Test Plan:
      `autoreconf; ./configure` on a system without boost
      installed; make sure configure fails and the last thing it prints is the
      boost error message.
      
      Reviewed By: delong.j@fb.com
      
      FB internal diff: D797389
      9345f46e
    • Peter Griess's avatar
      Add read*String() methods to Cursor · bae84035
      Peter Griess authored
      Summary:
      - Add some convenience methods for reading std::string objects via
      folly::Cursor
      
      Test Plan: - Unit tests
      
      Reviewed By: simpkins@fb.com
      
      FB internal diff: D795428
      bae84035