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
Removes segfault if T* out != nullptr and just
returns validation result.
Bug: 110758329
Test: libbase_test
Change-Id: I0f304533a7076bba977fbd1a715b9cc0d9e58e75
This reverts commit fcf2c01b55.
Commit broke full-eng, because libbase is being compiled against the NDK.
Test: treehugger
Change-Id: I8447b6a7fc33e6aa34cec0f037727322fa824446
There's still <cutils/atomic.h> in a test, but I don't understand why
that isn't just std::atomic.
Also add a shared tgkill wrapper to libbase.
Bug: N/A
Test: ran tests
Change-Id: Idd4baa1e1670a84b3a8f35803cc5ffe5aae008a6
Bug: http://b/69933090
Bug: http://b/69933068
MinGW uses gnu_printf to force C99 printf analysis with GCC, but clang
does not support gnu_printf. So just use the default that's used for
other platforms. This also mirrors upstream commit
015e637b4b/.
Test: m native-host-cross with Clang.
Change-Id: I3deb266d70e25296c4ae1d58637afbabc3d949c1
Bug: http://b/69933068
Bug: http://b/91353691: std::chrono_utils is not available in the
libstdc++ in the mingw/gcc prebuilts. They can be used once we switch
to using libc++ for Windows host.
Test: m native-host-cross with Clang
Change-Id: If9f0f1f201d5e4e445890075ad64c2d6086b0491
This change lets android::base::ScopeGuard be useful in STL containers
(e.g. std::vector<android::base::ScopeGuard<std::function<void()>>>). It
also provides perfect forwarding for android::base::make_scope_guard.
Bug: 34764308
Test: libbase_test
Change-Id: I7d1e5494b0f0695763cff0700efdb9ec18ae85c8
Allow the default tag (the program name) to be overwritten.
Bug: 34867873
Test: m
Test: logging_test
Test: manual
Change-Id: I4ef32bad413a7cc82e46ce16a2f26212925964b1
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
If LOG_TAG was not defined, falling back to a default
behaviour (using binary name).
Bug: 35361699
Test: manual
Change-Id: I209a6ebaf0df882f98642f6d1831766cb296c951
We should have done this from the beginning. Thanks to Windows, we're not
going to be able to switch libbase over to std::string_view any time soon.
Bug: N/A
Test: ran tests
Change-Id: Iff2f56986e39de53f3ac484415378af17dacf26b
Add some helper macros that perform regex string matching to
<android-base/test_utils.h>.
Test: libbase_test32/64 on host
Change-Id: I1b0f03dc73f8b4fdfb8ac6c75d59ef421e0e9640
This reverts commit 4ef5011a7b.
Reason for revert: Breaks an internal mocking case that cannot be changed.
Test: m
Change-Id: I83f9338bde02eb2b45b3e52b66ef78490ddbeeda
In most reasonable cases, this is actually a bug. So delete the
operator overload and let the compiler complain.
Test: m
Change-Id: I7d66ec2f33cc46588b6f549876241871f19ce995
Some tests may create a File* by calling fdopen() on the temp file's
fd. We should release the ownership of fd in this case to avoid the
double close.
Bug: 65430057
Test: libbase unit tests pass
Change-Id: I54fcce2029f9a574f53afdbdda737ee58620c73a
Clang's assert_capability and assert_shared_capability annotations are
nonfunctional until https://reviews.llvm.org/rL309725 is relanded and
makes its way into our toolchain. Work around this by using the
equivalent assert_lock and assert_shared_lock.
Bug: http://b/64226736
Test: manual
Change-Id: I40711f162ea1d492f1e0b3eff88bf6ae6d995e2f
The use of ReadAtOffset is meant to allow concurrent access
to the zip archive once it has been loaded. There were places
where this was the case, and some places that did a seek + read
combination, which could lead to data races.
NOTE: On Windows, we are not using pread as the implementation of
ReadAtOffset, therefore the guarantees on Windows are weaker.
On Linux, pread allows the file descriptor to be read at a specific
offset without changing the read pointer. This allows inherited fd's
and duped fds to be read concurrently.
On Windows, we use the ReadFile API, which allows for an atomic seek +
read operation, but modifies the read pointer. This means that any mix
use of ReadAtOffset and Read will have races. Just using ReadAtOffset is
safe.
For the Windows case, this is fine as the libziparchive code now only
uses ReadAtOffset.
Bug: 62184114
Bug: 62101783
Test: make ziparchive-tests (existing tests pass)
Change-Id: Ia7f9a30af2216682cdd9d578d26e84bc46773bb9
* Update android::base::utf8::open/unlink to support Windows long
paths
* Add android::base::utf8::fopen, also with support for Windows long
paths
* Upcoming CLs will add additional APIs to support additional use cases
Test: Added tests to utf8_test
Bug: 38268753
Change-Id: If72af327f3487766f5370a2f43ee9cabd4a8a810
::android::base::GetMinimumLogSeverity() is defined externally, so the
static analyzer was allowed to assume that we continue executing after a
LOG(FATAL).
I manually audited all of the code I have access to, and the only
"change the minimum log severity" statements I can see keep FATAL
enabled (...and continuing after a FATAL is highly sketchy to me
anyway).
(I'm sure I tested this at some point in making the previous patch. I
probably broke it in a refactor before sending it out for review; my
bad. :) )
Bug: None
Test: m without the static-analyzer builds; m with it yields fewer
false positives.
Change-Id: I216cd2034e1daa8d6f6c5e776f64b4cce88bb938