Commit graph

57 commits

Author SHA1 Message Date
Elliott Hughes
d1c5c5baaa NDK: add availability comments to <sync.h>.
Bug: N/A
Test: N/A
Change-Id: I0cc16cc9c32c6679098aa875d5f81829215868d4
2018-07-27 15:13:33 -07:00
Ryan Prichard
d2fec76063 Restore the libsync __ANDROID_API__ guard
Partially reverts 2a358106b7

Bug: http://b/111668906
Test: m
Change-Id: Ic35091e10edda12a97992fbeffefda7ddf1305a1
2018-07-19 22:58:14 -07:00
Elliott Hughes
9d9c91acdc Merge "libsync: add __INTRODUCED_IN annotations." 2018-06-15 16:08:51 +00:00
Elliott Hughes
2a358106b7 libsync: add __INTRODUCED_IN annotations.
Bug: https://github.com/android-ndk/ndk/issues/706
Test: N/A
Change-Id: I8a4f98f2c929e28d81672d7e2e0d5dd63d27c7a6
2018-06-14 15:27:26 -07:00
Jesse Hall
82d377b585 sync: remove legacy sync info API
The legacy fence/pt info API has been deprecated for a while. This
change removes it from headers, so remaining users will have to switch
to the modern API when they're re-compiled. The functions are still
provided by libsync.so and tests remain, so existing binaries should
continue to work. Eventually these will be removed too, though, once
it's reasonable to expect those binaries to have been recompiled.

This reverts commit eed25df46a, which
reverted the previous attempt in commit
798ba95bda now that more users of the
legacy API have been converted.

Bug: 35326015
Test: make checkbuild
Test: adb shell dumpsys SurfaceFlinger --latency
2018-06-13 11:52:10 -07:00
Treehugger Robot
666f62e1c7 Merge "libsync: OWNERS." 2018-06-05 19:38:25 +00:00
Elliott Hughes
f2570c2f92 libsync: OWNERS.
Based on git shortlog and my memory.

Bug: N/A
Test: N/A
Change-Id: I2e821a1214c349fd75f2971f632de3d30c602b83
2018-06-05 10:56:38 -07:00
Marissa Wall
eed25df46a Revert "sync: remove legacy sync info API"
This reverts commit 798ba95bda.

Brodcom uses the sync_fence_info_data directly.
https://android-build.googleplex.com/builds/submitted/4821789/elfin-userdebug/latest/view/logs/build_error.log

Change-Id: I72fed683397e9b10007b71253e20ded43726d377
2018-06-05 17:22:32 +00:00
Jesse Hall
798ba95bda sync: remove legacy sync info API
The legacy fence/pt info API has been deprecated for a while. This
change removes it from headers, so remaining users will have to switch
to the modern API when they're re-compiled. The functions are still
provided by libsync.so and tests remain, so existing binaries should
continue to work. Eventually these will be removed too, though, once
it's reasonable to expect those binaries to have been recompiled.

Bug: 35326015
Test: make checkbuild
Test: adb shell dumpsys SurfaceFlinger --latency
Change-Id: Id086fafe37c2bc1cfdca4a21107bc9208ed61f89
2018-05-23 16:45:48 -07:00
Jesse Hall
2576a439e6 Remove obsolete sync_test.c
Tests in this file depends on long out-of-date behavior of the sync
api. More current tests are in tests/sync_test.cpp.

Test: quis custodiet ipsos custodes?
Change-Id: Ia0a0970dde17c1ae4e1d79fac1a9fe3b54e8fcd6
2018-05-23 16:45:48 -07:00
Dan Albert
55a76719e2 Add missing @addtogroup tags.
These NDK docs weren't in any groups, so they don't show up in the
new site.

Test: https://irina-dot-devsite.googleplex.com/ndk/reference/group/logging
Test: https://irina-dot-devsite.googleplex.com/ndk/reference/group/sync
Bug: http://b/77236573
Change-Id: I300f96585dec94359ecf96fbf39c6dc3ec4579e5
2018-04-13 14:49:41 -07:00
Treehugger Robot
6832535cd5 Merge "libsync: Add fence info tests" 2017-09-26 23:46:32 +00:00
Alexandros Frantzis
68223500ea libsync: Add fence info tests
This patch adds regression tests to check that the fence info returned
by libsync contains valid data.

Test: sync-unit-tests

Change-Id: I0c57c49b7be563efc9a43f12381059f20e0a4e52
Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
2017-09-26 13:09:35 +03:00
Saurabh Shah
90a74600d7 sync: store the num_fences from first SYNC_IOC_FILE_INFO
Fixes a bug with the signal time of devices using the
modern sync file interface. The bug only affects kernels running
an Android kernel 4.9 and later.

b/63395253

Test: tests/sync_test.cpp

