Commit graph

204 commits

Author SHA1 Message Date
Elliott Hughes
fdc642643d Reduce <CallStack.h> namespace pollution.
Use the CALLSTACK_ prefix uniformly, and undefine all the macros
at the end of the file.

Change-Id: Ie5f92bb8cb8b3753082b1c1145696a1e0409e04d
2024-02-23 00:46:16 +00:00
Serdar Kocdemir
593b19b5ce Check if ALWAYS_INLINE is already defined
Fixes build errors when using callstack library in gfxstream
project, where the definition is already made.

Test: build
Change-Id: I80d4038160725b5dc70f9af93d338aca66a2f0d5
2024-02-14 17:52:19 +00:00
Steven Moreland
34a09861af libutils: Looper add 'repoll'
To help cases where kernel drivers do not
implement poll events correctly.

Bug: 316829336
Test: boot

Change-Id: Ibad16a8e8e061a5be8cede7e8680c3095d6e6f32
2024-01-23 21:51:13 +00:00
Steven Moreland
c738370273 libutils_binder: isolate headers
This isolated all libutils_binder headers from libutils
except for RefBase use of CallStack.h. This header can
be disabled with a macro option easily.

Bug: N/A
Test: N/A
Change-Id: I83af091fc17b5418ab9e4d7fc41fb43792ec547d
2023-10-24 23:45:01 +00:00
Steven Moreland
7a1ca59839 libutils: split out libutils_binder
Dependencies of libbinder, so we can build
a core libbinder library, libbinder_sdk.

This is preparing the way to move this part of libbinder
together with binder code into a single project.

Bug: 302720583
Change-Id: Icff078ac6e36c7f2b91cf815d5b9ed19b2e706e1
2023-10-09 21:56:15 +00:00
Tomasz Wasilczyk
010c37b615 Revert "Revert "Lock down String8|16.string() usage""
This reverts commit 7210b285c2.

Reason for revert: attempt re-submit

Change-Id: Ia95d11628c512163ae3d13cbdd5ebbe60f435937
2023-09-15 22:22:14 +00:00
Devika Krishnadas
7210b285c2 Revert "Lock down String8|16.string() usage"
This reverts commit 8b95a12489.

Reason for revert: DroidMonitor: Test failure

Change-Id: I09230ea7c3b80e1b4d277d3c6c6355a38f7bbc92
2023-09-15 18:46:03 +00:00
Tomasz Wasilczyk
8b95a12489 Lock down String8|16.string() usage
All users should migrate to .c_str()

Bug: 295394788
Test: make checkbuild
Change-Id: Ic6295848cf3377e0bf5334448d5ed7ea53fae7ae
2023-09-14 18:37:52 +00:00
Tomasz Wasilczyk
358a982b71 Merge "Lock down String8.isEmpty() usage" into main 2023-09-14 16:18:49 +00:00
Tomasz Wasilczyk
8b5c8477f9 Lock down String8.isEmpty() usage
All users should migrate to .empty()

Bug: 295394788
Test: make checkbuild
Change-Id: I5ec7921b9cf70e6b0857e1087f141dce958d2587
2023-09-14 15:04:00 +00:00
Tomasz Wasilczyk
771bda6c0b Merge "Implement android::String access methods that avoid C string cast" into main 2023-09-12 20:43:20 +00:00
Tomasz Wasilczyk
86c9ea8f86 Implement android::String access methods that avoid C string cast
Bug: 295394788
Test: m checkbuild
Change-Id: If25fd69319171e8c549fc8fcfd95a0819291d8e6
2023-09-12 17:25:29 +00:00
Tomasz Wasilczyk
8245afd47d Merge "Revert "Revert "Revert "Revert "Drop all path-related methods from android::String8""""" into main 2023-09-12 14:02:13 +00:00
Tomasz Wasilczyk
a1853516ff Revert "Revert "Revert "Revert "Drop all path-related methods from android::String8""""
This reverts commit 141255f30c.

Reason for revert: Attempt re-submit again

