Commit Graph

461 Commits

Author SHA1 Message Date
Mark Salyzyn 5c8bdf42e7 Merge "liblog: use log/log.h for ALOG macros" am: dd9fa24091 am: 112d1dcd95 am: 33807cd6c2
am: 07388af1e6

Change-Id: I3789497189d23724824babaacbc8aa442e7a026c
2017-01-12 23:57:31 +00:00
Mark Salyzyn 51c33b7011 liblog: use log/log.h for ALOG macros
Test: compile
Bug: 34250038
Change-Id: I0f56c563871f377c03380498cd867b916892f1dc
2017-01-12 15:44:06 -08:00
Josh Gao f64256f47f libutils: allow multiple ATRACE_NAMEs in a scope. am: 01937ee2b9 am: d28920f745 am: e152b1b418
am: e12d7beedf

Change-Id: Idf23a284f706ba0ce1f29c7d1a69902c99985595
2016-12-13 01:10:45 +00:00
Josh Gao 01937ee2b9 libutils: allow multiple ATRACE_NAMEs in a scope.
Bug: http://b/31289465
Test: m
Change-Id: Iabd97439fa55ea285ce0501dbb4fd9d07149ae61
2016-12-12 12:28:04 -08:00
Mark Salyzyn 9b66d51a1f Merge "utils: Add FastStrcmp.h" am: 0f8890d985 am: dcd44168d3 am: 54890a929c
am: 41c99f83d9

Change-Id: Ic0d10a2a6536a75c5d99345475135418fc943380
2016-12-10 00:00:27 +00:00
Mark Salyzyn 0eeb06b932 utils: Add FastStrcmp.h
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
2016-12-09 12:40:17 -08:00
Mark Salyzyn b4c9ab960e Merge "system/core: preparation to pull back interfaces from android/log.h" am: 27d2d49f48 am: 8a7297a09f
am: c561af07ae

Change-Id: I7bfb6dd925739345624a1ed16c0c3cb2106ad098
2016-10-20 18:21:18 +00:00
Mark Salyzyn 8a7297a09f Merge "system/core: preparation to pull back interfaces from android/log.h"
am: 27d2d49f48

Change-Id: I604bb1d4cf62636663fa92e3d14a55887dbcae23
2016-10-20 18:03:57 +00:00
Mark Salyzyn cfd5b080af system/core: preparation to pull back interfaces from android/log.h
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
2016-10-20 08:11:39 -07:00
Mark Salyzyn 4bf372ae30 system/core Replace cutils/log.h with android/log.h am: 66ce3e08c5 am: eb189f147b am: 16f7786032
am: 0abff8fc61

Change-Id: I8c9d221094f0c27838e120aeb41fff276fbab4b2
2016-10-01 00:43:07 +00:00
Mark Salyzyn 0abff8fc61 system/core Replace cutils/log.h with android/log.h am: 66ce3e08c5 am: eb189f147b
am: 16f7786032

Change-Id: I26939d55686b6182c9fae5fc74f3e7ed92132cdb
2016-09-30 22:18:03 +00:00
Mark Salyzyn 66ce3e08c5 system/core Replace cutils/log.h with android/log.h
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
2016-09-30 12:47:05 -07:00
Colin Cross 910ab5ec75 Merge "Fix more system/core/include warnings" am: 18fbd80504 am: 5fe194a9fd am: b5ca47989c
am: 0763c30289

Change-Id: I4dcce9ecde9c7f1bf02952a1aafb6407a260d73b
2016-09-29 18:04:35 +00:00
Colin Cross 0763c30289 Merge "Fix more system/core/include warnings" am: 18fbd80504 am: 5fe194a9fd
am: b5ca47989c

Change-Id: I8d5a602f94bc57866aa3827cc508c94afb4ac4ba
2016-09-29 17:58:08 +00:00
Colin Cross 1811d156e9 Fix more system/core/include warnings
The warnings in these files were hidden by -isystem
framework/native/include.

Bug: 31752268
Test: m -j
Change-Id: I2a54376aea380ee24e6483fb7d35fdfe8991c490
2016-09-27 16:21:12 -07:00
David Pursell ab024abe3a Merge "Flattenable: switch from assignment to memcpy()." am: b2356a6993 am: bb276d8555 am: 9f106bece8
am: 7bc0052ff1