Change-Id: I6fb00bcb8e16a3268c357153edd8e35a44546caa
2017-09-25 15:51:46 -07:00
Jiyong Park
b87f884b99 Mark libsync as LL-NDK
libsync is used both by platform (e.g. libui.so) and by same-process
HALs (e.g. android.hardware.graphics.mapper@2.0-impl.so). Therefore it
is eligible for either VNDK-SP or LL-NDK. Among the two choices, LL-NDK
was selected because it is already an NDK and is just a thin wrapper
around a few kernel ioctls.

However, since libui (which is a vendor_available:true library) is using
more symbols that are not available to NDK clients, the extra symbols
are exposed as # vndk tag so that they are only available to VNDK
clients, but not to NDK clients.

Bug: 63866913
Test: BOARD_VNDK_VERSION=current m -j successful (2017 pixel)
Test: the built image is bootable
Merged-In: I60f883c049bd9b4562e6ce34d34ead47ba28af5f
Change-Id: I60f883c049bd9b4562e6ce34d34ead47ba28af5f
(cherry picked from commit 058e0919f6)
2017-09-15 00:33:52 +00:00
Jesse Hall
b5ec6a032c Fix NDK libsync to match ndk/sync.h
The header names were changed during review, but the library map file
wasn't updated.

Bug: 62229958
Test: CtsGraphicsTestCases:android.graphics.cts.SyncTest
Merged-In: Ie5955865667b35067f1ee209933f159f170419cd
Change-Id: Ie5955865667b35067f1ee209933f159f170419cd
(cherry picked from commit 59d9ee5d02)
2017-09-15 00:32:27 +00:00
George Burgess IV
4ff5ff29d2 libsync: Fix a double-free.
sync_file_info, the only caller of legacy_fence_info_to_sync_file_info,
unconditionally frees legacy_info after
legacy_fence_info_to_sync_file_info is called. So, if this calloc
fails, we'll end up freeing legacy_info twice.

Bug: 27101951
Test: mma. Static analyzer complaint about double-free is gone.
Change-Id: I43bf820af9aadf30cb8eabce57416f69a8fccf89
2017-09-05 16:26:36 -07:00
Lennart Wieboldt
f7b315c985 Merge "Remove LOCAL_CLANG and clang: true"
am: 80ec81cf4b

Change-Id: Ia7f79d8e25ee9870fe44d198568d0e5dabdff811
2017-07-25 22:28:56 +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
Steven Moreland
9990de1f64 libsync: 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 libsync
Test: build with BOARD_VNDK_VERSION := current
(cherry picked from commit d0b26edf30)
Merged-In: I5b23d2c1f41b842e5a9b7ea257921133b80c3f98
Change-Id: I5b23d2c1f41b842e5a9b7ea257921133b80c3f98
2017-04-19 10:32:51 -07:00
Alistair Strachan
5bebf84845 libsync: ndk: Fix compilation in C mode.
Use of 'inline' without 'static' may allow the C compiler to uninline it
within the compilation unit, depending on the C standard level. Always
using 'static inline' avoids this problem.

Test: build + boot to launcher
Change-Id: Ifb6e1fa6b84286067ddc2daca4c8942c410e56ab
2017-04-14 15:12:06 -07:00
Steven Moreland
d0b26edf30 libsync: 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 libsync
Test: build with BOARD_VNDK_VERSION := current
Change-Id: I5b23d2c1f41b842e5a9b7ea257921133b80c3f98
2017-04-13 23:28:39 -07:00
Steven Moreland
db9b260096 Remove .(ll)ndk suffix from (ll)ndk_library
Soong handles these automatically now.

Bug: 33241851
Test: Android-aosp_arm.mk is the same before/after
Test: build.ninja is the same before/after
Test: build-aosp_arm.ninja is the same before/after
Change-Id: Ia039812817495c00e450eec7292447d5e8f93adb
2017-04-10 12:58:03 -07:00
Jesse Hall
6cd0fc56c0 sync: Cache knowledge of kernel uapi version
Previously all libsync calls would try first the modern/mainline uapi
and if that failed try the legacy uapi, or vice versa. This is
inefficient, and confusing when looking at strace. With this change,
after the first successful syscall, libsync know's what uapi version
the kernel supports, and will only try that version in the future.

Test: sync-unit-tests on bullhead
Change-Id: I8b5de0194da0cfc6c080c0180318e16bb673d3c9
2017-03-08 17:34:14 -08:00
Jesse Hall
41129a2526 sync: rename sync/sync.h to android/sync.h
Leave a temporary symlink from the old name to avoid having to change
all dependencies simultaneously.

