android_system_core/libutils/include/utils
Hans Boehm 6e75ad6e13 Revert "Revert "Fix wp and sp comparison bugs""
Fix wp and sp comparison bugs

Make clear() actually clear wp m_refs, so that nulls compare equal.

Make equality consistent with < and >, ensuring that a weak pointer
cannot be both equal to and greater than another.

Don't rely on the built-in < and > operators to correctly order
different objects. The standard does not guarantee that, and there is
a risk of compiler relying on that lack of guarantee.

Remove unnecessary comparison overloads, especially those
comparing a wp<> to an sp<>.

Change the remaining wp<> to sp<> comparisons to check for equivalence
of the mRefs pointer instead of the object address, thus eliminating
the dubious equal comparison result for a dead wp<> and an sp<> that
happen to point to the same object address.

Add comparison tests.

This reverts commit a2a2ad8057.

The original code, and my original CL, both failed to initialize m_refs
in various wp<> constructors. This now became more important, since
comparisons now rely more on m_refs. However I believe it was always
a bug, since some comparisons always relied on m_refs.

Test: Treehugger, boot AOSP, atest RefBase
Bug: 126922090
This reverts commit a2a2ad8057.

Reason for revert: Reapply after constructor fixes.

Change-Id: I2c8917416a2306e36d2b6bb7b397f653020e5688
2019-03-13 13:26:35 -07:00
..
AndroidThreads.h Modernize codebase by replacing NULL with nullptr 2018-07-13 15:28:59 -07:00
Atomic.h
BitSet.h
ByteOrder.h
CallStack.h CallStack: include prefix/tag when unlinked 2019-01-03 10:17:07 -08:00
Compat.h
Condition.h [libutils] Modernize codebase by replacing NULL with nullptr 2018-07-16 18:11:34 -07:00
Debug.h
Endian.h
Errors.h "utils/Errors.h": include <stdint.h> for `int32_t`. 2018-10-16 13:17:15 -07:00
FastStrcmp.h
FileMap.h Add noexcept to move constructors and assignment operators. 2018-10-05 16:43:47 +00:00
Flattenable.h Move system/core/ off NO_ERROR. 2018-10-08 11:15:52 -07:00
Functor.h Move system/core/ off NO_ERROR. 2018-10-08 11:15:52 -07:00
JenkinsHash.h
KeyedVector.h
LightRefBase.h
List.h
Log.h
Looper.h libutils: switch Looper's fds to unique_fd. 2018-07-18 18:12:12 -07:00
LruCache.h [libutils] Modernize codebase by replacing NULL with nullptr 2018-07-16 18:11:34 -07:00
Mutex.h Modernize codebase by replacing NULL with nullptr 2018-07-13 15:28:59 -07:00
NativeHandle.h
Printer.h [libutils] Modernize codebase by replacing NULL with nullptr 2018-07-16 18:11:34 -07:00
ProcessCallStack.h [libutils] Modernize codebase by replacing NULL with nullptr 2018-07-16 18:11:34 -07:00
PropertyMap.h
RWLock.h Modernize codebase by replacing NULL with nullptr 2018-07-13 15:28:59 -07:00
RefBase.h Revert "Revert "Fix wp and sp comparison bugs"" 2019-03-13 13:26:35 -07:00
Singleton.h Modernize codebase by replacing NULL with nullptr 2018-07-13 15:28:59 -07:00
SortedVector.h
StopWatch.h
String8.h Modernize codebase by replacing NULL with nullptr 2018-07-13 15:28:59 -07:00
String16.h
StrongPointer.h Revert "Revert "Fix wp and sp comparison bugs"" 2019-03-13 13:26:35 -07:00
SystemClock.h
Thread.h Suppress lint warnings on google-default-arguments 2018-10-29 23:06:23 +09:00
ThreadDefs.h
Timers.h
Tokenizer.h Move system/core/ off NO_ERROR. 2018-10-08 11:15:52 -07:00
Trace.h
TypeHelpers.h
Unicode.h Remove dead code. 2019-01-24 13:07:18 -08:00
Vector.h
VectorImpl.h Modernize codebase by replacing NULL with nullptr 2018-07-13 15:28:59 -07:00
misc.h
threads.h