Commit graph

293 commits

Author SHA1 Message Date
Josh Gao
fdf832dfd3 base: add Pipe and Socketpair wrappers.
Also, switch debuggerd_handler over to using android::base::unique_fd.

Test: treehugger
Change-Id: I97b2ce22f1795ce1c4370f95d00d769846cc54b8
2017-08-28 14:51:07 -07:00
Dimitry Ivanov
2732a7e023 Merge "Define current ABI string in android-base/macros.h" 2017-08-24 09:38:34 +00:00
dimitry
b6ba817de4 Define current ABI string in android-base/macros.h
Test: make
Change-Id: I8200d7b3232edba43a583c5ff1e1b0f78c768f69
2017-08-23 20:46:38 +02:00
Justin Yun
9ca92458e2 Mark the modules as VNDK-SP in Android.bp
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)
2017-08-23 17:56:13 +09:00
Josh Gao
b5c90e9d6b Merge "Revert "base: work around thread safety analysis bug."" 2017-08-02 23:10:42 +00:00
Josh Gao
c54e3dba8d Revert "base: work around thread safety analysis bug."
This reverts commit e4509da961.

Reason for revert: probably breaks checkbuild?

Change-Id: I04a6284dee82761c90fa355da0472855a228b849
2017-08-02 23:10:26 +00:00
Josh Gao
f3c7f10abd Merge "base: work around thread safety analysis bug." 2017-08-02 23:09:07 +00:00
Josh Gao
e4509da961 base: work around thread safety analysis bug.
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
2017-08-02 14:44:58 -07:00
Adam Lesinski
5fff67f2ec Add definition of off64_t for mac os builds
Mac OS does not define off64_t, since off_t is always 64 bit.

Test: manual
Change-Id: Ib02a912a2eaf38143e124f2b6aaf294ecf84ff88
2017-07-25 16:26:23 -07:00
Adam Lesinski
a0360ad6a3 Merge "libziparchive: Use ReadAtOffset exclusively" 2017-07-25 22:22:21 +00:00
Adam Lesinski
de117e4a49 libziparchive: Use ReadAtOffset exclusively
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
2017-07-25 18:12:12 +00:00
Lennart Wieboldt
cd15fc7ba8 Remove LOCAL_CLANG and clang: true
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>
2017-07-25 14:29:50 +02:00
Tom Cherry
ede0d53850 Move Timer from init to libbase
Test: boot bullhead
Test: new libbase unit tests

Change-Id: Ic398a1daa1fe92c10ea7bc1e6ac3f781cee9a5b5
2017-07-10 09:28:24 -07:00
Renaud Paquay
e3e7813e5f Add (partial) support for Windows long paths
* 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
2017-06-28 17:12:37 +00:00
George Burgess IV
6466ced8f6 logging: make LOG(FATAL) always run with the static analyzer.
::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
2017-05-31 14:41:22 +00:00
George Burgess IV
7e771de38f logging: always enable DCHECK for the static analyzer
This helps us have less false-positives.

We do this instead of `#undef NDEBUG`, since undefing NDEBUG actually
gave us more false-positives (...and build breakages) than simply
leaving it defined.

Bug: None
Test: Ran the static analyzer across internal master. 213 fewer warnings
(15 Medium, 2 Low, the remainder are 'Analyzer'). All of the dropped
warnings I audited were false-positives. It adds ~3 Tidy warnings.
Change-Id: Ibedab60ca7e9d2b0772896222b83d2e7ab064afe
2017-05-26 11:04:48 -07:00
Elliott Hughes
282ec458be Remove libbase's trivial libutils-headers dependency.
Bug: N/A
Test: builds
Change-Id: I59eb464a0127564a42775bf19b516ad8a53ee235
2017-05-15 17:31:15 -07:00
George Burgess IV
582ec2b078 fix static-analyzer logging/CHECK macros
Two small changes in one:

- `foo || for (;;abort()) bar();` isn't valid C or C++, since for is a
  statement. We need an expression instead.
- we'll now treat everything after LOG(foo) as unreachable in the
  static analyzer, as long as we can prove at compile-time that
  foo == FATAL.

The impact of this, running across internal master, is that we see ~50
fewer medium/high-severity false positives from clang-tidy. We see 15
new complaints about unreachable code (at the "tidy" severity), but all
of them are harmless AFAICT (e.g.

switch (foo) {
  // ...
  default:
    LOG(FATAL) << "Unhandled case!"; // or CHECK(false);
    break; // clang-tidy: unreachable break.
})

(Some of the macros were forcibly formatted by the clang-format hook)

Bug: None
Test: Ran
`DEFAULT_GLOBAL_TIDY_CHECKS=clang-analyzer*,-clang-analyzer-alpha* m`;
stared at warn.py output.

Change-Id: Ie984eda0481afad4274b9def7c61ba777cfa289a
2017-05-03 17:16:01 -07:00
Josh Gao
637483de91 base: remove execute bit from utf8.cpp, utf8_test.cpp.
Test: none
Change-Id: Idcd7feb2f3a7dc8706c498c55100e82d029858e0
2017-04-27 19:10:07 -07:00
Colin Cross
4eda982a77 Don't export libutils_headers from libbase
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
2017-04-20 10:36:32 -07:00
Steven Moreland
e131f31db5 libbase: fix build breakage
Two changes were merged at the same time that conflicted.

Test: builds
(cherry picked from commit 72b9d28423)
Merged-In: Ia6c730804cd5a3b2655e6d69b8e4f346d198dabb
Change-Id: Ia6c730804cd5a3b2655e6d69b8e4f346d198dabb
2017-04-19 10:39:54 -07:00
Steven Moreland
d10a023208 libbase: make 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: 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
2017-04-19 10:32:47 -07:00
Steven Moreland
3c71bbdde3 libbase: add libbase_headers
Test: can include headers in other soong modules
Bug: 33241851
(cherry picked from commit 8f56c1ecd7)
Merged-In: Ie3d11d1559f5aae46125695fd1f3a63da8e429ae
Change-Id: Ie3d11d1559f5aae46125695fd1f3a63da8e429ae
2017-04-19 10:32:41 -07:00
Tom Cherry
5c3961c547 Merge "Add android::base::ScopeGuard" 2017-04-06 22:41:02 +00:00
Tom Cherry
c996a8e73e Add android::base::ScopeGuard
Taken from bionic/libc/private/ScopeGuard.h.

