Path: blob/21.2-virgl/include/android_stub/ndk/sync.h
7136 views
/*1* Copyright 2017 The Android Open Source Project2*3* Licensed under the Apache License, Version 2.0 (the "License");4* you may not use this file except in compliance with the License.5* You may obtain a copy of the License at6*7* http://www.apache.org/licenses/LICENSE-2.08*9* Unless required by applicable law or agreed to in writing, software10* distributed under the License is distributed on an "AS IS" BASIS,11* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.12* See the License for the specific language governing permissions and13* limitations under the License.14*/1516/**17* @addtogroup Sync18* @{19*/2021/**22* @file sync.h23*/2425#ifndef ANDROID_SYNC_H26#define ANDROID_SYNC_H2728#include <stdint.h>29#include <sys/cdefs.h>3031#include <linux/sync_file.h>3233__BEGIN_DECLS3435#if __ANDROID_API__ >= 263637/* Fences indicate the status of an asynchronous task. They are initially38* in unsignaled state (0), and make a one-time transition to either signaled39* (1) or error (< 0) state. A sync file is a collection of one or more fences;40* the sync file's status is error if any of its fences are in error state,41* signaled if all of the child fences are signaled, or unsignaled otherwise.42*43* Sync files are created by various device APIs in response to submitting44* tasks to the device. Standard file descriptor lifetime syscalls like dup()45* and close() are used to manage sync file lifetime.46*47* The poll(), ppoll(), or select() syscalls can be used to wait for the sync48* file to change status, or (with a timeout of zero) to check its status.49*50* The functions below provide a few additional sync-specific operations.51*/5253/**54* Merge two sync files.55*56* This produces a new sync file with the given name which has the union of the57* two original sync file's fences; redundant fences may be removed.58*59* If one of the input sync files is signaled or invalid, then this function60* may behave like dup(): the new file descriptor refers to the valid/unsignaled61* sync file with its original name, rather than a new sync file.62*63* The original fences remain valid, and the caller is responsible for closing64* them.65*66* Available since API level 26.67*/68int32_t sync_merge(const char* name, int32_t fd1, int32_t fd2) __INTRODUCED_IN(26);6970/**71* Retrieve detailed information about a sync file and its fences.72*73* The returned sync_file_info must be freed by calling sync_file_info_free().74*75* Available since API level 26.76*/77struct sync_file_info* sync_file_info(int32_t fd) __INTRODUCED_IN(26);7879/**80* Get the array of fence infos from the sync file's info.81*82* The returned array is owned by the parent sync file info, and has83* info->num_fences entries.84*85* Available since API level 26.86*/87static inline struct sync_fence_info* sync_get_fence_info(const struct sync_file_info* info) {88// This header should compile in C, but some C++ projects enable89// warnings-as-error for C-style casts.90#pragma GCC diagnostic push91#pragma GCC diagnostic ignored "-Wold-style-cast"92return (struct sync_fence_info *)(uintptr_t)(info->sync_fence_info);93#pragma GCC diagnostic pop94}9596/**97* Free a struct sync_file_info structure98*99* Available since API level 26.100*/101void sync_file_info_free(struct sync_file_info* info) __INTRODUCED_IN(26);102103#endif /* __ANDROID_API__ >= 26 */104105__END_DECLS106107#endif /* ANDROID_SYNC_H */108109/** @} */110111112