diff options
author | Gustavo Padovan <gustavo.padovan@collabora.com> | 2016-06-10 16:09:36 -0300 |
---|---|---|
committer | Dmitry Shmidt <dimitrysh@google.com> | 2017-01-17 14:28:00 -0800 |
commit | d6bbc5de66fc7ac51773bc92d6a48a94e622f9b1 (patch) | |
tree | 8d28229412eb8edf4bb4906ce5a94e38a0e0d1d9 /libsync | |
parent | 60c763ed52004a3c2330fd8ab7c5b2b6968e7822 (diff) | |
download | system_core-d6bbc5de66fc7ac51773bc92d6a48a94e622f9b1.tar.gz system_core-d6bbc5de66fc7ac51773bc92d6a48a94e622f9b1.tar.bz2 system_core-d6bbc5de66fc7ac51773bc92d6a48a94e622f9b1.zip |
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
Diffstat (limited to 'libsync')
-rw-r--r-- | libsync/include/sync/sync.h | 51 | ||||
-rw-r--r-- | libsync/sync.c | 20 |
2 files changed, 54 insertions, 17 deletions
diff --git a/libsync/include/sync/sync.h b/libsync/include/sync/sync.h index 2e5d82f15..60989f2e3 100644 --- a/libsync/include/sync/sync.h +++ b/libsync/include/sync/sync.h @@ -22,9 +22,16 @@ #include <sys/cdefs.h> #include <stdint.h> +#include <linux/types.h> + __BEGIN_DECLS -// XXX: These structs are copied from the header "linux/sync.h". +struct sync_legacy_merge_data { + int32_t fd2; + char name[32]; + int32_t fence; +}; + struct sync_fence_info_data { uint32_t len; char name[32]; @@ -41,6 +48,48 @@ struct sync_pt_info { uint8_t driver_data[0]; }; +#define SYNC_IOC_MAGIC '>' + +/** + * DOC: SYNC_IOC_LEGACY_WAIT - wait for a fence to signal + * + * pass timeout in milliseconds. Waits indefinitely timeout < 0. + * + * This is the legacy version of the Sync API before the de-stage that happened + * on Linux kernel 4.7. + */ +#define SYNC_IOC_LEGACY_WAIT _IOW(SYNC_IOC_MAGIC, 0, __s32) + +/** + * DOC: SYNC_IOC_MERGE - merge two fences + * + * Takes a struct sync_merge_data. Creates a new fence containing copies of + * the sync_pts in both the calling fd and sync_merge_data.fd2. Returns the + * new fence's fd in sync_merge_data.fence + * + * This is the legacy version of the Sync API before the de-stage that happened + * on Linux kernel 4.7. + */ +#define SYNC_IOC_LEGACY_MERGE _IOWR(SYNC_IOC_MAGIC, 1, \ + struct sync_legacy_merge_data) + +/** + * DOC: SYNC_IOC_LEGACY_FENCE_INFO - get detailed information on a fence + * + * Takes a struct sync_fence_info_data with extra space allocated for pt_info. + * Caller should write the size of the buffer into len. On return, len is + * updated to reflect the total size of the sync_fence_info_data including + * pt_info. + * + * pt_info is a buffer containing sync_pt_infos for every sync_pt in the fence. + * To iterate over the sync_pt_infos, use the sync_pt_info.len field. + * + * This is the legacy version of the Sync API before the de-stage that happened + * on Linux kernel 4.7. + */ +#define SYNC_IOC_LEGACY_FENCE_INFO _IOWR(SYNC_IOC_MAGIC, 2,\ + struct sync_fence_info_data) + /* timeout in msecs */ int sync_wait(int fd, int timeout); int sync_merge(const char *name, int fd1, int fd2); diff --git a/libsync/sync.c b/libsync/sync.c index 6281b205c..fff62e77c 100644 --- a/libsync/sync.c +++ b/libsync/sync.c @@ -27,18 +27,6 @@ #include <sync/sync.h> -// The sync code is undergoing a major change. Add enough in to get -// everything to compile wih the latest uapi headers. -struct sync_merge_data { - int32_t fd2; - char name[32]; - int32_t fence; -}; - -#define SYNC_IOC_MAGIC '>' -#define SYNC_IOC_WAIT _IOW(SYNC_IOC_MAGIC, 0, __s32) -#define SYNC_IOC_MERGE _IOWR(SYNC_IOC_MAGIC, 1, struct sync_merge_data) -#define SYNC_IOC_FENCE_INFO _IOWR(SYNC_IOC_MAGIC, 2, struct sync_fence_info_data) struct sw_sync_create_fence_data { __u32 value; @@ -54,18 +42,18 @@ int sync_wait(int fd, int timeout) { __s32 to = timeout; - return ioctl(fd, SYNC_IOC_WAIT, &to); + return ioctl(fd, SYNC_IOC_LEGACY_WAIT, &to); } int sync_merge(const char *name, int fd1, int fd2) { - struct sync_merge_data data; + struct sync_legacy_merge_data data; int err; data.fd2 = fd2; strlcpy(data.name, name, sizeof(data.name)); - err = ioctl(fd1, SYNC_IOC_MERGE, &data); + err = ioctl(fd1, SYNC_IOC_LEGACY_MERGE, &data); if (err < 0) return err; @@ -82,7 +70,7 @@ struct sync_fence_info_data *sync_fence_info(int fd) return NULL; info->len = 4096; - err = ioctl(fd, SYNC_IOC_FENCE_INFO, info); + err = ioctl(fd, SYNC_IOC_LEGACY_FENCE_INFO, info); if (err < 0) { free(info); return NULL; |