Test: New unit tests
Change-Id: If83c1990efbf294aee0b5d40a7a9ac326e5e765e
2017-04-05 16:15:33 -07:00
Christopher Ferris
48d08c2c9d Convert opens to use unique_fd.
Fixes a potential leak of fds in WriteStringToFile.

Test: I wrote a temporary test that failed the fchmod on host in
Test: WriteStringToFile. I verified this fails with the old code after running
Test: out of fds and passes with the new code.
Change-Id: I168160841e35dd480d59a69bb4aa8176899fbb32
2017-04-05 12:30:12 -07:00
James Hawkins
e78ea77f69 bootstat: Refactor init/utils/boot_clock into base/chrono_utils.
Use this for bootstat and init. This replaces the custom uptime parser in
bootstat.

This is a reland of aosp/338325 with a stubbed implementation for Darwin.

This change also has clang_format fixes (automatic).

Bug: 34352037
Test: chrono_utils_test
Change-Id: I72a62a3ca1ccfc0a4ccc6294ff1776c263144686
2017-03-30 14:24:12 -07:00
Tom Cherry
3d5729402e Fix timeouts for android::base::WaitForProperty*
std::chrono doesn't handle integer overflow, so using
std::chrono::milliseconds::max() to indicate an infinite timeout is
not handled well in the current code.  It causes an 'absolute_timeout'
earlier in time than 'now' and causes the associated WaitForProperty*
functions to return immediately.

Also, any duration_cast from relative_timeout to nanoseconds would
cause the same issue, as it would overflow in the conversion and
result in an invalid results.

This change prevents any duration_casts of relative_timeout to
nanoseconds and replaces the logic to wait on an absolute timeout with
logic that compares the time elapsed to the provided relative timeout.

This change also includes a test that std::chrono::milliseconds::max()
does not return immediately and that negative values do return immediately.

Test: Boot bullhead + libbase_test

Change-Id: I335bfa7ba71e86c20119a0ed46014cad44361162
2017-03-27 18:05:58 -07:00
Elliott Hughes
9bb7971ae7 Keep the ReadFileToString/ReadFdToString overhead down.
Bug: https://code.google.com/p/android/issues/detail?id=258500
Bug: http://b/36046324
Test: ran tests
Change-Id: I40e76a6dd164ea9a5e8e18159f543e1bb221dcba
2017-03-21 13:43:08 -07:00
Dimitry Ivanov
840b6019c0 Add android::base::Realpath.
Bug: http://b/31396973
Test: libbase_test on host and device
Change-Id: I1e5f15c76227ec1c2128baa38eb454d347987703
2017-03-15 22:20:50 -07:00
Tom Cherry
5b4eb23cfd Remove extraneous .clang-format files
The .clang-format files in the base, debuggerd, adb, libprocinfo, and
fastboot subdirectories each differ slightly from the top level
.clang-format-2 and .clang-format-4, but not in a substantially
meaningful way, as the source files in those directories have not been
re-formatted with clang-format.  Therefore, let's reduce the
differences and use only the two top level clang-format files.

Secondly perform some small clean-up of the top level .clang-format
files.  AllowShortBlocksOnASingleLine is already false in the Google
style, so it can be removed.  AllowShortFunctionsOnASingleLine should
not change between the -2 and -4 versions, so leave it at the Google
default style in both, which is 'All'.

The diff stats for these changes are:

./base/
Old:
640 insertions(+), 531 deletions(-)
New:
563 insertions(+), 808 deletions(-)

./debuggerd/
Old:
910 insertions(+), 886 deletions(-)
New:
991 insertions(+), 1023 deletions(-)

./adb/
Old:
2623 insertions(+), 2886 deletions(-)
New:
2655 insertions(+), 3103 deletions(-)

./libprocinfo/
Old:
2 insertions(+), 1 deletion(-)
New:
4 insertions(+), 18 deletions(-)

./fastboot/
Old:
618 insertions(+), 743 deletions(-)
New:
726 insertions(+), 882 deletions(-)

./init/
Old:
1755 insertions(+), 1866 deletions(-)
New:
1715 insertions(+), 1952 deletions(-)

Test: Above clang-format stats
Change-Id: I3f7b8ab0660c8394c5008ba95ea15e70dd22b55b
2017-03-14 14:06:31 -07:00
Keun-young Park
22a64b3a8a Merge "add base::WaitForPropertyCreation" 2017-02-28 22:39:41 +00:00
Keun-young Park
e2d986daa6 add base::WaitForPropertyCreation
- unlike base::WaitForProperty, which waits for specific value to
  be set, this one only waits until the property is created.

bug: 35178781
Test: added unit test
Change-Id: Idbf98c2152fe768357302f6b69310c55305f5d54
2017-02-28 12:08:54 -08:00
Colin Cross
bb3a515f46 Add GetExecutableDirectory to libbase
Tests will often want to get the executable directory in order to
find test data.

Test: out/host/linux-x86/nativetest64/libbase_tests/libbase_tests
Change-Id: Ica9d211bcd039fcf83a22fd494816abd01b97aa3
2017-02-28 16:34:04 +00:00
Colin Cross
58021d15c9 Move adb_dirname and adb_basename to libbase
adb already provides an implementation of dirname and basename that
take and produce std::strings, move it into libbase so it can be
used in the implementation of GetExecutableDirectory.

Test: out/host/linux-x86/nativetest64/adb_test/adb_test
Test: out/host/linux-x86/nativetest64/libbase_test/libbase_test
Test: adb shell /data/nativetest64/libbase_test/libbase_test64
Change-Id: Ideb1627607b14562121316d4ed27fa6fb0930684
2017-02-27 18:18:31 -08:00
Elliott Hughes
8a16081fa1 Merge "Add cross-platform <android-base/endian.h>." 2017-02-25 02:07:05 +00:00
Elliott Hughes
1dbd976200 Add cross-platform <android-base/endian.h>.
Bionic has <sys/endian.h>, glibc <endian.h>, and macOS and Windows have
nothing. This has often been annoying.

