1. 16 Dec, 2012 39 commits
    • Yiding Jia's avatar
      folly/stats - fix c++ spec compliance for call to template name · 3e8d7341
      Yiding Jia authored
      Summary:
      This code is not strictly correct per c++ spec section 14.2.4:
      
      > When the name of a member template specialization appears after . or -> in a
      > postfix-expression or after a nested-name-specifier in a qualified-id, and the
      > object or pointer expression of the postfix-expression or the
      > nested-name-specifier in the qualified-id depends on a template parameter
      > (14.6.2) but does not refer to a member of the current instantiation
      > (14.6.2.1), the member template name must be prefixed by the keyword template.
      > Otherwise the name is assumed to name a non-template.
      
      This causes clang to complain, but gcc is lax about this, as usual.
      
      Test Plan: compile stuff that use this.
      
      Reviewed By: delong.j@fb.com
      
      FB internal diff: D643515
      3e8d7341
    • Yiding Jia's avatar
      folly/dynamic fix use of incomplete type in template definition · 407e633f
      Yiding Jia authored
      Summary:
      the old code is ill-formed per spec (section 14.6.8):
      
      > If a type used in a non-dependent name is incomplete at the point at which a
      > template is defined but is complete at the point at which an instantiation is
      > done, and if the completeness of that type affects whether or not the program
      > is well-formed or affects the semantics of the program, the program is
      > ill-formed; no diagnostic is required.
      
      GCC is lax and allows this, clang gives an error.
      
      Test Plan: compiles.
      
      Reviewed By: delong.j@fb.com
      
      FB internal diff: D643431
      407e633f
    • Yiding Jia's avatar
      fix std::out_of_range calls to use real constructors · 35a186fe
      Yiding Jia authored
      Summary:
      curiously, std::out_of_range doesn't have a zero-argument constructor according
      to the spec. This was causing issues in my clang setup...
      
      Test Plan: compiles.
      
      Reviewed By: delong.j@fb.com
      
      FB internal diff: D643363
      35a186fe
    • Tudor Bosman's avatar
      fix Traits.md · 87e1985f
      Tudor Bosman authored
      Test Plan: looked at the generated html in a browser
      
      Reviewed By: andrei.alexandrescu@fb.com
      
      FB internal diff: D642998
      87e1985f
    • Davide Bolcioni's avatar
      Fix output of 128 bit integer to string conversion. · 785dd995
      Davide Bolcioni authored
      Summary:
      Added specializations of folly::to<String> for __int128_t
      and __uint128_t.
      
      Test Plan: Added tests of the above to the integral to string tests.
      
      Reviewed By: andrei.alexandrescu@fb.com
      
      FB internal diff: D636992
      785dd995
    • Sergey Doroshenko's avatar
      Add bytesUsed() to folly::Arena · 817e76cb
      Sergey Doroshenko authored
      Summary:
      Returns number of bytes "really used by the user", i.e. number of bytes
      allocated on the arena via calls to `allocate()`.
      
      Test Plan: compiled, unit tests
      
      Reviewed By: azzolini@fb.com
      
      FB internal diff: D636976
      817e76cb
    • Tom Jackson's avatar
      Supressing GCC 4.7 warning for Optional · 4b1e7193
      Tom Jackson authored
      Summary:
      Supressing the warning for GCC4.7, and supressing the error supressing
      the warning in GCC4.6.
      
      Test Plan: Compile, run unit tests on GCC4.6 and GCC4.7
      
      Reviewed By: ldbrandy@fb.com
      
      FB internal diff: D635982
      4b1e7193
    • Soren Lassen's avatar
      use std::underlying_type to support enum classes · 4f0bc527
      Soren Lassen authored
      Summary:
      Noticed these TODOs in Conv.h and decided to fix them.
      Discovered that the underlying_type implementation also
      covers enum classes, which didn't work with the pre-existing code.
      
      Test Plan:
      fbconfig -r folly --platform=gcc-4.7.1-glibc-2.14.1-fb
      fbmake dbg _bin/folly/test/conv_test
      _bin/folly/test/conv_test
      
      --platform=gcc-4.6.2-glibc-2.13
      fbmake dbg _bin/folly/test/conv_test
      _bin/folly/test/conv_test
      
      Reviewed By: tudorb@fb.com
      
      FB internal diff: D634309
      4f0bc527
    • Alan Frindell's avatar
      Fix IOBufQueue::preallocate for callers who really wanted a hard max · c462b064
      Alan Frindell authored
      Summary: D633912 broke unicorn because it relied on preallocate having a hard max.  Add an optional hard max parameter and rename maxHint to newAllocationSize.  Pass the hard max in for unicorn
      
      Test Plan: folly and unicorn unit tests
      
      Reviewed By: tudorb@fb.com
      
      FB internal diff: D634894
      c462b064
    • Alan Frindell's avatar
      Return the maximum available space from IOBufQueue::preallocate · 01e1af4a
      Alan Frindell authored
      Summary: IOBufQueue::preallocate currently takes a min and max size, and will return to the caller a buffer with N writable bytes with min <= N <= max.  This is a bit wasteful, since there may be more than max bytes available at the end if the queue with no extra cost.  Now preallocate will return the full amount of contigious space to the caller, even if it is larger than the requested max.
      
      Test Plan: folly and proxygen unit tests
      
      Reviewed By: simpkins@fb.com
      
      FB internal diff: D633912
      01e1af4a
    • Dave Watson's avatar
      add clone / insert methods · 559830c8
      Dave Watson authored
      Summary:
      cursor.clone() will clone a length of the chain.  insert(std::move(buf)) will splice in a length of chain
      I want this to change thrift2 binary type to IOBuf: we will clone() the network data for zero-copy userspace data, and insert() it if the return value is a IOBuf.
      
      Test Plan: added unittest
      
      Reviewed By: afrind@fb.com
      
      FB internal diff: D632073
      559830c8
    • Adam Simpkins's avatar
      add IOBuf::maybeCopyBuffer() · cb771e84
      Adam Simpkins authored
      Summary:
      Add a version of IOBuf::copyBuffer() which accepts a std::string, as
      well as a maybeCopyBuffer() function which returns a null pointer if the
      input string is empty.
      
      In proxygen we have a few places where we construct an IOBuf from a
      string configuration parameter, and we almost always want a null pointer
      rather than an empty IOBuf chain if the string is empty.
      
      Test Plan: Included unit tests for these new functions.
      
      Reviewed By: tudorb@fb.com
      
      FB internal diff: D630547
      cb771e84
    • Tom Jackson's avatar
      Removing unneeded eachAs() operators · 389fb8a5
      Tom Jackson authored
      Summary: ##byLine## already yields StringPieces, no neat to ##eachAs()## then.
      
      Test Plan:
      fbconfig folly/experimental/symbolizer folly/test folly/experimental/io folly/experimental/io/test tupperware/agent
      fbmake opt
      
      Reviewed By: tudorb@fb.com
      
      FB internal diff: D630422
      389fb8a5
    • Tudor Bosman's avatar
      static constexpr in enclosing class + lambdas make compilers unhappy? · b24f3cf8
      Tudor Bosman authored
      Test Plan: build
      
      Reviewed By: dneiter@fb.com
      
      FB internal diff: D630324
      b24f3cf8
    • Tudor Bosman's avatar
      one more · 47fc6cdf
      Tudor Bosman authored
      Test Plan: build
      
      Reviewed By: tjackson@fb.com
      
      FB internal diff: D630280
      47fc6cdf
    • Tudor Bosman's avatar
      fix ~File crash in debug mode · c7796707
      Tudor Bosman authored
      Test Plan: test added
      
      Reviewed By: tjackson@fb.com
      
      FB internal diff: D630163
      c7796707
    • Tudor Bosman's avatar
      unbreak build · e4d6eb2a
      Tudor Bosman authored
      Test Plan: build
      
      Reviewed By: tjackson@fb.com
      
      FB internal diff: D630266
      e4d6eb2a
    • Tudor Bosman's avatar
      Remove Stream · d8c1a8c0
      Tudor Bosman authored
      Summary:
      Switch existing code to gen::byLine.  Also fix namespaces in
      folly/experimental/(symbolizer|exception_tracer).
      
      Test Plan:
      fbconfig -r folly && fbmake runtests_opt, ran non-test folly
      binaries by hand, fbgs for other uses (there aren't any)
      
      Reviewed By: tjackson@fb.com
      
      FB internal diff: D629576
      d8c1a8c0
    • Tom Jackson's avatar
      split() · a0b4acce
      Tom Jackson authored
      Summary: Normal split to complement resplit, and it's a bit faster than folly::split().
      
      Test Plan: Unit tests, Benchmarks (result in code comment)
      
      Reviewed By: tudorb@fb.com
      
      FB internal diff: D629998
      a0b4acce
    • Tudor Bosman's avatar
      fix comments · 00126171
      Tudor Bosman authored
      Test Plan: no
      
      Reviewed By: tjackson@fb.com
      
      FB internal diff: D629502
      00126171
    • Tudor Bosman's avatar
      add split operator · ed448247
      Tudor Bosman authored
      Summary:
      Also added eachAs (cast each value as a given type) and eachTo (use folly::to
      on each value)
      
      Test Plan: test added
      
      Reviewed By: tjackson@fb.com
      
      FB internal diff: D628868
      ed448247
    • Tudor Bosman's avatar
      movify generators (but mostly operators) · 8d246c45
      Tudor Bosman authored
      Summary: Make things work with non-copyable generators.
      
      Test Plan: folly/experimental/test
      
      Reviewed By: tjackson@fb.com
      
      FB internal diff: D628520
      8d246c45
    • Philip Pronin's avatar
      constexpr-ize folly/Bits.h · 6aa05bb9
      Philip Pronin authored
      Summary:
      Want to be able to call them from other constexpr functions
      and from within static_assert()s.
      
      Test Plan: compiled and ran folly tests
      
      Reviewed By: tudorb@fb.com
      
      FB internal diff: D627413
      6aa05bb9
    • Chao Yang's avatar
      Fix example for folly::format · 91d0ef0e
      Chao Yang authored
      Summary: That's all.
      
      Test Plan: .
      
      Reviewed By: tjackson@fb.com
      
      FB internal diff: D618824
      91d0ef0e
    • Tom Jackson's avatar
      Composed, for lightweight operator composition · c9ce99c0
      Tom Jackson authored
      Summary:
      Sometimes it'll be handy to have a custom operator which is little more than the
      composition of a few base operators. This makes that really easy to do, as shown
      in examples, tests, and benchmarks.
      
      Test Plan: Unit tests, benchmarks
      
      Reviewed By: rsagula@fb.com
      
      FB internal diff: D617152
      c9ce99c0
    • Tom Jackson's avatar
      Adding support for printing arbitrary pointers · 24f6247d
      Tom Jackson authored
      Summary: We should be able to print ##Foo*##, even if we can't print ##Foo##.
      
      Test Plan: Unit Tests.
      
      Reviewed By: tudorb@fb.com
      
      FB internal diff: D625977
      24f6247d
    • Tom Jackson's avatar
      Enabling format("{}", format(...)) · 8ff3329c
      Tom Jackson authored
      Summary:
      If your format string ends up being conditional, it's handy to be able to chain
      together formatters.
      
      Test Plan: Unit tests
      
      Reviewed By: tudorb@fb.com
      
      FB internal diff: D625502
      8ff3329c
    • Tudor Bosman's avatar
      add IOBuf::moveToFbString · aef2fb09
      Tudor Bosman authored
      Summary:
      Convert a IOBuf chain into a fbstring, with zero copies in the common case
      (unshared, unchained, no headroom) and one copy in all other cases.
      
      Test Plan: tests added
      
      Reviewed By: simpkins@fb.com
      
      FB internal diff: D621210
      aef2fb09
    • Marcelo Juchem's avatar
      Clang complains about errors in folly String-inl.h and FBString.h (P1825995) · a8370f02
      Marcelo Juchem authored
      Summary: fixing clang errors (used clang 3.1)
      
      Test Plan: doh
      
      Reviewed By: tudorb@fb.com
      
      FB internal diff: D622593
      a8370f02
    • Marcelo Juchem's avatar
      Adding usage example for BENCHMARK_DRAW_LINE() · 99f7266b
      Marcelo Juchem authored
      Summary:
      Yes, I admit, I was dumb enough to try it in a benchmark's
      body.
      
      Test Plan: review
      
      Reviewed By: tudorb@fb.com
      
      FB internal diff: D622613
      99f7266b
    • Nicholas Ormrod's avatar
      Augment DynamicConverter's is_container check · c9f168a1
      Nicholas Ormrod authored
      Summary:
      DynamicConverter uses some simple heuristics to determine if a
      class is a container. One of those tests was to check that the
      constructor 'template <class Iterator> [container-name](Iterator first,
      Iterator last)' was present. That test was performed by checking if the
      class could be constructed by two parameters of some dummy class.
      
      However, it is possible to restrict the template parameter such that it
      only accepts iterators, and not any arbitrary dummy class. This would be
      useful, for example, to solve overload ambiguity with constructors like
      'vector(const T& val, size_type n)', where T and size_type are the same
      (see N3337 23.2.3 item 14). It also (I believe) produces more meaningful
      compiler errors when a non-iterator is supplied, since it errors at the
      function callsite instead of inside the constructor itself.
      
      The new FBVector implementation uses such a feature, and so checking for
      [container-name](dummy, dummy) will fail. Hence the dummy class has been
      upgraded to reverse_iterator<T*>, a valid iterator class which almost
      certainly does not have a specialized contructor in any class (and hence
      will not cause any visible change in class_is_container's value).
      
      Test Plan:
      Run DynamicConverterTest; it has tests for the correctness of
      class_is_container.
      
      Reviewed By: delong.j@fb.com
      
      FB internal diff: D620607
      c9f168a1
    • Tudor Bosman's avatar
      ints used as flags (bitwise): so C · 96bd762f
      Tudor Bosman authored
      Summary:
      Changed communicate() flags from int to a class.
      Made Options and CommunicateFlags composable with |
      Simplified API so you don't have to type Subprocess::Options().stdout(Subprocess::PIPE)
      
      Test Plan: subprocess_test
      
      Reviewed By: chip@fb.com
      
      FB internal diff: D620186
      96bd762f
    • Tudor Bosman's avatar
      Retry wait() on EINTR; clean up signal handling · dcbf9149
      Tudor Bosman authored
      Test Plan: subprocess_test
      
      Reviewed By: delong.j@fb.com
      
      FB internal diff: D619713
      dcbf9149
    • Tudor Bosman's avatar
      fix typos in comment; RV_* do not have to be public · d870f36c
      Tudor Bosman authored
      Test Plan: subprocess_test
      
      Reviewed By: chip@fb.com
      
      FB internal diff: D619189
      d870f36c
    • Tudor Bosman's avatar
      Subprocess library, modeled after python's subprocess module · 677bed09
      Tudor Bosman authored
      Summary:
      Surprised we don't have one.  The API is modeled after Python's
      subprocess module, http://docs.python.org/2/library/subprocess.html
      
      Inspired by
      https://www.facebook.com/groups/fbcode/permalink/445399858830192/, plus
      I needed this functionality now.
      
      Test Plan: test added
      
      Reviewed By: chip@fb.com
      
      FB internal diff: D614056
      677bed09
    • Misha Shneerson's avatar
      [Conv] Remove __int128 overload · f919a052
      Misha Shneerson authored
      Summary: parseInt128 is only available for GCC 4.7 and above.
      
      Test Plan: .
      
      Reviewed By: igorzi@fb.com
      
      FB internal diff: D618456
      
      Blame Revision: rFBCODEeaec97e2991f
      f919a052
    • Adam Simpkins's avatar
      update function_benchmark to test exception handling · 5196d1e2
      Adam Simpkins authored
      Summary:
      Add benchmarks for throwing an exception versus returning
      std::exception_ptr or other types of return values.
      
      Throwing an exception is very expensive.  Calling std::make_exception_ptr()
      without ever throwing is nearly as bad.
      
      The exc_ptr_param_return tests were the ones I was most interested in.
      (Accepting a std::exception_ptr* argument so the caller can indicate if they
      want to receive an exception or not.)  This is fast if the caller doesn't care
      about the exception value, but very slow if an error occurs and an
      exception_ptr is required.
      
      Test Plan:
      ======================================================================
      folly/test/function_benchmark/main.cpp    relative  time/iter  iters/s
      ======================================================================
      throw_exception                                        3.90us  256.25K
      catch_no_exception                                     1.88ns  533.25M
      return_exc_ptr                                         2.79us  357.85K
      exc_ptr_param_return                                   2.83us  353.25K
      exc_ptr_param_return_null                              2.25ns  444.38M
      return_string                                         69.39ns   14.41M
      return_string_noexcept                                69.39ns   14.41M
      return_code                                            1.50ns  666.54M
      return_code_noexcept                                   1.50ns  666.54M
      
      Reviewed By: rajat@fb.com
      
      FB internal diff: D616474
      5196d1e2
    • Misha Shneerson's avatar
      [Conv] MaxString specialization for __int128 · 5ec53c6f
      Misha Shneerson authored
      Summary: Just that.
      
      Test Plan: .
      
      Reviewed By: igorzi@fb.com
      
      FB internal diff: D613291
      5ec53c6f
    • Hari Manikarnika's avatar
      make folly::toJson retain non-ascii chars if encode_non_ascii is disabled · e18efdc4
      Hari Manikarnika authored
      Summary:
      folly::toJson as demonstrated by the test cases was wrongly encoding utf8 strings.
      specifically, a utf8 char made up of x bytes was encodeded into x unicode chars.
      
      for example, the char:
      \u2665
      which is made of 3 bytes:
      \xe2\x99\xa5
      was encoded correctly when using encode_non_ascii = true:
      "\u2665"
      but when encode_non_ascii = false, the json value was wrongly set as:
      "\u00e2\u0099\u00a5"
      
      because we use an signed char that wrongly detects non-readable chars with
      ascii value > 127 as control chars with ascii value < 32 (\t, \n, etc.)
      
      Test Plan: run the test
      
      Reviewed By: delong.j@fb.com
      
      FB internal diff: D612782
      e18efdc4
  2. 29 Oct, 2012 1 commit
    • Tom Jackson's avatar
      Optional bugfixes · 6e230a3f
      Tom Jackson authored
      Summary: Tests were run in 'opt', which masked issues alterted by asserts.
      
      Test Plan: Unit tests
      
      Reviewed By: delong.j@fb.com
      
      FB internal diff: D611957
      6e230a3f