Change-Id: I0e568fdf8f7a141ee3c5d54f68530ff478a47439
2023-09-11 17:45:16 +00:00
Rhed Jao
d395f638fa Merge "Revert "Revert "Revert "Drop all path-related methods from android::String8"""" into main 2023-09-11 03:43:31 +00:00
Rhed Jao
141255f30c Revert "Revert "Revert "Drop all path-related methods from android::String8"""
This reverts commit 4b6a7c3940.

Reason for revert: b/299695302, b/299694769

Change-Id: I89c6719d23446f2f9ce24e5b75d321538b580431
2023-09-11 02:05:58 +00:00
Tomasz Wasilczyk
b2b037d9f0 Merge "Revert "Revert "Drop all path-related methods from android::String8""" into main 2023-09-08 19:59:48 +00:00
Tomasz Wasilczyk
9cbae9d75b Merge "Drop String8::std_string" into main 2023-09-08 18:17:25 +00:00
Tomasz Wasilczyk
4b6a7c3940 Revert "Revert "Drop all path-related methods from android::String8""
This reverts commit cff2e40d19.

Reason for revert: Attempt re-submit

Change-Id: I8802b519e4ae3046858b854815ba580c7a6b965d
2023-09-08 11:03:59 -07:00
Tomasz Wasilczyk
cff2e40d19 Revert "Drop all path-related methods from android::String8"
This reverts commit b9dc1c2991.

Reason for revert: http://b/299624573

Change-Id: I0d5993295df65ec31c180b6b5a76fbe939891f45
2023-09-08 17:08:39 +00:00
Tomasz Wasilczyk
adaf33026a Drop String8::std_string
This method was preserved under assumption it would be baked into many
prebuilts, but since it's inline, there should be no linkage to libutils
- thus, should be safe to remove anyway.

Bug: 35363681
Bug: 295394788
Test: treehugger
Change-Id: I59964935600e9e786424136177bfc8a70bebec67
2023-09-08 09:51:24 -07:00
Tomasz Wasilczyk
b9dc1c2991 Drop all path-related methods from android::String8
Move them to androidfw and aapt, the last users.

Bug: 295394788
Test: m checkbuild
Change-Id: I7268b88d11bf221f93efed06cfd1ee65449a2421
2023-09-08 03:07:52 +00:00
Tomasz Wasilczyk
9578c774a9 Merge "Implement String8|16::empty and String16::length" into main 2023-08-24 18:31:56 +00:00
Tomasz Wasilczyk
92ad0d32c0 Merge "Lose convertToResPath to aapt." into main 2023-08-24 16:46:49 +00:00
Elliott Hughes
1d98fe0d39 Lose convertToResPath to aapt.
aapt (not aapt2) is the only user.

Test: treehugger
Change-Id: Ie69f84f4f805c69f838e345b44755a316b9f9b06
2023-08-24 04:33:05 +00:00
Tomasz Wasilczyk
2676893dd8 Implement String8|16::empty and String16::length
This time following std::string::empty meaning.

String16::length is for parity with String8::length and to
follow std::string::length/size duo.

Bug: 295394788
Test: mma
Change-Id: I43df2cbb9ca6f980a4cf6d971064d594d661f884
2023-08-18 22:07:28 +00:00
Tomasz Wasilczyk
6d1b644930 Drop String::empty()
This method causes confuction and bugs by having the same name, but
different meaning versus std::string::empty().

Bug: 295394788
Test: make checkbuild
Change-Id: I15aadc023b20559930e4ec79f43f7032e8cd90d0
2023-08-18 22:07:28 +00:00
Tomasz Wasilczyk
90af4157c5 Add String16::c_str and start using it.
This is for parity with String8::c_str and in general the first step
in transition from String8|16.string() - to make it more similar to
std::string.

Bug: 295394788
Test: mma -j
Change-Id: I6c1411bef07c761fb2fb3fb38c27801ac4cffc57
2023-08-11 19:40:34 +00:00
Tomasz Wasilczyk
aab4105ef6 Drop const assignment operator.
Also, silence cert-oop54-cpp - self-assignment is already handled in
VectorImpl class.