Change-Id: I2ce0426298c62249c3be164dc4488c26883cb6d6
2016-09-25 20:34:40 +00:00
David Pursell 7bc0052ff1 Merge "Flattenable: switch from assignment to memcpy()." am: b2356a6993 am: bb276d8555
am: 9f106bece8

Change-Id: I43e4e5c6bb0aa1fd23a1d0d9776c9e2c8028527e
2016-09-23 22:56:01 +00:00
David Pursell b2356a6993 Merge "Flattenable: switch from assignment to memcpy()." 2016-09-23 22:46:03 +00:00
David Pursell 2ebce7384b Flattenable: switch from assignment to memcpy().
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
2016-09-23 13:56:40 -07:00
Colin Cross fd49e46c39 Merge "Fix warnings in libutils headers" am: 65a1633ec3 am: 0f79b62bf6 am: 1446cbac58
am: 28cda0bf38

Change-Id: I1190211b67e0c8d02ed1eb09c6b25401687069dd
2016-09-23 01:17:43 +00:00
Colin Cross c5c30e0735 Merge "Remove has_trivial_move trait from Vector<T>" am: 588b3b0c03 am: 85942090f6 am: 749181c10b
am: 021899fa8a

Change-Id: I4c93cda9b55ae1caf043f94e7ee27b2bbabbe4d8
2016-09-23 01:10:59 +00:00
Colin Cross 28cda0bf38 Merge "Fix warnings in libutils headers" am: 65a1633ec3 am: 0f79b62bf6
am: 1446cbac58

Change-Id: I94a39bb24224218ef1c48080ace3455c1fc7233a
2016-09-22 23:04:13 +00:00
Colin Cross 021899fa8a Merge "Remove has_trivial_move trait from Vector<T>" am: 588b3b0c03 am: 85942090f6
am: 749181c10b

Change-Id: Ie339e0ea27463d0c5b093e9a5e262367d1ca57a5
2016-09-22 22:58:13 +00:00
Colin Cross 17b5b82d64 Fix warnings in libutils headers
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
2016-09-22 13:03:15 -07:00
Colin Cross 097395532b Remove has_trivial_move trait from Vector<T>
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
2016-09-22 10:14:05 -07:00
Martijn Coenen 111ef54a28 Merge changes from topic 'utf' am: 3a07e5bf94 am: aa7fd8a3ec
am: ade3876260

Change-Id: Ifec806c7553b36a6502a8b5bb3dec559c117f4cc
2016-08-25 20:31:42 +00:00
Sergio Giro 1cfa56d46c libutils/Unicode.cpp: Correct length computation and add checks for utf16->utf8
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 c4966a363e)
2016-08-25 20:07:51 +00:00
Sergio Giro 9de6776321 Unicode: specify destination length in utf8_to_utf16 methods
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 1dcc0c8239

Change-Id: I5223caa7d42f4582a982609a898a02043265c6d3
2016-08-25 19:57:06 +00:00
Hans Boehm a1709d5269 Merge "Make RefBase more robust and debuggable" am: daac359be7 am: 7bf3d21fde am: 7dddf9433c
am: 2d3545fe82

Change-Id: I65537ec0db45b05f96dae43b8f4a91bd4af2d39b
2016-08-25 00:14:54 +00:00
Hans Boehm 2d3545fe82 Merge "Make RefBase more robust and debuggable" am: daac359be7 am: 7bf3d21fde
am: 7dddf9433c

Change-Id: Ia8bdef250b29d964a9ab07c450da31a368bb3143
2016-08-24 23:52:14 +00:00
Hans Boehm 7dddf9433c Merge "Make RefBase more robust and debuggable" am: daac359be7
am: 7bf3d21fde

Change-Id: I643c4bd38062b80d382c50ed161f5440f35c1dd9
2016-08-24 23:49:14 +00:00
Hans Boehm daac359be7 Merge "Make RefBase more robust and debuggable" 2016-08-24 23:36:13 +00:00
Andy Hung e131ea2a25 Fix Mutex::timedLock to properly handle relative time am: 604ba48220 am: 708b9d118a am: 47e5ca61e2
am: 8ec6753d61