Bug: N/A
Test: new tests
Change-Id: I2a40c570df6a9bb30607ace1af653265938cc4b8
2017-02-24 14:03:36 -08:00
Elliott Hughes
9f4c8f753b Add some basic docs for <android-base/logging.h>
Bug: http://b/35360600
Test: N/A
Change-Id: I3de6bbe4afc7ca6adbfb0c9b01a5a3d4c2c35cfc
2017-02-22 18:02:46 -08:00
Elliott Hughes
03edc9f764 Add timeout support to android::base::WaitForProperty.
Bug: http://b/35201172
Test: ran tests
Change-Id: I025aa0217dc94fabf0eb076b285a84866b00e741
2017-02-21 14:57:15 -08:00
Elliott Hughes
ec46f4ed28 Only sanitize Android.
Bug: N/A
Test: didn't
Change-Id: I9b9bc04112501eaa9f9ccf23152fc5d118b03000
2017-02-14 15:46:33 -08:00
James Hawkins
91cf0bd5c0 Merge "Revert "bootstat: Refactor init/utils/boot_clock into base/chrono_utils."" 2017-02-14 19:24:36 +00:00
James Hawkins
c8ac067773 Revert "bootstat: Refactor init/utils/boot_clock into base/chrono_utils."
This reverts commit 7c92e48450.

Mac sdk still broken (despite testing locally).

Change-Id: I7d9206e15997cd0efe081bd3fa17d53d2b20ec32
2017-02-14 19:20:20 +00:00
Treehugger Robot
aa9548dbb4 Merge "Fix ubsan failure in android::base::Split." 2017-02-14 18:43:17 +00:00
Treehugger Robot
e968b73e19 Merge "bootstat: Refactor init/utils/boot_clock into base/chrono_utils." 2017-02-14 18:35:54 +00:00
Treehugger Robot
01003d40fc Merge "Implement android::base::WaitForProperty." 2017-02-14 03:48:26 +00:00
Yabin Cui
b13d4a31a3 Merge "libbase: fix the way to find temp dir." 2017-02-14 00:29:40 +00:00
Yabin Cui
57e9cea099 libbase: fix the way to find temp dir.
Tests running in app context can't access /data/local/tmp,
so try current directory if /data/local/tmp is not accessible.

Bug: http://b/18790309
Test: run unit test in app context and shell context.
Change-Id: If66fe8f0ac3edb3a32a2a2a50a524364f818a58b
2017-02-13 15:50:56 -08:00
James Hawkins
7c92e48450 bootstat: Refactor init/utils/boot_clock into base/chrono_utils.
Use this for bootstat and init. This replaces the custom uptime parser in
bootstat.

This is a reland of aosp/332854 with a fix for Darwin.

Bug: 34352037
Test: chrono_utils_test
Change-Id: Ib2567d8df0e460ab59753ac1c053dd7f9f1008a7
2017-02-13 15:47:21 -08:00
Elliott Hughes
bf0dd7cb03 Fix ubsan failure in android::base::Split.
ubsan doesn't like us incrementing std::string::npos, even if we won't use
the result.

Bug: http://b/28729303
Test: ran tests
Change-Id: I8227eca57dc6f3e49626c7025514caa04ef18f0a
2017-02-13 14:13:24 -08:00
Elliott Hughes
b30769a87a Implement android::base::WaitForProperty.
Also adapt libcutils to the bionic change that was necessary for this.

Bug: http://b/35201172
Test: ran tests
Change-Id: I72a98b70b03d23e958b46778b505fbd5c86c32ae
2017-02-13 11:29:02 -08:00
James Hawkins
0e3167e203 Revert "bootstat: Remove custom uptime parser in favor of elapsedRealtime."
This reverts commit 26f40c04c3.

This change broke the Darwin SDK target.

Test: none
Change-Id: Ia54fe2c31da8d8fa2825e023b035fb8321dcd457
2017-02-08 14:16:51 -08:00
James Hawkins
26f40c04c3 bootstat: Remove custom uptime parser in favor of elapsedRealtime.
Refactored init/utils/boot_clock into base/chrono_utils.

Bug: 34352037
Test: none
Change-Id: Ied0c00867336b85922369d7ff37520e3d28fc61e
2017-02-07 15:43:32 -08:00
Yabin Cui
0c68953778 base: support logging before enter main function.
Bug: http://b/30974760
Test: run libbase_test.

Change-Id: I3f45fc21e8fe6301b5fef027728ea91f2188911d
2017-01-25 15:50:47 -08:00
Elliott Hughes
2140782d24 bootable/recovery wants EqualsIgnoreCase.
Bug: N/A
Test: ran tests
Change-Id: I4a6ee9eba0514b8bb8fb0489f4d370964ce9c1c2
2017-01-13 18:51:32 -08:00
Elliott Hughes
a6c65704d6 Fix libbase file.Readlink test on marlin/sailfish.
Bug: http://b/33306057
Test: ran tests
Change-Id: Ie6797e71d3507572da66d6b6966f8ee9373124a4
2017-01-11 17:34:40 -08:00
Charles He
40feda6ae9 [nit] Fix typo in properties.h
Test: none
Change-Id: I6fe25bc9404c18bedc5802b3d830ede8a1bc28df
2016-12-15 10:47:32 +00:00
Stephen Hines
b0775ca517 Switch to memcpy for accessing misaligned data.
Bug: http://b/31532493

Using misaligned pointers forces us to potentially take the address of
members in a packed structure (which is now a warning/error in the
latest Clang). Using memcpy() is the proper way to handle this kind of
problem, as the compiler can insert the proper instructions (and usually
elide the memcpy() entirely).

Test: Built correctly with updated compilers.
Change-Id: Ia1f6eb62cf19404ff76b71d3c6c7ffffa1403120
2016-12-07 03:46:55 -08:00
Dan Willemsen
ab34b47b35 Enable libbase/libutils/libziparchive on host bionic
Bug: 31559095
Test: Test linux_bionic compile
Change-Id: Ib42c063532c1cbeb3e1418ab16a1fb54d5902aab
2016-11-29 13:38:53 -08:00
Elliott Hughes
42937492c8 Add StartsWithIgnoreCase/EndsWithIgnoreCase.
This has come up a couple of times now.

