summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Hall2017-02-12 18:32:39 -0600
committerJesse Hall2017-02-23 20:44:50 -0600
commit836661616fcf4bc023b192d1c320f0727a9dfef9 (patch)
tree49e82464c7eca7aa4774f45ae099918ddb66d0e9 /libsync/sync.c
parent89530820d7f5837f00f3f04e18dfa05c7506eb68 (diff)
downloadplatform-system-core-836661616fcf4bc023b192d1c320f0727a9dfef9.tar.gz
platform-system-core-836661616fcf4bc023b192d1c320f0727a9dfef9.tar.xz
platform-system-core-836661616fcf4bc023b192d1c320f0727a9dfef9.zip
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
Diffstat (limited to 'libsync/sync.c')
-rw-r--r--libsync/sync.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/libsync/sync.c b/libsync/sync.c
index 6680f1102..f3e26e111 100644
--- a/libsync/sync.c
+++ b/libsync/sync.c
@@ -173,6 +173,46 @@ static struct sync_fence_info_data *sync_file_info_to_legacy_fence_info(
173 return legacy_info; 173 return legacy_info;
174} 174}
175 175
176static struct sync_file_info* legacy_fence_info_to_sync_file_info(
177 struct sync_fence_info_data *legacy_info)
178{
179 struct sync_file_info *info;
180 struct sync_pt_info *pt;
181 struct sync_fence_info *fence;
182 size_t num_fences;
183 int err;
184
185 pt = NULL;
186 num_fences = 0;
187 while ((pt = sync_pt_info(legacy_info, pt)) != NULL)
188 num_fences++;
189
190 info = calloc(1, sizeof(struct sync_file_info) +
191 num_fences * sizeof(struct sync_fence_info));
192 if (!info) {
193 free(legacy_info);
194 return NULL;
195 }
196 info->sync_fence_info = (__u64)(uintptr_t)(info + 1);
197
198 strlcpy(info->name, legacy_info->name, sizeof(info->name));
199 info->status = legacy_info->status;
200 info->num_fences = num_fences;
201
202 pt = NULL;
203 fence = sync_get_fence_info(info);
204 while ((pt = sync_pt_info(legacy_info, pt)) != NULL) {
205 strlcpy(fence->obj_name, pt->obj_name, sizeof(fence->obj_name));
206 strlcpy(fence->driver_name, pt->driver_name,
207 sizeof(fence->driver_name));
208 fence->status = pt->status;
209 fence->timestamp_ns = pt->timestamp_ns;
210 fence++;
211 }
212
213 return info;
214}
215
176struct sync_fence_info_data *sync_fence_info(int fd) 216struct sync_fence_info_data *sync_fence_info(int fd)
177{ 217{
178 struct sync_fence_info_data *legacy_info; 218 struct sync_fence_info_data *legacy_info;
@@ -190,6 +230,23 @@ struct sync_fence_info_data *sync_fence_info(int fd)
190 return legacy_info; 230 return legacy_info;
191} 231}
192 232
233struct sync_file_info* sync_file_info(int32_t fd)
234{
235 struct sync_file_info *info;
236 struct sync_fence_info_data *legacy_info;
237
238 info = modern_sync_file_info(fd);
239 if (info || errno != ENOTTY)
240 return info;
241
242 legacy_info = legacy_sync_fence_info(fd);
243 if (!legacy_info)
244 return NULL;
245 info = legacy_fence_info_to_sync_file_info(legacy_info);
246 sync_fence_info_free(legacy_info);
247 return info;
248}
249
193struct sync_pt_info *sync_pt_info(struct sync_fence_info_data *info, 250struct sync_pt_info *sync_pt_info(struct sync_fence_info_data *info,
194 struct sync_pt_info *itr) 251 struct sync_pt_info *itr)
195{ 252{