Commit graph

399 commits

Author SHA1 Message Date
Mikhail Lappo
df36644d68 Merge "Va_end should be used with va_start" am: 5f4808382e
am: 34b7617cb7

Change-Id: Ibc9fed36270da3f960179086792ce1187be31e92
2017-06-14 23:11:05 +00:00
Treehugger Robot
5f4808382e Merge "Va_end should be used with va_start" 2017-06-14 23:00:42 +00:00
Jiyong Park
94baf7270a Merge "fix: ATRACE does not work for libs loaded in sphal namespace" into oc-dev
am: b560e6db6a

Change-Id: I3c81f72c2d5f1eb30401012b92a1a3b65cbfdb80
2017-05-31 00:36:15 +00:00
Jiyong Park
0b3c24bd4f fix: ATRACE does not work for libs loaded in sphal namespace
From O, libutils.so is loaded twice. Once in the default namespace and
once in the sphal namespace for vendor libs. However, since the
framework only communicates with the instance loaded in the default
namespace, report_sysprop_change() event is not notified to the instance
in sphal namespace. This causes ATRACE to not work for vendor libs
loaded in sphal namespace.

So, the instance loaded in default namespace now explicitly redirects
the event to the other instance.

Bug: 62084107
Test: start an app, run 'adb shell atrace gfx --stream'. atrace from the
graphics driver are visible.

Change-Id: Ia6c2ca6bcb9a8849ebb09b5c38d60480c92d4571
2017-05-27 15:32:01 +09:00
Renaud Paquay
1033781b10 Merge "Fix uninitialized member variable" am: 46bb1ffa8a am: 9cf71d784e
am: c134530c37

Change-Id: I6f95919b2f3975754e8937aaa0c956feb79cc3e1
2017-05-12 01:55:47 +00:00
Renaud Paquay
b7a4f0b9e2 Fix uninitialized member variable
The default constructor of FileMap was missing an initializer for the
mFileMapping variables. This results in CloseHandle being called with
a "random" value, which can cause havoc in Win32 process over time (e.g.
in the case of libaapt2_jni.dll, which is loaded in a JVM process).

Also, update the code to use "NULL" for invalid file map handle
and "INVALID_HANDLE_VALUE" for invalid file handle.

Bug: 38197857
Test: Stress testing on (Windows) machine
Change-Id: Ibd769219d601fbafcfcee89e848b31cc5137826c
2017-05-11 10:30:52 -07:00
Chris Forbes
efa6100129 Merge "libutils: Make LightFlattenablePod safe for unaligned ptr" into oc-dev
am: ba73a138e0

Change-Id: I4a3e0d4a84465e35109c27032ad92e4577240a74
2017-05-04 20:31:36 +00:00
Chris Forbes
c46cbcbbf9 libutils: Make LightFlattenablePod safe for unaligned ptr
`buffer` may not be correctly aligned here. Assignment assumes correct
alignment and so then blows up on arm32.

Bug: b/37920153
Test: build, boot device
Change-Id: I23ef7c7f1d1511fd912b9485bba955db59e33832
2017-05-04 10:18:26 -07:00
Jaesoo Lee
1e00517d71 resolve merge conflicts of afc0aa78f to oc-dev-plus-aosp
Test: I solemnly swear I tested this conflict resolution.
Change-Id: I0e1cc5f5367c4840eea5f56670f74a44743f1853
2017-04-28 10:52:15 +09:00
Treehugger Robot
98cc0e1f02 Merge "added include for unistd.h that was missing" 2017-04-28 01:39:55 +00:00
Jaesoo Lee
1e8ac0fd03 libutils_headers: export libcutils_headers
These headers are used in headers in libutils_headers and must be
re-exported.

include/utils/Atomic.h:20:#include <cutils/atomic.h>
include/utils/Trace.h:24:#include <cutils/trace.h>
include/utils/Singleton.h:27:#include <cutils/compiler.h>

Test: modules using libutils_headers don't have to have
libcutils_headers include dirs set.
Bug: 33241851

Change-Id: I039aaaad93bf0944d42f04d2a9e6654b4f867042
2017-04-28 09:42:50 +09:00
Steven Moreland
4ad9d5155b libutils: export libbacktrace headers
This is used in CallStack.h.