Bug: wanted as part of http://b/32094640
Test: ran tests
Change-Id: I51b67074b7ddeedd771d7be9651ba33e05491b33
2016-10-25 14:56:04 -07:00
Wei Wang
8c176302e6 Move CapturedStderr to test_util library
Bug: 32181382
Test: run /data/nativetest(64)/binderTextOutputTest
Change-Id: Ifb2e1f6af2c3f57b5cbed7dde65efb31253c52a2
2016-10-22 10:35:21 -07:00
Mark Salyzyn
27d2d49f48 Merge "system/core: preparation to pull back interfaces from android/log.h" 2016-10-20 17:53:45 +00:00
Yabin Cui
d55705796e Merge "libbase: add parsedouble.h." 2016-10-20 17:18:36 +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
Yabin Cui
997cba4271 libbase: add parsedouble.h.
Bug: http://b/24905115
Test: run libbase_test --gtest_filter=parsedouble.smoke.
Change-Id: I604424772f2082b420935e6647da03981c0b8929
2016-10-19 11:19:42 -07:00
Elliott Hughes
da46b392f1 Move off std::sto* function which abort on failure.
Bug: http://b/31403370
Test: builds, boots, libbase tests pass
Change-Id: I89cd7ca3d8f1c8a1bad0ddf3043439449d19a293
2016-10-13 15:34:05 -07:00
Treehugger Robot
392a2c8f0f Merge "Add 0X as a valid hex prefix for parseint" 2016-10-08 10:36:02 +00:00
Yifan Hong
89fbd6349f Add 0X as a valid hex prefix for parseint
Bug: 31983995

Test: make android.hardware.tests.expression@1.0
Change-Id: I526d73f96c519f84dec93befa442b1d2fff7979b
2016-10-07 16:50:16 -07:00
Andreas Gampe
b4e32f3b33 Base: Hand complete log message to aborter
Undo zero-termination-substitution for linebreaks when logging.
This results in handing the complete log message to the aborter.
Add a test.

Bug: 31893081
Test: mmma system/core/base && $ANDROID_HOST_OUT/nativetest64/libbase_test/libbase_test64
Change-Id: I2ef6c6351db2fd494a02985f634f439104136227
2016-10-04 19:19:59 -07:00
Mark Salyzyn
ff2dcd9af9 system/core Replace log/log.h with android/log.h
Should use android/log.h instead of log/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: I33a8fb4e754d2dc4754d335660c450e0a67190fc
2016-09-30 12:47:05 -07:00
Treehugger Robot
aa00f5852f Merge "Base: Remove LOG_S variants." 2016-09-26 00:37:13 +00:00
Andreas Gampe
1f5fb43047 Base: Remove LOG_S variants.
Partially reverts commit 436f5a031f.

Remove the variants taking a fully qualified LogSeverity. Instead
use a lambda with "using" statements to translate both qualified
and unqualified names into valid expressions.

Compile-time regression was measured as 0.1s for a thousand LOG
statements on a z840.

Update tests.

Bug: 31338270
Test: m
Test: mmma system/core/base && $ANDROID_HOST_OUT/nativetest64/libbase_test/libbase_test64
Change-Id: I36fdf30a9d535b19543307b85d1b3c19a97f20dd
2016-09-24 10:18:38 -07:00
Treehugger Robot
3f049c3f19 Merge "Add std::string system property functions." 2016-09-24 04:52:59 +00:00
Elliott Hughes
1e88c8c0ac Add std::string system property functions.
Makes it easier to write correct code in a world where the maximum
property key/value lengths change.

Bug: http://b/23102347
Test: libbase_test64
Change-Id: I100f00904221bbcef9e8786a4e6e30428039bb49
2016-09-23 15:30:22 -07:00
Andreas Gampe
19ff8f1e57 Base: Check severity in destructor
Bug: 31338270
Test: m
Test: mmma system/core/base && $ANDROID_HOST_OUT/nativetest64/libbase_test/libbase_test64
Change-Id: Ic077822bcfd591bd11f4fa9d4b6e440b461c70c1
2016-09-23 13:31:52 -07:00
Andreas Gampe
436f5a031f Base: Add more log macros
Add WOULD_LOG to determine whether a given severity would be logged.

Add LOG_STREAM to have direct access to a logging stream.

Add LOG_S variants that take a fully qualified severity. This allows
complex expressions as parameters, e.g., ternaries for conditional
severity levels.

Add tests.

Bug: 31338270
Test: m
Test: mmma system/core/base && $ANDROID_HOST_OUT/nativetest64/libbase_test/libbase_test64
Change-Id: I242b960594e68caff6db9cd8aaa4ce8aaf90474c
2016-09-22 12:47:40 -07:00
Josh Gao
5d1b1a8b91 base: rename unique_fd::clear() to unique_fd::reset().
unique_fd is modeled on unique_ptr, so make this consistent.

Test: m checkbuild
Change-Id: Ia6a77095dc18746fbb432e96bb8dccfc049c57f6
2016-09-19 11:24:58 -07:00
Pirama Arumuga Nainar
70f281ae36 Remove mutex.h and its uses.
mutex.h is now available as a part of MinGW itself.

Test: Successful build
Change-Id: I036ee37600a39130d6fbf293398585cfc58209ca
2016-09-16 15:58:00 -07:00
Josh Gao
ffabc9651f base: add parameter that controls O_NOFOLLOW in file functions.
Bug: http://b/31491920
Change-Id: I19cb06941d87c0180ccab8bb2d85e57338811624
Test: m
2016-09-14 17:08:22 -07:00
Josh Gao
c95afaa20b Fix darwin build break.
Bug: http://b/31468413
Change-Id: I12fdf0977213eefc7043939964070025a672881a
2016-09-14 13:54:45 -07:00
Treehugger Robot
c9c555b8dd Merge changes Ie15fcb8f,I0a895911
* changes:
  base: add quick_exit emulation.
  base: extract mutex.h from logging.cpp.
2016-09-14 20:14:53 +00:00
Josh Gao
0c44256ae4 base: add quick_exit emulation.
Bug: http://b/31468413
Change-Id: Ie15fcb8ff0613d01a0eb7437a2cb37283aa52bab
Test: mma, libbase_test on Linux/Windows
2016-09-13 17:54:50 -07:00
Josh Gao
63bdcb57aa base: extract mutex.h from logging.cpp.
Extract the Windows-specific mutex implementation from logging.cpp.