Bug: 1901466
Test: m
Change-Id: Id210f0091457e52e1a6e048d241a723bdbe8779b
2017-02-23 18:44:50 -08:00
Jesse Hall
b7fdb2a128 sync: move declarations from sync/sync.h to sync.c
None of these should be needed or used outside of sync.c.

Test: lunch bullhead-eng ; m
Change-Id: I548a499d0e2ada2ab4987e63a8116327c3be0076
2017-02-23 18:44:50 -08:00
Jesse Hall
836661616f sync: implement sync_file_info
Also modifies sync-unit-test to use sync_file_info instead of the
deprecated sync_fence_info, but check that they match in several tests.

Bug: 35138793
Test: sync-unit-tests on bullhead
Change-Id: Ic672d1c89798435a8b71469500e82c770a66bf4d
2017-02-23 18:44:50 -08:00
Jesse Hall
89530820d7 sync: refactor sync_fence_info
Split the sync_fence_info implementation into multiple functions. This
clarifies the logic, and allows the parts to be reused in the upcoming
sync_file_info function.

Test: sync-unit-tests on bullhead
Change-Id: I0ea37067dddf41b831670f08eb99e0b7fd52adce
2017-02-23 18:44:50 -08:00
Jesse Hall
081806e5f2 sync: Add NDK sync.h and libsync
The new header provides an updated interface to libsync appropriate
for the NDK. Clients use existing syscalls where possible (e.g. poll()
instead of sync_wait()), and the remaining functions return structures
used in mainline Linux kernels rather than the Android staging sync
framework.

Over time, framework clients will be migrated to using the NDK
interface, which will eventually replace the current internal
interface. The only difference is the header will be named
<android/sync.h> in the NDK and <sync/sync.h> internally.

Bug: 35138793
Test: sync-unit-tests on bullhead
Change-Id: Ieb3649b80565393e26b604416158438d32c2a256
2017-02-23 18:44:50 -08:00
Jesse Hall
077ffd5055 sync: Use correct type in size calculation
The previous and current types are the same size, so this wouldn't
have caused a bug in practice, but it is confusing, and would have
been a problem in the unlikely event we changed the size of one of the
types.

Test: sync-unit-tests on bullhead
Change-Id: Ic43b81f3b4ff214af86b6b6d4d02c648f95d0c4b
2017-02-23 18:44:50 -08:00
mtezych
380b2f4fea libsync: Replace inserting tuple into unordered_map in favour of pair.
Inserting tuple into unordered_map relies on non standard libc++ extension:
http://stackoverflow.com/a/21313229
This change removes this dependency.

Test: sync-unit-tests (on hikey with SW_SYNC_USER built into kernel)
2017-01-30 23:39:03 +00:00
Gustavo Padovan
801492b8a6 libsync: tests: redefine PollOnDestroyedTimeline()
On mainline if the sw_sync timeline is destroyed the fences doesn't not
signal or error. So change the test to check if the fence is still there
by polling the fence with timeout zero and asserting if it is not
signalled.

Test: Sync unit tests still passes.
Change-Id: Icb8e629018eef35074ae91d0f29ed1f12e90492b
2017-01-17 14:29:41 -08:00
Gustavo Padovan
e4682802cb libsync: tests: remove WaitOnDestroyedTimeline test
The mainline Sync File implementation doesn't have wait ioctl anymore.
Only poll is supported now, and we already have a test for that.

Test: Sync unit tests still passes.
Change-Id: Iadde7b2173024af9b8d20316e640297cf214c645
2017-01-17 14:29:18 -08:00
Gustavo Padovan
61ab0d74d2 libsync: add support to new Sync API
Change libsync functions in a way that it can run dynamically on both
APIs.

v2: fix whitespace changes and poll return handling

v3: handle error cases on sync_wait()

Test: Sync unit tests still passes.
Change-Id: I743ab92ce39cbfa75dca41dd0a435efa9f2aab66
hange-Id: Ib56f2c6441b41028bc9f66998676790b7713988a
2017-01-17 14:29:01 -08:00
Gustavo Padovan
ffc687baad libsync: open new location of sw_sync file
sw_sync file for debug was moved to debugfs. Try to open it and if it
fails try to open /dev/sw_sync.

Test: Sync unit tests still passes.
Change-Id: Ie078fbc2eb5294f28b916a9e65b7fcd3a18a8580
hange-Id: I216874964368d939bed2779d98cd89e527a57d45
2017-01-17 14:28:45 -08:00
Gustavo Padovan
6786575d42 libsync: add new Sync kernel API
Add the new API to the internal sync.h file. As there is two different
APIs we will need to discovery dynamically which one to use.

v2: Fix Documentation

Test: Sync unit tests still passes.
Change-Id: I2ab3cd46e48ba5d9c73d54f9583b1a8141566581
2017-01-17 14:28:26 -08:00
Gustavo Padovan
d6bbc5de66 libsync: move kernel headers for sync ioctls to sync.h
This patch moves the legacy API to the internal sync.h header
and add documentation to it.