Test: m -j libutils
Test: links
Test: trying to compile with BOARD_VNDK_VERSION := current
Bug: 33241851
Change-Id: I076c9551d356824d6e69b82349b890369bc7eea3
Merged-In: If7258e7b38000a72fd520f725030fb0038f90167
2017-04-28 09:42:50 +09:00
Steven Moreland
2d0dc9966a libutils: export system_headers
vendor + vendor_available modules built with BOARD_VNDK_VERSION :=
current aren't allowed to use global headers. Since libutils uses
system headers itself, it should export them as well.

Bug: 33241851
Test: building with BOARD_VNDK_VERSION := current produces many fewer
errors.

Change-Id: Icc7d2beb2a17da291434c6282eb1b9eb458f114c
Merged-In: I950821f1dae3ddc110db50869247913d5b1aa638
2017-04-28 09:42:50 +09:00
Jaesoo Lee
ff39e9c606 added include for unistd.h that was missing
Before BOARD_VNDK_VERSION is defined, unistd.h was included via
utils/Log.h and then log/log.h in liblog.
This error is detected because include for unistd.h is missing for
log/log.h for include_vndk in liblog

Bug: 33241851
Test: built libutils successfully
Change-Id: Icf14f8a9dee46752536a57f707c4d8895496fd72
Merged-In: Ide4aee3cacad2a2bf6bd0cbdf0254c6c245f4020
2017-04-24 15:02:43 +09:00
TreeHugger Robot
2679d09d48 Merge "libutils: include what you use" into oc-dev 2017-04-14 18:58:01 +00:00
Steven Moreland
8da9613b3f libutils: include what you use
These includes are included transitively by liblog, but not by the VNDK
version of liblog.

Bug: 33241851
Test: links with BOARD_VNDK_VERSION := current
Change-Id: Ide4aee3cacad2a2bf6bd0cbdf0254c6c245f4020
2017-04-14 17:06:33 +00:00
Steven Moreland
d3b4b2c96f libutils: export libbacktrace headers
This is used in CallStack.h.

Test: m -j libutils
Test: links
Test: trying to compile with BOARD_VNDK_VERSION := current
Bug: 33241851
Change-Id: If7258e7b38000a72fd520f725030fb0038f90167
2017-04-13 21:11:28 -07:00
Steven Moreland
b084bc3545 libutils: export system_headers
vendor + vendor_available modules built with BOARD_VNDK_VERSION :=
current aren't allowed to use global headers. Since libutils uses
system headers itself, it should export them as well.

Also added some items into windows-deprecated.h. This file is supposed
to be in sync with the libnativewindow variant until all dependencies on
it can be fixed. However, it is missing some updates. This matters when
including libsystem_headers adds system headers before libnativewindow
headers in the lookup paths.

Bug: 33241851
Test: building with BOARD_VNDK_VERSION := current produces many fewer
errors.

Change-Id: I950821f1dae3ddc110db50869247913d5b1aa638
2017-04-13 12:05:16 -07:00
Steven Moreland
91527edec8 libutils: mark as vendor_available
By setting vendor_available, the following may become true:

* a prebuilt library from this release may be used at runtime by
  in a later releasse (by vendor code compiled against this release).
  so this library shouldn't depend on runtime state that may change
  in the future.
* this library may be loaded twice into a single process (potentially
  an old version and a newer version). The symbols will be isolated
  using linker namespaces, but this may break assumptions about 1
  library in 1 process (your singletons will run twice).

Background:

This means that these modules may be built and installed twice --
once for the system partition and once for the vendor partition. The
system version will build just like today, and will be used by the
framework components on /system. The vendor version will build
against a reduced set of exports and libraries -- similar to, but
separate from, the NDK. This means that all your dependencies must
also mark vendor_available.

At runtime, /system binaries will load libraries from /system/lib*,
while /vendor binaries will load libraries from /vendor/lib*. There
are some exceptions in both directions -- bionic(libc,etc) and liblog
are always loaded from /system. And SP-HALs (OpenGL, etc) may load
/vendor code into /system processes, but the dependencies of those
libraries will load from /vendor until it reaches a library that's
always on /system. In the SP-HAL case, if both framework and vendor
libraries depend on a library of the same name, both versions will be
loaded, but they will be isolated from each other.

It's possible to compile differently -- reducing your source files,
exporting different include directories, etc. For details see:

https://android-review.googlesource.com/368372