Bug: http://b/31468413
Change-Id: I0a895911ec6d815b8011b09d55209b64bbf9a70e
Test: mma
2016-09-13 15:59:46 -07:00
Andreas Gampe
d8f26e2ac9 Base: Fix dangling-else in CHECK_STROP
Follow-up to commit 2527628eda.

Bug: 26962895
Bug: 31338270
Test: m
Test: mmma system/core/base && $ANDROID_HOST_OUT/nativetest64/libbase_test/libbase_test64
Change-Id: Ifd71314e146ebf3957cc053ee95ef85002c909b4
2016-09-13 14:16:37 -07:00
Andreas Gampe
2691e335fe Base: Add AbortFunction for logging
Add a hook to modify FATAL behavior. Add a test.

Bug: 31338270
Test: m
Test: mmma system/core/base && $ANDROID_HOST_OUT/nativetest64/libbase_test/libbase_test64
Change-Id: I966da319cda613738b3f2ccdac8c21900d6a5c72
2016-09-08 15:33:27 -07:00
Andreas Gampe
550829d84b Base: Add INTERNAL_FATAL to logging severity
Add the INTERNAL_FATAL level. It will print 'F' like FATAL, but
does not abort after logging.

Add a test to logging_test.

Bug: 31338270
Test: m
Test: mmma system/core/base && adb sync && adb shell /data/nativetest/libbase_test/libbase_test32
Change-Id: Idf74c08e8516881efccaefc58fa3f41d57e56396
2016-09-07 18:19:42 -07:00
Elliott Hughes
13d78e440a Clean up the libbase logging test.
Use ECMAscript regex syntax (the default!) for a simpler regex.

Also test the cartesian product of logging options, with less copy & paste
than the previous test of a subset.

Change-Id: I7aae91d276dbbb8de6173d18b5c1ceb01c1dff73
2016-09-07 16:22:40 -07:00
Andreas Gampe
7c1cdd7700 Base: Fix logging_test
Update the expected logging pattern.

Bug: 31338270
Test: mmma system/core/base && adb sync && adb shell /data/nativetest/libbase_test/libbase_test32
Change-Id: I299620669126bc0258cad6e30d5b40bff5ea92ad
2016-09-07 11:39:59 -07:00
Treehugger Robot
43824e72c7 Merge "Base: assume and use C++11 in libbase" 2016-09-01 22:32:42 +00:00
Andreas Gampe
22847131da Base: assume and use C++11 in libbase
Assume C++11 support. logging.h already used constexpr before,
macros.h now also does no longer check the language level.

Use constexpr for the logging evaluator. This allows the usage
of CHECK and co in other constexpr expressions in C++14.

Test: m checkbuild (N9)
Change-Id: Ifdffa074271fff1f9949c48829a185800ec5e524
2016-09-01 13:38:12 -07:00
Josh Gao
7307f09457 base: use _NSGetExecutablePath in GetExecutablePath
Bug: http://b/31240820
Change-Id: I0dbf95d3667c7ce7b474ddbb3f8e3ed69476d13e
Test: mma && adb kill-server && adb devices
2016-09-01 12:32:35 -07:00
Josh Gao
945d1aaa32 Merge "Add android::base::GetExecutablePath, switch adb and fastboot over." 2016-09-01 18:38:12 +00:00
Elliott Hughes
82ff315bb0 Add android::base::GetExecutablePath, switch adb and fastboot over.
We'd long had two copies of this stuff, so rather than rewrite both
Linux versions to use android::base::Readlink, let's kill the duplication
too...

Bug: http://b/30988271
Change-Id: I4de58a94a22a4b1faf969a6fc70ca1560a4d5121
2016-09-01 09:24:24 -07:00
Treehugger Robot
3f3ea50828 Merge "Base: add more thread annotations" 2016-08-31 22:23:00 +00:00
Josh Gao
ca82aa7d1e Merge "base: disallow close() on unique_fd." 2016-08-31 20:47:13 +00:00
Andreas Gampe
bc5a32e2ad Base: add more thread annotations
These are taken from ART and wrap more attributes.

Test: m
Change-Id: I545fc9ab88cf9d2db4de2cb8893e2a35f6365f51
2016-08-31 13:29:07 -07:00
Treehugger Robot
a7c4424ebc Merge "Add android::base::Readlink." 2016-08-31 17:56:40 +00:00
Elliott Hughes
d3ff6e5231 Add android::base::Readlink.
Bug: http://b/30988271
Change-Id: Ib844d7c9e33465dabf7aee5e24dc3d1d8d799abd
2016-08-31 09:35:44 -07:00
Josh Gao
6496c4bf6f base: disallow close() on unique_fd.
unique_fd's implicit conversion to int allows it to be passed to
close(2), which is dangerous because unique_fd will think that it still
has ownership of the now-closed fd. Disallow this by providing an
overload for close that's tagged with an attribute that gives a
compile-time error.

Test: m
Change-Id: I514591335b337f2f57c1df371cf3979304aea17c
2016-08-29 14:37:49 -07:00
Andreas Gampe
247924a36f Libbase: add C++11 support to DISALLOW_IMPLICIT_CONSTRUCTORS
Use delete when possible.

Test: m
Test: m test-art-host
Change-Id: Ib741564c7a31348b2f706fe55eb23d9886f865e3
2016-08-29 09:36:31 -07:00
Elliott Hughes
7bc87a5a78 Move init's kernel logging into libbase.
This will let other stuff (such as adbd and recovery) use it too.

Bug: http://b/28467098
Change-Id: Idab51f438ed3edd6fe65a56c4b396eaff5f3833e
2016-08-04 16:09:39 -07:00
Elliott Hughes
e5dd71a290 libbase should use its own logging!
Not doing so led to us using a bogus log tag.

Bug: http://b/30281203
Change-Id: I3ac91758a1a043146c65f2ae0f36fcfbe372c30f
2016-07-28 15:15:28 -07:00
Colin Cross
fc06bd0ca3 Convert libbase Android.mk to Android.bp
Change-Id: I429d0a06c5138c3e54c9d25f15adb3e2647496e1
2016-07-11 14:23:32 -07:00
Elliott Hughes
4e5fd111d8 Add timestamps to libbase's stderr logging.
adb is the client that wants this, but I'm not aware of any client that
doesn't.