Bug: 289151149
Test: it builds
Change-Id: I8be7714ed53d1515df7cfdf6de6f3c90b3e5cc76
2023-06-28 11:21:47 -07:00
Fabien Sanglard
2aba0a2283 Fix LruCache, allow std:string caching
The default initalization for mNullValue uses 0 which is in the case of
a std::string TValue will invoke the contructor with undefined behavior
parameter.

Using an empty uniform initialization {} addresses the problem.

Test: Already tested in lrucache_test.cpp
Bug: 257127748
Change-Id: I37420ce8a16c99f3014538a0208d7e113870b1c7
2023-06-15 00:37:52 +00:00
Biswapriyo Nath
890f064990 libutils: Fix missing definition of shared_ptr and unique_ptr
This includes memory header for shared_ptr and unique_ptr templates.
Fixes the following errors:

RefBase.h:803:1: error: ‘shared_ptr’ does not name a type
RefBase.h:810:1: error: ‘unique_ptr’ does not name a type

Change-Id: I6a7a67333c9ef05250c5a3c6199d7fac288f946b
2022-11-25 12:15:53 +05:30
Ryan Prichard
4913ca88e5 Remove unnecessary std::unary_function base classes
The function objects work equally well without them, and the base
classes were wrong for both types:
 * HashForEntry: returns size_t but declared to return hash_t
   (uint32_t)
 * EqualityForHashedEntries: returns bool and takes two parameters but
   declared to return hash_t and take one parameter

std::unary_function was deprecated in C++11 and removed in C++17.
Upstream libc++ now removes the type for new-enough C++ dialects.

Bug: http://b/175635923
Test: treehugger
Change-Id: I2ff15c5da6a4e4f71df08c243f8af2f11d8d2b0d
2022-08-26 20:24:57 -07:00
Steven Moreland
643d08e706 Merge "RefBase: test for stack check" am: 5daa3bb90e
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2169132

Change-Id: Ib7b35af8469fdc563244f2dde4a4e0ee91e7f35a
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-07-29 18:31:32 +00:00
Steven Moreland
cd4ef87efd RefBase: test for stack check
Surprised this isn't breaking anything, so wanted to
make sure it worked.

Bug: 232557259
Test: libutils_test
Change-Id: Iaec47d644c02dc190e397c6f84dcfab4cc76f566
2022-07-29 00:54:57 +00:00
Steven Moreland
de52706513 Merge "libutils: RefBase always disallow on stack" am: 51e98b8378
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2166102

Change-Id: Ia8b3205fbb6e36b3c85a378df4c63db4f32759f5
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-07-28 16:29:49 +00:00
Steven Moreland
c340a08b1b libutils: RefBase always disallow on stack
Before, we only did this in sp<> constructors, but we can always make
this check during the initial incStrong.

Since prebuilts call into the existing report race function declared
in StrongPointer.h, we still call this function from RefBase.cpp.

Bug: 232557259
Test: libutils_test
Change-Id: I4080b1869b83ecf655fc9c182b6de768a6358adf
2022-07-26 22:10:51 +00:00
Xin Li
ebe6598a1c Merge tm-dev-plus-aosp-without-vendor@8763363
Bug: 236760014
Merged-In: Ia927c19f544536f78c20ccef5830bd1be0cebf9b
Change-Id: I0267b9eaad470a56db68f3a0b99abfc41192c6d7
2022-06-28 21:23:43 +00:00
Steven Moreland
9d8af6af65 RefBase: disallow make_shared, make_unique
It's risky to mix multiple-ownership types. Taken from SharedRefBase.

Bug: 232557259
Test: N/A
Change-Id: Ic0dbd6d11e44fa9db87c4f9b1776d4989cbf9f56
2022-06-22 21:54:43 +00:00
Treehugger Robot
e7da3eb805 Merge "Doc Thread requirement." am: c545516e2c am: 40ce64b6db
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2094349

