Brian Pane [Sat, 18 Jan 2014 01:09:01 +0000 (17:09 -0800)]
Enable the __builtin_ia32_crc* acceleration functions for gcc-4.7
Summary:
Adjusted the ifdefs to allow the use of the hardware CRC instructions
when compiling with gcc-4.7.x
Test Plan:
Built with gcc-4.7.1, ran the unit tests, verified that they ran the
hardware-accelerated code path
Reviewed By: saramg@fb.com
FB internal diff:
D1134567
Vladimir Tkachev [Fri, 17 Jan 2014 21:49:41 +0000 (13:49 -0800)]
Remove byLine(const char*) method
Summary:
Many callers of byLine method use it by providing arguments for File
explicit constructors. Added function breaks byLine(file desciptor)
use case. Commenting it out until File constructors are made exlicit to
fix failing tests.
Test Plan: unittest
Reviewed By: lucian@fb.com
FB internal diff:
D1133938
Blame Revision:
D1129497
Adam Simpkins [Wed, 20 Nov 2013 04:29:25 +0000 (20:29 -0800)]
support stack-allocated IOBufs
Summary:
Previously, all IOBuf APIs required that IOBufs always be allocated on
the heap. The only methods provided to create IOBufs returned
unique_ptr<IOBuf>.
This adds new methods to support creating IOBufs on the stack. This is
useful in cases where the IOBuf will be short-lived, and the overhead of
the heap allocation is undesirable. (One use case is to wrap an
existing buffer in a short-lived IOBuf so that it can be used with the
Cursor API.)
I have currently made IOBufs movable but not copyable. (Move operations
clearly should move only a single IOBuf, but it is not clear if the copy
operators should copy only a single IOBuf or the entire chain.)
Test Plan:
Updated the unit tests to test the new CREATE, WRAP_BUFFER,
TAKE_OWNERSHIP, and COPY_BUFFER constructors, as well as the move
constructor and assignment operator.
Reviewed By: davejwatson@fb.com
FB internal diff:
D1067341
Nathan Bronson [Fri, 17 Jan 2014 18:25:41 +0000 (10:25 -0800)]
Baton - minimalist inter-thread notification
Summary:
A Baton allows a thread to block once and be awoken: it captures
a single handoff. During its lifecycle (from construction/reset to
destruction/reset) a baton must either be post()ed and wait()ed exactly
once each, or not at all. Batons may be reused after a call to
recycle().
Baton includes no internal padding, and is only 4 bytes in size.
Any alignment or padding to avoid false sharing is up to the user.
This is basically a stripped-down semaphore that supports only a single
call to sem_post. The current posix semaphore sem_t isn't too bad, but
this provides more a bit more speed, checking, inlining, smaller size,
a guarantee that the implementation won't change, and compatibility
with DeterministicSchedule. Baton is directly implemented on top of
futex, and takes care to avoid system calls.
Test Plan:
1. new unit tests
2. this code has already been in production use in TAO for many months
Reviewed By: davejwatson@fb.com
FB internal diff:
D1130407
Alexander Sidorov [Fri, 17 Jan 2014 06:26:04 +0000 (22:26 -0800)]
folly json bug fix: overflow for -1LL<<63
Summary: -1LL<<63 was passed to folly::to() without '-' so it overflowed. Fixed that
Test Plan:
tried this:
int main() {
stringstream s;
s << "{\"int\":" << -1LL<<63 << "}";
string str = s.str();
cout << "string to parse: " << endl << str << endl;
int64_t sample = folly::parseJson(str.c_str())["int"].asInt();
LOG(INFO) << "test result = " << sample;
return 0;
}
it returns right value.
Also tried it with "-Infinity" and double type for sample. In works fine as well.
Reviewed By: andrei.alexandrescu@fb.com
FB internal diff:
D1130155
Andrei Alexandrescu [Wed, 15 Jan 2014 18:38:22 +0000 (10:38 -0800)]
readFile reads an entire file into a string, vector<char>, or similar
Test Plan: unittest
Reviewed By: lucian@fb.com
FB internal diff:
D1129497
Marc Horowitz [Thu, 16 Jan 2014 02:44:14 +0000 (18:44 -0800)]
move folly::detail::IsSomeString outside of folly::detail
Summary:
It is useful when writing additional specializations of of
toAppend() and related functions to use IsSomeString, the same way the
ones in Conv.h do. Move IsSomeString out of detail, so outside code
doesn't access a detail namespace inappropriately.
Test Plan: fbmake runtests; arc lint
Reviewed By: tudorb@fb.com
FB internal diff:
D1130910
Jordan DeLong [Thu, 16 Jan 2014 23:28:45 +0000 (15:28 -0800)]
Remove some files that should have been deleted in earlier commits
Summary: Our script wasn't picking up removed files.
Tudor Bosman [Thu, 16 Jan 2014 03:14:30 +0000 (19:14 -0800)]
stack_trace_test was broken in debug mode
Summary: A function was getting inlined in opt mode but not in debug mode.
Test Plan: ran test
Reviewed By: philipp@fb.com
FB internal diff:
D1130949
@override-unit-failures
test fix only
Nathan Bronson [Wed, 15 Jan 2014 23:25:04 +0000 (15:25 -0800)]
include guard name cleanup for IndexedMemPool
Summary: Include guard had FOLLY_DETAIL_.. even though code is in folly
Test Plan: unit tests
Reviewed By: davejwatson@fb.com
FB internal diff:
D1130269
@override-unit-failures
Nathan Bronson [Wed, 15 Jan 2014 23:15:31 +0000 (15:15 -0800)]
IndexedMemPool - pool allocator tailored for lock-free data structures
Summary:
Instances of IndexedMemPool dynamically allocate and then pool
their element type (T), returning 4-byte integer indices that can be
passed to the pool's operator[] method to access or obtain pointers to
the actual elements. Once they are constructed, elements are never
destroyed. These two features are useful for lock-free algorithms.
The indexing behavior makes it easy to build tagged pointer-like-things,
since a large number of elements can be managed using fewer bits than a
full pointer. The pooling behavior makes it safe to read from T-s even
after they have been recycled
Test Plan:
1. unit tests
2. unit tests using DeterministicSchedule
3. this code is moved from tao/queues where it is in production use
Reviewed By: davejwatson@fb.com
FB internal diff:
D1089053
Lucian Grijincu [Tue, 14 Jan 2014 23:38:21 +0000 (15:38 -0800)]
folly: symbolizer: small terse write fix + colorize signal handler output if printing to TTY
Summary:
Detailed output is a bit hard to parse visually. Add some colors for
clarity (clownyness?). Enabled only when printing stack traces from a
signal-handler to TTY.
Also:
- terse output printed empty lines if it could not find a symbol for an address; fixed by printing "(unknown)".
- added a dummy ##Crash## program to test colorization easily
Test Plan: n/a
Reviewed By: tudorb@fb.com
FB internal diff:
D1128303
Dario Russi [Tue, 14 Jan 2014 01:00:57 +0000 (17:00 -0800)]
fix AtomicHashMap race condition
Summary: AHM::find checks that the returned SimpleRetT index is >= numMapsAllocated_ but that value may have changed and find pick the first element in the next sub map. Use success instead.
@override-unit-failures
Test Plan: unit tests
Reviewed By: delong.j@fb.com
FB internal diff:
D1126684
Philip Pronin [Sun, 12 Jan 2014 22:37:26 +0000 (14:37 -0800)]
add FB_SINGLE_ARG macro
Test Plan: eyeballed it
@override-unit-failures
Reviewed By: soren@fb.com
FB internal diff:
D1125180
Sara Golemon [Mon, 6 Jan 2014 19:35:44 +0000 (11:35 -0800)]
Some fixes for folly-oss repo.
Summary:
The __builtin_ia32_crc[qd]i() functions are GCC >= 4.8 specific
folly-config.h includes must be wrapped in a FOLLY_NO_CONFIG guard
FOLLY_HAVE_WEAK_SYMBOLS needs to apply to the cpp file as well as the header
Closes #44
Closes #42
Test Plan: HHVM builds with recent folly
Reviewed By: seanc@fb.com
FB internal diff:
D1117181
Ajit Banerjee [Fri, 3 Jan 2014 00:30:59 +0000 (16:30 -0800)]
Fix cursor insert inconsistency
Summary:
The invariant after Cursor::insert is that the cursor points to the buffer
after the insert. That invariant was not followed in the branch where the
new buffer was just prepended. This change fixes the bug.
Test Plan:
Unit test modified, all tests run with
fbconfig -r folly && fbmake runtests_opt
Reviewed By: davejwatson@fb.com
FB internal diff:
D1114749
Nathan Bronson [Sun, 29 Dec 2013 05:35:56 +0000 (21:35 -0800)]
work around broken try_lock_for in gcc
Summary:
timed_mutex::try_lock_for is broken in gcc 4.8 (see
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54562), so this diff adds
a workaround using try_lock_until. The internal implementation of
try_lock_for converts to try_lock_until, but it uses the steady_clock
instead of the system_clock as its time base. In some gcc versions
these are the same clock so it works okay, but not in all.
Test Plan: unit tests
Reviewed By: delong.j@fb.com
FB internal diff:
D1108584
Peter Griess [Thu, 26 Dec 2013 21:32:41 +0000 (13:32 -0800)]
Remove FOLLY_NORETURN from definition.
Summary:
- Remove FOLLY_NORETURN from function definitions, which was causing
compilation errors on some platforms.
Test Plan: - Compile on Mac OS X with Clang
Reviewed By: tudorb@fb.com
FB internal diff:
D1111416
Brian Pane [Fri, 27 Dec 2013 02:06:44 +0000 (18:06 -0800)]
Add new CRC-32C checksum functions to folly
Summary:
* Added a new crc32c() function, with a portable implementation
and an optimized version for x86 with SSE4.2
Test Plan: New unit test included
Reviewed By: tudorb@fb.com
FB internal diff:
D1111515
Jim Meyering [Thu, 26 Dec 2013 18:44:10 +0000 (10:44 -0800)]
folly: avoid ASAN-detected new[] vs "delete" mismatch
Summary:
* folly/test/PackedSyncPtrTest.cpp: Avoid an operator new [] vs
operator delete mismatch.
Test Plan:
fbconfig --platform-all=gcc-4.8.1-glibc-2.17 --sanitize=address \
folly/test:packed_sync_ptr_test && fbmake runtests
Reviewed By: tudorb@fb.com
FB internal diff:
D1111227
Peter Griess [Fri, 20 Dec 2013 19:26:44 +0000 (11:26 -0800)]
Detect availability of cplus_demangle_v3_callback()
Summary:
- Add autoconf check for cplus_demangle_v3_callback() in libiberty and
avoid is usage when not available. Clang/libc++ on Mac OS X doesn't
support this.
Test Plan:
- fbconfig -r folly && fbmake runtests
- ./configure && make check on Mac OS X
Reviewed By: tudorb@fb.com
FB internal diff:
D1108543
Hitesh Khandelwal [Fri, 20 Dec 2013 22:02:39 +0000 (14:02 -0800)]
Revert "[Folly] Helper method to get exception type"
Summary: This reverts commit
2c4f8da739ba0294f2c947753a0e30fee291feb5.
Test Plan: Compiles
Reviewed By: tudorb@fb.com
FB internal diff:
D1108840
Hitesh Khandelwal [Fri, 20 Dec 2013 19:02:23 +0000 (11:02 -0800)]
Helper method to get exception type
Test Plan: Tested with subsequent thrift diff
Reviewed By: davejwatson@fb.com
FB internal diff:
D1108428
Peter Griess [Tue, 26 Nov 2013 20:12:14 +0000 (12:12 -0800)]
Handle lack of <bits/c++config.h> and <bits/functexcept.h>
Summary:
- Clang's libc++ doesn't provide these header files. Detect libc++ via
the _LIBCPP_VERSION symbol (pulling it in by sourcing some header files
earlier if necessary) and avoid using these files.
- This is another attempt at
D1074481.
Test Plan: .
Reviewed By: andrei.alexandrescu@fb.com
FB internal diff:
D1074723
Peter Griess [Tue, 26 Nov 2013 20:11:40 +0000 (12:11 -0800)]
Define weak r?allocm symbols in Malloc.h
Summary:
- This fixes a bug introduced in
D1002959 that broke -fb platform
compilation: there was noone to forward-declare these symbols.
Test Plan:
- Built the gcc-4.8.1-glibc-2.17-fb platform
- fbconfig -r folly && fbmake runtests
- configure/make check on Mac OS X
Reviewed By: andrei.alexandrescu@fb.com
FB internal diff:
D1074720
Blame Revision:
D1002959
Tudor Bosman [Wed, 18 Dec 2013 01:02:25 +0000 (17:02 -0800)]
Fix name handling when baseDir and subDir are both empty, simplify paths
Test Plan: fbconfig -r folly/experimental/symbolizer folly/experimental/exception_tracer && fbmake runtests_opt
Reviewed By: wez@fb.com
FB internal diff:
D1104426
Tudor Bosman [Thu, 19 Dec 2013 16:31:40 +0000 (08:31 -0800)]
Add startsWith, endsWith, removePrefix, removeSuffix to folly::Range
Summary:
Yes, I know about boost::starts_with, but I think the convenience is worth it.
Also, I've written then equivalent of removePrefix / removeSuffix way too
many times.
Test Plan: test added
Reviewed By: andrei.alexandrescu@fb.com
FB internal diff:
D1106425
Tudor Bosman [Tue, 17 Dec 2013 00:57:31 +0000 (16:57 -0800)]
unw_backtrace is not async-signal-safe
Summary:
Even though it should be according to the docs; tdep_trace allocates memory on
first use from each thread.
Wrote a slow loop that we can use from the signal handler. The exception tracer
still uses the fast version.
Test Plan: fbconfig -r folly/experimental/symbolizer folly/experimental/exception_tracer && fbmake runtests_opt
Reviewed By: philipp@fb.com
FB internal diff:
D1101095
Sarang Masti [Mon, 9 Dec 2013 23:08:02 +0000 (15:08 -0800)]
Add futexTimedWait
Summary:
Add futexTimedWait to Futex which allows callers to wait on the futex
for a specified max duration.
Test Plan: -- Ran all unitests
Reviewed By: ngbronson@fb.com
FB internal diff:
D1090115
Nathan Bronson [Thu, 19 Dec 2013 18:37:56 +0000 (10:37 -0800)]
AtomicStruct<T> provides atomic ops on small trivial classes
Summary:
AtomicStruct<T> acts like std::atomic<T>, but it supports any
trivial or trivially-copyable type up to 8 bytes in size. I'm not sure
why these types weren't included in the original std::atomic standard,
since this construct removes a lot of boilerplate for some uses of
std::atomic.
Test Plan:
1. unit tests
2. this code is adapted from production use in tao/queues/LifoSem
Reviewed By: davejwatson@fb.com
FB internal diff:
D1085106
Mark McDuff [Tue, 17 Dec 2013 03:07:42 +0000 (19:07 -0800)]
folly::json: allow skipping invalid UTF8
Summary:
folly::json::serialize by default doesn't check for valid UTF8, and as a result can generate invalid JSON. There is an option to check for valid UTF8, which throws on an error.
This diff introduces a new option, `skip_invalid`, which replaces invalid chars with U+FFFD. http://en.wikipedia.org/wiki/Specials_(Unicode_block) seems to suggest that this is the correct replacement.
@override-unit-failures
Test Plan: g-unittest
Reviewed By: delong.j@fb.com
FB internal diff:
D1102923
Andrew Gallagher [Tue, 10 Dec 2013 23:32:46 +0000 (15:32 -0800)]
folly/io:compression: add LZMA2 support
Summary:
Adds LZMA2 and LZMA2_VARINT_SIZE compression support for
folly::io::Compression. This format shows some big wins for
compressing ELF object files and is useful in our modified
ccache client.
Test Plan:
Compression unittests. Also, tested compressing object files built
in fbcode. On average, the compression percentage improved from
~16.5% to ~12%. But we save a lot more as object files get bigger,
which can help make bigger object files fit over fewer memcache
keys.
Reviewed By: njormrod@fb.com
FB internal diff:
D1092576
Tudor Bosman [Thu, 12 Dec 2013 23:08:05 +0000 (15:08 -0800)]
Fix test, also do not read from stack of another thread
Summary:
... even though Google's signal handler does it
(https://code.google.com/p/google-glog/source/browse/trunk/src/signalhandler.cc?r=16#235)
Assuming the existence of an invalid pthread_t is a lesser evil than reading
from another thread's stack, IMO.
Test Plan: folly/experimental/symbolizer/test
Reviewed By: simpkins@fb.com
FB internal diff:
D1096620
Alex Malyshev [Wed, 11 Dec 2013 22:29:33 +0000 (14:29 -0800)]
Don't forward declare ObjectMaker twice in dynamic
Summary: Makes clang nervous
@override-unit-failures
Test Plan: fbconfig -r folly && fbmake dbg succeeds
Reviewed By: delong.j@fb.com
FB internal diff:
D1094209
Adam Simpkins [Thu, 12 Dec 2013 21:46:01 +0000 (13:46 -0800)]
fix callPreviousSignalHandler()
Summary:
If a previous handler was found, the code was missing the step of
actually re-raising the handler after restoring the old handler.
Test Plan: Verified that our service actually exits after receiving SIGTERM.
Reviewed By: tudorb@fb.com
FB internal diff:
D1096360
Tudor Bosman [Tue, 10 Dec 2013 22:41:28 +0000 (14:41 -0800)]
Separate installFatalSignalCallbacks
Summary:
We want to install the signal handler first and then give users an opportunity
to add their callbacks.
Test Plan: built
Reviewed By: lucian@fb.com
FB internal diff:
D1092083
@override-unit-failures
Tudor Bosman [Tue, 10 Dec 2013 03:57:56 +0000 (19:57 -0800)]
Switch to folly symbolizer
Summary:
(not committing yet, but I want to trigger unittests)
The glog symbolizer that we use has a few bugs (abort()s on certain small
shared libraries) and doesn't allow us to distinguish between template
specializations and function overloads (which, given that our code is more
template-heavy than Google's, has in fact been an issue).
Luckily, we have our own in folly, which doesn't have these problems and also
supports mappings from address to file and line number.
Switch translateFrames (aka the fb303 call that cpprof uses) to our symbolizer.
Also, removed a lot of dead code in common/process.
Test Plan: common/process, tested cpprof by hand
Reviewed By: lucian@fb.com
FB internal diff:
D1090907
@override-unit-failures
Andrei Alexandrescu [Wed, 11 Dec 2013 15:43:27 +0000 (07:43 -0800)]
SCOPE_SUCCESS should be able to throw, the others shouldn't
Summary: SCOPE_SUCCESS may legitimately throw, so changed the `noexcept` attribute to a conditional one. Also added the noexcept promise to the lambdas in the hope the compiler will check code during compilation appropriately. (It currently doesn't.)
Test Plan: Added a unittest that failed, not passes.
Reviewed By: simpkins@fb.com
FB internal diff:
D1093328
@override-unit-failures
Nathan Bronson [Fri, 6 Dec 2013 00:48:13 +0000 (16:48 -0800)]
centralize cache-line alignment goo into CacheLocality
Summary:
The alignment requirements and details required to avoid false
sharing belong in CacheLocality, so this diff moves them there.
@override-unit-failures
Test Plan: fbmake runtests
Reviewed By: davejwatson@fb.com
FB internal diff:
D1086090
Nicholas Ormrod [Tue, 10 Dec 2013 22:14:00 +0000 (14:14 -0800)]
FBString iomanip fix.
Summary:
D1090936 noticed some problems with fbstring iomanip behavior.
The root cause is that os.write(ostream, char*, size_t) is an
UnformattedOutputFunction, so disregards setw(), setfill(), and
left/right alignment.
The use of os.write instead of os << str.data() is intentional:
D367009 switched from the latter to the former so that strings
containing a '\0' are printed properly.
There does not seem to be a public function to write with formatting.
Where needed in libgcc, the function __ostream_insert is used. Since
FBString already uses such 'private' functions, __ostream_insert is an
appropriate solution.
@override-unit-failures
Test Plan:
Added test cases to FBStringTest.cpp to cover iomanip.
fbconfig -r folly && fbmake opt && fbmake runtests_opt
Reviewed By: andrei.alexandrescu@fb.com
FB internal diff:
D1091474
Tudor Bosman [Fri, 6 Dec 2013 01:22:01 +0000 (17:22 -0800)]
Use fixed size stack traces; unify getStackTrace
Summary:
Also, switch to the simpler unw_backtrace(), which has the nice advantage of
actually doing IP adjustment (-1 in certain frames) correctly, unlike me :)
This is in preparation for the faster backtrace in libunwind 1.1.
Test Plan: folly/experimental/exception_tracer, folly/experimental/symbolizer, admarket/lib/util:memory_tracker_test
Reviewed By: lucian@fb.com
FB internal diff:
D1088357
Nathan Bronson [Fri, 22 Nov 2013 01:15:06 +0000 (17:15 -0800)]
detail/CacheLocality.h - utilities for dynamic cache optimizations
Summary:
CacheLocality reads cache sharing information from sysfs to
determine how CPUs should be grouped to minimize contention, Getcpu
provides fast access to the current CPU via __vdso_getcpu, and
AccessSpreader uses these two to optimally spread accesses among a
predetermined number of stripes.
AccessSpreader<>::current(n) microbenchmarks at 22 nanos, which is
substantially less than the cost of a cache miss. This means that we
can effectively use it to reduce cache line ping-pong on striped data
structures such as IndexedMemPool or statistics counters.
Because CacheLocality looks at all of the cache levels, it can be used for
different levels of optimization. AccessSpreader<>::stripeByChip.current()
uses as few stripes as possible to avoid off-chip communication,
AccessSpreader<>::stripeByCore.current() uses as many stripes as necessary
to get the optimal speedup, but no more.
@override-unit-failures
Test Plan: new unit tests
Reviewed By: davejwatson@fb.com
FB internal diff:
D1076718
Tudor Bosman [Thu, 5 Dec 2013 21:40:59 +0000 (13:40 -0800)]
Revert "Change exception tracer to use per-thread caching in libunwind"
Summary:
Per-thread caching calls malloc, which means it doesn't work for malloc's
profiling (and also it isn't async-signal-safe, despite the documentation).
Test Plan: compiled
Reviewed By: philipp@fb.com
FB internal diff:
D1085368
@override-unit-failures
Tudor Bosman [Tue, 3 Dec 2013 23:11:11 +0000 (15:11 -0800)]
Print (2 more) if stack trace truncated
Summary:
Also, C++ify the interface and switch to per-thread caching in libunwind as per
D1081259
Test Plan: folly/experimental/symbolizer/test
Reviewed By: lucian@fb.com
FB internal diff:
D1081272
bsimmers [Wed, 4 Dec 2013 21:58:07 +0000 (13:58 -0800)]
Fix asm constraints in folly::MicroSpinLock::cas
Summary:
If the compare part of cmpxchg fails, it writes the unexpected value
to %rax. At certain optimization levels this was causing me to hit an
incorrectly failed assertion in some thrift code. I also cleaned up the asm
statement to use named operands.
Test Plan: Added new test that fails before this diff.
Reviewed By: delong.j@fb.com
FB internal diff:
D1083222
@override-unit-failures
Adam Simpkins [Wed, 4 Dec 2013 02:38:07 +0000 (18:38 -0800)]
make IOBuf::gather() safe
Summary:
Update IOBuf::gather() and RWCursor::gather() to check their arguments
more carefully, and throw std::overflow_errors if the caller attempts to
gather more data than is available.
The comments for IOBuf::gather() claimed that it ensured that maxLength
bytes would always be available when it returned. However, if the total
chain length was less than maxLength, it would simply coalesce the full
chain and return successfully, even though fewer than maxLength bytes
were available. This fixes the code to throw a std::overflow_error
rather than coalescing the chain.
Additional, this updates RWCursor::gather() to ensure that it does not
attempt to gather past the end of the IOBuf chain. Previously it could
gather past the end of the chain, coalescing the head of the chain into
the tail. This would free the IOBuf head, which was owned by an
external caller.
A new RWCursor::gatherAtMost() API is provided for callers that wish to
gather as much as requested if possible, but still succeed if less than
this is available.
Test Plan:
Updated the unit tests to test calling gather() with more bytes than
actually available.
Reviewed By: davejwatson@fb.com
FB internal diff:
D1081995
Adam Simpkins [Wed, 4 Dec 2013 03:33:47 +0000 (19:33 -0800)]
fix issues when compiling with clang
Summary:
My previous change to re-implement IOBuf's internal storage mechanism
introduced a build failure when compiling with clang.
This fixes the new compilation error in IOBuf.cpp, as well as two
existing build failures in some of the unit tests.
Test Plan: Built the folly/io code with clang.
Reviewed By: andrewjcg@fb.com
FB internal diff:
D1082086
Adam Simpkins [Mon, 25 Nov 2013 00:02:11 +0000 (16:02 -0800)]
change the mechanism for "internal" buffer storage
Summary:
This removes kFlagExt, and instead implements the internal buffer
optimization using operator new and delete.
IOBuf::createCombined() will allocate a single buffer for the IOBuf,
SharedInfo, and the actual data itself. Each heap allocated IOBuf now
contains a set of flags indicating if the memory segment indicating when
it can actually be deleted. The delete operator won't actually free the
storage until both the IOBuf and the data buffer are unused (the
SharedInfo object always becomes unused at the same time as the data
buffer).
This has a couple advantages over the old mechanism:
- Other IOBufs can continue to use and share the data storage space even
after the original IOBuf associated with it is deleted. With the old
internal buffer mechanism, internal buffers could never be shared.
- This simplifies several parts of the code, since kFlagExt no longer
exists. Code that previously required special handling for internal
buffers no longer needs to be aware of them.
One downside is that this can result in wasted space in some cases if
the original IOBuf is changed to point at a different buffer, since the
space for the data buffer cannot be freed until the IOBuf itself is also
destroyed. The old internal buffer mechanism also had this problem,
which we mitigated simply by disallowing internal buffers for larger
than ~200 bytes. With the new mechanism we currently allocate an
internal buffer for up to 1024 bytes by default, but we also allow
callers to explicitly decide if they want an internal buffer or not.
Test Plan:
Added some new unit tests for the combined buffer behavior. Also ran
all of the existing IOBuf unit tests, with and without ASAN. (ASAN
performs additional memory checking, but also changes IOBuf's behavior
slightly as usingJEMalloc() is false with ASAN.)
Reviewed By: davejwatson@fb.com
FB internal diff:
D1072336
@override-unit-failures
Tudor Bosman [Tue, 3 Dec 2013 21:09:13 +0000 (13:09 -0800)]
Change exception tracer to use per-thread caching in libunwind
Summary: Because the global cache is slow and contends on locks.
Test Plan: testinproduction
Reviewed By: philipp@fb.com
FB internal diff:
D1081259
Soren Lassen [Tue, 3 Dec 2013 18:40:05 +0000 (10:40 -0800)]
Made File::release() return the released file descriptor.
Summary: It's convenient to get back the fd, similar to unique_ptr::release().
Test Plan: unittest
Reviewed By: tudorb@fb.com
FB internal diff:
D1080426
Tudor Bosman [Wed, 27 Nov 2013 16:58:51 +0000 (08:58 -0800)]
Async-signal-safe symbolizer, fatal signal handler
Test Plan: test added
Reviewed By: lucian@fb.com
FB internal diff:
D1076170
@override-unit-failures
Tudor Bosman [Wed, 27 Nov 2013 16:56:01 +0000 (08:56 -0800)]
Add async-signal-safe flavor of demangle
Summary: To be used in the new fatal signal handler.
Test Plan: test added
Reviewed By: lucian@fb.com
FB internal diff:
D1076169
@override-unit-failures
Tudor Bosman [Wed, 27 Nov 2013 16:54:52 +0000 (08:54 -0800)]
SafeAssert: async-signal-safe CHECK, DCHECK
Summary: To be used from the (new) fatal signal handler.
Test Plan: test added
Reviewed By: lucian@fb.com
FB internal diff:
D1076168
@override-unit-failures
Adam Simpkins [Mon, 25 Nov 2013 00:30:22 +0000 (16:30 -0800)]
update moveToFbString()'s handling of flags_
Summary:
Improve moveToFbString()'s code which determines if we actually have a
buffer that was allocated with malloc().
The old code simply checked if flags_ == kFlagExt. This check is rather
fragile, and relies on very specific behavior from the existing
construction methods. It also unnecessarily forced reallocation in some
cases.
This updates the code to have more specific checks for the flags and
fields that actually matter. In particular, even if we have an external
buffer, if sharedInfo->freeFn is set then it is not managed by malloc().
The old check happened to work because takeOwnership() was the only
function that set set freeFn, and it also set kFlagFreeSharedInfo.
This also improves the code so that it won't unnecessarily reallocate
the buffer if kFlagMaybeShared is set but the buffer isn't really
shared. The code will also no longer unnecessarily reallocates the
buffer just because kFlagFreeSharedInfo is set.
Test Plan:
Updated the moveToFbString() test to also test with buffers created
using takeOwnership() and wrapBuffer().
Reviewed By: davejwatson@fb.com
FB internal diff:
D1072304
@override-unit-failures
Adam Simpkins [Sun, 24 Nov 2013 23:46:46 +0000 (15:46 -0800)]
fix IOBuf::reserve() when operating on a user-supplied buffer
Summary:
The IOBuf::reserveSlow() code assumed that external buffers were always
allocated with malloc. This would cause problems when if reserve() was
ever used on a buffer created with IOBuf::takeOwnership().
This changes the code to now check if a user-specified free function has
been supplied. If so, then it does not try to use realloc()/rallocm(),
and it now frees the old buffer using the specified free function rather
than free().
User-supplied buffers also have a separately allocated SharedInfo
object, which must be freed when we no longer need it.
Test Plan:
Added additional unit tests to check calling reserve() on IOBufs created
with IOBuf::takeOwnership().
Reviewed By: davejwatson@fb.com
FB internal diff:
D1072292
Anton Likhtarov [Tue, 26 Nov 2013 02:26:29 +0000 (18:26 -0800)]
sort_keys option for json
Summary:
A dumb&slow implementation. I just needed something that outputs keys in a sorted order.
No easy to use API to discourage the use due to perf implications.
Test Plan: unit test
Reviewed By: delong.j@fb.com
FB internal diff:
D1073757
Brian Watling [Wed, 27 Nov 2013 21:31:51 +0000 (13:31 -0800)]
Trivial argument rename in MPMCQueue
Summary: Rename the 'capacity' argument so g++ will not complain when -Wshadow is enabled ('capacity' is also a method on MPMCQueue)
Test Plan: compiles, unit tests pass
Reviewed By: ngbronson@fb.com
FB internal diff:
D1076220
Soren Lassen [Sun, 24 Nov 2013 06:14:45 +0000 (22:14 -0800)]
Make FOR_EACH* work with temporary containers.
Test Plan: unittest
Reviewed By: tudorb@fb.com
FB internal diff:
D1071715
Adam Simpkins [Sun, 24 Nov 2013 23:07:33 +0000 (15:07 -0800)]
fix bugs in the cursor StringOperations test
Summary:
The IOBuf.StringOperations test contained two buggy tests. According to
the comments, they were intended to test a string spanning multiple
buffers. They created a chain of two buffers, but used Appender to
write the string, which only writes in the final buffer in the chain.
Additionally, the test didn't request enough space in the final buffer
for the string data, and didn't allow Appender to grow the buffer. (The
code also didn't check the return value from pushAtMost() to see if it
actually wrote all of the string data.) The test only passed because
IOBuf would normally allocate more capacity than the caller requested.
I fixed the tests to request sufficient capacity for the string data,
and use push() rather than pushAtMost() to ensure that all data was
written correctly. I also added two new tests which actually test with
strings spanning multiple buffers.
Test Plan:
Ran this test with some changes to IOBuf that cause it to only allocate
the requested capacity in some cases, and verified that the
StringOperations test pass now.
(The changes I was testing with use goodMallocSize() to determine the
allocation size even for small internal buffers. When not using
jemalloc, goodMallocSize() returns the original size, so it only
allocates the capacity requested by the caller.)
Reviewed By: pgriess@fb.com
FB internal diff:
D1072283
Peter Griess [Tue, 26 Nov 2013 17:51:52 +0000 (09:51 -0800)]
Revert "Handle lack of <bits/c++config.h> and <bits/functexcept.h>"
Summary:
- This diff introduces errors when compiling with clang in fbcode.
Revert until they get fixed.
Test Plan: .
Reviewed By: tconerly@fb.com
FB internal diff:
D1074481
Blame Revision:
D998595
Peter Griess [Wed, 20 Nov 2013 21:51:57 +0000 (13:51 -0800)]
Get Subprocess running for Mac OS X
Summary:
-
D1030008 added Subprocess to libfolly in automake builds. This
surfaced some ambient compilation errors that slipped through in my
prior run through porting this.
- Mac OS X uses a nonstandard location for wait.h
- Non-Linux platforms don't support prctl; gate that on Linux
Test Plan:
- fbmake runtests in fbcode
- make check on Mac OS X
Reviewed By: davejwatson@fb.com
FB internal diff:
D1066273
Blame Revision:
D1030008
Peter Griess [Wed, 20 Nov 2013 21:29:43 +0000 (13:29 -0800)]
Revert
D998590
Summary:
- It looks like Xcode 5.0.2 / clang 500.2.79 changed this behavior. The
prior behavior was seen against Xcode 5.0.1 / clang 500.2.75. Blerg.
If we really have to support different Xcode flavors we can come up
with a real solution for this, but for now just take advantage of the
fact that clang and gcc seem to agree on this.
Test Plan: - make check on Mac OS X
Reviewed By: andrei.alexandrescu@fb.com
FB internal diff:
D1066272
Blame Revision:
D998590
Peter Griess [Wed, 20 Nov 2013 21:36:57 +0000 (13:36 -0800)]
Remove generated .cpp files on 'make clean'
Summary:
- Add generated .cpp files to CLEANFILES so that they get swept up
during 'make clean' and friends
Test Plan: - autoreconf -i && ./configure && make check && make clean
Reviewed By: davejwatson@fb.com
FB internal diff:
D1066270
Peter Griess [Wed, 16 Oct 2013 19:43:02 +0000 (14:43 -0500)]
Fix broken clause11_21_4_6_6 test in Apple Clang.
Summary:
- Prior to this fix, the test relied upon begin() being evaluated after
the fbstring constructor (even thoug the order of evaluation of
function arguments is un-defined). When this assumption was violated,
begin() ended up with an iterator that was invalid since it points to
data internal to fbstring, and the fbstring copy constructor can end
up triggering re-allocation in the source.
Test Plan:
- fbconfig -r folly && fbmake runtests
- ./configure && make check on Ubuntu/FC/Mac
Reviewed By: andrei.alexandrescu@fb.com
FB internal diff:
D1014093
Peter Griess [Sat, 12 Oct 2013 11:11:59 +0000 (04:11 -0700)]
Handle platforms that don't support __thread.
Summary:
- Apple platforms either have different __thread behavior than Linux: on
i386 __thread values are zeroed out before the destructor provided to
pthread_key_create(3) is called; on ARM, __thread isn't supported at
all. To handle this, use pthread_getspecific(3) to manage the array of
IDs on these platforms only.
Test Plan:
- fbconfig -r folly && fbmake runtests
- ./configure && make check on Ubuntu/FC/Mac
Reviewed By: simpkins@fb.com
FB internal diff:
D1008923
Peter Griess [Mon, 23 Sep 2013 23:25:18 +0000 (18:25 -0500)]
Handle lack of weak symbols on some platforms
Summary:
- It turns out that it's not always desirable to perform runtime
resolution of weak symbols. For example, on iOS, weak symbols are
resolved at runtime only if *all* symbol resolution is deferred util
then, which is undesirable for othe reasons. Detect such platforms at
configure time and use that information to populate detail/Malloc.h
with the correct declarations: weak symbols or extern symbols with
a value of nullptr.
Test Plan:
- fbconfig -r folly && fbmake runtests
- ./configure && make check on Ubuntu/FC/Mac
Reviewed By: andrei.alexandrescu@fb.com
FB internal diff:
D1002959
Peter Griess [Wed, 25 Sep 2013 23:49:10 +0000 (18:49 -0500)]
Handle lack of <bits/c++config.h> and <bits/functexcept.h>
Summary:
- Clang's libc++ doesn't provide these header files. Detect libc++ via
the _LIBCPP_VERSION symbol (pulling it in by sourcing some header
files earlier if necessary) and avoid using these files.
Test Plan:
- fbconfig -r folly && fbmake runtests
- ./configure && make check on Ubuntu/FC/Mac
Reviewed By: andrewjcg@fb.com
FB internal diff:
D998595
Ben Maurer [Mon, 25 Nov 2013 19:28:40 +0000 (11:28 -0800)]
Avoid copy in folly::toJson
Summary: Adding const avoids a copy constuctor.
Test Plan:
Unit tests, new benchmark:
toJson 1.83us 546.15K
toJson 1.54us 649.98K
Reviewed By: tudorb@fb.com
FB internal diff:
D1071781
Stephen Chen [Thu, 21 Nov 2013 07:19:55 +0000 (23:19 -0800)]
fix broken clang build: add missing template keyword
Summary: Broken in
D1054291
Test Plan: build adpublisher in clang mode which was one of the two projects that failed to build.
Reviewed By: bmaurer@fb.com
FB internal diff:
D1067652
@override-unit-failures
Stephen Chen [Mon, 11 Nov 2013 21:32:34 +0000 (13:32 -0800)]
Port TimeseriesHistogram from common/stats to folly
Summary:
Port TimeseriesHistogram from common/stats to folly. Similarly to
MultiLevelTimeSeries and Histogram classes we've converted before.
Test Plan:
Ported the old unittest for TimeseriesHistogram from common/stats to
folly/test. The same unittest is left in tact and is still passing as well. Ran
all tests in folly/test and common/stats
Reviewed By: simpkins@fb.com
FB internal diff:
D1054291
Dave Watson [Tue, 19 Nov 2013 00:33:21 +0000 (16:33 -0800)]
Add generated files to Makefile.am
Summary: Missed these on the first pass because they're generated
Test Plan: Built open source folly, links
Reviewed By: pgriess@fb.com
FB internal diff:
D1062451
Tudor Bosman [Mon, 18 Nov 2013 18:42:02 +0000 (10:42 -0800)]
Improve CompressionTest
Summary: Test compressing low-entropy (constant) data as well.
Test Plan: ran it
Reviewed By: tuomas.pelkonen@fb.com
FB internal diff:
D1061444
@override-unit-failures
Tudor Bosman [Wed, 13 Nov 2013 23:01:33 +0000 (15:01 -0800)]
Fix bad implementation of fnv32
Summary: See https://www.facebook.com/groups/fbcode/permalink/
601496126553897/
Test Plan: contbuild
Reviewed By: ldbrandy@fb.com
FB internal diff:
D1055852
@override-unit-failures
some hphp_dbg tests postponed for 1.5 days, all other hphp tests
(including some hphp_dbg ones) are passing
Tom Jackson [Thu, 14 Nov 2013 23:41:09 +0000 (15:41 -0800)]
Move byLine to FileGen.h, add explanatory note
Summary: There's a bit of a gotcha here, let's provide at least a note on this.
Test Plan: Unit tests
Reviewed By: tudorb@fb.com
FB internal diff:
D1058244
Daniel Marinescu [Thu, 14 Nov 2013 04:41:24 +0000 (20:41 -0800)]
Added SCOPE_FAIL and SCOPE_SUCCESS macros in non-portable C++.
Summary:
Added SCOPE_FAIL and SCOPE_SUCCESS macros in non-portable C++. The macros are similar to D's scope(failure) and scope(success).
Currently the supported platforms are GCC and MSVC. For all others, std::uncaught_exception() is used, which will fail if the macros are used in a destructor called during stack unwinding.
@override-unit-failures
Test Plan:
1. Added new unit test to ScopeGuardTest.cpp.
2. Ran fbconfig -r folly && fbmake dbg
3. Ran _build/dbg/folly/test/scope_guard_test to make sure my unit test was running and passing.
Reviewed By: andrei.alexandrescu@fb.com
FB internal diff:
D1033621
Yasser Ganjisaffar [Mon, 11 Nov 2013 18:03:16 +0000 (10:03 -0800)]
Add missing files to Makefile headers
Summary:
This two header files are missing from the Makefile which make the
open source version broken.
Test Plan: code using open source version compiles
Reviewed By: meyering@fb.com
FB internal diff:
D1050326
Tudor Bosman [Tue, 29 Oct 2013 19:00:50 +0000 (12:00 -0700)]
Add Formatter::writeTo(FILE*)
Summary: Because I needed it.
Test Plan: test added
Reviewed By: delong.j@fb.com
FB internal diff:
D1032179
denisspb [Wed, 30 Oct 2013 17:27:00 +0000 (10:27 -0700)]
Update Overview.md
Summary: just added few words about Subprocess.
Reviewed By: delong.j@fb.com
Test Plan: none
Avani Nandini [Tue, 29 Oct 2013 07:11:49 +0000 (00:11 -0700)]
make move-ctor and destructor noexcept for folly::Optional
Summary:
as per summary
@override-unit-failures
Test Plan: run unit tests
Reviewed By: delong.j@fb.com
FB internal diff:
D1031726
Alex Landau [Tue, 29 Oct 2013 21:06:18 +0000 (14:06 -0700)]
Fix passing MoveWrapper into lambdas
Summary:
GCC can't compile code that passes a MoveWrapper into a lambda
in some cases. For example if the capture list has
[someConstObject, myMoveWrapper], gcc 4.7 fails. This specific case
works with gcc 4.8, but other cases (e.g. [this, myMoveWrapper]) still
fail.
This diff is a hack that makes code like that compile. It can be
removed, along with MoveWrapper itself once we move to C++14 with its
extended lambda syntax.
Test Plan: fbmake
Reviewed By: hans@fb.com
FB internal diff:
D1032585
Dave Watson [Sat, 26 Oct 2013 20:13:26 +0000 (13:13 -0700)]
updating folly makefiles
Summary:
Update Makefile.am with recent files.
Leaves out io/Compression because it uses lz4, of which there are no prebuilt packages for ubuntu (didn't check fedora, but I assume it is the same story there)
Test Plan: on ubuntu 12.10, ./configure, make, make install
Reviewed By: tudorb@fb.com
FB internal diff:
D1030008
Dave Watson [Fri, 25 Oct 2013 19:35:25 +0000 (12:35 -0700)]
move MoveWrapper to folly
Summary: Add MoveWrapper to folly.
@override-unit-failures
Test Plan: arc unit
Reviewed By: hans@fb.com
FB internal diff:
D1030005
Sara Golemon [Fri, 25 Oct 2013 20:57:53 +0000 (13:57 -0700)]
Add missing define guard for folly-config.h
Summary:
Other inclusions of folly-config.h watch for this.
It must have been missed when this file was added.
Test Plan: Fixes Mac OSX build.
Reviewed By: seanc@fb.com
FB internal diff:
D1028354
Sara Golemon [Thu, 24 Oct 2013 21:40:22 +0000 (14:40 -0700)]
Add missing include
Summary:
MemoryMapping.cpp uses DEFINE_int64() from gflags,
but doesn't include it anywhere.
@override-unit-failures
Test Plan: OSS build failure goes away
Reviewed By: seanc@fb.com
FB internal diff:
D1026364
Andrey Goder [Mon, 21 Oct 2013 22:48:26 +0000 (15:48 -0700)]
fix typo in comment
Summary: Pretty sure it was meant to be this way...
@override-unit-failures
Test Plan: n/a
Reviewed By: tudorb@fb.com
FB internal diff:
D1020789
Philip Pronin [Thu, 17 Oct 2013 03:13:33 +0000 (20:13 -0700)]
exponential capacity growth for io::TypedIOBuf
Summary:
Amortized cost of `TypedIOBuf::push()` is `O(N)` at this moment.
Unless we're using jemalloc where we can rely on `realloc()`. In this
diff we switch to exponential growth otherwise.
Test Plan:
built unicorn/test with ASan (and thus without jemalloc), ran
end-to-end tests and verified we no longer spend minutes to build di4
@override-unit-failures
Reviewed By: tudorb@fb.com
FB internal diff:
D1015233
Philip Pronin [Wed, 16 Oct 2013 07:01:53 +0000 (00:01 -0700)]
avoid using ifunc + ASan
Summary:
Code that is using ifunc dies with SIGSEGV on startup when used
with ASan.
Here is gdb output: {P2882504}
Seems like `ifunc` dispatch is happening before ASan is initialized,
but ASan instrumentation logic being called from there.
Test Plan:
built affected unicorn binaries with ASan, ran them, verified
there is no more SIGSEGV
Reviewed By: meyering@fb.com
FB internal diff:
D1013420
Rajat Goel [Wed, 16 Oct 2013 00:25:36 +0000 (17:25 -0700)]
Issue with find and npos
Summary:
I dont know whats the expected behavior but for std::string it seems
to work.
@override-unit-failures
Test Plan:
unit-tests
[ RUN ] FBString.findWithNpos
folly/test/FBStringTest.cpp:1147: Failure
Value of: fbstr.find(":", fbstring::npos)
Actual: 9
Expected: fbstring::npos
Which is:
18446744073709551615
Reviewed By: andrei.alexandrescu@fb.com
FB internal diff:
D1012870
Nicholas Ormrod [Wed, 16 Oct 2013 00:02:24 +0000 (17:02 -0700)]
Change FBString's #define throw
Summary:
Instead of defining throw to nothing, define it to something
which creates a grepable error message (re @tudorb in
D1005889).
@override-unit-failures
Test Plan:
fbconfig -r folly
fbmake dbg && fbmake runtests && fbmake opt && fbmake runtests_opt
All tests passing.
Added throw to a few places in FBString; noticed that error messages
were produced, and that they contained the defined text. Those changes
not committed.
Reviewed By: tudorb@fb.com
FB internal diff:
D1011963
Philip Pronin [Tue, 15 Oct 2013 21:39:44 +0000 (14:39 -0700)]
fix a few bugs in FBString
Summary:
* `push_back()` fails for medium strings of zero capacity if not linked
with jemalloc (see added test),
* we incorrectly initiliaze capacity when acquire mallocated string
(forgot about null terminator).
Test Plan: fbconfig --allocator=malloc folly/test:fbstring_test_using_jemalloc && fbmake runtests_opt
@override-unit-failures
Reviewed By: tudorb@fb.com
FB internal diff:
D1012196
Jim Meyering [Tue, 15 Oct 2013 17:23:46 +0000 (10:23 -0700)]
folly, tao: don't impose C constraints on folly's Portability.h
Summary:
* folly/Portability.h: Move the definitions that Tao uses
into a new file, and include that new file here.
* folly/AddressSanitizer.h: New file.
* tao/server/config.h: Include that small new file, rather
than all of folly's Portability.h
Test Plan:
fbconfig -r tao/server &&
tao/server/tests/run_unit_tests.sh -d --save-log=log
For folly, watch the arc-run tests.
Reviewed By: pgriess@fb.com
FB internal diff:
D1011800
@override-unit-failures
Sathya Gunasekar [Tue, 15 Oct 2013 02:50:20 +0000 (19:50 -0700)]
Include cpp only when needed
Summary:
D1008921 broke compilation for tao which uses folly/Portability.h
This diff guards the change for only c++ code. Not sure if this breaks the
definition of portability.
Test Plan: Compile tao, fbconfig -r folly and fbmake runtests
Reviewed By: simpkins@fb.com
FB internal diff:
D1010967
@override-unit-failures
Peter Griess [Sat, 12 Oct 2013 12:12:57 +0000 (05:12 -0700)]
Remove trailing comma in configure.ac.
Summary:
- We were inadvertantly emitting a superfluous comma when generating the
configure script, causing it warn on execution. This was caused by
separating two AC_DEFINE() invocations w/ a comma.
Test Plan:
- fbconfig -r folly && fbmake runtests
- ./configure && make check on Ubuntu/FC/Mac
Reviewed By: meyering@fb.com
FB internal diff:
D1008924
Peter Griess [Thu, 10 Oct 2013 17:51:28 +0000 (10:51 -0700)]
Remove check that depends on malloc implementation.
Summary:
- The EXPECT_EQ(vec.capacity(), vec2.capacity()) check is implicitly
testing how the platform's malloc() and malloc_usable_size()
implementations interact. We know that small_vector will attempt to
allocate storage for 3 elements via malloc(), but the small_vector
implementation then uses malloc_usable_size() to determine capacity,
which can return more than the size requested by malloc(). As a
result, capacity may grow more than expected depending on how the
malloc implementation works.
Test Plan:
- fbconfig -r folly && fbmake runtests
- ./configure && make check on Ubuntu/FC/Mac
Reviewed By: alandau@fb.com
FB internal diff:
D1008922
Peter Griess [Thu, 10 Oct 2013 17:12:00 +0000 (10:12 -0700)]
Detect and use std::is_trivially_copyable<T> where possible.
Summary:
- Sadly, boost::has_trivial_copy<T> is not a suitable replacement for
std::is_trivially_copyable<T> on libc++. Fortunately, the latter is
actually supported (and works), so use it directly.
Test Plan:
- fbconfig -r folly && fbmake runtests
- ./configure && make check on Ubuntu/FC/Mac
Reviewed By: delong.j@fb.com
FB internal diff:
D1008921
Peter Griess [Wed, 9 Oct 2013 08:24:28 +0000 (01:24 -0700)]
Only run FBString.testConstructionFromLiteralZero under GNU libstdc++
Summary:
- This test verifies the behavior of std::string(0), which the GNU
library expects to throw an std::logic_error. Other libraries may have
other behaviors; libc++ segfaults.
Test Plan:
- fbconfig -r folly && fbmake runtests
- ./configure && make check on Ubuntu/FC/Mac
Reviewed By: simpkins@fb.com
FB internal diff:
D1003125
Peter Griess [Wed, 9 Oct 2013 18:50:05 +0000 (11:50 -0700)]
Set -std=XXX flags earlier; use in AC_COMPILE_IFELSE()
Summary:
- We had a bug where AC_COMPILE_IFELSE() invocations weren't using the
same -std=XXX flags that we're using in our actual build. This
happened because we made these checks before figuring out which
flag to use.
- Stop setting -std=XXX flags in CPPFLAGS. It's only useful for
CFLAGS/CXXFLAGS.
Test Plan:
- fbconfig -r folly && fbmake runtests
- ./configure && make check on Ubuntu/FC/Mac
Reviewed By: meyering@fb.com
FB internal diff:
D1003972
Peter Griess [Wed, 9 Oct 2013 06:01:34 +0000 (23:01 -0700)]
Detect C++ implementations that support constexpr strlen()
Summary:
- Only declare the Range constructor as a constexpr if strlen() is also
a constexpr. Otherwise, we'll get compilation errors.
Test Plan:
- fbconfig -r folly && fbmake runtests
- ./configure && make check on Ubuntu/FC/Mac
Reviewed By: soren@fb.com
FB internal diff:
D1003124
Peter Griess [Wed, 9 Oct 2013 03:57:32 +0000 (20:57 -0700)]
Check for std::this_thread::sleep_for.
Summary:
- Some installations of libstdc++ don't have this defined. This happens
if they were built without --enable-libstdcxx-time. Detect this and
avoid tests that rely on this behavior.
Test Plan:
- fbconfig -r folly && fbmake runtests
- ./configure && make check on Ubuntu/FC/Mac
Reviewed By: meyering@fb.com
FB internal diff:
D1002963
Peter Griess [Tue, 8 Oct 2013 23:57:39 +0000 (16:57 -0700)]
Detect libc++ in configure.ac.
Summary:
- Explicitly detect use of libc++ in configure.ac and reflect this in
folly-config.h. Do this rather than looking for to pop up organically
_LIBCPP_VERSION since this only exists if we've included some libc++
header files prior to refernce. This isn't always the case, e.g. in
Portability.h.
Test Plan:
- fbconfig -r folly && fbmake runtests
- ./configure && make check on Ubuntu/FC/Mac
Reviewed By: simpkins@fb.com
FB internal diff:
D1002958