!1 添加配置文件

Merge pull request !1 from shuaiguo/master
This commit is contained in:
openharmony_ci
2023-12-29 09:08:37 +00:00
committed by Gitee
5 changed files with 216 additions and 0 deletions
+46
View File
@@ -0,0 +1,46 @@
# Copyright (C) 2023 Huawei Device Co., Ltd.
# 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.
import("//build/ohos.gni")
liburing_source = [
"//third_party/liburing/src/nolibc.c",
"//third_party/liburing/src/queue.c",
"//third_party/liburing/src/register.c",
"//third_party/liburing/src/setup.c",
"//third_party/liburing/src/syscall.c",
]
import("//build/ohos.gni")
config("liburing_config") {
visibility = [ ":*" ]
include_dirs = [
"//third_party/liburing",
"//third_party/liburing/src",
"//third_party/liburing/src/include",
"//third_party/liburing/src/include/liburing",
"//third_party/liburing/src/arch"
]
}
ohos_shared_library("liburing") {
configs = [ "//third_party/liburing:liburing_config" ]
sources = liburing_source
external_deps = [ "c_utils:utils" ]
subsystem_name = "thirdparty"
part_name = "liburing"
output_name = "liburing"
}
+51
View File
@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright (c) 2022 Huawei Device Co., Ltd.
This library is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of
the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
This is the configuration file template for OpenHarmony OSS Audit Tool, please copy it to your project root dir and modify it refer to OpenHarmony/tools_oat/README.
-->
<configuration>
<oatconfig>
<licensefile>COPYING</licensefile>
<policylist>
<policy name="projectPolicy" desc="">
<filteritem type="compatibility" name="GPL-2.0+" path=".*" desc="Compile tool not runs target,running on host build environment only."/>
<filteritem type="compatibility" name="GPLStyleLicense" path=".*" desc="Compile tool not runs target,running on host build environment only."/>
<filteritem type="compatibility" name="GPL-2+" path=".*" desc=""/>
<filteritem type="compatibility" name="GPL-2.0-or-later" path=".*" rule="may" group="defaultGroup" filefilter="defaultPolicyFilter" desc=""/>
<filteritem type="compatibility" name="GPL-2.0-or-later" path=".*" desc="Compile tool not runs target,running on host build environment only."/>
<filteritem type="compatibility" name="InvalidLicense" path=".*" desc="Compile tool not runs target,running on host build environment only."/>
</policy>
</policylist>
<filefilterlist>
<filefilter name="defaultFilter" desc="Filters for compatibility,license header policies">
<filteritem type="filename" name="README.OpenSource"/>
<filteritem type="filename" name="README"/>
<filteritem type="filename" name="COPYING"/>
<filteritem type="filename" name="README_zh.md"/>
<filteritem type="filename" name="BUILD.gn"/>
<filteritem type="filename" name="tests/BUILD.gn"/>
<filteritem type="filename" name="tests/conan/conanfile.py" desc=""/>
<filteritem type="filename" name="build.py" desc=""/>
<filteritem type="filename" name="conanfile.py" desc=""/>
<filteritem type="filename" name="tests/pkgconfig/pkgconfig.c" desc=""/>
</filefilter>
</filefilterlist>
</oatconfig>
</configuration>
+11
View File
@@ -0,0 +1,11 @@
[
{
"Name": "liburing",
"License": "LGPL V2.1",
"License File": "COPYING",
"Version Number": "2.3",
"Owner": "maojingjing1@huawei.com",
"Upstream URL": "https://github.com/axboe/liburing/releases/tag/liburing-2.3",
"Description": "liburing provides helpers to setup and reardown io_uring instances, and also a simplified interface for applications that don't need (or want) to deal with the full kernel side implementation."
}
]
+74
View File
@@ -0,0 +1,74 @@
# liburing
由于直接使用系统调用较为复杂,Jens Axboe 还提供了封装好的用户态库liburing,简化了io_uring的使用。
o_uring库,libouling提供了设置和拆除io_ouling实例的帮助程序,以及为不需要(或不希望)处理完整内核端实现的应用程序提供简化的接口
## 目录结构
```
debian/
example/ #样例代码
man/
src/liburing #库源代码
test/ #测试脚本代码
```
## OpenHarmony如何使用liburing
liburing提供了以下基本助手来完成相同任务:
struct io_uring ring;
io_uring_queue_init(ENTRIES, &ring, 0);
一旦应用程序使用io_uring实例完成,它只需调用:io_uring_queue_exit(&ring)。相关接口在src/include/liburing.h定义
## 接口说明
1. 初始化
```
extern int io_uring_queue_init_params(unsigned entries, struct io_uring ring,struct io_uring_params p);
extern int io_uring_queue_init(unsigned entries, struct io_uring ring, unsigned flags);
entries 表示队列大小
ring 就是需要初始化的io_uring结构指针
flags是标志参数,此值会改变io_uring_params p->flags
io_uring_params *p更多的设置
```
2. 创建请求(获取一个sqe请求并初始化)
```
extern struct io_uring_sqe io_uring_get_sqe(struct io_uring ring);
static inline void io_uring_prep_readv(struct io_uring_sqe sqe,int fd, const struct iovec iovecs, unsigned nr_vecs,off_t offset);
static inline void io_uring_prep_writev(struct io_uring_sqe sqe,int fd, const struct iovec iovecs, unsigned nr_vecs,off_t offset);
sqe即前面获取的sqe结构指针
fd为需要读写的文件描述符,可以是磁盘文件也可以是socket
iovecs为iovec数组,具体使用请参照readv和writev
nr_vecs 为iovecs数组元素个数
offset 为文件操作的偏移量
```
3. 传入用户数据
```
static inline void io_uring_sqe_set_data(struct io_uring_sqe *sqe, void *data);
```
4. 提交请求
```
extern int io_uring_submit(struct io_uring *ring);
extern int io_uring_submit_and_wait(struct io_uring *ring, unsigned wait_nr);
wait_nr 等待事件数量
```
5. 获取结果(提取完成事件)
```
static inline int io_uring_peek_cqe(struct io_uring *ring, struct io_uring_cqe **cqe_ptr);
static inline int io_uring_wait_cqe(struct io_uring *ring, struct io_uring_cqe **cqe_ptr);
cqe_ptr 输出参数,是cqe指针变量的额地址
注意:io_uring_peek_cqe如果没有已完成的IO操作时,也会立即返回,cqe_ptr被置空;而io_uring_wait_cqe会阻塞线程,等待IO操作完成。
```
6. 获取数据
```
static inline void *io_uring_cqe_get_data(const struct io_uring_cqe *cqe);
```
7. 清理完成时间
```
static inline void io_uring_cqe_seen(struct io_uring *ring, struct io_uring_cqe *cqe);
```
8. 释放
```
extern void io_uring_queue_exit(struct io_uring *ring);
```
+34
View File
@@ -0,0 +1,34 @@
{
"name": "@ohos/liburing",
"description": "liburing provides helpers to setup and teardown io_uring instances, and also a simplified interface for applications that don't need (or want) to deal with the full kernel side implementation.",
"version": "2.3",
"license": "LGPL V2.1",
"publishAs": "code-segment",
"segment": {
"destPath": "third_party/liburing"
},
"dirs": {},
"scripts": {},
"licensePath": "COPYING",
"readmePath": {
"en": "README"
},
"component": {
"name": "liburing",
"subsystem": "thirdparty",
"syscap": [],
"features": [],
"adapted_system_type": [],
"rom": "",
"ram": "",
"deps": {
"components": [],
"third_party": []
},
"build": {
"sub_component": [],
"inner_kits": [],
"test": []
}
}
}