Test: Sync unit tests still passes.
Change-Id: I9b17eb23af30043b3df5fb9e857affad68ba8521
2017-01-17 14:28:00 -08:00
Christopher Ferris
1514bb4f2f Update for kernel headers v4.8.14.
Update sync.c to include the structurs from sw_sync.h. This uapi
header has been deleted.

Test: Built mips/arm/arm64/x86/x86_64. Built and booted angler.
Change-Id: I2495cb17b35f697fb8a2a00f6633ccb53f78293f
2016-12-12 18:59:42 -08:00
Elliott Hughes
36e0d390a2 Rely on the platform -std default.
Bug: http://b/32019064
Test: builds
Change-Id: I18a1d816d63b64601485045070851f32d44e85eb
2016-10-10 14:31:12 -07:00
Treehugger Robot
10348cbeb9 Merge "Convert to Android.bp" 2016-08-29 20:32:12 +00:00
Christopher Ferris
f83c7923f9 Update for kernel headers v4.7.2.
The new uapi kernel headers added a new SEGV reason code, so
add it to the tombstone code.

Update sync.c to include the needed data structures itself. Someone
else will be fixing this to work on old versus new kernels.

Change-Id: Icb27713ea38a20003c7671a9bca262eebd96099b
2016-08-26 16:48:18 -07:00
Dan Willemsen
194edf772e Convert to Android.bp
See build/soong/README.md for more information.

I tested the following tests on a Nexus9 and linux host, and they
continued to pass:

/data/nativetest{,64}/bootstat_tests/bootstat_tests
out/host/linux-x86/bin/nativetest{,64}/bootstat_tests/bootstat_tests
/data/nativetest64/memunreachable_test/memunreachable_test
out/host/linux-x86/bin/nativetest{,64}/memunreachable_test/memunreachable_test

These continue to fail just like before this change:

/data/nativetest{,64}/sync_test/sync_test (was /system/bin/sync_test)
/data/nativetest{,64}/sync-unit-test/sync-unit-test
/data/nativetest/memunreachable_test/memunreachable_test

Test: See above
Change-Id: I691e564e0cf008dd363e3746223b153d712e024d
2016-08-26 16:19:21 -07:00
Greg Hackmann
d86dd3b838 libsync: add static library for recovery
Change-Id: If43188c3b4b16c698c077338ea0ef1dfd16b9c56
Signed-off-by: Greg Hackmann <ghackmann@google.com>
2016-08-05 15:03:58 -07:00
Greg Hackmann
a90aa13b5b libsync: remove unused liblog dependency
Change-Id: I69840ece3f13809b2440edbe6cfa412a56aee4aa
Signed-off-by: Greg Hackmann <ghackmann@google.com>
2016-08-05 14:50:39 -07:00
George Burgess IV
e7aa2b2c83 Cleanup uses of sprintf so we can deprecate it.
Also cleans up two instances of open() with useless mode params, and
changes a few uses of snprintf to use sizeof(buffer) instead of
hardcoded buffer sizes.

Change-Id: If11591003d910c995e72ad8f75afd072c255a3c5
2016-03-07 18:40:40 -08:00
Tom Cherry
a7c7bce252 Fix isValid() condition for libsync tests
Upstream modifications in K3.12 to the sw_sync driver set O_CLOEXEC on
the fd's returned by the SW_SYNC_IOC_CREATE_FENCE ioctl, therefore we
check the return of fcntl() for a non-negative value instead of strictly 0.

Change-Id: If4c82750fcc0aa3a57f243fa2a94691e3150e4a4
2015-11-05 10:07:53 -08:00
Elliott Hughes
bcc2b5f44a Remove LOCAL_ADDITIONAL_DEPENDENCIES in cases where it's not needed.
Change-Id: I720b8ef1050da45a7833adef8219b6acb2cf3a38
2015-04-02 14:31:07 -07:00
Dan Albert
d0a793dca3 Remove uses of libcxx.mk.
This is a no-op.

Change-Id: Iecbcd5f6d818abbf98767a2e996c10f454b652e4
2015-03-27 11:24:04 -07:00
Elliott Hughes
a744b05984 Add missing <malloc.h> and <string.h> includes.
Change-Id: Ia41756e607663d056e7d2fdd7ecbec7e5841a913
2015-01-28 11:37:57 -08:00
Riley Andrews
d0d7f6ac08 Add gtest conformance tests for libsync.
Not complete yet, but substantially more comprehensive than the
interactive test that was there before.

(cherry-picked from internal master, same change-id).
Change-Id: I9019b0a8babbc91f78aa850e0e288bbf05f93500
2014-10-11 02:10:23 +00:00