Simple interface for Mbed Cloud Client
Embed:
(wiki syntax)
Show/hide line numbers
sotp_shared_lock.h
00001 /* 00002 * Copyright (c) 2016 ARM Limited. All rights reserved. 00003 * SPDX-License-Identifier: Apache-2.0 00004 * Licensed under the Apache License, Version 2.0 (the License); you may 00005 * not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an AS IS BASIS, WITHOUT 00012 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00017 00018 00019 #ifndef __SOTP_SHARED_LOCK_H 00020 #define __SOTP_SHARED_LOCK_H 00021 00022 #include <stdint.h> 00023 #include "pal_types.h" 00024 00025 #ifdef __cplusplus 00026 extern "C" { 00027 #endif 00028 00029 typedef enum { 00030 SOTP_SHL_SUCCESS = 0, 00031 SOTP_SHL_INVALID_ARG = 1, 00032 SOTP_SHL_NULL_PTR = 2, 00033 SOTP_SHL_NO_MEM = 3, 00034 SOTP_SHL_PAL_ERR = 4, 00035 SOTP_SHL_MISUSE = 5, 00036 SOTP_SHL_ERROR_MAXVAL = 0xFFFF 00037 } sotp_sh_lock_result_e; 00038 00039 typedef uintptr_t sotp_shared_lock_t; 00040 00041 // Create a shared lock. 00042 // Parameters : 00043 // sh_lock - [OUT] lock handle. 00044 // Return : SOTP_SHL_SUCCESS on success. Error code otherwise. 00045 sotp_sh_lock_result_e sotp_sh_lock_create(sotp_shared_lock_t *sh_lock); 00046 00047 // Destroy a shared lock. 00048 // Parameters : 00049 // sh_lock - [OUT] lock handle. 00050 // Return : SOTP_SHL_SUCCESS on success. Error code otherwise. 00051 sotp_sh_lock_result_e sotp_sh_lock_destroy(sotp_shared_lock_t sh_lock); 00052 00053 // Lock a shared-lock in a shared manner. 00054 // Parameters : 00055 // sh_lock - [OUT] lock handle. 00056 // Return : SOTP_SHL_SUCCESS on success. Error code otherwise. 00057 sotp_sh_lock_result_e sotp_sh_lock_shared_lock(sotp_shared_lock_t sh_lock); 00058 00059 // Release a shared-lock in a shared manner. 00060 // Parameters : 00061 // sh_lock - [OUT] lock handle. 00062 // Return : SOTP_SHL_SUCCESS on success. Error code otherwise. 00063 sotp_sh_lock_result_e sotp_sh_lock_shared_release(sotp_shared_lock_t sh_lock); 00064 00065 // Lock a shared-lock in an exclusive manner. 00066 // Parameters : 00067 // sh_lock - [OUT] lock handle. 00068 // Return : SOTP_SHL_SUCCESS on success. Error code otherwise. 00069 sotp_sh_lock_result_e sotp_sh_lock_exclusive_lock(sotp_shared_lock_t sh_lock); 00070 00071 // Release a shared-lock in an exclusive manner. 00072 // Parameters : 00073 // sh_lock - [OUT] lock handle. 00074 // Return : SOTP_SHL_SUCCESS on success. Error code otherwise. 00075 sotp_sh_lock_result_e sotp_sh_lock_exclusive_release(sotp_shared_lock_t sh_lock); 00076 00077 // Promote a shared-lock from shared mode to exclusive mode. 00078 // Parameters : 00079 // sh_lock - [OUT] lock handle. 00080 // Return : SOTP_SHL_SUCCESS on success. Error code otherwise. 00081 sotp_sh_lock_result_e sotp_sh_lock_promote(sotp_shared_lock_t sh_lock); 00082 00083 00084 #ifdef __cplusplus 00085 } 00086 #endif 00087 00088 #endif
Generated on Tue Jul 12 2022 19:01:37 by 1.7.2