Bug: http://b/28467098
Test: tested manually with cat.
Change-Id: I82c3f7ddf466a67aedfbb9010e0939a44b71d3e5
2016-06-21 14:27:16 -07:00
Chih-Hung Hsieh
c713bce901 Fix misc-macro-parentheses warnings in init and other core modules.
Bug: 28705665
Change-Id: Ice67cebb8c42538f8fb9cf1756678f41a9d68a31
2016-05-18 18:11:49 -07:00
Josh Gao
13ea01db45 adb/base: allow use of unique_fd inside adb.
adb implements its own file descriptor emulation layer on Windows,
which requires the use of adb_close instead of close throughout the
codebase. Add a template argument to unique_fd that allows for this.

Bug: http://b/28347842
Change-Id: I6397261f4973d49f2f8e04257bf67b348585bb63
2016-05-14 18:25:51 -07:00
Christopher Wiley
2a7b86337f Don't include android-base/macros.h from android-base/unique_fd.h
This prevents a ton of macro collisions when libfoo includes libbinder
includes unique_fd.h.

Bug: 27804373
Change-Id: Ide834afb1052b32e86fad3fcba10cff3dafeb899
2016-04-19 14:45:48 -07:00
Christopher Wiley
ec9ea66a2b Define LIKELY and UNLIKELY in a vendor friendly way
This prevents macro conflicts with vendor code.

