summaryrefslogtreecommitdiffstats
path: root/include/utils
Commit message (Collapse)AuthorAgeFilesLines
* Exporting C++ headers from system/coreVijay Venkatraman2017-01-2448-7637/+1
| | | | | | | | | | | | | | | | | | | | | | Moved headers from include/libutils and include/libsysutils to libutils/include and libsysutils/include respectively, so they can be exported via these libs. They needed to be moved since Soong does not allow export from external folder. Added symlink from old locations. They are needed since Soong includes system/core/include by default. Once all modules are cleaned up to explicitly add the required libs, the symlinks will be removed. Moved headers of libutils to libutils_headers. They should be used by modules for header-only inlines. Added libutils_headers as dependency of libutils. Split of C++ headers into those that have no dependency and those that have dependency on libutils.so will be handled in a later CL. Test: Add above libs to shared lib of local module Change-Id: I122db72056b26b1f39bad1d9a0c2a1c5efda3550
* liblog: use log/log.h for ALOG macrosMark Salyzyn2017-01-121-1/+1
| | | | | | Test: compile Bug: 34250038 Change-Id: I0f56c563871f377c03380498cd867b916892f1dc
* libutils: allow multiple ATRACE_NAMEs in a scope.Josh Gao2016-12-121-4/+4
| | | | | | Bug: http://b/31289465 Test: m Change-Id: Iabd97439fa55ea285ce0501dbb4fd9d07149ae61
* utils: Add FastStrcmp.hMark Salyzyn2016-12-091-0/+54
| | | | | | | | | | Move existing fast<str*cmp> templates for general use, pulled from the implementation used in logd that dealt with speed through cache locality and subroutine call mitigation. Rename to fastcmp. Test: logd-benchmarks and based on manual profiling from the past Bug: 31456426 Change-Id: Ic62f4a437fc3e06ffdeaae73a6f34e197957a6b0
* Merge "system/core: preparation to pull back interfaces from android/log.h"Mark Salyzyn2016-10-203-3/+3
|\ | | | | | | | | | | am: 27d2d49f48 Change-Id: I604bb1d4cf62636663fa92e3d14a55887dbcae23
| * system/core: preparation to pull back interfaces from android/log.hMark Salyzyn2016-10-203-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Point to log/log.h where necessary, define LOG_TAG where necessary. Accept that private/android_logger.h is suitable replacement for log/logger.h and android/log.h. Correct liblog/README Effectively a cleanup and controlled select revert of 'system/core: drop or replace log/logger.h' and 'system/core: Replace log/log.h with android/log.h'. Test: compile Bug: 30465923 Change-Id: Ic2ad157bad6f5efe2c6af293a73bb753300b17a2
* | system/core Replace cutils/log.h with android/log.h am: 66ce3e08c5 am: ↵Mark Salyzyn2016-09-304-10/+9
|\| | | | | | | | | | | | | | | eb189f147b am: 16f7786032 Change-Id: I26939d55686b6182c9fae5fc74f3e7ed92132cdb
| * system/core Replace cutils/log.h with android/log.hMark Salyzyn2016-09-304-10/+9
| | | | | | | | | | | | | | | | | | | | | | Should use android/log.h instead of cutils/log.h as a good example to all others. Adjust header order to comply with Android Coding standards. Test: Compile Bug: 26552300 Bug: 31289077 Change-Id: I2c9cbbbd64d8dccf2d44356361d9742e4a9b9031
* | Merge "Fix more system/core/include warnings" am: 18fbd80504 am: 5fe194a9fdColin Cross2016-09-295-21/+38
|\| | | | | | | | | | | am: b5ca47989c Change-Id: I8d5a602f94bc57866aa3827cc508c94afb4ac4ba
| * Fix more system/core/include warningsColin Cross2016-09-275-21/+38
| | | | | | | | | | | | | | | | | | The warnings in these files were hidden by -isystem framework/native/include. Bug: 31752268 Test: m -j Change-Id: I2a54376aea380ee24e6483fb7d35fdfe8991c490
* | Merge "Flattenable: switch from assignment to memcpy()." am: b2356a6993 am: ↵David Pursell2016-09-231-2/+9
|\| | | | | | | | | | | | | | | bb276d8555 am: 9f106bece8 Change-Id: I43e4e5c6bb0aa1fd23a1d0d9776c9e2c8028527e
| * Merge "Flattenable: switch from assignment to memcpy()."David Pursell2016-09-231-2/+9
| |\
| | * Flattenable: switch from assignment to memcpy().David Pursell2016-09-231-2/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | FlattenableUtils read() and write() currently use assignment to copy bytes. However, by casting the void* buffer to type T, the compiler is allowed to assume that buffer obeys the alignment requirements of T, which is not necessarily the case during serialization. On some architectures, we can get SIGBUS when this alignment is violated. We don't want the users of these routines to have to worry about alignment when packing structures, so use memcpy() instead which should always be safe since the compiler won't assume any alignment for the void* buffer. On architectures that can handle unaligned direct read/write of type T, the compiler should be smart enough to optimize this code back to a direct read/write anyway, but architectures that can't handle it will fall back to memcpy; this means that this change shouldn't have any impact on current Android devices. See the linked bug for more details. Bug: http://b/31671510 Test: libgui Sensor serialization no longer gives SIGBUS. Test: libgui.so unchanged on Shamu before and after this CL. Change-Id: I2197127e8cbfb43f4f553bda6464f6ebe087febd
* | | Merge "Fix warnings in libutils headers" am: 65a1633ec3 am: 0f79b62bf6Colin Cross2016-09-2211-82/+104
|\| | | | | | | | | | | | | | | | | am: 1446cbac58 Change-Id: I94a39bb24224218ef1c48080ace3455c1fc7233a
| * | Fix warnings in libutils headersColin Cross2016-09-2211-82/+104
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | system/core/include is included in the global include path using -isystem, which hides all warnings. Fix warnings in libutils headers in preparation for moving from -isystem to -I. - Fix implicit cast from int64_t to long in Condition.h. Remove the __LP64__ check and always compare against LONG_MAX before casting. - Fix implicit cast from size_t to ssize_t in KeyedVector.h - Fix -Wshadow-field-in-constructor warnings in Looper.h and RefBase.h - Move destructors for MessageHandler and LooperCallback to Looper.cpp and ReferenceRenamer and VirtualLightRefBase to RefBase.cpp to prevent vtables in every compilation unit. - Declare template variables in Singleton.h - Fix old-style casts in StrongPointer.h and TypeHelpers.h - Use template metaprogramming in TypeHelpers.h to avoid warnings on memmove on non-trivial types. - Add an assignment operator to key_value_pair_t to complete rule-of-three - Use memcpy instead of dereferencing a reinterpret_casted pointer to treat the bits of a float or double as int32_t or int64_t - Escape unicode sequences inside doxygen comments between \code and \endcode - Remove WIN32 ZD definition in Compat.h, %zd works fine with mingw - Fix WIN32 printf warnings in Filemap.cpp - Initialize mNullValue with 0 in LruCache.h, some of the tests use a non-pointer type for TValue. Test: m -j native Bug: 31492149 Change-Id: I385a05a3ca01258e44fe3b37ef77e4aaff547b26
* | | Merge "Remove has_trivial_move trait from Vector<T>" am: 588b3b0c03 am: ↵Colin Cross2016-09-223-15/+0
|\| | | | | | | | | | | | | | | | | | | | | | | 85942090f6 am: 749181c10b Change-Id: Ie339e0ea27463d0c5b093e9a5e262367d1ca57a5
| * | Remove has_trivial_move trait from Vector<T>Colin Cross2016-09-223-15/+0
| |/ | | | | | | | | | | | | | | | | | | | | Vector<T> objects are a dynamic type with a vtable, which is not trivially moveable. Impact on aapt for frameworks-res is negligible, ~3%. Bug: 31595853 Test: m -j framework-res Change-Id: I8a3269c35d95affb6e86d60588bcfca46db7f445
* | Merge changes from topic 'utf' am: 3a07e5bf94 am: aa7fd8a3ecMartijn Coenen2016-08-251-24/+27
|\| | | | | | | | | | | am: ade3876260 Change-Id: Ifec806c7553b36a6502a8b5bb3dec559c117f4cc
| * libutils/Unicode.cpp: Correct length computation and add checks for utf16->utf8Sergio Giro2016-08-251-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | Inconsistent behaviour between utf16_to_utf8 and utf16_to_utf8_length is causing a heap overflow. Correcting the length computation and adding bound checks to the conversion functions. Test: ran libutils_tests Bug: 29250543 Change-Id: I6115e3357141ed245c63c6eb25fc0fd0a9a7a2bb (cherry picked from commit c4966a363e46d2e1074d1a365e232af0dcedd6a1)
| * Unicode: specify destination length in utf8_to_utf16 methodsSergio Giro2016-08-251-24/+27
| | | | | | | | | | | | | | | | | | | | String16(const char *utf8) now returns the empty string in case a string ends halfway throw a utf8 character. Bug: 29267949 Clean cherry-pick from 1dcc0c82394ec9cd6887c7ca39f9b5024db01ac9 Change-Id: I5223caa7d42f4582a982609a898a02043265c6d3
* | Merge "Make RefBase more robust and debuggable" am: daac359be7 am: 7bf3d21fdeHans Boehm2016-08-241-12/+25
|\ \ | | | | | | | | | | | | | | | am: 7dddf9433c Change-Id: Ia8bdef250b29d964a9ab07c450da31a368bb3143
| * | Merge "Make RefBase more robust and debuggable" am: daac359be7Hans Boehm2016-08-241-12/+25
| |\| | | | | | | | | | | | | | | | am: 7bf3d21fde Change-Id: I643c4bd38062b80d382c50ed161f5440f35c1dd9
| | * Merge "Make RefBase more robust and debuggable"Hans Boehm2016-08-241-12/+25
| | |\
| | | * Make RefBase more robust and debuggableHans Boehm2016-08-131-12/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This prevents two different kinds of client errors from causing undetected memory corruption, and helps with the detection of others: 1. We no longer deallocate objects when the weak count goes to zero and there have been no strong references. This otherwise causes us to return a garbage object from a constructor if the constructor allocates and deallocates a weak pointer to this. And we do know that clients allocate such weak pointers in constructors and their lifetime is hard to trace. 2. We abort if a RefBase object is explicitly destroyed while the weak count is nonzero. Otherwise a subsequent decrement would cause a write to potentially reallocated memory. 3. We check counter values returned by atomic decrements for plausibility, and fail immediately if they are not plausible. We unconditionally log any cases in which 1 changes behavior from before. We abort in cases in which 2 changes behavior, since those reflect clear bugs. In case 1, a log message now indicates a possible leak. We have not seen such a message in practice. The third point introduces a small amount of overhead into the reference count decrement path. But this should be negligible compared to the actual decrement cost. Add a test for promote/attemptIncStrong that tries to check for both (1) above and concurrent operation of attemptIncStrong. Add some additional warnings and explanations to the RefBase documentation. Bug: 30503444 Bug: 30292291 Bug: 30292538 Change-Id: Ida92b9a2e247f543a948a75d221fbc0038dea66c
* | | | Fix Mutex::timedLock to properly handle relative time am: 604ba48220 am: ↵Andy Hung2016-08-241-2/+8
|\ \ \ \ | |/ / / |/| | | | | | | | | | | | | | | | | | | | | | | 708b9d118a am: 47e5ca61e2 Change-Id: I5c351fbdc485acbcb33426b99ea6b900519ee0e3
| * | | Fix Mutex::timedLock to properly handle relative timeAndy Hung2016-08-241-2/+8
| | | | | | | | | | | | | | | | | | | | Bug: 31008450 Change-Id: Ie6c17e17b7a8c3d8a087c47be535e9d04f285380
| * | | libutils/Unicode.cpp: Correct length computation and add checks for utf16->utf8Sergio Giro2016-07-111-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Inconsistent behaviour between utf16_to_utf8 and utf16_to_utf8_length is causing a heap overflow. Correcting the length computation and adding bound checks to the conversion functions. Test: ran libutils_tests Bug: 29250543 Change-Id: I6115e3357141ed245c63c6eb25fc0fd0a9a7a2bb
* | | | Merge "Improve RefBase documentation, especially for clients." am: 0f39fe22aeHans Boehm2016-08-101-1/+151
|\ \ \ \ | | |/ / | |/| | | | | | | | | | | | | | am: df6c464e9a Change-Id: I8fa12835ff648d78c68265facb5b63ca7b1eab6a
| * | | Merge "Improve RefBase documentation, especially for clients."Hans Boehm2016-08-101-1/+151
| |\ \ \ | | | |/ | | |/| | | | | | | | | | | | | am: 0f39fe22ae Change-Id: I804989b192142dc9d69ca36f0122079822625e7e
| | * | Merge "Improve RefBase documentation, especially for clients."Hans Boehm2016-08-101-1/+151
| | |\ \
| | | * | Improve RefBase documentation, especially for clients.Hans Boehm2016-08-091-1/+151
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add basic interface documentation to RefBase.h. Much, but not all, of this is cut-and-pasted from an email message from Mathias Agopian. The rest is reconstructed from the code. Delete some, now redundant, text from Refbase.cpp, and add a bit more about the implementation strategy. Some minor fixes to internal comments. Bug: 30292291 Change-Id: I56518ae5553bc6de0cc2331778e7fcf2e6c4fd87
* | | | | Merge "Fix google-explicit-constructor warnings in utils." am: 5b7e3b9a2aChih-Hung Hsieh2016-08-048-21/+21
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | am: 4d031d6358 Change-Id: I89352ced43afd415aefe2b8e45dd9fdd76dc0551
| * | | | Merge "Fix google-explicit-constructor warnings in utils."Chih-Hung Hsieh2016-08-048-21/+21
| |\| | | | | | | | | | | | | | | | | | | | | | | | | | | | am: 5b7e3b9a2a Change-Id: I88b7d5f20f26a028c90efdb837730e5b8631ce80
| | * | | Fix google-explicit-constructor warnings in utils.Chih-Hung Hsieh2016-08-028-21/+21
| | |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Declare explicit conversion constructors. * Use NOLINT(implicit) for implicit conversion constructors. Bug: 28341362 Change-Id: I4fb58fa32aafc520b2ed862a05a8bdbfabbc6c35 Test: build with WITH_TIDY=1
* | | | Merge \\"LruCache: avoid copying keys in lookup\\" am: 896c6b14aeSergio Giro2016-07-201-15/+40
|\| | | | | | | | | | | | | | | | | | | | | | | am: 4476929073 Change-Id: I3c49a22c68c8a66c912f08e3b7cdd8340de69532
| * | | Merge \"LruCache: avoid copying keys in lookup\"Sergio Giro2016-07-201-15/+40
| |\| | | | | | | | | | | | | | | | | | | | | | am: 896c6b14ae Change-Id: If8223e90988510385378506cd3a05d382ab73fc9
| | * | LruCache: avoid copying keys in lookupSergio Giro2016-07-201-15/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Create objects of type KeyedEntry for lookups that only have a key reference Bug: 27567036 Change-Id: I5e609a3db63d3b9277ff1547a3cca37dce70251c
* | | | Merge \"libutils/Unicode.cpp: Correct length computation and add checks for ↵Sergio Giro2016-07-141-2/+2
|\ \ \ \ | |/ / / |/| | | | | | | | | | | | | | | | | | | | | | | utf16->utf8\" into nyc-dev am: 757f4ef340 Change-Id: I29dfaa3968597fc3b0cdadd140b5790c1e61008d
| * | | libutils/Unicode.cpp: Correct length computation and add checks for utf16->utf8Sergio Giro2016-07-141-2/+2
| | |/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Inconsistent behaviour between utf16_to_utf8 and utf16_to_utf8_length is causing a heap overflow. Correcting the length computation and adding bound checks to the conversion functions. Test: ran libutils_tests Bug: 29250543 Change-Id: I6115e3357141ed245c63c6eb25fc0fd0a9a7a2bb (cherry picked from commit c4966a363e46d2e1074d1a365e232af0dcedd6a1)
| * | Fix memory order and race bugs in Refbase.h & RefBase.cppHans Boehm2016-05-191-5/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Convert to use std::atomic directly. Consistently use relaxed ordering for increments, release ordering for decrements, and an added acquire fence when the count goes to zero. Fix what looks like another race in attemptIncStrong: It seems entirely possible that the final adjustment for INITIAL_STRONG_VALUE would see e.g. INITIAL_STRONG_VALUE + 1, since we could be running in the middle of another initial increment. Attempt to somewhat document what this actually does, and what's expected from the client. Hide the documentation in the .cpp file for now. Remove a confusing redundant test in decWeak. OBJECT_LIFETIME_STRONG and OBJECT_LIFETIME_WEAK are the only options, in spite of some of the original comments. It's conceivable that either of these issues has resulted in actual crashes, though I would guess the probability is small. It's hard enough to reason about this code without the bugs. Bug: 28705989 Change-Id: I4107a56c3fc0fdb7ee17fc8a8f0dd7fb128af9d8 (cherry picked from commit e263e6c6337a24d56dc803792206e54981ad53a5)
* | | Merge \"RefBase: Silence compiler warnings\"Greg Kaiser2016-07-121-3/+4
|\ \ \ | | |/ | |/| | | | | | | | | | am: f76ca2a43b Change-Id: I4a146e36db49fc336baa7a59f8fbea0ca1dbb084
| * | RefBase: Silence compiler warningsGreg Kaiser2016-07-111-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | We comment out the names of the parameters we're intentionally not using. (cherrypick of 44a0eb4d8cdf4ab881f5d5a1acc1155266a46f6a.) Change-Id: I0a92d9200ca26cdc4700d2ff9e3ab33c102520d5
* | | Merge "Fix memory order and race bugs in Refbase.h & RefBase.cpp" am: 62212954efHans Boehm2016-05-191-5/+6
|\| | | | | | | | | | | | | | | | | | | | | | | | | | am: d657e639cf * commit 'd657e639cf74e0ee5a32d0f67efe0097c3df17a1': Fix memory order and race bugs in Refbase.h & RefBase.cpp Change-Id: I79106bb0399e7699d51d526235843504ab52708b
| * | Fix memory order and race bugs in Refbase.h & RefBase.cppHans Boehm2016-05-171-5/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Convert to use std::atomic directly. Consistently use relaxed ordering for increments, release ordering for decrements, and an added acquire fence when the count goes to zero. Fix what looks like another race in attemptIncStrong: It seems entirely possible that the final adjustment for INITIAL_STRONG_VALUE would see e.g. INITIAL_STRONG_VALUE + 1, since we could be running in the middle of another initial increment. Attempt to somewhat document what this actually does, and what's expected from the client. Hide the documentation in the .cpp file for now. Remove a confusing redundant test in decWeak. OBJECT_LIFETIME_STRONG and OBJECT_LIFETIME_WEAK are the only options, in spite of some of the original comments. It's conceivable that either of these issues has resulted in actual crashes, though I would guess the probability is small. It's hard enough to reason about this code without the bugs. Bug: 28705989 Change-Id: I4107a56c3fc0fdb7ee17fc8a8f0dd7fb128af9d8
* | | Merge commit '8b452b876b90dcfff1dab9012b65b5e67c4531a4' into ↵Michael Wright2016-05-162-0/+3
|\ \ \ | | |/ | |/| | | | | | | | | | manual_merge_8b452b8 Change-Id: Iacdc2d521f669661b4979c03b0476512abdb37c7
| * | Add String16#contains and strstr16 methods.Michael Wright2016-05-092-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | These are needed for aapt to find javadoc comments that contain "@removed" in order to skip them when printing styleable docs. Bug: 28663748 Change-Id: I8866d2167c41e11d6c2586da369560d5815fd13e
* | | Merge "Remove <utils/ashmem.h>." am: f9f76146a1Elliott Hughes2016-05-041-41/+0
|\ \ \ | | |/ | |/| | | | | | | | | | | | | | | | | | | am: ee3202563b * commit 'ee3202563be401328ad318d77d7c6c0622ab0960': Remove <utils/ashmem.h>. Change-Id: I6d076a9097df4969b703fc2833d464a15692835b
| * | Remove <utils/ashmem.h>.Elliott Hughes2016-05-041-41/+0
| | | | | | | | | | | | | | | | | | | | | Not to be confused with <cutils/ashmem.h> or <linux/ashmem.h>, one or other of which is what you should be using instead. Change-Id: Ie158530591b28b94c2cda9e2686cae56b7aeb1a3
* | | Merge "Mutex: Note that STL is generally prefered" into nyc-devGreg Kaiser2016-04-061-0/+4
|\ \ \ | | |/ | |/| | | | | | | | | | | | | | | | | | | am: a30a626 * commit 'a30a6263d632a7d2dedc4f09c6707ab20df3fb1a': Mutex: Note that STL is generally prefered Change-Id: I69eec173bf9679dc592987bd78cc8edcc81a1fbb
| * | Mutex: Note that STL is generally preferedGreg Kaiser2016-04-051-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | This class was designed prior to Android having usable C++11 support. With that support now in place, we prefer people to start using the STL threading classes, unless the code needs to build on Win32. Change-Id: If1b4d9bdfcb1e65824909376f022842bab9653d6