Change-Id: I95cebb43fcd70803fe0bdece39d57546053264cb
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-12 03:21:16 +00:00
Treehugger Robot
c545516e2c Merge "Doc Thread requirement." 2022-05-12 01:53:32 +00:00
Christopher Ferris
39819bbc94 Merge "Use the new AndroidUnwinder object." am: af4db6749a am: ce1c33332c
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2095264

Change-Id: Icc76b39136bce395106c070aeb338d4e6922a28e
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-12 00:32:48 +00:00
Steven Moreland
90722d254e Doc Thread requirement.
Fixes: 230893354
Test: N/A
Change-Id: I426184840c7bf61fe3369388cfc6db184470acf0
2022-05-11 23:13:17 +00:00
Christopher Ferris
ab63124cd9 Use the new AndroidUnwinder object.
Replaces libbacktrace in CallStack. There is one small behavioral
change, the BuildId data is added to the unwinds.

Bug: 120606663

Test: All unit tests pass.
Test: Run the fuzzer for over an hour without any crashes.
Change-Id: Ic8a4247c515ce0d3cdc4d2cc15167d1948b15fa5
2022-05-10 17:19:12 -07:00
Treehugger Robot
8da2dbe534 Merge "Fix TEMP_FAILURE_RETRY on non-GNU C++ dialects" am: addba34668 am: aae9c4ec53 am: 5c3f7bd328
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2025446

Change-Id: I73dae25afe75e8e26f365898685a6a17d6ff635d
2022-03-17 06:31:05 +00:00
Treehugger Robot
1727c0c622 Merge changes Iee0932b5,I0d77c490 am: f8cd69af8b am: e8c3bd931b am: 4db635bb0a
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2025448

Change-Id: Ic6452433dc944a8d53dc78c70815e18492f9f61b
2022-03-16 23:22:07 +00:00
Andrei Homescu
fcbc96191c Fix TEMP_FAILURE_RETRY on non-GNU C++ dialects
TEMP_FAILURE_RETRY uses typeof which is only allowed by gcc and clang
for GNU dialects. This switches to __typeof__ which is always supported.

Bug: 224644083
Test: m
Change-Id: I96d48d2f0dc5cd9ab903755d93c71c4eb80f7529
2022-03-16 20:54:31 +00:00
Andrei Homescu
aa4ebf2ce1 Fix Errors.h on systems that define NO_ERROR
Some systems (originally only Windows) define their own
NO_ERROR macro that overlaps with the enumerator from Errors.h.
The enumerator is only defined if the macro was not.

Bug: 224644083
Test: m
Change-Id: Iee0932b5259b3bfcf6494656b27e6e7488319f5c
2022-03-16 02:15:04 +00:00
Treehugger Robot
e76d8254bf Merge "Fix OkOrFail<status_t> conversion ambiguities" am: 5a1f51b070 am: fb78f6f5e4 am: 7826f9a738
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2000911

Change-Id: Ia5c6fc34fe562a143d18acd89688b88e125442b2
2022-02-25 22:34:41 +00:00
Atneya Nair
dde6034eac Fix OkOrFail<status_t> conversion ambiguities
OkOrFail<status_t> has specialized conversions for Result<int, StatusT>
to avoid ambiguous implicit conversion sequences. Since user conversion
operators sequences can be followed by integral promotion, specializing
for integral types is necessary.

Specialize ResultError<StatusT> so calling code() returns a status_t
instead of a StatusT and message() is implemented even when not carrying
a string.
Eventually, these classes should be combined.

Add equality operators for ResultError<StatusT>.

Bug: 219580167
Test: atest Errors_test.cpp
Merged-In: I14acecfd2aef33c40e79ddb091e2f4af9291d837
Change-Id: Ifb5ed3c2d3452b10901e4aeb19368d873225d9ce
2022-02-25 14:27:41 -05:00
Jiyong Park
549a4a638b OR_RETURN supports status_t am: 705abe2d30 am: e1bd3f4b34 am: 29f45b2f1f am: 96413ff019
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1922318

Change-Id: I4c1dc92f6bcb231c6d3578454b1bb3959f8e2faf
2022-01-12 08:37:12 +00:00