upload android base code part6

This commit is contained in:
August 2018-08-08 17:48:24 +08:00
parent 421e214c7d
commit 4e516ec6ed
35396 changed files with 9188716 additions and 0 deletions

View file

@ -0,0 +1,69 @@
/*
* 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
/* This file contains the legacy sync interface used by Android platform and
* device code. The direct contents will be removed over time as code
* transitions to using the updated interface in ndk/sync.h. When this file is
* empty other than the ndk/sync.h include, that file will be renamed to
* replace this one.
*
* New code should continue to include this file (#include <android/sync.h>)
* instead of ndk/sync.h so the eventual rename is seamless, but should only
* use the things declared in ndk/sync.h.
*
* This file used to be called sync/sync.h, but we renamed to that both the
* platform and NDK call it android/sync.h. A symlink from the old name to this
* one exists temporarily to avoid having to change all sync clients
* simultaneously. It will be removed when they've been updated, and probably
* after this change has been delivered to AOSP so that integrations don't
* break builds.
*/
#include "../ndk/sync.h"
__BEGIN_DECLS
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);
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 */

View file

@ -0,0 +1,88 @@
/*
* Copyright 2017 The Android Open Source Project
*
* 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 ANDROID_SYNC_H
#define ANDROID_SYNC_H
#include <stdint.h>
#include <linux/sync_file.h>
__BEGIN_DECLS
#if __ANDROID_API__ >= __ANDROID_API_O__
/* Fences indicate the status of an asynchronous task. They are initially
* in unsignaled state (0), and make a one-time transition to either signaled
* (1) or error (< 0) state. A sync file is a collection of one or more fences;
* the sync file's status is error if any of its fences are in error state,
* signaled if all of the child fences are signaled, or unsignaled otherwise.
*
* Sync files are created by various device APIs in response to submitting
* tasks to the device. Standard file descriptor lifetime syscalls like dup()
* and close() are used to manage sync file lifetime.
*
* The poll(), ppoll(), or select() syscalls can be used to wait for the sync
* file to change status, or (with a timeout of zero) to check its status.
*
* The functions below provide a few additional sync-specific operations.
*/
/**
* Merge two sync files.
*
* This produces a new sync file with the given name which has the union of the
* two original sync file's fences; redundant fences may be removed.
*
* If one of the input sync files is signaled or invalid, then this function
* may behave like dup(): the new file descriptor refers to the valid/unsignaled
* sync file with its original name, rather than a new sync file.
*
* The original fences remain valid, and the caller is responsible for closing
* them.
*/
int32_t sync_merge(const char *name, int32_t fd1, int32_t fd2);
/**
* Retrieve detailed information about a sync file and its fences.
*
* The returned sync_file_info must be freed by calling sync_file_info_free().
*/
struct sync_file_info *sync_file_info(int32_t fd);
/**
* Get the array of fence infos from the sync file's info.
*
* The returned array is owned by the parent sync file info, and has
* info->num_fences entries.
*/
static inline struct sync_fence_info* sync_get_fence_info(const struct sync_file_info* info) {
// This header should compile in C, but some C++ projects enable
// warnings-as-error for C-style casts.
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wold-style-cast"
return (struct sync_fence_info *)(uintptr_t)(info->sync_fence_info);
#pragma GCC diagnostic pop
}
/** Free a struct sync_file_info structure */
void sync_file_info_free(struct sync_file_info *info);
#endif // __ANDROID_API__ >= __ANDROID_API_O__
__END_DECLS
#endif /* ANDROID_SYNC_H */

View file

@ -0,0 +1 @@
../android/sync.h