Bug: 27804373
Change-Id: I759c2b7b611203d0afdc35ddd5c2adb8f942ea17
Test: Compiles when libbinder include path changes to include libbase.
2016-04-18 16:08:19 -07:00
Elliott Hughes
2c5d1d7cd9 Add operator int() to unique_fd.
Change-Id: I7512559be7befbb8772d5529e06550267a2f1543
2016-03-28 12:15:36 -07:00
Elliott Hughes
3761365735 Merge "Fix <android-base/*.h> header guards." 2016-03-26 16:08:59 +00:00
Elliott Hughes
19388fc312 Merge "Copy the good comment and warn_unused_result from ScopedFd to unique_fd." 2016-03-26 15:53:20 +00:00
Elliott Hughes
54c72aaccc Fix <android-base/*.h> header guards.
I've been meaning to do this for a while, and it came up on the bug below
that there have been conflicts with similar-named files in <base/*.h>,
so let's rule out one possible explanation.

Bug: http://b/27804373
Change-Id: I69e5d52b6260c573c308513420aee0e281426bd4
2016-03-23 15:04:52 -07:00
Elliott Hughes
c0e6e40cc9 Copy the good comment and warn_unused_result from ScopedFd to unique_fd.
Also list all known aliases of this class to increase the chances that
anyone searching for it by another name finds it anyway.

Change-Id: I58ea0a5421987fb69f93cc56252a771e9c34147e
2016-03-23 14:56:37 -07:00
Pierre Imai
e65f8bedec Merge "Add C++ thread annotations support to core." 2016-03-23 03:13:22 +00:00
Pierre Imai
021ea2d176 Add C++ thread annotations support to core.
Change-Id: I7b8940c12e0f3121d8c09d86d2d4077b0a0ce376
2016-03-23 11:23:28 +09:00
Yabin Cui
2527628eda base: Avoid compilation error when compiled with -Wdangling-else.
As logging macros uses `if xxx else yyy` style, it is reported as an
error when DCHECK() is compiled with -Wdangling-else option. Because
after preprocess, DCHECK(x) becomes:
if (EnableDChecks)
  if (x)
    ;
  else
    LogMessage(FATAL) << yyy;

This CL avoids compilation error by replacing `if xxx else yyy`
with `xxx && yyy` or `!(xxx) || yyy`.

Bug: 26962895

Change-Id: Ib0bf242cc04a238ec31a1ab66b53fc8a5b5ed28f
2016-03-21 17:46:21 -07:00
Chih-Hung Hsieh
7e0e14ca84 Make CHECK(x) work with static analyzer.
When __clang_analyzer__ is defined call abort after FATAL LogMessage.
BUG: 27379879

Change-Id: I198aad2be1191b6eb45db5333f94436f619facd9
2016-03-02 09:23:02 -08:00
Elliott Hughes
38e2b63db8 Remove libbase's libutils dependency.
Yuck.

Change-Id: If84758f25bc15d5b1a732eaccc226385f51cac13
2016-02-17 11:53:54 -08:00
Yabin Cui
b958d22310 Merge "libziparchive: port unit tests to darwin and windows." 2016-02-09 00:56:43 +00:00
Yabin Cui
8e6f722764 libziparchive: port unit tests to darwin and windows.
Also use ReadFully to replace read, because read can
return reading bytes less than requested. And use
WriteFully to replace write.

Bug: 26962895
Change-Id: Iff0b2bc6d925619a537f7fef682c2a7ad89a2dc2
2016-02-08 16:52:55 -08:00
Dan Willemsen
3f68ba4dc6 Merge "Fix windows 64-bit builds" 2016-02-08 23:40:48 +00:00
Dan Willemsen
86cf941c48 Fix windows 64-bit builds
pid_t is 64-bit in 64-bit mingw, but the windows process/thread
functions return a DWORD(uint32_t). Instead of promoting to a pid_t and
fixing the format strings, just use a uint32_t to store the values.

android_thread_id also cannot be a 64-bit pointer, so for windows just
force it to be a uint32_t.

libutils/ProcessCallStack only works under Linux, since it makes heavy
use of /proc. Don't compile it under Windows or Darwin.

Bug: 26957718
Change-Id: I4e43e7cf18a96f22b3a9a08dbab8c3e960c12930
2016-02-05 16:10:10 -08:00
Elliott Hughes
5cf0dcd5b2 Fix libbase's logging dependency.
Get liblog directly, rather than transitively through libcutils.

Change-Id: Ia08ac6f04ac68c39807989d869709bae0a051578
2016-02-04 08:24:55 -08:00
David Pursell
5f787ed2b3 base: add SystemErrorCodeToString() function.
Pulls the Windows error string generation out of adb into libbase so
that it can be used by fastboot as well. Also makes a Unix equivalent
that just wraps strerror() so that upcoming fastboot error reporting
code can be platform-independent.

The intent here is just to provide a portable way to report an error to
the user. More general cross-platform error handling is out of scope.

Bug: http://b/26236380
Change-Id: I5a784a844775949562d069bb41dcb0ebd13a32bc
2016-02-01 12:18:26 -08:00
Yabin Cui
b6e314aa86 base: add API to remove file if it exists.
It is a function needed in different places like uncrypt, simpleperf.

Bug: 26883096
Change-Id: I26f4f30e8367867a88272625f00858569fc8e950
2016-01-29 19:24:55 -08:00
David Pursell
706955ff0d base: add network address parsing function from adb.
This CL moves the network address parsing function from adb to libbase
so that it can be used by fastboot as well as adb.

libbase seemed like the right choice because:
  1. It already has some parsing functions (parseint)
  2. The net address parsing function uses the libbase string
     functions so we have a libbase dependency anyway.

The parsing function has been modified slightly to make the canonical
address optional, and debug logging on success has been removed.

For adb the only functional difference is that parsing a network
address will no longer print the result to the debug log, which seemed
unnecessary.

Bug: http://b/26236380
Change-Id: Ife6df02937225fc66de87884d3572d79c092c522
2016-01-21 20:03:33 -08:00
Dan Albert
bac7bb5c16 Fix a couple sign-comparison warnings.
Bug: http://b/26523949
Change-Id: Id33146b5544147945fee3f14f7f72f39bae449f6
2016-01-15 12:18:14 -08:00
Elliott Hughes
f2584be414 Rename base/ to android-base/.
Bug: http://b/26023797
Change-Id: Ie6c63bf86bed05faab87d290de6f34d9af3532a8
2015-12-07 14:31:53 -08:00
Elliott Hughes
4f71319df0 Track rename of base/ to android-base/.
Change-Id: Idf9444fece4aa89c93e15640de59a91f6e758ccf
2015-12-04 22:00:26 -08:00
Elliott Hughes
7f24c45b7d Add a symlink android-base/ pointing to base/.
This lets us move things over piece by piece without breaking anything.

Change-Id: I06fc29572f63c4af9675888987acdcdea086711d
2015-12-04 15:18:27 -08:00
Casey Dahlin
918b9e8dc6 Introduce unique_fd
unique_fds are wrappers for integer file descriptors that automatically
close when they go out of scope. They are movable but not copyable and
generally mimic the semantics of std::unique_ptr

Change-Id: I0657b848b6536d5ad9fc06686e240ea5c387b0ac
Test: Considerable exercise in new AIDL integration tests
Bug: None
Signed-off-by: Casey Dahlin <sadmac@google.com>
2015-11-18 12:01:24 -08:00
Spencer Low
d21dc825bb adb: win32: remove widen()/narrow() in favor of UTF8ToWide()/WideToUTF8()
Now that we have a more standardized API (also available in Chromium),
switch to it. Another benefit is real error handling instead of just
killing the process on invalid Unicode.

Make UTF8ToWide()/WideToUTF8() set errno to EILSEQ on bad input. This is
the same error code that wcsrtombs(3) uses.

Update the unittest to check for EILSEQ.

Change-Id: Ie92acf74d37adaea116cf610c1bf8cd433741e16
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2015-11-12 17:13:08 -08:00
Josh Gao
26f2e1fd4f Merge changes Ic124ecb9,I94de55d2
* changes:
  libbase: remove exit-time destructors.
  adb: remove exit-time destructors.
2015-11-12 22:50:03 +00:00
Josh Gao
7df6b5fc79 libbase: remove exit-time destructors.
Removed for the same reason as the adb exit-time destructors.

Bug: http://b/23384853
Change-Id: Ic124ecb9df132b850a3855e207baffec926dde29
2015-11-12 11:54:47 -08:00
Elliott Hughes
c1fd492ac5 Revert "Revert "adb/base: fix adb push of Unicode filenames on Win32""
This reverts commit cc8cd59456.

With the dependency on libcutils (for gettid for non-bionic) removed,
this no longer breaks the build.

Change-Id: I645bd6876e2502ddc1535b69af1e645c0df9d178
2015-11-11 18:23:00 -08:00
Elliott Hughes
cc8cd59456 Revert "adb/base: fix adb push of Unicode filenames on Win32"
This reverts commit ac9514a452.

The new gettid dependency caused other breakage.

Change-Id: I74a75e40c30a45beb275f9dd38eb5c7beac15fbd
2015-11-11 18:01:12 +00:00
Spencer Low
ac9514a452 adb/base: fix adb push of Unicode filenames on Win32
ae5a6c06cd made adb push use
android::base::ReadFileToString() for small files, but that API did not
support UTF-8 filenames on Windows, until this fix which does the
following:

- Add android::base::{WideToUTF8,UTF8ToWide}() which are only available
  on Windows. The signatures are based on Chromium's APIs of the same
  name.

- Add the namespace android::base::utf8 which has versions of APIs that
  take UTF-8 strings. To use this, make sure your code is in a namespace
  and then do "using namespace android::base::utf8;". On Windows, this will
  make calls to open() call android::base::utf8::open(), and on other
  platforms, it will just call the regular ::open().

- Make ReadFileToString() and WriteStringToFile() use utf8::open() and
  utf8::unlink().

- Adapt unittests from Chromium.

- fastboot needs to link with libcutils because it links with libbase
  which depends on libcutils for gettid() for logging.

Change-Id: I1aeac40ff358331d7a1ff457ce894bfb17863904
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2015-11-10 15:48:54 -08:00
Spencer Low
363af568b8 adb/base: minor compiler portability improvements
I've been using these changes to compile with Visual Studio.

- GetFileBasename(): __FILE__ uses \ with Visual Studio.

- adb_trace.cpp: Apparently VS needs an ampersand before the function name.

- "expr1 ? : expr2" is a GCC extension.

- <algorithm> contains std::min().

- seekdir can't always be #define'd because some headers have members
  named seekdir.

- adb_utils.cpp: Not really a compiler issue, just a random fix:
  0x7F/DEL is not printable.

Change-Id: I0dfb634f1ba4ccbc0d1b9f71b00e838fbebb3b41
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2015-11-09 10:22:13 -08:00
Casey Dahlin
46776e7423 Merge "Make Join support string delimiters" 2015-11-02 20:28:09 +00:00
Casey Dahlin
5345f1df0d Make Join support string delimiters
We've needed this several times in the past.

Change-Id: I7324e8083fe2ff1aa0bf392a8c124fc2f3bb26e2
Test: Full android build
Signed-off-by: Casey Dahlin <sadmac@google.com>
2015-11-02 11:04:34 -08:00
Elliott Hughes
3ab05869d8 Fix ParseInt/ParseUint to handle explicit "0x" hex.
Also improve fastboot error reporting around max-download-size.

Change-Id: Ic3aec9460de01e5264a2803a0a6be3706d73026b
2015-11-02 09:01:53 -08:00
Elliott Hughes
c96de0d36e Fix lseek argument order.
Change-Id: I12feed2de8a4e0782f90609254a3e2ec66d7d98e
2015-10-20 13:18:22 -07:00
Spencer Low
765ae6bcfc base logging: fix errno restoring, severity conditionality, dangling ifs
Fix LOG() to properly save and restore errno. Test this properly.

Only do logging if severity is >= the minimum.

Fix dangling if statements in CHECK(), CHECK_STR{EQ,NE}(). Test this
properly.

Fix base logging tests on Windows. All libbase_tests now pass on
Windows.

Change place to lock, so the lock can protect logging of all data in
LogMessage.

Change-Id: I7ff531c67ae10a99ef0a2bbfe279aa77282d5ae9
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2015-09-21 12:46:12 -07:00
Spencer Low
b2d4949cee libbase_test: get it building for Windows
Add to whitelist.

For some reason, when compiling, parseint_test.cpp would encounter
errors like the following:

host cross C++: host_cross_libbase_test <= system/core/base/parseint_test.cpp
In file included from external/gtest/include/gtest/gtest.h:1929:0,
                 from system/core/base/parseint_test.cpp:19:
system/core/base/parseint_test.cpp: In member function ‘virtual void parseint_signed_smoke_Test::TestBody()’:
external/gtest/include/gtest/internal/gtest-internal.h:133:55: error: converting ‘false’ to pointer type for argument 1 of ‘char testing::internal::IsNullLiteralHelper(testing::internal::Secret*)’ [-Werror=conversion-null]
     (sizeof(::testing::internal::IsNullLiteralHelper(x)) == 1)
                                                       ^
external/gtest/include/gtest/gtest_pred_impl.h:77:52: note: in definition of macro ‘GTEST_ASSERT_’
   if (const ::testing::AssertionResult gtest_ar = (expression)) \
                                                    ^
external/gtest/include/gtest/gtest_pred_impl.h:166:3: note: in expansion of macro ‘GTEST_PRED_FORMAT2_’
   GTEST_PRED_FORMAT2_(pred_format, v1, v2, GTEST_FATAL_FAILURE_)
   ^
external/gtest/include/gtest/gtest.h:1993:3: note: in expansion of macro ‘ASSERT_PRED_FORMAT2’
   ASSERT_PRED_FORMAT2(::testing::internal:: \
   ^
external/gtest/include/gtest/gtest.h:1994:32: note: in expansion of macro ‘GTEST_IS_NULL_LITERAL_’
                       EqHelper<GTEST_IS_NULL_LITERAL_(expected)>::Compare, \
                                ^
external/gtest/include/gtest/gtest.h:2011:32: note: in expansion of macro ‘GTEST_ASSERT_EQ’
 # define ASSERT_EQ(val1, val2) GTEST_ASSERT_EQ(val1, val2)
                                ^
system/core/base/parseint_test.cpp:23:3: note: in expansion of macro ‘ASSERT_EQ’
   ASSERT_EQ(false, android::base::ParseInt("x", &i));
   ^

For whatever reason, the gcc for Windows isn't handling the template
metaprogramming correctly, so to work-around the issue, I
search-and-replaced "ASSERT_EQ(false, " to "ASSERT_FALSE(" and
"ASSERT_EQ(true, " to "ASSERT_TRUE(" and that seems to compile just fine
for Linux and Windows (and the tests pass on both platforms).

Change-Id: I05132909d1f4b18afff23139652a218649689f2d
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2015-09-11 20:01:29 -07:00
Dan Albert
933f4fd413 Merge "Ensure that libbase and liblog can be built for Windows." 2015-09-11 20:47:07 +00:00
Stephen Hines
b0e4f08226 Ensure that libbase and liblog can be built for Windows.
Change-Id: If4adf1e2bd7ec36a7f02ae2e263d2db5187c6e7b
2015-09-11 11:39:16 -07:00
Elliott Hughes
afe151fb02 Add ParseInt (and ParseUint).
strtol and family are hard to use correctly, and most callers don't
even try.

Change-Id: I2833622a92cccd4662c0c5bdbbef5eeb4e496914
2015-09-04 16:32:00 -07:00
Dan Willemsen
87a419c8b1 Remove USE_MINGW/CYGWIN; Whitelist windows modules
CYGWIN is not supported, USE_MINGW and HOST_OS==windows are being
replaced with LOCAL_..._windows variables.

Bug: 23566667
Change-Id: I3e4a1e4097dc994cf5abdce6939e83a91758fd75
2015-09-02 17:10:35 -07:00
Spencer Low
2fbeb0cc71 adb/base win32 tests: fix comment and open() flags
Match base's use of O_BINARY.

Change-Id: I930b5c8fddde20966580069f2e681b99cb26f1a3
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2015-09-01 14:57:58 -07:00
Elliott Hughes
470d79a09c Use O_BINARY in base/file for Windows.
This matches the behavior of the google3/Chrome APIs. It's probably what you
want in all cases except where you plan on calling Split(content, "\n"), but
we should probably have something like simpleperf's LineReader for that
anyway.

Change-Id: I1a128ed8c328bc95b0b2ef4068a65a8562721418
2015-09-01 13:35:44 -07:00
Elliott Hughes
2e5ae0044a Fix the Mac libbase build.
Change-Id: I34224fa66850915ef47c88ef4c79efbc53f3f38e
2015-08-13 20:09:29 -07:00