Change-Id: Ia281e33c13df240baf0c2bb187b0c13fefdeff8e
2016-08-24 23:08:27 +00:00
Andy Hung 8ec6753d61 Fix Mutex::timedLock to properly handle relative time am: 604ba48220 am: 708b9d118a
am: 47e5ca61e2

Change-Id: I5c351fbdc485acbcb33426b99ea6b900519ee0e3
2016-08-24 22:50:00 +00:00
Andy Hung 604ba48220 Fix Mutex::timedLock to properly handle relative time
Bug: 31008450
Change-Id: Ie6c17e17b7a8c3d8a087c47be535e9d04f285380
2016-08-24 22:29:11 +00:00
Hans Boehm 23c857ebd6 Make RefBase more robust and debuggable
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
2016-08-13 11:17:51 -07:00
Hans Boehm 9fb33735be Merge "Improve RefBase documentation, especially for clients." am: 0f39fe22ae am: df6c464e9a am: f997434b06
am: e725c79831

Change-Id: Idbc29ea28c0a63a35340b052a30b0106f8eae46d
2016-08-10 16:33:00 +00:00
Hans Boehm f997434b06 Merge "Improve RefBase documentation, especially for clients." am: 0f39fe22ae
am: df6c464e9a

Change-Id: I8fa12835ff648d78c68265facb5b63ca7b1eab6a
2016-08-10 16:26:59 +00:00
Hans Boehm df6c464e9a Merge "Improve RefBase documentation, especially for clients."
am: 0f39fe22ae

Change-Id: I804989b192142dc9d69ca36f0122079822625e7e
2016-08-10 16:24:01 +00:00
Hans Boehm 0f39fe22ae Merge "Improve RefBase documentation, especially for clients." 2016-08-10 16:16:22 +00:00
Hans Boehm 9ba7192c1f Improve RefBase documentation, especially for clients.
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
2016-08-09 15:12:19 -07:00
Chih-Hung Hsieh 94aa3aaee0 Merge "Fix google-explicit-constructor warnings in utils." am: 5b7e3b9a2a am: 4d031d6358 am: e1fff2572c
am: d8ced2029b

Change-Id: Ie0092027487b3089b6602c53fd73f6e95b881a85
2016-08-04 21:55:59 +00:00
Chih-Hung Hsieh e1fff2572c Merge "Fix google-explicit-constructor warnings in utils." am: 5b7e3b9a2a
am: 4d031d6358

Change-Id: I89352ced43afd415aefe2b8e45dd9fdd76dc0551
2016-08-04 21:51:20 +00:00
Chih-Hung Hsieh 4d031d6358 Merge "Fix google-explicit-constructor warnings in utils."
am: 5b7e3b9a2a

Change-Id: I88b7d5f20f26a028c90efdb837730e5b8631ce80
2016-08-04 21:48:20 +00:00
Chih-Hung Hsieh 2a929968e1 Fix google-explicit-constructor warnings in utils.
* Declare explicit conversion constructors.
* Use NOLINT(implicit) for implicit conversion constructors.

Bug: 28341362
Change-Id: I4fb58fa32aafc520b2ed862a05a8bdbfabbc6c35
Test: build with WITH_TIDY=1
2016-08-02 12:20:06 -07:00
Sergio Giro 8ee4cc5302 Merge "Unicode: specify destination length in utf8_to_utf16 methods" 2016-08-02 18:48:19 +00:00
Sergio Giro 1dcc0c8239 Unicode: specify destination length in utf8_to_utf16 methods
String16(const char *utf8) now returns the empty string in case
a string ends halfway throw a utf8 character.

Bug: 29267949

Change-Id: I5223caa7d42f4582a982609a898a02043265c6d3
2016-08-02 18:47:53 +00:00
Irvel Nduva Matias Vega 825499c53e Merge "Add some level of compatibility with STL" 2016-07-21 22:57:42 +00:00
Sergio Giro d20120ae1f Merge \\"LruCache: avoid copying keys in lookup\\" am: 896c6b14ae
am: 4476929073

Change-Id: I3c49a22c68c8a66c912f08e3b7cdd8340de69532
2016-07-20 19:51:07 +00:00
Sergio Giro 4476929073 Merge \"LruCache: avoid copying keys in lookup\"
am: 896c6b14ae

Change-Id: If8223e90988510385378506cd3a05d382ab73fc9
2016-07-20 19:48:44 +00:00