None of this is enabled unless the device opts into the system/vendor
split with BOARD_VNDK_VERSION := current.

Bug: 36426473
Bug: 36079834
Test: m -j libutils
Test: attempt to compile with BOARD_VNDK_VERSION := current
Merged-In: I6c1279a74ef071851401e38bbdd377f13827694c
Change-Id: I6c1279a74ef071851401e38bbdd377f13827694c
2017-04-12 16:00:02 +00:00
Steven Moreland
48cdaff063 libutils: mark as vendor_available
By setting vendor_available, the following may become true:

* a prebuilt library from this release may be used at runtime by
  in a later releasse (by vendor code compiled against this release).
  so this library shouldn't depend on runtime state that may change
  in the future.
* this library may be loaded twice into a single process (potentially
  an old version and a newer version). The symbols will be isolated
  using linker namespaces, but this may break assumptions about 1
  library in 1 process (your singletons will run twice).

Background:

This means that these modules may be built and installed twice --
once for the system partition and once for the vendor partition. The
system version will build just like today, and will be used by the
framework components on /system. The vendor version will build
against a reduced set of exports and libraries -- similar to, but
separate from, the NDK. This means that all your dependencies must
also mark vendor_available.

At runtime, /system binaries will load libraries from /system/lib*,
while /vendor binaries will load libraries from /vendor/lib*. There
are some exceptions in both directions -- bionic(libc,etc) and liblog
are always loaded from /system. And SP-HALs (OpenGL, etc) may load
/vendor code into /system processes, but the dependencies of those
libraries will load from /vendor until it reaches a library that's
always on /system. In the SP-HAL case, if both framework and vendor
libraries depend on a library of the same name, both versions will be
loaded, but they will be isolated from each other.

It's possible to compile differently -- reducing your source files,
exporting different include directories, etc. For details see:

https://android-review.googlesource.com/368372

None of this is enabled unless the device opts into the system/vendor
split with BOARD_VNDK_VERSION := current.

Bug: 36426473
Bug: 36079834
Test: m -j libutils
Test: attempt to compile with BOARD_VNDK_VERSION := current
Change-Id: I6c1279a74ef071851401e38bbdd377f13827694c
2017-04-12 08:59:41 -07:00
Mathias Agopian
44cee05904 split LightRefBase out of RefBase
Bug: 36532900
Test: compiled
Change-Id: I3088e1a219e04cf924744d3a0c2d374918bb6395
2017-03-29 20:39:06 +00:00
Mark Salyzyn
02ce4262dc Merge changes I96998c4b,I161bf03b am: dd0cd8d88f am: f17500474a
am: 77a1fa9070

Change-Id: I5b296f6c1b01a8b2dc51c7ebbd44d599a3aa49c1
2017-03-27 22:42:44 +00:00
Mark Salyzyn
0484b3b575 logd: ASAN cleansing
A mixture of fixes and cleanup for LogKlog.cpp and friends.

- sscanf calls strlen.  Check if the string is missing a nul
  terminator, if it is, do not call sscanf.
- replace NULL with nullptr for stronger typechecking.
- pass by reference for simpler code.
- Use ssize_t where possible to check for negative values.
- fix FastCmp to add some validity checking since ASAN reports that
  callers are not making sure pre-conditions are met.
- add fasticmp templates for completeness.
- if the buffer is too small to contain a meaningful time, do not
  call down to log_time::strptime() because it does not limit its
  accesses to the buffer boundaries, instead stopping at a
  terminating nul or invalid match.
- move strnstr to LogUtils.h, drop size checking of needle and
  clearly report the list of needles used with android::strnstr
- replace 'sizeof(static const char[]) - 1' with strlen.

Test: gTest liblog-unit-test, logd-unit-tests & logcat-unit-tests
Bug: 30792935
Bug: 36536248
Bug: 35468874
Bug: 34949125
Bug: 34606909
Bug: 36075298
Bug: 36608728
Change-Id: I161bf03ba029050e809b31cceef03f729d318866
2017-03-27 13:32:57 -07:00
Vishwath Mohan
c94c4d269a Merge "Blacklist some vector functions for CFI." 2017-03-23 23:14:48 +00:00
Mikhail Lappo
90f5d64848 Va_end should be used with va_start
va_start is used and va_end should
be invoked accordingly

