mirror of
https://gitee.com/openharmony/interface_sdk_c
synced 2024-11-27 00:41:01 +00:00
同步NDK差异
Signed-off-by: huangdongting <huangdongting3@huawei.com>
This commit is contained in:
parent
7875955258
commit
3d4753c4f0
@ -45,8 +45,13 @@
|
|||||||
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## 相关仓
|
## 相关仓
|
||||||
|
|
||||||
[interface_sdk_c](https://gitee.com/openharmony-sig/interface_sdk_c/)
|
[interface_sdk_c](https://gitee.com/openharmony-sig/interface_sdk_c/)
|
||||||
|
|
||||||
[C API编码规范](https://gitee.com/openharmony-sig/interface_sdk_c/blob/master/docs/capi_naming.md): 描述了OpenHarmony C API的设计规范,指导开发者如何设计发布一个接口。
|
[C API编码规范](https://gitee.com/openharmony-sig/interface_sdk_c/blob/master/docs/capi_naming.md): 描述了OpenHarmony C API的设计规范,指导开发者如何设计发布一个接口。
|
||||||
|
|
||||||
[C API构建指南](https://gitee.com/openharmony-sig/interface_sdk_c/blob/master/docs/howto_add.md):描述了如何在build.gn中添加C API的构建目标。
|
[C API构建指南](https://gitee.com/openharmony-sig/interface_sdk_c/blob/master/docs/howto_add.md):描述了如何在build.gn中添加C API的构建目标。
|
||||||
|
|
||||||
|
|
||||||
|
@ -35,8 +35,8 @@
|
|||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef ST_NATIVE_AUDIOSTREAM_BASE_H
|
#ifndef NATIVE_AUDIOSTREAM_BASE_H
|
||||||
#define ST_NATIVE_AUDIOSTREAM_BASE_H
|
#define NATIVE_AUDIOSTREAM_BASE_H
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
@ -479,7 +479,7 @@ typedef struct OH_AudioRenderer_Callbacks_Struct {
|
|||||||
*
|
*
|
||||||
* @since 10
|
* @since 10
|
||||||
*/
|
*/
|
||||||
int32_t (*OH_AudioRenderer_OnInterrptEvent)(
|
int32_t (*OH_AudioRenderer_OnInterruptEvent)(
|
||||||
OH_AudioRenderer* renderer,
|
OH_AudioRenderer* renderer,
|
||||||
void* userData,
|
void* userData,
|
||||||
OH_AudioInterrupt_ForceType type,
|
OH_AudioInterrupt_ForceType type,
|
||||||
@ -532,8 +532,8 @@ typedef struct OH_AudioCapturer_Callbacks_Struct {
|
|||||||
*
|
*
|
||||||
* @since 10
|
* @since 10
|
||||||
*/
|
*/
|
||||||
int32_t (*OH_AudioCapturer_OnInterrptEvent)(
|
int32_t (*OH_AudioCapturer_OnInterruptEvent)(
|
||||||
OH_AudioCapturer* renderer,
|
OH_AudioCapturer* capturer,
|
||||||
void* userData,
|
void* userData,
|
||||||
OH_AudioInterrupt_ForceType type,
|
OH_AudioInterrupt_ForceType type,
|
||||||
OH_AudioInterrupt_Hint hint);
|
OH_AudioInterrupt_Hint hint);
|
||||||
@ -553,4 +553,4 @@ typedef struct OH_AudioCapturer_Callbacks_Struct {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // ST_NATIVE_AUDIOSTREAM_BASE_H
|
#endif // NATIVE_AUDIOSTREAM_BASE_H
|
||||||
|
@ -146,14 +146,18 @@ enum AudioChannelLayout : uint64_t {
|
|||||||
AudioChannelSet::TOP_FRONT_LEFT | AudioChannelSet::TOP_FRONT_RIGHT),
|
AudioChannelSet::TOP_FRONT_LEFT | AudioChannelSet::TOP_FRONT_RIGHT),
|
||||||
STEREO_DOWNMIX = (AudioChannelSet::STEREO_LEFT | AudioChannelSet::STEREO_RIGHT),
|
STEREO_DOWNMIX = (AudioChannelSet::STEREO_LEFT | AudioChannelSet::STEREO_RIGHT),
|
||||||
|
|
||||||
HOA_FIRST = AudioChannelSet::AMBISONICS_ACN0 | AudioChannelSet::AMBISONICS_ACN1 | AudioChannelSet::AMBISONICS_ACN2 |
|
CH_2POINT0POINT2 = (STEREO | AudioChannelSet::TOP_SIDE_LEFT | AudioChannelSet::TOP_SIDE_RIGHT),
|
||||||
AudioChannelSet::AMBISONICS_ACN3,
|
CH_2POINT1POINT2 = (CH_2POINT0POINT2 | AudioChannelSet::LOW_FREQUENCY),
|
||||||
HOA_SECOND = HOA_FIRST | AudioChannelSet::AMBISONICS_ACN4 | AudioChannelSet::AMBISONICS_ACN5 |
|
CH_3POINT0POINT2 = (CH_2POINT0POINT2 | AudioChannelSet::FRONT_CENTER),
|
||||||
AudioChannelSet::AMBISONICS_ACN6 | AudioChannelSet::AMBISONICS_ACN7 | AudioChannelSet::AMBISONICS_ACN8,
|
HOA_ORDER1_ACN_N3D = 0x100000000001,
|
||||||
HOA_THIRD = HOA_SECOND | AudioChannelSet::AMBISONICS_ACN9 | AudioChannelSet::AMBISONICS_ACN10 |
|
HOA_ORDER1_ACN_SN3D = 0x100000001001,
|
||||||
AudioChannelSet::AMBISONICS_ACN11 | AudioChannelSet::AMBISONICS_ACN12 |
|
HOA_ORDER1_FUMA = 0x100000000101,
|
||||||
AudioChannelSet::AMBISONICS_ACN13 | AudioChannelSet::AMBISONICS_ACN14 |
|
HOA_ORDER2_ACN_N3D = 0x100000000002,
|
||||||
AudioChannelSet::AMBISONICS_ACN15,
|
HOA_ORDER2_ACN_SN3D = 0x100000001002,
|
||||||
|
HOA_ORDER2_FUMA = 0x100000000102,
|
||||||
|
HOA_ORDER3_ACN_N3D = 0x100000000003,
|
||||||
|
HOA_ORDER3_ACN_SN3D = 0x100000001003,
|
||||||
|
HOA_ORDER3_FUMA = 0x100000000103,
|
||||||
};
|
};
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -160,6 +160,10 @@ extern const char *OH_AVCODEC_MIMETYPE_VIDEO_MPEG4;
|
|||||||
extern const char *OH_AVCODEC_MIMETYPE_IMAGE_JPG;
|
extern const char *OH_AVCODEC_MIMETYPE_IMAGE_JPG;
|
||||||
extern const char *OH_AVCODEC_MIMETYPE_IMAGE_PNG;
|
extern const char *OH_AVCODEC_MIMETYPE_IMAGE_PNG;
|
||||||
extern const char *OH_AVCODEC_MIMETYPE_IMAGE_BMP;
|
extern const char *OH_AVCODEC_MIMETYPE_IMAGE_BMP;
|
||||||
|
extern const char *OH_AVCODEC_MIMETYPE_AUDIO_AVS3DA;
|
||||||
|
extern const char *OH_AVCODEC_MIMETYPE_AUDIO_AMR_NB;
|
||||||
|
extern const char *OH_AVCODEC_MIMETYPE_AUDIO_AMR_WB;
|
||||||
|
extern const char *OH_AVCODEC_MIMETYPE_AUDIO_OPUS;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The extra data's key of surface Buffer
|
* @brief The extra data's key of surface Buffer
|
||||||
@ -184,7 +188,7 @@ extern const char *OH_MD_KEY_TRACK_TYPE;
|
|||||||
extern const char *OH_MD_KEY_CODEC_MIME;
|
extern const char *OH_MD_KEY_CODEC_MIME;
|
||||||
/* Key for duration, value type is int64_t. */
|
/* Key for duration, value type is int64_t. */
|
||||||
extern const char *OH_MD_KEY_DURATION;
|
extern const char *OH_MD_KEY_DURATION;
|
||||||
/* Key for bitrate, value type is uint32_t. */
|
/* Key for bitrate, value type is int64_t. */
|
||||||
extern const char *OH_MD_KEY_BITRATE;
|
extern const char *OH_MD_KEY_BITRATE;
|
||||||
/* Key for max input size, value type is uint32_t */
|
/* Key for max input size, value type is uint32_t */
|
||||||
extern const char *OH_MD_KEY_MAX_INPUT_SIZE;
|
extern const char *OH_MD_KEY_MAX_INPUT_SIZE;
|
||||||
@ -255,6 +259,18 @@ extern const char *OH_MD_KEY_DESCRIPTION;
|
|||||||
extern const char *OH_MD_KEY_LYRICS;
|
extern const char *OH_MD_KEY_LYRICS;
|
||||||
/* source format Key for track count, value type is uint32_t */
|
/* source format Key for track count, value type is uint32_t */
|
||||||
extern const char *OH_MD_KEY_TRACK_COUNT;
|
extern const char *OH_MD_KEY_TRACK_COUNT;
|
||||||
|
/* Key for type of file, value type is int32_t, see @OH_FileType */
|
||||||
|
extern const char *OH_MD_KEY_FILE_TYPE;
|
||||||
|
/* Key for whether the file contains video tracks, value type is boolean */
|
||||||
|
extern const char *OH_MD_KEY_HAS_VIDEO;
|
||||||
|
/* Key for whether the file contains audio tracks, value type is boolean */
|
||||||
|
extern const char *OH_MD_KEY_HAS_AUDIO;
|
||||||
|
/* Key for author of file, value type is string */
|
||||||
|
extern const char *OH_MD_KEY_AUTHOR;
|
||||||
|
/* Key for composer of file, value type is string */
|
||||||
|
extern const char *OH_MD_KEY_COMPOSER;
|
||||||
|
/* Key for cover of file, value type is uint8_t pointer */
|
||||||
|
extern const char *OH_MD_KEY_COVER;
|
||||||
/* Key for the desired encoding channel layout, value type is int64_t, this key is only supported for encoders */
|
/* Key for the desired encoding channel layout, value type is int64_t, this key is only supported for encoders */
|
||||||
extern const char *OH_MD_KEY_CHANNEL_LAYOUT;
|
extern const char *OH_MD_KEY_CHANNEL_LAYOUT;
|
||||||
/* Key for bits per coded sample, value type is uint32_t, supported for flac encoder, see @OH_BitsPerSample */
|
/* Key for bits per coded sample, value type is uint32_t, supported for flac encoder, see @OH_BitsPerSample */
|
||||||
@ -275,6 +291,32 @@ extern const char *OH_MD_KEY_SCALING_MODE;
|
|||||||
extern const char *OH_MD_MAX_INPUT_BUFFER_COUNT;
|
extern const char *OH_MD_MAX_INPUT_BUFFER_COUNT;
|
||||||
/* Key for max output buffer count, value type is int32_t */
|
/* Key for max output buffer count, value type is int32_t */
|
||||||
extern const char *OH_MD_MAX_OUTPUT_BUFFER_COUNT;
|
extern const char *OH_MD_MAX_OUTPUT_BUFFER_COUNT;
|
||||||
|
/* Key for codec compression level, value type is uint32_t */
|
||||||
|
extern const char *OH_MD_KEY_COMPRESSION_LEVEL;
|
||||||
|
/* Key for encode level, value type is int32_t. see @OH_HEVCLevel. */
|
||||||
|
extern const char *OH_MD_KEY_LEVEL;
|
||||||
|
/* Key for chroma location, value type is int32_t. see @OH_ChromaLocation. */
|
||||||
|
extern const char *OH_MD_KEY_VIDEO_CHROMA_LOCATION;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief File type.
|
||||||
|
* @syscap SystemCapability.Multimedia.Media.CodecBase
|
||||||
|
* @since 10
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
typedef enum OH_FileType {
|
||||||
|
FILE_TYPE_UNKNOW = 0,
|
||||||
|
FILE_TYPE_MP4 = 101,
|
||||||
|
FILE_TYPE_MPEGTS = 102,
|
||||||
|
FILE_TYPE_MKV = 103,
|
||||||
|
FILE_TYPE_AMR = 201,
|
||||||
|
FILE_TYPE_AAC = 202,
|
||||||
|
FILE_TYPE_MP3 = 203,
|
||||||
|
FILE_TYPE_FLAC = 204,
|
||||||
|
FILE_TYPE_OGG = 205,
|
||||||
|
FILE_TYPE_M4A = 206,
|
||||||
|
FILE_TYPE_WAV = 207,
|
||||||
|
} OH_FileType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Media type.
|
* @brief Media type.
|
||||||
@ -349,6 +391,27 @@ typedef enum OH_HEVCProfile {
|
|||||||
HEVC_PROFILE_MAIN_10_HDR10_PLUS = 4,
|
HEVC_PROFILE_MAIN_10_HDR10_PLUS = 4,
|
||||||
} OH_HEVCProfile;
|
} OH_HEVCProfile;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief HEVC Level
|
||||||
|
* @syscap SystemCapability.Multimedia.Media.CodecBase
|
||||||
|
* @since 10
|
||||||
|
*/
|
||||||
|
enum OH_HEVCLevel {
|
||||||
|
HEVC_LEVEL_1 = 0,
|
||||||
|
HEVC_LEVEL_2 = 1,
|
||||||
|
HEVC_LEVEL_21 = 2,
|
||||||
|
HEVC_LEVEL_3 = 3,
|
||||||
|
HEVC_LEVEL_31 = 4,
|
||||||
|
HEVC_LEVEL_4 = 5,
|
||||||
|
HEVC_LEVEL_41 = 6,
|
||||||
|
HEVC_LEVEL_5 = 7,
|
||||||
|
HEVC_LEVEL_51 = 8,
|
||||||
|
HEVC_LEVEL_52 = 9,
|
||||||
|
HEVC_LEVEL_6 = 10,
|
||||||
|
HEVC_LEVEL_61 = 11,
|
||||||
|
HEVC_LEVEL_62 = 12,
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Color Primary
|
* @brief Color Primary
|
||||||
* @syscap SystemCapability.Multimedia.Media.CodecBase
|
* @syscap SystemCapability.Multimedia.Media.CodecBase
|
||||||
@ -415,6 +478,21 @@ typedef enum OH_MatrixCoefficient {
|
|||||||
MATRIX_COEFFICIENT_ICTCP = 14,
|
MATRIX_COEFFICIENT_ICTCP = 14,
|
||||||
} OH_MatrixCoefficient;
|
} OH_MatrixCoefficient;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Chroma Location
|
||||||
|
* @syscap SystemCapability.Multimedia.Media.CodecBase
|
||||||
|
* @since 10
|
||||||
|
*/
|
||||||
|
enum OH_ChromaLocation {
|
||||||
|
CHROMA_LOC_UNSPECIFIED = 0,
|
||||||
|
CHROMA_LOC_LEFT = 1, ///< MPEG-2/4 4:2:0, H.264 default for 4:2:0
|
||||||
|
CHROMA_LOC_CENTER = 2, ///< MPEG-1 4:2:0, JPEG 4:2:0, H.263 4:2:0
|
||||||
|
CHROMA_LOC_TOPLEFT = 3, ///< ITU-R 601, SMPTE 274M 296M S314M(DV 4:1:1), mpeg2 4:2:2
|
||||||
|
CHROMA_LOC_TOP = 4,
|
||||||
|
CHROMA_LOC_BOTTOMLEFT = 5,
|
||||||
|
CHROMA_LOC_BOTTOM = 6,
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Scaling Mode
|
* @brief Scaling Mode
|
||||||
* @syscap SystemCapability.Multimedia.Media.CodecBase
|
* @syscap SystemCapability.Multimedia.Media.CodecBase
|
||||||
|
@ -31,8 +31,7 @@ typedef struct OH_AVSource OH_AVSource;
|
|||||||
* @brief Creates an OH_AVSource instance that models the media at the URI.
|
* @brief Creates an OH_AVSource instance that models the media at the URI.
|
||||||
* @syscap SystemCapability.Multimedia.Media.Spliter
|
* @syscap SystemCapability.Multimedia.Media.Spliter
|
||||||
* @param uri An URI for a remote media resource.
|
* @param uri An URI for a remote media resource.
|
||||||
* @return Returns AV_ERR_OK if the execution is successful,
|
* @return Returns a pointer to an OH_AVSource instance
|
||||||
* otherwise returns a specific error code, refer to {@link OH_AVErrCode}
|
|
||||||
* @since 10
|
* @since 10
|
||||||
*/
|
*/
|
||||||
OH_AVSource *OH_AVSource_CreateWithURI(char *uri);
|
OH_AVSource *OH_AVSource_CreateWithURI(char *uri);
|
||||||
@ -43,8 +42,7 @@ OH_AVSource *OH_AVSource_CreateWithURI(char *uri);
|
|||||||
* @param fd The fileDescriptor of data source.
|
* @param fd The fileDescriptor of data source.
|
||||||
* @param offset The offset into the file to start reading.
|
* @param offset The offset into the file to start reading.
|
||||||
* @param size The file size in bytes.
|
* @param size The file size in bytes.
|
||||||
* @return Returns AV_ERR_OK if the execution is successful,
|
* @return Returns a pointer to an OH_AVSource instance
|
||||||
* otherwise returns a specific error code, refer to {@link OH_AVErrCode}
|
|
||||||
* @since 10
|
* @since 10
|
||||||
*/
|
*/
|
||||||
OH_AVSource *OH_AVSource_CreateWithFD(int32_t fd, int64_t offset, int64_t size);
|
OH_AVSource *OH_AVSource_CreateWithFD(int32_t fd, int64_t offset, int64_t size);
|
||||||
|
@ -1,118 +1,118 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @addtogroup Ffrt
|
* @addtogroup Ffrt
|
||||||
* @{
|
* @{
|
||||||
*
|
*
|
||||||
* @brief ffrt provides APIs.
|
* @brief ffrt provides APIs.
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @syscap SystemCapability.Resourceschedule.Ffrt.Core
|
* @syscap SystemCapability.Resourceschedule.Ffrt.Core
|
||||||
*
|
*
|
||||||
* @since 10
|
* @since 10
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file condition_variable.h
|
* @file condition_variable.h
|
||||||
*
|
*
|
||||||
* @brief Declares the condition variable interfaces in C.
|
* @brief Declares the condition variable interfaces in C.
|
||||||
*
|
*
|
||||||
* @syscap SystemCapability.Resourceschedule.Ffrt.Core
|
* @syscap SystemCapability.Resourceschedule.Ffrt.Core
|
||||||
* @since 10
|
* @since 10
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
#ifndef FFRT_API_C_CONDITION_VARIABLE_H
|
#ifndef FFRT_API_C_CONDITION_VARIABLE_H
|
||||||
#define FFRT_API_C_CONDITION_VARIABLE_H
|
#define FFRT_API_C_CONDITION_VARIABLE_H
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include "type_def.h"
|
#include "type_def.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Initializes a condition variable.
|
* @brief Initializes a condition variable.
|
||||||
*
|
*
|
||||||
* @param cond Indicates a pointer to the condition variable.
|
* @param cond Indicates a pointer to the condition variable.
|
||||||
* @param attr Indicates a pointer to the condition variable attribute.
|
* @param attr Indicates a pointer to the condition variable attribute.
|
||||||
* @return Returns <b>ffrt_thrd_success</b> if the condition variable is initialized;
|
* @return Returns <b>ffrt_thrd_success</b> if the condition variable is initialized;
|
||||||
returns <b>ffrt_thrd_error</b> otherwise.
|
returns <b>ffrt_thrd_error</b> otherwise.
|
||||||
* @syscap SystemCapability.Resourceschedule.Ffrt.Core
|
* @syscap SystemCapability.Resourceschedule.Ffrt.Core
|
||||||
* @since 10
|
* @since 10
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
FFRT_C_API int ffrt_cond_init(ffrt_cond_t* cond, const ffrt_condattr_t* attr);
|
FFRT_C_API int ffrt_cond_init(ffrt_cond_t* cond, const ffrt_condattr_t* attr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Unblocks at least one of the threads that are blocked on a condition variable.
|
* @brief Unblocks at least one of the threads that are blocked on a condition variable.
|
||||||
*
|
*
|
||||||
* @param cond Indicates a pointer to the condition variable.
|
* @param cond Indicates a pointer to the condition variable.
|
||||||
* @return Returns <b>ffrt_thrd_success</b> if the thread is unblocked;
|
* @return Returns <b>ffrt_thrd_success</b> if the thread is unblocked;
|
||||||
returns <b>ffrt_thrd_error</b> otherwise.
|
returns <b>ffrt_thrd_error</b> otherwise.
|
||||||
* @syscap SystemCapability.Resourceschedule.Ffrt.Core
|
* @syscap SystemCapability.Resourceschedule.Ffrt.Core
|
||||||
* @since 10
|
* @since 10
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
FFRT_C_API int ffrt_cond_signal(ffrt_cond_t* cond);
|
FFRT_C_API int ffrt_cond_signal(ffrt_cond_t* cond);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Unblocks all threads currently blocked on a condition variable.
|
* @brief Unblocks all threads currently blocked on a condition variable.
|
||||||
*
|
*
|
||||||
* @param cond Indicates a pointer to the condition variable.
|
* @param cond Indicates a pointer to the condition variable.
|
||||||
* @return Returns <b>ffrt_thrd_success</b> if the threads are unblocked;
|
* @return Returns <b>ffrt_thrd_success</b> if the threads are unblocked;
|
||||||
returns <b>ffrt_thrd_error</b> otherwise.
|
returns <b>ffrt_thrd_error</b> otherwise.
|
||||||
* @syscap SystemCapability.Resourceschedule.Ffrt.Core
|
* @syscap SystemCapability.Resourceschedule.Ffrt.Core
|
||||||
* @since 10
|
* @since 10
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
FFRT_C_API int ffrt_cond_broadcast(ffrt_cond_t* cond);
|
FFRT_C_API int ffrt_cond_broadcast(ffrt_cond_t* cond);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Blocks the calling thread.
|
* @brief Blocks the calling thread.
|
||||||
*
|
*
|
||||||
* @param cond Indicates a pointer to the condition variable.
|
* @param cond Indicates a pointer to the condition variable.
|
||||||
* @param mutex Indicates a pointer to the mutex.
|
* @param mutex Indicates a pointer to the mutex.
|
||||||
* @return Returns <b>ffrt_thrd_success</b> if the thread is unblocked after being blocked;
|
* @return Returns <b>ffrt_thrd_success</b> if the thread is unblocked after being blocked;
|
||||||
returns <b>ffrt_thrd_error</b> otherwise.
|
returns <b>ffrt_thrd_error</b> otherwise.
|
||||||
* @syscap SystemCapability.Resourceschedule.Ffrt.Core
|
* @syscap SystemCapability.Resourceschedule.Ffrt.Core
|
||||||
* @since 10
|
* @since 10
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
FFRT_C_API int ffrt_cond_wait(ffrt_cond_t* cond, ffrt_mutex_t* mutex);
|
FFRT_C_API int ffrt_cond_wait(ffrt_cond_t* cond, ffrt_mutex_t* mutex);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Blocks the calling thread for a given duration.
|
* @brief Blocks the calling thread for a given duration.
|
||||||
*
|
*
|
||||||
* @param cond Indicates a pointer to the condition variable.
|
* @param cond Indicates a pointer to the condition variable.
|
||||||
* @param mutex Indicates a pointer to the mutex.
|
* @param mutex Indicates a pointer to the mutex.
|
||||||
* @param time_point Indicates the maximum duration that the thread is blocked.
|
* @param time_point Indicates the maximum duration that the thread is blocked.
|
||||||
* If <b>ffrt_cond_signal</b> or <b>ffrt_cond_broadcast</b> is not called to unblock the thread
|
* If <b>ffrt_cond_signal</b> or <b>ffrt_cond_broadcast</b> is not called to unblock the thread
|
||||||
* when the maximum duration reaches, the thread is automatically unblocked.
|
* when the maximum duration reaches, the thread is automatically unblocked.
|
||||||
* @return Returns <b>ffrt_thrd_success</b> if the thread is unblocked after being blocked;
|
* @return Returns <b>ffrt_thrd_success</b> if the thread is unblocked after being blocked;
|
||||||
returns <b>ffrt_thrd_timedout</b> if the maximum duration reaches;
|
returns <b>ffrt_thrd_timedout</b> if the maximum duration reaches;
|
||||||
returns <b>ffrt_thrd_error</b> if the blocking fails.
|
returns <b>ffrt_thrd_error</b> if the blocking fails.
|
||||||
* @since 10
|
* @since 10
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
FFRT_C_API int ffrt_cond_timedwait(ffrt_cond_t* cond, ffrt_mutex_t* mutex, const struct timespec* time_point);
|
FFRT_C_API int ffrt_cond_timedwait(ffrt_cond_t* cond, ffrt_mutex_t* mutex, const struct timespec* time_point);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Destroys a condition variable.
|
* @brief Destroys a condition variable.
|
||||||
*
|
*
|
||||||
* @param cond Indicates a pointer to the condition variable.
|
* @param cond Indicates a pointer to the condition variable.
|
||||||
* @return Returns <b>ffrt_thrd_success</b> if the condition variable is destroyed;
|
* @return Returns <b>ffrt_thrd_success</b> if the condition variable is destroyed;
|
||||||
returns <b>ffrt_thrd_error</b> otherwise.
|
returns <b>ffrt_thrd_error</b> otherwise.
|
||||||
* @since 10
|
* @since 10
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
FFRT_C_API int ffrt_cond_destroy(ffrt_cond_t* cond);
|
FFRT_C_API int ffrt_cond_destroy(ffrt_cond_t* cond);
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,96 +1,96 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @addtogroup Ffrt
|
* @addtogroup Ffrt
|
||||||
* @{
|
* @{
|
||||||
*
|
*
|
||||||
* @brief ffrt provides APIs.
|
* @brief ffrt provides APIs.
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @syscap SystemCapability.Resourceschedule.Ffrt.Core
|
* @syscap SystemCapability.Resourceschedule.Ffrt.Core
|
||||||
*
|
*
|
||||||
* @since 10
|
* @since 10
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file mutex.h
|
* @file mutex.h
|
||||||
*
|
*
|
||||||
* @brief Declares the mutex interfaces in C.
|
* @brief Declares the mutex interfaces in C.
|
||||||
*
|
*
|
||||||
* @syscap SystemCapability.Resourceschedule.Ffrt.Core
|
* @syscap SystemCapability.Resourceschedule.Ffrt.Core
|
||||||
* @since 10
|
* @since 10
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
#ifndef FFRT_API_C_MUTEX_H
|
#ifndef FFRT_API_C_MUTEX_H
|
||||||
#define FFRT_API_C_MUTEX_H
|
#define FFRT_API_C_MUTEX_H
|
||||||
#include "type_def.h"
|
#include "type_def.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Initializes a mutex.
|
* @brief Initializes a mutex.
|
||||||
*
|
*
|
||||||
* @param mutex Indicates a pointer to the mutex.
|
* @param mutex Indicates a pointer to the mutex.
|
||||||
* @param attr Indicates a pointer to the mutex attribute.
|
* @param attr Indicates a pointer to the mutex attribute.
|
||||||
* @return Returns <b>ffrt_thrd_success</b> if the mutex is initialized;
|
* @return Returns <b>ffrt_thrd_success</b> if the mutex is initialized;
|
||||||
returns <b>ffrt_thrd_error</b> otherwise.
|
returns <b>ffrt_thrd_error</b> otherwise.
|
||||||
* @since 10
|
* @since 10
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
FFRT_C_API int ffrt_mutex_init(ffrt_mutex_t* mutex, const ffrt_mutexattr_t* attr);
|
FFRT_C_API int ffrt_mutex_init(ffrt_mutex_t* mutex, const ffrt_mutexattr_t* attr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Locks a mutex.
|
* @brief Locks a mutex.
|
||||||
*
|
*
|
||||||
* @param mutex Indicates a pointer to the mutex.
|
* @param mutex Indicates a pointer to the mutex.
|
||||||
* @return Returns <b>ffrt_thrd_success</b> if the mutex is locked;
|
* @return Returns <b>ffrt_thrd_success</b> if the mutex is locked;
|
||||||
returns <b>ffrt_thrd_error</b> or blocks the calling thread otherwise.
|
returns <b>ffrt_thrd_error</b> or blocks the calling thread otherwise.
|
||||||
* @since 10
|
* @since 10
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
FFRT_C_API int ffrt_mutex_lock(ffrt_mutex_t* mutex);
|
FFRT_C_API int ffrt_mutex_lock(ffrt_mutex_t* mutex);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Unlocks a mutex.
|
* @brief Unlocks a mutex.
|
||||||
*
|
*
|
||||||
* @param mutex Indicates a pointer to the mutex.
|
* @param mutex Indicates a pointer to the mutex.
|
||||||
* @return Returns <b>ffrt_thrd_success</b> if the mutex is unlocked;
|
* @return Returns <b>ffrt_thrd_success</b> if the mutex is unlocked;
|
||||||
returns <b>ffrt_thrd_error</b> otherwise.
|
returns <b>ffrt_thrd_error</b> otherwise.
|
||||||
* @since 10
|
* @since 10
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
FFRT_C_API int ffrt_mutex_unlock(ffrt_mutex_t* mutex);
|
FFRT_C_API int ffrt_mutex_unlock(ffrt_mutex_t* mutex);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Attempts to lock a mutex.
|
* @brief Attempts to lock a mutex.
|
||||||
*
|
*
|
||||||
* @param mutex Indicates a pointer to the mutex.
|
* @param mutex Indicates a pointer to the mutex.
|
||||||
* @return Returns <b>ffrt_thrd_success</b> if the mutex is locked;
|
* @return Returns <b>ffrt_thrd_success</b> if the mutex is locked;
|
||||||
returns <b>ffrt_thrd_error</b> or <b>ffrt_thrd_busy</b> otherwise.
|
returns <b>ffrt_thrd_error</b> or <b>ffrt_thrd_busy</b> otherwise.
|
||||||
* @since 10
|
* @since 10
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
FFRT_C_API int ffrt_mutex_trylock(ffrt_mutex_t* mutex);
|
FFRT_C_API int ffrt_mutex_trylock(ffrt_mutex_t* mutex);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Destroys a mutex.
|
* @brief Destroys a mutex.
|
||||||
*
|
*
|
||||||
* @param mutex Indicates a pointer to the mutex.
|
* @param mutex Indicates a pointer to the mutex.
|
||||||
* @return Returns <b>ffrt_thrd_success</b> if the mutex is destroyed;
|
* @return Returns <b>ffrt_thrd_success</b> if the mutex is destroyed;
|
||||||
returns <b>ffrt_thrd_error</b> otherwise.
|
returns <b>ffrt_thrd_error</b> otherwise.
|
||||||
* @since 10
|
* @since 10
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
FFRT_C_API int ffrt_mutex_destroy(ffrt_mutex_t* mutex);
|
FFRT_C_API int ffrt_mutex_destroy(ffrt_mutex_t* mutex);
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,192 +1,192 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @addtogroup Ffrt
|
* @addtogroup Ffrt
|
||||||
* @{
|
* @{
|
||||||
*
|
*
|
||||||
* @brief ffrt provides APIs.
|
* @brief ffrt provides APIs.
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @syscap SystemCapability.Resourceschedule.Ffrt.Core
|
* @syscap SystemCapability.Resourceschedule.Ffrt.Core
|
||||||
*
|
*
|
||||||
* @since 10
|
* @since 10
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file queue.h
|
* @file queue.h
|
||||||
*
|
*
|
||||||
* @brief Declares the queue interfaces in C.
|
* @brief Declares the queue interfaces in C.
|
||||||
*
|
*
|
||||||
* @syscap SystemCapability.Resourceschedule.Ffrt.Core
|
* @syscap SystemCapability.Resourceschedule.Ffrt.Core
|
||||||
* @since 10
|
* @since 10
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
#ifndef FFRT_API_C_QUEUE_H
|
#ifndef FFRT_API_C_QUEUE_H
|
||||||
#define FFRT_API_C_QUEUE_H
|
#define FFRT_API_C_QUEUE_H
|
||||||
|
|
||||||
#include "type_def.h"
|
#include "type_def.h"
|
||||||
|
|
||||||
typedef enum { ffrt_queue_serial, ffrt_queue_max } ffrt_queue_type_t;
|
typedef enum { ffrt_queue_serial, ffrt_queue_max } ffrt_queue_type_t;
|
||||||
typedef void* ffrt_queue_t;
|
typedef void* ffrt_queue_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Initializes the queue attribute.
|
* @brief Initializes the queue attribute.
|
||||||
*
|
*
|
||||||
* @param attr Indicates a pointer to the queue attribute.
|
* @param attr Indicates a pointer to the queue attribute.
|
||||||
* @return Returns <b>0</b> if the queue attribute is initialized;
|
* @return Returns <b>0</b> if the queue attribute is initialized;
|
||||||
returns <b>-1</b> otherwise.
|
returns <b>-1</b> otherwise.
|
||||||
* @since 10
|
* @since 10
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
FFRT_C_API int ffrt_queue_attr_init(ffrt_queue_attr_t* attr);
|
FFRT_C_API int ffrt_queue_attr_init(ffrt_queue_attr_t* attr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Destroys a queue attribute.
|
* @brief Destroys a queue attribute.
|
||||||
*
|
*
|
||||||
* @param attr Indicates a pointer to the queue attribute.
|
* @param attr Indicates a pointer to the queue attribute.
|
||||||
* @since 10
|
* @since 10
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
FFRT_C_API void ffrt_queue_attr_destroy(ffrt_queue_attr_t* attr);
|
FFRT_C_API void ffrt_queue_attr_destroy(ffrt_queue_attr_t* attr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Sets the QoS for a queue attribute.
|
* @brief Sets the QoS for a queue attribute.
|
||||||
*
|
*
|
||||||
* @param attr Indicates a pointer to the queue attribute.
|
* @param attr Indicates a pointer to the queue attribute.
|
||||||
* @param attr Indicates the QoS.
|
* @param attr Indicates the QoS.
|
||||||
* @since 10
|
* @since 10
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
FFRT_C_API void ffrt_queue_attr_set_qos(ffrt_queue_attr_t* attr, ffrt_qos_t qos);
|
FFRT_C_API void ffrt_queue_attr_set_qos(ffrt_queue_attr_t* attr, ffrt_qos_t qos);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Obtains the QoS of a queue attribute.
|
* @brief Obtains the QoS of a queue attribute.
|
||||||
*
|
*
|
||||||
* @param attr Indicates a pointer to the queue attribute.
|
* @param attr Indicates a pointer to the queue attribute.
|
||||||
* @return Returns the QoS.
|
* @return Returns the QoS.
|
||||||
* @since 10
|
* @since 10
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
FFRT_C_API ffrt_qos_t ffrt_queue_attr_get_qos(const ffrt_queue_attr_t* attr);
|
FFRT_C_API ffrt_qos_t ffrt_queue_attr_get_qos(const ffrt_queue_attr_t* attr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Set the serial queue task execution timeout.
|
* @brief Set the serial queue task execution timeout.
|
||||||
*
|
*
|
||||||
* @param attr Serial Queue Property Pointer.
|
* @param attr Serial Queue Property Pointer.
|
||||||
* @param timeout_us Serial queue task execution timeout.
|
* @param timeout_us Serial queue task execution timeout.
|
||||||
* @since 10
|
* @since 10
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
FFRT_C_API void ffrt_queue_attr_set_timeout(ffrt_queue_attr_t* attr, uint64_t timeout_us);
|
FFRT_C_API void ffrt_queue_attr_set_timeout(ffrt_queue_attr_t* attr, uint64_t timeout_us);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get the serial queue task execution timeout.
|
* @brief Get the serial queue task execution timeout.
|
||||||
*
|
*
|
||||||
* @param attr Serial Queue Property Pointer.
|
* @param attr Serial Queue Property Pointer.
|
||||||
* @return Returns the serial queue task execution timeout.
|
* @return Returns the serial queue task execution timeout.
|
||||||
* @since 10
|
* @since 10
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
FFRT_C_API uint64_t ffrt_queue_attr_get_timeout(const ffrt_queue_attr_t* attr);
|
FFRT_C_API uint64_t ffrt_queue_attr_get_timeout(const ffrt_queue_attr_t* attr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Set the serial queue timeout callback function.
|
* @brief Set the serial queue timeout callback function.
|
||||||
*
|
*
|
||||||
* @param attr Serial Queue Property Pointer.
|
* @param attr Serial Queue Property Pointer.
|
||||||
* @param f Serial queue timeout callback function.
|
* @param f Serial queue timeout callback function.
|
||||||
* @since 10
|
* @since 10
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
FFRT_C_API void ffrt_queue_attr_set_callback(ffrt_queue_attr_t* attr, ffrt_function_header_t* f);
|
FFRT_C_API void ffrt_queue_attr_set_callback(ffrt_queue_attr_t* attr, ffrt_function_header_t* f);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get the serial queue task timeout callback function.
|
* @brief Get the serial queue task timeout callback function.
|
||||||
*
|
*
|
||||||
* @param attr Serial Queue Property Pointer.
|
* @param attr Serial Queue Property Pointer.
|
||||||
* @return Returns the serial queue task timeout callback function.
|
* @return Returns the serial queue task timeout callback function.
|
||||||
* @since 10
|
* @since 10
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
FFRT_C_API ffrt_function_header_t* ffrt_queue_attr_get_callback(const ffrt_queue_attr_t* attr);
|
FFRT_C_API ffrt_function_header_t* ffrt_queue_attr_get_callback(const ffrt_queue_attr_t* attr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Creates a queue.
|
* @brief Creates a queue.
|
||||||
*
|
*
|
||||||
* @param type Indicates the queue type.
|
* @param type Indicates the queue type.
|
||||||
* @param name Indicates a pointer to the queue name.
|
* @param name Indicates a pointer to the queue name.
|
||||||
* @param attr Indicates a pointer to the queue attribute.
|
* @param attr Indicates a pointer to the queue attribute.
|
||||||
* @return Returns a non-null queue handle if the queue is created;
|
* @return Returns a non-null queue handle if the queue is created;
|
||||||
returns a null pointer otherwise.
|
returns a null pointer otherwise.
|
||||||
* @since 10
|
* @since 10
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
FFRT_C_API ffrt_queue_t ffrt_queue_create(ffrt_queue_type_t type, const char* name, const ffrt_queue_attr_t* attr);
|
FFRT_C_API ffrt_queue_t ffrt_queue_create(ffrt_queue_type_t type, const char* name, const ffrt_queue_attr_t* attr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Destroys a queue.
|
* @brief Destroys a queue.
|
||||||
*
|
*
|
||||||
* @param queue Indicates a queue handle.
|
* @param queue Indicates a queue handle.
|
||||||
* @since 10
|
* @since 10
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
FFRT_C_API void ffrt_queue_destroy(ffrt_queue_t queue);
|
FFRT_C_API void ffrt_queue_destroy(ffrt_queue_t queue);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Submits a task to a queue.
|
* @brief Submits a task to a queue.
|
||||||
*
|
*
|
||||||
* @param queue Indicates a queue handle.
|
* @param queue Indicates a queue handle.
|
||||||
* @param f Indicates a pointer to the task executor.
|
* @param f Indicates a pointer to the task executor.
|
||||||
* @param attr Indicates a pointer to the task attribute.
|
* @param attr Indicates a pointer to the task attribute.
|
||||||
* @since 10
|
* @since 10
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
FFRT_C_API void ffrt_queue_submit(ffrt_queue_t queue, ffrt_function_header_t* f, const ffrt_task_attr_t* attr);
|
FFRT_C_API void ffrt_queue_submit(ffrt_queue_t queue, ffrt_function_header_t* f, const ffrt_task_attr_t* attr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Submits a task to the queue, and obtains a task handle.
|
* @brief Submits a task to the queue, and obtains a task handle.
|
||||||
*
|
*
|
||||||
* @param queue Indicates a queue handle.
|
* @param queue Indicates a queue handle.
|
||||||
* @param f Indicates a pointer to the task executor.
|
* @param f Indicates a pointer to the task executor.
|
||||||
* @param attr Indicates a pointer to the task attribute.
|
* @param attr Indicates a pointer to the task attribute.
|
||||||
* @return Returns a non-null task handle if the task is submitted;
|
* @return Returns a non-null task handle if the task is submitted;
|
||||||
returns a null pointer otherwise.
|
returns a null pointer otherwise.
|
||||||
* @since 10
|
* @since 10
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
FFRT_C_API ffrt_task_handle_t ffrt_queue_submit_h(
|
FFRT_C_API ffrt_task_handle_t ffrt_queue_submit_h(
|
||||||
ffrt_queue_t queue, ffrt_function_header_t* f, const ffrt_task_attr_t* attr);
|
ffrt_queue_t queue, ffrt_function_header_t* f, const ffrt_task_attr_t* attr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Waits until a task in the queue is complete.
|
* @brief Waits until a task in the queue is complete.
|
||||||
*
|
*
|
||||||
* @param handle Indicates a task handle.
|
* @param handle Indicates a task handle.
|
||||||
* @since 10
|
* @since 10
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
FFRT_C_API void ffrt_queue_wait(ffrt_task_handle_t handle);
|
FFRT_C_API void ffrt_queue_wait(ffrt_task_handle_t handle);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Cancels a task in the queue.
|
* @brief Cancels a task in the queue.
|
||||||
*
|
*
|
||||||
* @param handle Indicates a task handle.
|
* @param handle Indicates a task handle.
|
||||||
* @return Returns <b>0</b> if the task is canceled;
|
* @return Returns <b>0</b> if the task is canceled;
|
||||||
returns <b>-1</b> otherwise.
|
returns <b>-1</b> otherwise.
|
||||||
* @since 10
|
* @since 10
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
FFRT_C_API int ffrt_queue_cancel(ffrt_task_handle_t handle);
|
FFRT_C_API int ffrt_queue_cancel(ffrt_task_handle_t handle);
|
||||||
|
|
||||||
#endif // FFRT_API_C_QUEUE_H
|
#endif // FFRT_API_C_QUEUE_H
|
@ -1,59 +1,59 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @addtogroup Ffrt
|
* @addtogroup Ffrt
|
||||||
* @{
|
* @{
|
||||||
*
|
*
|
||||||
* @brief ffrt provides APIs.
|
* @brief ffrt provides APIs.
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @syscap SystemCapability.Resourceschedule.Ffrt.Core
|
* @syscap SystemCapability.Resourceschedule.Ffrt.Core
|
||||||
*
|
*
|
||||||
* @since 10
|
* @since 10
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file sleep.h
|
* @file sleep.h
|
||||||
*
|
*
|
||||||
* @brief Declares the sleep and yield interfaces in C.
|
* @brief Declares the sleep and yield interfaces in C.
|
||||||
*
|
*
|
||||||
* @syscap SystemCapability.Resourceschedule.Ffrt.Core
|
* @syscap SystemCapability.Resourceschedule.Ffrt.Core
|
||||||
* @since 10
|
* @since 10
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
#ifndef FFRT_API_C_SLEEP_H
|
#ifndef FFRT_API_C_SLEEP_H
|
||||||
#define FFRT_API_C_SLEEP_H
|
#define FFRT_API_C_SLEEP_H
|
||||||
#include "type_def.h"
|
#include "type_def.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Suspends the calling thread for a given duration.
|
* @brief Suspends the calling thread for a given duration.
|
||||||
*
|
*
|
||||||
* @param usec Indicates the duration that the calling thread is suspended, in microseconds.
|
* @param usec Indicates the duration that the calling thread is suspended, in microseconds.
|
||||||
* @return Returns <b>ffrt_thrd_success</b> if the thread is suspended;
|
* @return Returns <b>ffrt_thrd_success</b> if the thread is suspended;
|
||||||
returns <b>ffrt_thrd_error</b> otherwise.
|
returns <b>ffrt_thrd_error</b> otherwise.
|
||||||
* @since 10
|
* @since 10
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
FFRT_C_API int ffrt_usleep(uint64_t usec);
|
FFRT_C_API int ffrt_usleep(uint64_t usec);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Passes control to other tasks so that they can be executed.
|
* @brief Passes control to other tasks so that they can be executed.
|
||||||
*
|
*
|
||||||
* @since 10
|
* @since 10
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
FFRT_C_API void ffrt_yield(void);
|
FFRT_C_API void ffrt_yield(void);
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,204 +1,207 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @addtogroup Ffrt
|
* @addtogroup Ffrt
|
||||||
* @{
|
* @{
|
||||||
*
|
*
|
||||||
* @brief ffrt provides APIs.
|
* @brief ffrt provides APIs.
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @syscap SystemCapability.Resourceschedule.Ffrt.Core
|
* @syscap SystemCapability.Resourceschedule.Ffrt.Core
|
||||||
*
|
*
|
||||||
* @since 10
|
* @since 10
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file task.h
|
* @file task.h
|
||||||
*
|
*
|
||||||
* @brief Declares the task interfaces in C.
|
* @brief Declares the task interfaces in C.
|
||||||
*
|
*
|
||||||
* @syscap SystemCapability.Resourceschedule.Ffrt.Core
|
* @syscap SystemCapability.Resourceschedule.Ffrt.Core
|
||||||
* @since 10
|
* @since 10
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
#ifndef FFRT_API_C_TASK_H
|
#ifndef FFRT_API_C_TASK_H
|
||||||
#define FFRT_API_C_TASK_H
|
#define FFRT_API_C_TASK_H
|
||||||
#include "type_def.h"
|
#include "type_def.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Initializes a task attribute.
|
* @brief Initializes a task attribute.
|
||||||
*
|
*
|
||||||
* @param attr Indicates a pointer to the task attribute.
|
* @param attr Indicates a pointer to the task attribute.
|
||||||
* @return Returns <b>0</b> if the task attribute is initialized;
|
* @return Returns <b>0</b> if the task attribute is initialized;
|
||||||
returns <b>-1</b> otherwise.
|
returns <b>-1</b> otherwise.
|
||||||
* @since 10
|
* @since 10
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
FFRT_C_API int ffrt_task_attr_init(ffrt_task_attr_t* attr);
|
FFRT_C_API int ffrt_task_attr_init(ffrt_task_attr_t* attr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Sets a task name.
|
* @brief Sets a task name.
|
||||||
*
|
*
|
||||||
* @param attr Indicates a pointer to the task attribute.
|
* @param attr Indicates a pointer to the task attribute.
|
||||||
* @param name Indicates a pointer to the task name.
|
* @param name Indicates a pointer to the task name.
|
||||||
* @since 10
|
* @since 10
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
FFRT_C_API void ffrt_task_attr_set_name(ffrt_task_attr_t* attr, const char* name);
|
FFRT_C_API void ffrt_task_attr_set_name(ffrt_task_attr_t* attr, const char* name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Obtains a task name.
|
* @brief Obtains a task name.
|
||||||
*
|
*
|
||||||
* @param attr Indicates a pointer to the task attribute.
|
* @param attr Indicates a pointer to the task attribute.
|
||||||
* @return Returns a non-null pointer to the task name if the name is obtained;
|
* @return Returns a non-null pointer to the task name if the name is obtained;
|
||||||
returns a null pointer otherwise.
|
returns a null pointer otherwise.
|
||||||
* @since 10
|
* @since 10
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
FFRT_C_API const char* ffrt_task_attr_get_name(const ffrt_task_attr_t* attr);
|
FFRT_C_API const char* ffrt_task_attr_get_name(const ffrt_task_attr_t* attr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Destroys a task attribute.
|
* @brief Destroys a task attribute.
|
||||||
*
|
*
|
||||||
* @param attr Indicates a pointer to the task attribute.
|
* @param attr Indicates a pointer to the task attribute.
|
||||||
* @since 10
|
* @since 10
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
FFRT_C_API void ffrt_task_attr_destroy(ffrt_task_attr_t* attr);
|
FFRT_C_API void ffrt_task_attr_destroy(ffrt_task_attr_t* attr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Sets the QoS for a task attribute.
|
* @brief Sets the QoS for a task attribute.
|
||||||
*
|
*
|
||||||
* @param attr Indicates a pointer to the task attribute.
|
* @param attr Indicates a pointer to the task attribute.
|
||||||
* @param qos Indicates the QoS.
|
* @param qos Indicates the QoS.
|
||||||
* @since 10
|
* @since 10
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
FFRT_C_API void ffrt_task_attr_set_qos(ffrt_task_attr_t* attr, ffrt_qos_t qos);
|
FFRT_C_API void ffrt_task_attr_set_qos(ffrt_task_attr_t* attr, ffrt_qos_t qos);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Obtains the QoS of a task attribute.
|
* @brief Obtains the QoS of a task attribute.
|
||||||
*
|
*
|
||||||
* @param attr Indicates a pointer to the task attribute.
|
* @param attr Indicates a pointer to the task attribute.
|
||||||
* @return Returns the QoS, which is <b>ffrt_qos_default</b> by default.
|
* @return Returns the QoS, which is <b>ffrt_qos_default</b> by default.
|
||||||
* @since 10
|
* @since 10
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
FFRT_C_API ffrt_qos_t ffrt_task_attr_get_qos(const ffrt_task_attr_t* attr);
|
FFRT_C_API ffrt_qos_t ffrt_task_attr_get_qos(const ffrt_task_attr_t* attr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Sets the task delay time.
|
* @brief Sets the task delay time.
|
||||||
*
|
*
|
||||||
* @param attr Indicates a pointer to the task attribute.
|
* @param attr Indicates a pointer to the task attribute.
|
||||||
* @param delay_us Indicates the delay time, in microseconds.
|
* @param delay_us Indicates the delay time, in microseconds.
|
||||||
* @since 10
|
* @since 10
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
FFRT_C_API void ffrt_task_attr_set_delay(ffrt_task_attr_t* attr, uint64_t delay_us);
|
FFRT_C_API void ffrt_task_attr_set_delay(ffrt_task_attr_t* attr, uint64_t delay_us);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Obtains the task delay time.
|
* @brief Obtains the task delay time.
|
||||||
*
|
*
|
||||||
* @param attr Indicates a pointer to the task attribute.
|
* @param attr Indicates a pointer to the task attribute.
|
||||||
* @return Returns the delay time.
|
* @return Returns the delay time.
|
||||||
* @since 10
|
* @since 10
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
FFRT_C_API uint64_t ffrt_task_attr_get_delay(const ffrt_task_attr_t* attr);
|
FFRT_C_API uint64_t ffrt_task_attr_get_delay(const ffrt_task_attr_t* attr);
|
||||||
/**
|
|
||||||
* @brief Updates the QoS of this task.
|
/**
|
||||||
*
|
* @brief Updates the QoS of this task.
|
||||||
* @param qos Indicates the new QoS.
|
*
|
||||||
* @return Returns <b>0</b> if the QoS is updated;
|
* @param qos Indicates the new QoS.
|
||||||
returns <b>-1</b> otherwise.
|
* @return Returns <b>0</b> if the QoS is updated;
|
||||||
* @since 10
|
returns <b>-1</b> otherwise.
|
||||||
* @version 1.0
|
* @since 10
|
||||||
*/
|
* @version 1.0
|
||||||
FFRT_C_API int ffrt_this_task_update_qos(ffrt_qos_t task_qos);
|
*/
|
||||||
/**
|
FFRT_C_API int ffrt_this_task_update_qos(ffrt_qos_t qos);
|
||||||
* @brief Obtains the ID of this task.
|
|
||||||
*
|
/**
|
||||||
* @return Returns the task ID.
|
* @brief Obtains the ID of this task.
|
||||||
* @since 10
|
*
|
||||||
* @version 1.0
|
* @return Returns the task ID.
|
||||||
*/
|
* @since 10
|
||||||
FFRT_C_API uint64_t ffrt_this_task_get_id(void);
|
* @version 1.0
|
||||||
|
*/
|
||||||
/**
|
FFRT_C_API uint64_t ffrt_this_task_get_id(void);
|
||||||
* @brief Applies for memory for the function execution structure.
|
|
||||||
*
|
/**
|
||||||
* @param kind Indicates the type of the function execution structure, which can be common or queue.
|
* @brief Applies for memory for the function execution structure.
|
||||||
* @return Returns a non-null pointer if the memory is allocated;
|
*
|
||||||
returns a null pointer otherwise.
|
* @param kind Indicates the type of the function execution structure, which can be common or queue.
|
||||||
* @since 10
|
* @return Returns a non-null pointer if the memory is allocated;
|
||||||
* @version 1.0
|
returns a null pointer otherwise.
|
||||||
*/
|
* @since 10
|
||||||
FFRT_C_API void *ffrt_alloc_auto_managed_function_storage_base(ffrt_function_kind_t kind);
|
* @version 1.0
|
||||||
|
*/
|
||||||
/**
|
FFRT_C_API void *ffrt_alloc_auto_managed_function_storage_base(ffrt_function_kind_t kind);
|
||||||
* @brief Submits a task.
|
|
||||||
*
|
/**
|
||||||
* @param f Indicates a pointer to the task executor.
|
* @brief Submits a task.
|
||||||
* @param in_deps Indicates a pointer to the input dependencies.
|
*
|
||||||
* @param out_deps Indicates a pointer to the output dependencies.
|
* @param f Indicates a pointer to the task executor.
|
||||||
* @param attr Indicates a pointer to the task attribute.
|
* @param in_deps Indicates a pointer to the input dependencies.
|
||||||
* @since 10
|
* @param out_deps Indicates a pointer to the output dependencies.
|
||||||
* @version 1.0
|
* @param attr Indicates a pointer to the task attribute.
|
||||||
*/
|
* @since 10
|
||||||
FFRT_C_API void ffrt_submit_base(ffrt_function_header_t* f, const ffrt_deps_t* in_deps, const ffrt_deps_t* out_deps,
|
* @version 1.0
|
||||||
const ffrt_task_attr_t* attr);
|
*/
|
||||||
|
FFRT_C_API void ffrt_submit_base(ffrt_function_header_t* f, const ffrt_deps_t* in_deps, const ffrt_deps_t* out_deps,
|
||||||
/**
|
const ffrt_task_attr_t* attr);
|
||||||
* @brief Submits a task, and obtains a task handle.
|
|
||||||
*
|
/**
|
||||||
* @param f Indicates a pointer to the task executor.
|
* @brief Submits a task, and obtains a task handle.
|
||||||
* @param in_deps Indicates a pointer to the input dependencies.
|
*
|
||||||
* @param out_deps Indicates a pointer to the output dependencies.
|
* @param f Indicates a pointer to the task executor.
|
||||||
* @param attr Indicates a pointer to the task attribute.
|
* @param in_deps Indicates a pointer to the input dependencies.
|
||||||
* @return Returns a non-null task handle if the task is submitted;
|
* @param out_deps Indicates a pointer to the output dependencies.
|
||||||
returns a null pointer otherwise.
|
* @param attr Indicates a pointer to the task attribute.
|
||||||
* @since 10
|
* @return Returns a non-null task handle if the task is submitted;
|
||||||
* @version 1.0
|
returns a null pointer otherwise.
|
||||||
*/
|
* @since 10
|
||||||
FFRT_C_API ffrt_task_handle_t ffrt_submit_h_base(ffrt_function_header_t* f, const ffrt_deps_t* in_deps,
|
* @version 1.0
|
||||||
const ffrt_deps_t* out_deps, const ffrt_task_attr_t* attr);
|
*/
|
||||||
|
FFRT_C_API ffrt_task_handle_t ffrt_submit_h_base(ffrt_function_header_t* f, const ffrt_deps_t* in_deps,
|
||||||
/**
|
const ffrt_deps_t* out_deps, const ffrt_task_attr_t* attr);
|
||||||
* @brief Destroys a task handle.
|
|
||||||
*
|
/**
|
||||||
* @param handle Indicates a task handle.
|
* @brief Destroys a task handle.
|
||||||
* @since 10
|
*
|
||||||
* @version 1.0
|
* @param handle Indicates a task handle.
|
||||||
*/
|
* @since 10
|
||||||
FFRT_C_API void ffrt_task_handle_destroy(ffrt_task_handle_t handle);
|
* @version 1.0
|
||||||
|
*/
|
||||||
/**
|
FFRT_C_API void ffrt_task_handle_destroy(ffrt_task_handle_t handle);
|
||||||
* @brief Waits until the dependent tasks are complete.
|
|
||||||
*
|
/**
|
||||||
* @param deps Indicates a pointer to the dependent tasks.
|
* @brief Waits until the dependent tasks are complete.
|
||||||
* @since 10
|
*
|
||||||
* @version 1.0
|
* @param deps Indicates a pointer to the dependent tasks.
|
||||||
*/
|
* @since 10
|
||||||
FFRT_C_API void ffrt_wait_deps(const ffrt_deps_t* deps);
|
* @version 1.0
|
||||||
|
*/
|
||||||
/**
|
FFRT_C_API void ffrt_wait_deps(const ffrt_deps_t* deps);
|
||||||
* @brief Waits until all submitted tasks are complete.
|
|
||||||
*
|
/**
|
||||||
* @since 10
|
* @brief Waits until all submitted tasks are complete.
|
||||||
* @version 1.0
|
*
|
||||||
*/
|
* @since 10
|
||||||
FFRT_C_API void ffrt_wait(void);
|
* @version 1.0
|
||||||
#endif
|
*/
|
||||||
|
FFRT_C_API void ffrt_wait(void);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
@ -1,175 +1,189 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @addtogroup Ffrt
|
* @addtogroup Ffrt
|
||||||
* @{
|
* @{
|
||||||
*
|
*
|
||||||
* @brief ffrt provides APIs.
|
* @brief ffrt provides APIs.
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @syscap SystemCapability.Resourceschedule.Ffrt.Core
|
* @syscap SystemCapability.Resourceschedule.Ffrt.Core
|
||||||
*
|
*
|
||||||
* @since 10
|
* @since 10
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file type_def.h
|
* @file type_def.h
|
||||||
*
|
*
|
||||||
* @brief Declares common types.
|
* @brief Declares common types.
|
||||||
*
|
*
|
||||||
* @syscap SystemCapability.Resourceschedule.Ffrt.Core
|
* @syscap SystemCapability.Resourceschedule.Ffrt.Core
|
||||||
* @since 10
|
* @since 10
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
#ifndef FFRT_API_C_TYPE_DEF_H
|
#ifndef FFRT_API_C_TYPE_DEF_H
|
||||||
#define FFRT_API_C_TYPE_DEF_H
|
#define FFRT_API_C_TYPE_DEF_H
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#define FFRT_C_API extern "C"
|
#define FFRT_C_API extern "C"
|
||||||
#else
|
#else
|
||||||
#define FFRT_C_API
|
#define FFRT_C_API
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Enumerates the task QoS types.
|
* @brief Enumerates the task QoS types.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
typedef enum {
|
typedef enum {
|
||||||
ffrt_qos_inherit = -1,
|
/** Inheritance. */
|
||||||
/** Background task. */
|
ffrt_qos_inherit = -1,
|
||||||
ffrt_qos_background,
|
/** Background task. */
|
||||||
/** Real-time tool. */
|
ffrt_qos_background,
|
||||||
ffrt_qos_utility,
|
/** Real-time tool. */
|
||||||
/** Default type. */
|
ffrt_qos_utility,
|
||||||
ffrt_qos_default,
|
/** Default type. */
|
||||||
/** User initiated. */
|
ffrt_qos_default,
|
||||||
ffrt_qos_user_initiated,
|
/** User initiated. */
|
||||||
} ffrt_qos_default_t;
|
ffrt_qos_user_initiated,
|
||||||
typedef int ffrt_qos_t;
|
} ffrt_qos_default_t;
|
||||||
|
typedef int ffrt_qos_t;
|
||||||
typedef void(*ffrt_function_t)(void*);
|
|
||||||
|
typedef void(*ffrt_function_t)(void*);
|
||||||
/**
|
|
||||||
* @brief Defines a task executor.
|
/**
|
||||||
*
|
* @brief Defines a task executor.
|
||||||
*/
|
*
|
||||||
typedef struct {
|
*/
|
||||||
/** Function used to execute a task. */
|
typedef struct {
|
||||||
ffrt_function_t exec;
|
/** Function used to execute a task. */
|
||||||
/** Function used to destroy a task. */
|
ffrt_function_t exec;
|
||||||
ffrt_function_t destroy;
|
/** Function used to destroy a task. */
|
||||||
uint64_t reserve[2];
|
ffrt_function_t destroy;
|
||||||
} ffrt_function_header_t;
|
/** Need to be set to 0. */
|
||||||
|
uint64_t reserve[2];
|
||||||
/**
|
} ffrt_function_header_t;
|
||||||
* @brief Defines the storage size of multiple types of structs.
|
|
||||||
*
|
/**
|
||||||
*/
|
* @brief Defines the storage size of multiple types of structs.
|
||||||
typedef enum {
|
*
|
||||||
/** Task attribute storage size. */
|
*/
|
||||||
ffrt_task_attr_storage_size = 128,
|
typedef enum {
|
||||||
/** Task executor storage size. */
|
/** Task attribute storage size. */
|
||||||
ffrt_auto_managed_function_storage_size = 64 + sizeof(ffrt_function_header_t),
|
ffrt_task_attr_storage_size = 128,
|
||||||
/* Mutex storage size. */
|
/** Task executor storage size. */
|
||||||
ffrt_mutex_storage_size = 64,
|
ffrt_auto_managed_function_storage_size = 64 + sizeof(ffrt_function_header_t),
|
||||||
/** Condition variable storage size. */
|
/* Mutex storage size. */
|
||||||
ffrt_cond_storage_size = 64,
|
ffrt_mutex_storage_size = 64,
|
||||||
/** Queue storage size. */
|
/** Condition variable storage size. */
|
||||||
ffrt_queue_attr_storage_size = 128,
|
ffrt_cond_storage_size = 64,
|
||||||
} ffrt_storage_size_t;
|
/** Queue storage size. */
|
||||||
|
ffrt_queue_attr_storage_size = 128,
|
||||||
/**
|
} ffrt_storage_size_t;
|
||||||
* @brief Enumerates the task types.
|
|
||||||
*
|
/**
|
||||||
*/
|
* @brief Enumerates the task types.
|
||||||
typedef enum {
|
*
|
||||||
/** General task. */
|
*/
|
||||||
ffrt_function_kind_general,
|
typedef enum {
|
||||||
/** Queue task. */
|
/** General task. */
|
||||||
ffrt_function_kind_queue
|
ffrt_function_kind_general,
|
||||||
} ffrt_function_kind_t;
|
/** Queue task. */
|
||||||
|
ffrt_function_kind_queue
|
||||||
typedef enum {
|
} ffrt_function_kind_t;
|
||||||
ffrt_dependence_data,
|
|
||||||
ffrt_dependence_task,
|
/**
|
||||||
} ffrt_dependence_type_t;
|
* @brief dependency type.
|
||||||
|
*
|
||||||
typedef struct {
|
*/
|
||||||
ffrt_dependence_type_t type;
|
typedef enum {
|
||||||
const void* ptr;
|
/** Data dependency type. */
|
||||||
} ffrt_dependence_t;
|
ffrt_dependence_data,
|
||||||
|
/** Task dependency type. */
|
||||||
/**
|
ffrt_dependence_task,
|
||||||
* @brief Defines the dependency struct.
|
} ffrt_dependence_type_t;
|
||||||
*
|
|
||||||
*/
|
/**
|
||||||
typedef struct {
|
* @brief dependency data structure.
|
||||||
/** Number of dependencies. */
|
*
|
||||||
uint32_t len;
|
*/
|
||||||
/** Dependent data. */
|
typedef struct {
|
||||||
const ffrt_dependence_t* items;
|
/** Dependency type. */
|
||||||
} ffrt_deps_t;
|
ffrt_dependence_type_t type;
|
||||||
|
/** Dependency pointer. */
|
||||||
typedef struct {
|
const void* ptr;
|
||||||
uint32_t storage[(ffrt_task_attr_storage_size + sizeof(uint32_t) - 1) / sizeof(uint32_t)];
|
} ffrt_dependence_t;
|
||||||
} ffrt_task_attr_t;
|
|
||||||
|
/**
|
||||||
typedef struct {
|
* @brief Defines the dependency struct.
|
||||||
uint32_t storage[(ffrt_queue_attr_storage_size + sizeof(uint32_t) - 1) / sizeof(uint32_t)];
|
*
|
||||||
} ffrt_queue_attr_t;
|
*/
|
||||||
|
typedef struct {
|
||||||
typedef void* ffrt_task_handle_t;
|
/** Number of dependencies. */
|
||||||
|
uint32_t len;
|
||||||
typedef enum {
|
/** Dependent data. */
|
||||||
ffrt_error = -1,
|
const ffrt_dependence_t* items;
|
||||||
ffrt_success = 0,
|
} ffrt_deps_t;
|
||||||
ffrt_error_nomem = ENOMEM,
|
|
||||||
ffrt_error_timedout = ETIMEDOUT,
|
typedef struct {
|
||||||
ffrt_error_busy = EBUSY,
|
uint32_t storage[(ffrt_task_attr_storage_size + sizeof(uint32_t) - 1) / sizeof(uint32_t)];
|
||||||
ffrt_error_inval = EINVAL
|
} ffrt_task_attr_t;
|
||||||
} ffrt_error_t;
|
|
||||||
|
typedef struct {
|
||||||
typedef struct {
|
uint32_t storage[(ffrt_queue_attr_storage_size + sizeof(uint32_t) - 1) / sizeof(uint32_t)];
|
||||||
long storage;
|
} ffrt_queue_attr_t;
|
||||||
} ffrt_condattr_t;
|
|
||||||
|
typedef void* ffrt_task_handle_t;
|
||||||
typedef struct {
|
|
||||||
long storage;
|
typedef enum {
|
||||||
} ffrt_mutexattr_t;
|
ffrt_error = -1,
|
||||||
|
ffrt_success = 0,
|
||||||
typedef struct {
|
ffrt_error_nomem = ENOMEM,
|
||||||
uint32_t storage[(ffrt_mutex_storage_size + sizeof(uint32_t) - 1) / sizeof(uint32_t)];
|
ffrt_error_timedout = ETIMEDOUT,
|
||||||
} ffrt_mutex_t;
|
ffrt_error_busy = EBUSY,
|
||||||
|
ffrt_error_inval = EINVAL
|
||||||
typedef struct {
|
} ffrt_error_t;
|
||||||
uint32_t storage[(ffrt_cond_storage_size + sizeof(uint32_t) - 1) / sizeof(uint32_t)];
|
|
||||||
} ffrt_cond_t;
|
typedef struct {
|
||||||
|
long storage;
|
||||||
#ifdef __cplusplus
|
} ffrt_condattr_t;
|
||||||
namespace ffrt {
|
|
||||||
enum qos_default {
|
typedef struct {
|
||||||
qos_inherit = ffrt_qos_inherit,
|
long storage;
|
||||||
qos_background = ffrt_qos_background,
|
} ffrt_mutexattr_t;
|
||||||
qos_utility = ffrt_qos_utility,
|
|
||||||
qos_default = ffrt_qos_default,
|
typedef struct {
|
||||||
qos_user_initiated = ffrt_qos_user_initiated,
|
uint32_t storage[(ffrt_mutex_storage_size + sizeof(uint32_t) - 1) / sizeof(uint32_t)];
|
||||||
};
|
} ffrt_mutex_t;
|
||||||
using qos = int;
|
|
||||||
}
|
typedef struct {
|
||||||
#endif
|
uint32_t storage[(ffrt_cond_storage_size + sizeof(uint32_t) - 1) / sizeof(uint32_t)];
|
||||||
#endif
|
} ffrt_cond_t;
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
namespace ffrt {
|
||||||
|
enum qos_default {
|
||||||
|
qos_inherit = ffrt_qos_inherit,
|
||||||
|
qos_background = ffrt_qos_background,
|
||||||
|
qos_utility = ffrt_qos_utility,
|
||||||
|
qos_default = ffrt_qos_default,
|
||||||
|
qos_user_initiated = ffrt_qos_user_initiated,
|
||||||
|
};
|
||||||
|
using qos = int;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
@ -1,126 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2022 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "native_huks_api.h"
|
|
||||||
|
|
||||||
#include "hks_api.h"
|
|
||||||
#include "hks_errcode_adapter.h"
|
|
||||||
#include "native_huks_api_adapter.h"
|
|
||||||
|
|
||||||
static struct OH_Huks_Result ConvertApiResult(int32_t ret)
|
|
||||||
{
|
|
||||||
struct HksResult result = HksConvertErrCode(ret);
|
|
||||||
return *((struct OH_Huks_Result *)(&result));
|
|
||||||
}
|
|
||||||
|
|
||||||
struct OH_Huks_Result OH_Huks_GetSdkVersion(struct OH_Huks_Blob *sdkVersion)
|
|
||||||
{
|
|
||||||
int32_t result = HksGetSdkVersion((struct HksBlob *) sdkVersion);
|
|
||||||
return ConvertApiResult(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct OH_Huks_Result OH_Huks_GenerateKeyItem(const struct OH_Huks_Blob *keyAlias,
|
|
||||||
const struct OH_Huks_ParamSet *paramSetIn, struct OH_Huks_ParamSet *paramSetOut)
|
|
||||||
{
|
|
||||||
int32_t result = HksGenerateKey((const struct HksBlob *) keyAlias,
|
|
||||||
(const struct HksParamSet *) paramSetIn, (struct HksParamSet *) paramSetOut);
|
|
||||||
return ConvertApiResult(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct OH_Huks_Result OH_Huks_ImportKeyItem(const struct OH_Huks_Blob *keyAlias,
|
|
||||||
const struct OH_Huks_ParamSet *paramSet, const struct OH_Huks_Blob *key)
|
|
||||||
{
|
|
||||||
int32_t result = HksImportKey((const struct HksBlob *) keyAlias,
|
|
||||||
(const struct HksParamSet *) paramSet, (const struct HksBlob *) key);
|
|
||||||
return ConvertApiResult(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct OH_Huks_Result OH_Huks_ImportWrappedKeyItem(const struct OH_Huks_Blob *keyAlias,
|
|
||||||
const struct OH_Huks_Blob *wrappingKeyAlias, const struct OH_Huks_ParamSet *paramSet,
|
|
||||||
const struct OH_Huks_Blob *wrappedKeyData)
|
|
||||||
{
|
|
||||||
int32_t result = HksImportWrappedKey((const struct HksBlob *) keyAlias,
|
|
||||||
(const struct HksBlob *) wrappingKeyAlias, (const struct HksParamSet *) paramSet,
|
|
||||||
(const struct HksBlob *) wrappedKeyData);
|
|
||||||
return ConvertApiResult(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct OH_Huks_Result OH_Huks_ExportPublicKeyItem(const struct OH_Huks_Blob *keyAlias,
|
|
||||||
const struct OH_Huks_ParamSet *paramSet, struct OH_Huks_Blob *key)
|
|
||||||
{
|
|
||||||
int32_t result = HksExportPublicKey((const struct HksBlob *) keyAlias,
|
|
||||||
(const struct HksParamSet *) paramSet, (struct HksBlob *) key);
|
|
||||||
return ConvertApiResult(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct OH_Huks_Result OH_Huks_DeleteKeyItem(const struct OH_Huks_Blob *keyAlias,
|
|
||||||
const struct OH_Huks_ParamSet *paramSet)
|
|
||||||
{
|
|
||||||
int32_t result = HksDeleteKey((const struct HksBlob *) keyAlias, (const struct HksParamSet *) paramSet);
|
|
||||||
return ConvertApiResult(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct OH_Huks_Result OH_Huks_GetKeyItemParamSet(const struct OH_Huks_Blob *keyAlias,
|
|
||||||
const struct OH_Huks_ParamSet *paramSetIn, struct OH_Huks_ParamSet *paramSetOut)
|
|
||||||
{
|
|
||||||
int32_t result = HksGetKeyParamSet((const struct HksBlob *) keyAlias,
|
|
||||||
(const struct HksParamSet *) paramSetIn, (struct HksParamSet *) paramSetOut);
|
|
||||||
return ConvertApiResult(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct OH_Huks_Result OH_Huks_IsKeyItemExist(const struct OH_Huks_Blob *keyAlias,
|
|
||||||
const struct OH_Huks_ParamSet *paramSet)
|
|
||||||
{
|
|
||||||
int32_t result = HksKeyExist((const struct HksBlob *) keyAlias, (const struct HksParamSet *) paramSet);
|
|
||||||
return ConvertApiResult(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct OH_Huks_Result OH_Huks_AttestKeyItem(const struct OH_Huks_Blob *keyAlias,
|
|
||||||
const struct OH_Huks_ParamSet *paramSet, struct OH_Huks_CertChain *certChain)
|
|
||||||
{
|
|
||||||
int32_t result = HuksAttestAdapter(keyAlias, paramSet, certChain);
|
|
||||||
return ConvertApiResult(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct OH_Huks_Result OH_Huks_InitSession(const struct OH_Huks_Blob *keyAlias,
|
|
||||||
const struct OH_Huks_ParamSet *paramSet, struct OH_Huks_Blob *handle, struct OH_Huks_Blob *token)
|
|
||||||
{
|
|
||||||
int32_t result = HksInit((const struct HksBlob *) keyAlias,
|
|
||||||
(const struct HksParamSet *) paramSet, (struct HksBlob *) handle, (struct HksBlob *) token);
|
|
||||||
return ConvertApiResult(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct OH_Huks_Result OH_Huks_UpdateSession(const struct OH_Huks_Blob *handle,
|
|
||||||
const struct OH_Huks_ParamSet *paramSet, const struct OH_Huks_Blob *inData, struct OH_Huks_Blob *outData)
|
|
||||||
{
|
|
||||||
int32_t result = HksUpdate((const struct HksBlob *) handle,
|
|
||||||
(const struct HksParamSet *) paramSet, (const struct HksBlob *) inData, (struct HksBlob *) outData);
|
|
||||||
return ConvertApiResult(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct OH_Huks_Result OH_Huks_FinishSession(const struct OH_Huks_Blob *handle,
|
|
||||||
const struct OH_Huks_ParamSet *paramSet, const struct OH_Huks_Blob *inData, struct OH_Huks_Blob *outData)
|
|
||||||
{
|
|
||||||
int32_t result = HksFinish((const struct HksBlob *) handle,
|
|
||||||
(const struct HksParamSet *) paramSet, (const struct HksBlob *) inData, (struct HksBlob *) outData);
|
|
||||||
return ConvertApiResult(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct OH_Huks_Result OH_Huks_AbortSession(const struct OH_Huks_Blob *handle,
|
|
||||||
const struct OH_Huks_ParamSet *paramSet)
|
|
||||||
{
|
|
||||||
int32_t result = HksAbort((const struct HksBlob *) handle, (const struct HksParamSet *) paramSet);
|
|
||||||
return ConvertApiResult(result);
|
|
||||||
}
|
|
@ -1,62 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2022 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "hks_api.h"
|
|
||||||
#include "hks_param.h"
|
|
||||||
|
|
||||||
#include "native_huks_api_adapter.h"
|
|
||||||
#include "native_huks_param.h"
|
|
||||||
|
|
||||||
int32_t HuksAttestAdapter(const struct OH_Huks_Blob *keyAlias, const struct OH_Huks_ParamSet *paramSet,
|
|
||||||
struct OH_Huks_CertChain *certChain)
|
|
||||||
{
|
|
||||||
int32_t ret;
|
|
||||||
struct HksParamSet *newParamSet = NULL;
|
|
||||||
do {
|
|
||||||
if (paramSet == NULL) {
|
|
||||||
ret = HKS_ERROR_NULL_POINTER;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
ret = HksCheckParamSet((struct HksParamSet *)paramSet, paramSet->paramSetSize);
|
|
||||||
if (ret != HKS_SUCCESS) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
ret = HksInitParamSet(&newParamSet);
|
|
||||||
if (ret != HKS_SUCCESS) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
ret = HksFreshParamSet((struct HksParamSet *)paramSet, false);
|
|
||||||
if (ret != HKS_SUCCESS) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
ret = HksAddParams(newParamSet, (const struct HksParam *)paramSet->params, paramSet->paramsCnt);
|
|
||||||
if (ret != HKS_SUCCESS) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
struct HksParam isBase64Param = { .tag = HKS_TAG_ATTESTATION_BASE64, .boolParam = true };
|
|
||||||
ret = HksAddParams(newParamSet, &isBase64Param, 1);
|
|
||||||
if (ret != HKS_SUCCESS) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
ret = HksBuildParamSet(&newParamSet);
|
|
||||||
if (ret != HKS_SUCCESS) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
ret = HksAttestKey((const struct HksBlob *)keyAlias, (struct HksParamSet *)newParamSet,
|
|
||||||
(struct HksCertChain *)certChain);
|
|
||||||
} while (0);
|
|
||||||
HksFreeParamSet(&newParamSet);
|
|
||||||
return ret;
|
|
||||||
}
|
|
@ -1,89 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2022 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "native_huks_param.h"
|
|
||||||
|
|
||||||
#include "hks_param.h"
|
|
||||||
#include "hks_errcode_adapter.h"
|
|
||||||
|
|
||||||
static struct OH_Huks_Result ConvertParamResult(int32_t ret)
|
|
||||||
{
|
|
||||||
struct HksResult result = HksConvertErrCode(ret);
|
|
||||||
return *((struct OH_Huks_Result *)(&result));
|
|
||||||
}
|
|
||||||
|
|
||||||
struct OH_Huks_Result OH_Huks_InitParamSet(struct OH_Huks_ParamSet **paramSet)
|
|
||||||
{
|
|
||||||
int32_t result = HksInitParamSet((struct HksParamSet **) paramSet);
|
|
||||||
return ConvertParamResult(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct OH_Huks_Result OH_Huks_AddParams(struct OH_Huks_ParamSet *paramSet,
|
|
||||||
const struct OH_Huks_Param *params, uint32_t paramCnt)
|
|
||||||
{
|
|
||||||
int32_t result = HksAddParams((struct HksParamSet *) paramSet,
|
|
||||||
(const struct HksParam *) params, paramCnt);
|
|
||||||
return ConvertParamResult(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct OH_Huks_Result OH_Huks_BuildParamSet(struct OH_Huks_ParamSet **paramSet)
|
|
||||||
{
|
|
||||||
int32_t result = HksBuildParamSet((struct HksParamSet **) paramSet);
|
|
||||||
return ConvertParamResult(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
void OH_Huks_FreeParamSet(struct OH_Huks_ParamSet **paramSet)
|
|
||||||
{
|
|
||||||
HksFreeParamSet((struct HksParamSet **) paramSet);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct OH_Huks_Result OH_Huks_CopyParamSet(const struct OH_Huks_ParamSet *fromParamSet,
|
|
||||||
uint32_t fromParamSetSize, struct OH_Huks_ParamSet **paramSet)
|
|
||||||
{
|
|
||||||
int32_t result = HksGetParamSet((const struct HksParamSet *) fromParamSet,
|
|
||||||
fromParamSetSize, (struct HksParamSet **) paramSet);
|
|
||||||
return ConvertParamResult(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct OH_Huks_Result OH_Huks_GetParam(const struct OH_Huks_ParamSet *paramSet, uint32_t tag,
|
|
||||||
struct OH_Huks_Param **param)
|
|
||||||
{
|
|
||||||
int32_t result = HksGetParam((const struct HksParamSet *) paramSet, tag, (struct HksParam **) param);
|
|
||||||
return ConvertParamResult(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct OH_Huks_Result OH_Huks_FreshParamSet(struct OH_Huks_ParamSet *paramSet, bool isCopy)
|
|
||||||
{
|
|
||||||
int32_t result = HksFreshParamSet((struct HksParamSet *) paramSet, isCopy);
|
|
||||||
return ConvertParamResult(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct OH_Huks_Result OH_Huks_IsParamSetTagValid(const struct OH_Huks_ParamSet *paramSet)
|
|
||||||
{
|
|
||||||
int32_t result = HksCheckParamSetTag((const struct HksParamSet *) paramSet);
|
|
||||||
return ConvertParamResult(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct OH_Huks_Result OH_Huks_IsParamSetValid(const struct OH_Huks_ParamSet *paramSet, uint32_t size)
|
|
||||||
{
|
|
||||||
int32_t result = HksCheckParamSet((const struct HksParamSet *) paramSet, size);
|
|
||||||
return ConvertParamResult(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct OH_Huks_Result OH_Huks_CheckParamMatch(const struct OH_Huks_Param *baseParam, const struct OH_Huks_Param *param)
|
|
||||||
{
|
|
||||||
int32_t result = HksCheckParamMatch((const struct HksParam *) baseParam, (const struct HksParam *) param);
|
|
||||||
return ConvertParamResult(result);
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user