libbase is copied into each APEX module which requires it, meaning
that there may be multiple instances of libbase running within a
single process with their own copy of libbase's globals. This means
that SetLogger() and SetAborter() will only impact logs from the
instance of libbase that calls it. This change moves this state to
liblog, since it will only ever have one instance in a single
process.
One major side-effect here is that now both ALOGE style and LOG(...)
style logs will be handled through the same logger function. For
example, a logger specified through libbase's SetLogger() will now see
logs sent to liblog through ALOGE(). This is intended behavior.
A second side-effect is that libbase's stderr logger is used for all
host logging now. It's simply a better logging default than the
fake_log_device logger in liblog currently and makes ALOGE and
LOG(...) logs on host follow the same format.
Bug: 119867234
Test: libbase and liblog unit tests; logging works
Change-Id: Ib52cbfb4e43749e50910ed19a993dffae19ace86
Pillage from Chromium a wrapper type that skips destruction of its
wrapped type, to avoid problems with premature destruction of
variables with static lifetime.
Test: libbase_test on host
Change-Id: I7d4541f7b59f467b232d5c4f8250dc1ea45e28fa
Also change the properties implementation to call the new API. We use
this ParseBool API in the new SystemProperties implementation, with
which we want the libbase property API to be consistent.
Test: included
Change-Id: I89cb3eb4e1203a6bb0da41914dad720e44c00303
This prevents us from using glibc's <fts.h> because of
https://sourceware.org/bugzilla/show_bug.cgi?id=11460,
and we now only support 64-bit hosts.
Bug: 139544611
Test: Treehugger
Change-Id: Iaacc9ea17473201bf3d701e82081264921062d5e
We loop over /proc to iterate through pids in a lot of code, so let's
consolidate this into a single function in libbase.
Test: new unit test
Change-Id: I908fab90b603546d0e3e8b8acdc8dadfc3552d62
We're already including fmtlib statically in libbase, so let's also
expose its functionality directly.
Also create a small benchmark of the most common operations for
format() and StringPrintf(): int, float, and string arguments. Note
that fmt::format is faster than StringPrintf() in all of these cases.
Test: build, run benchmark
Change-Id: I1e18f13673dd89ea936ea5c51418fad723495b08
String formatting for error message can be done by using Errorf and
ErrnoErrorf. e.g. `return Errorf("{} failures", num_failure);`
The string format follows that of fmtlib, not printf.
Bug: 132145659
Test: libbase_test
Change-Id: I65f45d5f12ed23e2c14d6eb442278f467cc42e83
The Result, Error, ErrnoError are quite generic. Moving them from init
to libbase so that they can be used from other places.
Bug: 132145659
Test: libbase_test
Change-Id: Id774a587f74380fadd7a0fc88c0aa892c3d9a489
android::base::expected is an Android implementation of the
std::expected proposal.
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0323r7.html
For usage, refer to the expected.h header file and
expected_test.cpp
Bug: 132145659
Test: libbase_test
Change-Id: I65d3a1ecf8654d9858989755dfd0065c81f7b209
The original commit broke aosp-master-with-phones, because of
vendor libraries the depended on the int versions of libbase functions.
This patch reverts the revert, and also adds ABI-compatibility shims for
the replaced functions.
This reverts commit 2c58e1924a.
Bug: http://b/131312539
Test: treehugger
Test: forrest run of aosp-master-with-phones
Change-Id: I75cc84ec8d963e20862f7662e8e2f409471f41cc
Enable native bridge support for libbase, liblog,
libziparchive and libpropertyinfoparser.
This makes it possible to use them in binaries for translated
architectures.
Bug: http://b/77159578
Test: make
Change-Id: If67ce92288b17a052ea1e79a268e284f7d941439
Almost all of the uses of cmsg(3) in our source tree are wrong in at
least one of the following ways:
- not aligning the cmsg buffer
- leaking fds if more fds are received than expected
- blindly dereferencing CMSG_DATA without checking the header
- using CMSG_SPACE instead of CMSG_LEN for .cmsg_len
- using CMSG_LEN instead of CMSG_SPACE for .msg_controllen
- using a length specified in number of fds instead of bytes
Implement wrapper functions that implement this dumpster fire of an
API correctly.
Bug: http://b/122047630
Test: libbase_test32
Change-Id: I6ac34d67bbbf1bfa9727ab598248fc178ea19df9
sehr points out that we already have two bugs caused by not doing this:
file.cpp has a call to pread with an off64_t that gets truncated, and
mapped_file.cpp does similar with mmap.
Bug: N/A
Test: ran tests
Change-Id: Ia098a836457e5adf109541235ad71c0ad7219da8
This allows us to remove libziparchive's dependency on libutils.
Bug: http://b/79112958
Test: ran libbase and libziparchive tests, ran fastboot manually
Change-Id: I95c651976dad222863e5b8c37d4514b778f5dce7
EXPECT_DEATH forks behind the scenes, which turns off fdsan, leading to
these tests failing. Instead of duplicating the special
EXPECT_FDSAN_DEATH macro, just move these tests into the bionic fdsan
tests.
Test: none
Change-Id: Ia7b65d4560601d5a78d143aced887a6773b401c0
Use __attribute__((weak)) to check for fdsan availability at runtime,
to support being used when built with the NDK while targeting older
platform versions.
This reverts commit af798acaea49b8d9150b94eb9f5f11450a6b8893.
Bug: http://b/110100358
Test: m libjnitest
Change-Id: Ie59d041d69cc3d4b6c59412d706f702dd1d2dab2
This reverts commit fcf2c01b55.
Commit broke full-eng, because libbase is being compiled against the NDK.
Test: treehugger
Change-Id: I8447b6a7fc33e6aa34cec0f037727322fa824446
adbd (and its dependencies) are marked as recovery_available:true so
that recovery version of the binary is built separately from the one for
system partition. This allows us to stop copying the system version to
the recovery partition and also opens up the way to enable shared
libraries in the recovery partition. Then we can also build adbd as a
dynamic executable.
Bug: 79146551
Test: m -j adbd.recovery
Change-Id: Ib95614c7435f9d0afc02a0c7d5ae1a94e439e32a
Libraries that are direct or indirect dependencies of modules installed
to recovery partition (e.g. toybox) are marked as recovery_available:
true. This allows a recovery variant of the lib is created when it is
depended by other recovery or recovery_available modules.
Bug: 67916654
Bug: 64960723
Test: m -j
Change-Id: Ie59155c08890e96ce1893fa3687afcf763d7aea3
Windows build of adb is broken because of the lack of
std::chrono_literals and for an implementation of
android::boot_clock::now().
Test: make -j vts
Bug: 72941624
Change-Id: Ie65fed098633eb45a94ea553de6903f8d55fc5b2
Add some helper macros that perform regex string matching to
<android-base/test_utils.h>.
Test: libbase_test32/64 on host
Change-Id: I1b0f03dc73f8b4fdfb8ac6c75d59ef421e0e9640
Now in Android.bp files, target.linux applies to all targets running a
linux kernel (android, linux_glibc, linux_bionic). So common
flags/sources/etc can be combined instead of copying them to each
target.
Test: m
Change-Id: If7ad138ea1c540c160731f86b6ccc0daa5c69b83
In the future, target.linux will apply to all targets running a linux kernel
(android, linux_glibc, linux_bionic). So move all current users to the specific
linux_glibc.
There will be another cleanup pass later that will move some instances back to
target.linux if the properties should be shared with target.android and
target.linux_bionic, but target.linux needs to be removed first.
Test: out/soong/build.ninja identical before/after
Change-Id: I72ef34689c60ce547cab2898e354b027e335f6a1
Exempt-From-Owner-Approval: build system cleanup
libdl is part of system_shared_libs now. -ldl -lpthread -lm are now defaults
for host_ldlibs on Linux and Darwin. -lrt is a default for host_ldlibs on
Linux.
Test: m host
Change-Id: I0b3c147b00a8ab6ff289b85db55b88836c905f5c
Exempt-From-Owner-Approval: build system cleanup
As a VNDK-SP module, Android.bp must have 'vndk' tag as well as
'vendor_available: true'.
The 'vndk' tag for VNDK-SP formated as follows:
vndk: {
enabled: true,
support_system_process: true,
},
VNDK-SP modules will be installed both in system/lib(64) as normal
and in system/lib(64)/vndk-sp as a vendor variant.
Bug: 63866913
Test: build and boot with BOARD_VNDK_VERSION=current
Merged-In: I51fe0859f63ad58b7b91909e7d7d4206443228cd
Change-Id: I51fe0859f63ad58b7b91909e7d7d4206443228cd
(cherry picked from commit aeb68e86e4)
clang is the default compiler since Android nougat
Test: mma & verified it´s still build with clang
Change-Id: I34adaeef2f6558a09f26027271222bad94780507
Signed-off-by: Lennart Wieboldt <lennart.1997@gmx.de>
boot_clock was previously returning zero on any platform that doesn't
define __ANDROID__, including host bionic. Instead of returning a bogus
value, just hide it on non-Linux platforms.
Bug: http://b/37758947
Test: libbase_test32/64 on linux
Change-Id: I96e1d8b92dc44c6308408900cf0d27e1e7db5569
libutils headers are only used by the implementation of libbase,
and should not be exported to everything that uses libbase headers.
Test: m -j
Change-Id: I76f248908f649e3a3c91cd3e84d629a0049939ef
Two changes were merged at the same time that conflicted.
Test: builds
(cherry picked from commit 72b9d28423)
Merged-In: Ia6c730804cd5a3b2655e6d69b8e4f346d198dabb
Change-Id: Ia6c730804cd5a3b2655e6d69b8e4f346d198dabb
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: 33241851
Test: build and flash internal marlin
Test: m -j libbase
Test: build with BOARD_VNDK_VERSION := current
(cherry picked from commit c28517f956)
Merged-In: I720a00deada4e62628e6fbc4ac830265de9c669f
Change-Id: I720a00deada4e62628e6fbc4ac830265de9c669f
Test: can include headers in other soong modules
Bug: 33241851
(cherry picked from commit 8f56c1ecd7)
Merged-In: Ie3d11d1559f5aae46125695fd1f3a63da8e429ae
Change-Id: Ie3d11d1559f5aae46125695fd1f3a63da8e429ae