Change-Id: Id7037aa8092438b27e445e5147972836602bfd55
2017-03-23 22:41:42 +01:00
Vishwath Mohan
27a7aa0f59 Blacklist some vector functions for CFI.
This CL blacklists some vector functions (construct, copy, splat,
move) that use reinterpret_cast on freshly allocated memory (where the
object doesn't exist yet). This is technically correct, but not
friendly for CFI, which enforces stricter checking to catch type
confusion errors. Blacklisting these specific functions from CFI does
not cause an appreciable coverage loss though, so this should be fine.

Bug: 36219323
Test: Builds and boots, and the reinterpret error goes away on CFI builds.
Test: All 98 libutils_tests pass
Change-Id: I4944b179116bb1e1608d92697e95e182d8c0ac9f
2017-03-23 14:37:12 -07:00
Adam Lesinski
aa1d43230c Merge "libziparchive: fix mac os breakage" am: 390f3b364c am: 7cfe1d69b0
am: cdbadafb4a

Change-Id: Ie327879eaea542911603640e36f0d867e05afd61
2017-03-23 21:12:58 +00:00
Adam Lesinski
b02d690336 libziparchive: fix mac os breakage
Add ftruncate64 to utils/Compat.h definitions for mac.

Change-Id: I82cb46927be911e867b606f4f4429a5e1b1987f7
Test: builds on mac
2017-03-23 12:02:09 -07:00
Hans Boehm
d9bcc37269 Merge "Add heuristic data race detection to sp<>" am: 04abdc6153 am: 12d6afe6f1
am: 764d347183

Change-Id: I6a27520e80c2adefe30b0d04ce7e470188d3ad99
2017-03-19 04:56:09 +00:00
Hans Boehm
7f0b2601d3 Add heuristic data race detection to sp<>
Force assignment to read the old pointer value twice, and check
that it didn't change in the interim. Previous experience with
Skia suggests that this has a high probability of correctly detecting
a data race when it occurs, instead of potentially letting the
count associated with the old pointer value get decremented twice,
and corrupting the heap.

This does increase the size of sp assignments, which seem to
commonly get inlined. For the general case, we add a third
comparison and function call.

Some code reformatting to make this consistent with modern conventions
and pass automated checks.

Test: Booted aosp build. Ran libutils tests. Looked at generated code.

Bug: 31227650

Change-Id: Id93a05c6bf10f01ee15ff1bb409611f2058f988f
2017-03-17 17:47:28 -07:00
TreeHugger Robot
6258cfee90 Merge "Formatting changes for TypeHelpers.h and Vectors.h" 2017-03-16 07:38:32 +00:00
Vishwath Mohan
fc3f57acbb Formatting changes for TypeHelpers.h and Vectors.h
This CL nukes all spurious whitespace in the two files.

Bug: 36219323
Test: Device builds and boots.
Test: All 98 libutils_tests pass
Change-Id: I8054a0f0ba5df95f5115dc06597eb9fd539da942
2017-03-15 22:48:27 -07:00
Dan Willemsen
5dfa912f03 Merge "Enable more modules on linux_bionic builds" am: 75c414d1a3 am: 5bb9220b75
am: 5e30ce0ca0

Change-Id: I8d1ba8749e9c0e6433236b42bda7da5188e5f810
2017-03-16 02:40:00 +00:00
Dan Willemsen
e0cd1e043d Enable more modules on linux_bionic builds
Bug: 31559095
Test: Enable host bionic, run soong
Change-Id: Ib4ebd909322cf464b6a40040e4b60ece7d905b6f
2017-03-15 15:44:00 -07:00
Mathias Agopian
f520b73103 Get rid of LinearTransform
It had 3 clients
- one in vendor/google_athome which was disabled
- one in a device specific folder, which will die out
- and one in frameworks/base

This reverts commit 6c942304ed.

Test: compile/run
Bug: treble cleanup

Change-Id: Ia76009d550c294198c083cf89718bc498b5c9e3e
2017-03-15 14:16:13 -07:00
Ian Pedowitz
6c942304ed Revert "get rid of LinearTransform"
This reverts commit bcd592053a.

Bug: 36206160
Test:  Fugu compiles, didn't before the revert
Change-Id: Id80fd4ce9db3fce03b049cf81f938187c7ddb8b0
2017-03-14 08:11:41 +00:00
Mathias Agopian
bcd592053a get rid of LinearTransform
it had a single client in frameworks/base

Test: compile & run
Bug: treble cleanup
Change-Id: I9a17bbffed4724f8a329c5a15d621293bb800d45
2017-03-13 12:27:35 -07:00
Steven Moreland
aa47993b23 Merge "libutils: String\d+ make std_string private" am: 76850afa52 am: 2ebb1e5404
am: 4ba3f784ef

Change-Id: I14f003992db222ef285551c6d9a8ffe71620f70d
2017-03-11 09:07:23 +00:00
Steven Moreland
2aac335128 libutils: String\d+ make std_string private
This method is still used by prebuilts, but making it private to start
the process of removing it from everywhere.

Test: pass
Bug: 35363681
Change-Id: I4d53f68d10c9abcca32023c4d930e99912afa697
2017-03-10 22:51:55 -08:00
TreeHugger Robot
decccc2e8f Merge "Remove BlobCAche from libutils" 2017-03-11 01:32:47 +00:00
Mathias Agopian
f088e4e238 Remove BlobCAche from libutils
it has moved to libEGL which was the only client.


Test: compiled & Run
Bug: vndk-stable
Change-Id: Ife18727fa1c48b1be6910058867016348b7f02c1
2017-03-10 12:27:46 -08:00
Steven Moreland
d21cfab244 Add missing includes.
Includes are transitively imported by <string> in String8.h + String16.h
but that include is being removed.

Test: pass
Change-Id: Ide5c011b40b4a4f031dd26ead08b5c8d5d299693
2017-03-10 09:05:30 -08:00
Tom Cherry
101573e3f5 Merge "Clarify that Condition::wait() can spuriously wake up" am: 514e0aa2e2 am: 675e05c48a
am: df8fc09716

Change-Id: Id99d721415d93b2d3f0539bf5a2acb1995f01000
2017-03-06 20:06:03 +00:00
Tom Cherry
514e0aa2e2 Merge "Clarify that Condition::wait() can spuriously wake up" 2017-03-06 19:26:30 +00:00
Mathias Agopian
22dbf3947f clean-up libutils includes
moved Foo.h as first include of Foo.cpp, and
removed redundant includes.

Made NativeHandle non virtual.


Test: run & compile
Bug: n/a

Change-Id: I37fa746cd42c9ba23aba181f84cb6c619386406a
2017-03-03 14:47:47 -08:00
Tom Cherry
f1147f7dde Clarify that Condition::wait() can spuriously wake up
Also, remove the clarification that Condition::signal() wakes exactly
one thread as in the presence of spurious wake ups, this clarification
does not provide a safe guarantee to developers.

Bug: 34592766
Test: Build
Change-Id: I34df02e44a70a18fe04ceda858d002ef129c1fd9
2017-03-02 12:36:45 -08:00
Colin Cross
a4ca06b3b3 Merge changes I975ba933,Ica9d211b am: a9ef4dc7a2 am: 9ece9401a4
am: f695f6e842

Change-Id: I570c55be7a7cf3ad44e32717040689a68f67ada2
2017-02-28 20:37:29 +00:00
Colin Cross
a0931ebd64 Add tests for multiton issue
Test accessing a singleton from two libraries, the second of which
depends on the first but is dlopen'd after the first is already
loaded.

Bug: 35674422
Test: out/host/linux-x86/nativetest64/libutils_tests/libutils_tests
Change-Id: I975ba933a19b941a52bdb6e9c221a6910ffb8081
2017-02-28 16:34:35 +00:00
Colin Cross
62a6b16c4b Merge "Make libutils test compile on the host" am: f5fd4888ce am: a05a666c01
am: 3bc7d607d4

Change-Id: I00ac6f6871d925c805953eff0fa0c918cee3600a
2017-02-24 21:25:24 +00:00
Colin Cross
155c983ad1 Make libutils test compile on the host
Reapply of Icd5f39ae71b57167e9b2fe7ec09c5400bcb90e78 with
RefBase_test.cpp and Looper_test.cpp removed from mac builds.

Test: out/host/linux-x86/nativetest64/libutils_tests/libutils_tests
Test: out/host/darwin-x86/nativetest64/libutils_tests/libutils_tests
Change-Id: I5979b296a8500b5697d94d64fc441363047adcea
2017-02-24 08:10:06 -08:00