Commit e878bca1 authored by David Reveman's avatar David Reveman Committed by Commit Bot

third_party: Import libsync from chromium.googlesource.com.

BUG=b/27447486

Change-Id: Ie08130329f12f34b6af4538aba56eb4e942abf3c
Reviewed-on: https://chromium-review.googlesource.com/530766Reviewed-by: default avatarAntoine Labour <piman@chromium.org>
Commit-Queue: David Reveman <reveman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#478713}
parent 116dc368
......@@ -458,6 +458,10 @@ deps_os = {
# Minizip library. Used on Chrome OS.
'src/third_party/minizip/src':
Var('chromium_git') + '/external/github.com/nmoinvaz/minizip' + '@' + 'dc3ad01e3d5928e9105f770b7e896a8e9fe0d3b4',
# Android Explicit Synchronization.
'src/third_party/libsync/src':
Var('chromium_git') + '/aosp/platform/system/core/libsync.git' + '@' + 'aa6cda6f638bd57d3a024f0d201f723a5c3bb875',
},
'android': {
'src/third_party/android_protobuf/src':
......
......@@ -106,6 +106,7 @@
/liblouis/src
/libphonenumber/dist
/libsrtp
/libsync/src
/libupnp
/libvpx/source/libvpx
/libwebm/source
......
......@@ -3,17 +3,21 @@
# found in the LICENSE file.
config("libsync_config") {
include_dirs = [ "include" ]
include_dirs = [
"include",
"src",
"src/include",
]
}
source_set("libsync") {
sources = [
"include/linux/sw_sync.h",
"include/linux/sync.h",
"include/sw_sync.h",
"include/sync/sync.h",
"src/include/sync.h",
"src/sw_sync.h",
"src/sync.c",
"strlcpy.c",
"sync.c",
]
configs -= [ "//build/config/compiler:chromium_code" ]
......
Name: Android Explicit Synchronization
URL: http://source.android.com
Description: libsync helper library.
Version: a7c7bce252a6bce1539e9caa84420de3698029e7
Version: aa6cda6f638bd57d3a024f0d201f723a5c3bb875
Security Critical: yes
License: Apache 2.0
......@@ -11,11 +11,6 @@ Modifications:
- Added strlcpy.c
To import a new snapshot of libsync:
- Clone the core repository and checkout new version:
git clone https://android.googlesource.com/platform/system/core
git -C core checkout a7c7bce252a6bce1539e9caa84420de3698029e7
- Update files:
cp core/libsync/sync.c sync.c
cp core/libsync/sw_sync.h include/sw_sync.h
cp core/libsync/include/sync/sync.h include/sync/sync.h
- Update this README to reflect the new version number.
- Checkout the latest version: git checkout aa6cda6f638bd57d3a024f0d201f723a5c3bb875
- Change the DEPS entry to the newly checked out commit.
- Update this README to reflect the new version.
/*
* sw_sync.h
*
* Copyright 2013 Google, Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __SYS_CORE_SW_SYNC_H
#define __SYS_CORE_SW_SYNC_H
__BEGIN_DECLS
/*
* sw_sync is mainly intended for testing and should not be compiled into
* production kernels
*/
int sw_sync_timeline_create(void);
int sw_sync_timeline_inc(int fd, unsigned count);
int sw_sync_fence_create(int fd, const char *name, unsigned value);
__END_DECLS
#endif /* __SYS_CORE_SW_SYNC_H */
/*
* sync.h
*
* Copyright 2012 Google, Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __SYS_CORE_SYNC_H
#define __SYS_CORE_SYNC_H
#include <sys/cdefs.h>
#include <stdint.h>
__BEGIN_DECLS
// XXX: These structs are copied from the header "linux/sync.h".
struct sync_fence_info_data {
uint32_t len;
char name[32];
int32_t status;
uint8_t pt_info[0];
};
struct sync_pt_info {
uint32_t len;
char obj_name[32];
char driver_name[32];
int32_t status;
uint64_t timestamp_ns;
uint8_t driver_data[0];
};
/* timeout in msecs */
int sync_wait(int fd, int timeout);
int sync_merge(const char *name, int fd1, int fd2);
struct sync_fence_info_data *sync_fence_info(int fd);
struct sync_pt_info *sync_pt_info(struct sync_fence_info_data *info,
struct sync_pt_info *itr);
void sync_fence_info_free(struct sync_fence_info_data *info);
__END_DECLS
#endif /* __SYS_CORE_SYNC_H */
/*
* sync.c
*
* Copyright 2012 Google, Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <fcntl.h>
#include <malloc.h>
#include <stdint.h>
#include <string.h>
#include <linux/sync.h>
#include <linux/sw_sync.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/types.h>
int sync_wait(int fd, int timeout)
{
__s32 to = timeout;
return ioctl(fd, SYNC_IOC_WAIT, &to);
}
int sync_merge(const char *name, int fd1, int fd2)
{
struct sync_merge_data data;
int err;
data.fd2 = fd2;
strlcpy(data.name, name, sizeof(data.name));
err = ioctl(fd1, SYNC_IOC_MERGE, &data);
if (err < 0)
return err;
return data.fence;
}
struct sync_fence_info_data *sync_fence_info(int fd)
{
struct sync_fence_info_data *info;
int err;
info = malloc(4096);
if (info == NULL)
return NULL;
info->len = 4096;
err = ioctl(fd, SYNC_IOC_FENCE_INFO, info);
if (err < 0) {
free(info);
return NULL;
}
return info;
}
struct sync_pt_info *sync_pt_info(struct sync_fence_info_data *info,
struct sync_pt_info *itr)
{
if (itr == NULL)
itr = (struct sync_pt_info *) info->pt_info;
else
itr = (struct sync_pt_info *) ((__u8 *)itr + itr->len);
if ((__u8 *)itr - (__u8 *)info >= (int)info->len)
return NULL;
return itr;
}
void sync_fence_info_free(struct sync_fence_info_data *info)
{
free(info);
}
int sw_sync_timeline_create(void)
{
return open("/dev/sw_sync", O_RDWR);
}
int sw_sync_timeline_inc(int fd, unsigned count)
{
__u32 arg = count;
return ioctl(fd, SW_SYNC_IOC_INC, &arg);
}
int sw_sync_fence_create(int fd, const char *name, unsigned value)
{
struct sw_sync_create_fence_data data;
int err;
data.value = value;
strlcpy(data.name, name, sizeof(data.name));
err = ioctl(fd, SW_SYNC_IOC_CREATE_FENCE, &data);
if (err < 0)
return err;
return data.fence;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment