1d9f0492fSopenharmony_ci/* 2d9f0492fSopenharmony_ci * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3d9f0492fSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4d9f0492fSopenharmony_ci * you may not use this file except in compliance with the License. 5d9f0492fSopenharmony_ci * You may obtain a copy of the License at 6d9f0492fSopenharmony_ci * 7d9f0492fSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8d9f0492fSopenharmony_ci * 9d9f0492fSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10d9f0492fSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11d9f0492fSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12d9f0492fSopenharmony_ci * See the License for the specific language governing permissions and 13d9f0492fSopenharmony_ci * limitations under the License. 14d9f0492fSopenharmony_ci */ 15d9f0492fSopenharmony_ci#include "param_osadp.h" 16d9f0492fSopenharmony_ci 17d9f0492fSopenharmony_ci#include <errno.h> 18d9f0492fSopenharmony_ci#include <fcntl.h> 19d9f0492fSopenharmony_ci#include <pthread.h> 20d9f0492fSopenharmony_ci#include <string.h> 21d9f0492fSopenharmony_ci#ifdef __LITEOS_A__ 22d9f0492fSopenharmony_ci#include <sys/ipc.h> 23d9f0492fSopenharmony_ci#include <sys/mman.h> 24d9f0492fSopenharmony_ci#include <sys/shm.h> 25d9f0492fSopenharmony_ci#else 26d9f0492fSopenharmony_ci#include "los_task.h" 27d9f0492fSopenharmony_ci#include "los_mux.h" 28d9f0492fSopenharmony_ci#endif 29d9f0492fSopenharmony_ci#include <sys/stat.h> 30d9f0492fSopenharmony_ci#include <sys/time.h> 31d9f0492fSopenharmony_ci#include <sys/types.h> 32d9f0492fSopenharmony_ci#include <unistd.h> 33d9f0492fSopenharmony_ci#include <signal.h> 34d9f0492fSopenharmony_ci#include <time.h> 35d9f0492fSopenharmony_ci 36d9f0492fSopenharmony_ci#include "param_security.h" 37d9f0492fSopenharmony_ci#include "securec.h" 38d9f0492fSopenharmony_ci 39d9f0492fSopenharmony_ci#define NSEC_PER_MSEC 1000000LL 40d9f0492fSopenharmony_ci#define MSEC_PER_SEC 1000LL 41d9f0492fSopenharmony_ci 42d9f0492fSopenharmony_cistatic void TimerHandle(union sigval v) 43d9f0492fSopenharmony_ci{ 44d9f0492fSopenharmony_ci ParamTimer *timer = (ParamTimer *)v.sival_ptr; 45d9f0492fSopenharmony_ci PARAM_CHECK(timer != NULL, return, "Invalid timer"); 46d9f0492fSopenharmony_ci if (timer->timeProcessor != NULL) { 47d9f0492fSopenharmony_ci timer->timeProcessor(timer, timer->context); 48d9f0492fSopenharmony_ci } 49d9f0492fSopenharmony_ci} 50d9f0492fSopenharmony_ci 51d9f0492fSopenharmony_cistatic void SetTimeSpec(struct timespec *ts, int64_t msec) 52d9f0492fSopenharmony_ci{ 53d9f0492fSopenharmony_ci ts->tv_sec = msec / MSEC_PER_SEC; // 1000LL ms --> m 54d9f0492fSopenharmony_ci ts->tv_nsec = (msec - ts->tv_sec * MSEC_PER_SEC) * NSEC_PER_MSEC; 55d9f0492fSopenharmony_ci} 56d9f0492fSopenharmony_ci 57d9f0492fSopenharmony_cistatic int StartTimer(const ParamTimer *paramTimer, int64_t whenMsec, int64_t repeat) 58d9f0492fSopenharmony_ci{ 59d9f0492fSopenharmony_ci UNUSED(repeat); 60d9f0492fSopenharmony_ci struct itimerspec ts; 61d9f0492fSopenharmony_ci SetTimeSpec(&ts.it_value, whenMsec); 62d9f0492fSopenharmony_ci SetTimeSpec(&ts.it_interval, whenMsec); 63d9f0492fSopenharmony_ci int32_t ret = timer_settime(paramTimer->timerId, 0, &ts, NULL); 64d9f0492fSopenharmony_ci if (ret < 0) { 65d9f0492fSopenharmony_ci PARAM_LOGE("Failed to start timer"); 66d9f0492fSopenharmony_ci return -1; 67d9f0492fSopenharmony_ci } 68d9f0492fSopenharmony_ci return 0; 69d9f0492fSopenharmony_ci} 70d9f0492fSopenharmony_ci 71d9f0492fSopenharmony_ciint ParamTimerCreate(ParamTaskPtr *timer, ProcessTimer process, void *context) 72d9f0492fSopenharmony_ci{ 73d9f0492fSopenharmony_ci PARAM_CHECK(timer != NULL && process != NULL, return -1, "Invalid timer"); 74d9f0492fSopenharmony_ci ParamTimer *paramTimer = malloc(sizeof(ParamTimer)); 75d9f0492fSopenharmony_ci PARAM_CHECK(paramTimer != NULL, return -1, "Failed to create timer"); 76d9f0492fSopenharmony_ci paramTimer->timeProcessor = process; 77d9f0492fSopenharmony_ci paramTimer->context = context; 78d9f0492fSopenharmony_ci 79d9f0492fSopenharmony_ci struct sigevent evp; 80d9f0492fSopenharmony_ci (void)memset_s(&evp, sizeof(evp), 0, sizeof(evp)); 81d9f0492fSopenharmony_ci evp.sigev_value.sival_ptr = paramTimer; 82d9f0492fSopenharmony_ci evp.sigev_notify = SIGEV_THREAD; 83d9f0492fSopenharmony_ci evp.sigev_notify_function = TimerHandle; 84d9f0492fSopenharmony_ci int32_t ret = timer_create(CLOCK_REALTIME, &evp, ¶mTimer->timerId); 85d9f0492fSopenharmony_ci if (ret < 0) { 86d9f0492fSopenharmony_ci PARAM_LOGE("Failed to create timer"); 87d9f0492fSopenharmony_ci free(paramTimer); 88d9f0492fSopenharmony_ci return -1; 89d9f0492fSopenharmony_ci } 90d9f0492fSopenharmony_ci *timer = paramTimer; 91d9f0492fSopenharmony_ci return 0; 92d9f0492fSopenharmony_ci} 93d9f0492fSopenharmony_ci 94d9f0492fSopenharmony_ciint ParamTimerStart(const ParamTaskPtr timer, uint64_t timeout, uint64_t repeat) 95d9f0492fSopenharmony_ci{ 96d9f0492fSopenharmony_ci PARAM_CHECK(timer != NULL, return -1, "Invalid timer"); 97d9f0492fSopenharmony_ci ParamTimer *paramTimer = (ParamTimer *)timer; 98d9f0492fSopenharmony_ci PARAM_LOGV("ParamTimerStart timeout %llu ", timeout); 99d9f0492fSopenharmony_ci int32_t ret = StartTimer(paramTimer, timeout, repeat); 100d9f0492fSopenharmony_ci PARAM_CHECK(ret >= 0, return -1, "Failed to start timer"); 101d9f0492fSopenharmony_ci return 0; 102d9f0492fSopenharmony_ci} 103d9f0492fSopenharmony_ci 104d9f0492fSopenharmony_civoid ParamTimerClose(ParamTaskPtr timer) 105d9f0492fSopenharmony_ci{ 106d9f0492fSopenharmony_ci PARAM_CHECK(timer != NULL, return, "Invalid timer"); 107d9f0492fSopenharmony_ci ParamTimer *paramTimer = (ParamTimer *)timer; 108d9f0492fSopenharmony_ci timer_delete(paramTimer->timerId); 109d9f0492fSopenharmony_ci free(paramTimer); 110d9f0492fSopenharmony_ci} 111d9f0492fSopenharmony_ci 112d9f0492fSopenharmony_ci#ifdef __LITEOS_A__ 113d9f0492fSopenharmony_ciINIT_LOCAL_API void *GetSharedMem(const char *fileName, MemHandle *handle, uint32_t spaceSize, int readOnly) 114d9f0492fSopenharmony_ci{ 115d9f0492fSopenharmony_ci PARAM_CHECK(fileName != NULL && handle != NULL, return NULL, "Invalid filename or handle"); 116d9f0492fSopenharmony_ci int mode = readOnly ? O_RDONLY : O_CREAT | O_RDWR; 117d9f0492fSopenharmony_ci void *areaAddr = NULL; 118d9f0492fSopenharmony_ci if (!readOnly) { 119d9f0492fSopenharmony_ci int fd = open(fileName, mode, S_IRWXU | S_IRWXG | S_IROTH); 120d9f0492fSopenharmony_ci PARAM_CHECK(fd >= 0, return NULL, "Open file %s mode %x fail error %d", fileName, mode, errno); 121d9f0492fSopenharmony_ci close(fd); 122d9f0492fSopenharmony_ci } 123d9f0492fSopenharmony_ci key_t key = ftok(fileName, 0x03); // 0x03 flags for shmget 124d9f0492fSopenharmony_ci PARAM_CHECK(key != -1, return NULL, "Invalid errno %d key for %s", errno, fileName); 125d9f0492fSopenharmony_ci handle->shmid = shmget(key, spaceSize, IPC_CREAT | IPC_EXCL | 0666); // 0666 126d9f0492fSopenharmony_ci if (handle->shmid == -1) { 127d9f0492fSopenharmony_ci handle->shmid = shmget(key, spaceSize, 0); // 0666 128d9f0492fSopenharmony_ci } 129d9f0492fSopenharmony_ci PARAM_CHECK(handle->shmid != -1, return NULL, "Invalid shmId errno %d for %s", errno, fileName); 130d9f0492fSopenharmony_ci areaAddr = (void *)shmat(handle->shmid, NULL, 0); 131d9f0492fSopenharmony_ci return areaAddr; 132d9f0492fSopenharmony_ci} 133d9f0492fSopenharmony_ci 134d9f0492fSopenharmony_ciINIT_LOCAL_API void FreeSharedMem(const MemHandle *handle, void *mem, uint32_t dataSize) 135d9f0492fSopenharmony_ci{ 136d9f0492fSopenharmony_ci PARAM_CHECK(mem != NULL && handle != NULL, return, "Invalid mem or handle"); 137d9f0492fSopenharmony_ci shmdt(mem); 138d9f0492fSopenharmony_ci shmctl(handle->shmid, IPC_RMID, NULL); 139d9f0492fSopenharmony_ci} 140d9f0492fSopenharmony_ci 141d9f0492fSopenharmony_ciINIT_LOCAL_API void paramMutexEnvInit(void) 142d9f0492fSopenharmony_ci{ 143d9f0492fSopenharmony_ci return; 144d9f0492fSopenharmony_ci} 145d9f0492fSopenharmony_ci 146d9f0492fSopenharmony_ciINIT_LOCAL_API int ParamRWMutexCreate(ParamRWMutex *lock) 147d9f0492fSopenharmony_ci{ 148d9f0492fSopenharmony_ci PARAM_CHECK(lock != NULL, return -1, "Invalid lock"); 149d9f0492fSopenharmony_ci pthread_rwlockattr_t rwlockatt; 150d9f0492fSopenharmony_ci pthread_rwlockattr_init(&rwlockatt); 151d9f0492fSopenharmony_ci pthread_rwlockattr_setpshared(&rwlockatt, PTHREAD_PROCESS_SHARED); 152d9f0492fSopenharmony_ci pthread_rwlock_init(&lock->rwlock, &rwlockatt); 153d9f0492fSopenharmony_ci return 0; 154d9f0492fSopenharmony_ci} 155d9f0492fSopenharmony_ci 156d9f0492fSopenharmony_ciINIT_LOCAL_API int ParamRWMutexWRLock(ParamRWMutex *lock) 157d9f0492fSopenharmony_ci{ 158d9f0492fSopenharmony_ci PARAM_CHECK(lock != NULL, return -1, "Invalid lock"); 159d9f0492fSopenharmony_ci pthread_rwlock_wrlock(&lock->rwlock); 160d9f0492fSopenharmony_ci return 0; 161d9f0492fSopenharmony_ci} 162d9f0492fSopenharmony_ciINIT_LOCAL_API int ParamRWMutexRDLock(ParamRWMutex *lock) 163d9f0492fSopenharmony_ci{ 164d9f0492fSopenharmony_ci PARAM_CHECK(lock != NULL, return -1, "Invalid lock"); 165d9f0492fSopenharmony_ci pthread_rwlock_rdlock(&lock->rwlock); 166d9f0492fSopenharmony_ci return 0; 167d9f0492fSopenharmony_ci} 168d9f0492fSopenharmony_ciINIT_LOCAL_API int ParamRWMutexUnlock(ParamRWMutex *lock) 169d9f0492fSopenharmony_ci{ 170d9f0492fSopenharmony_ci PARAM_CHECK(lock != NULL, return -1, "Invalid lock"); 171d9f0492fSopenharmony_ci pthread_rwlock_unlock(&lock->rwlock); 172d9f0492fSopenharmony_ci return 0; 173d9f0492fSopenharmony_ci} 174d9f0492fSopenharmony_ci 175d9f0492fSopenharmony_ciINIT_LOCAL_API int ParamRWMutexDelete(ParamRWMutex *lock) 176d9f0492fSopenharmony_ci{ 177d9f0492fSopenharmony_ci PARAM_CHECK(lock != NULL, return -1, "Invalid lock"); 178d9f0492fSopenharmony_ci uint32_t ret = pthread_rwlock_destroy(&lock->rwlock); 179d9f0492fSopenharmony_ci PARAM_CHECK(ret == 0, return -1, "Failed to mutex lock ret %d", ret); 180d9f0492fSopenharmony_ci return 0; 181d9f0492fSopenharmony_ci} 182d9f0492fSopenharmony_ci 183d9f0492fSopenharmony_ciINIT_LOCAL_API int ParamMutexCreate(ParamMutex *mutex) 184d9f0492fSopenharmony_ci{ 185d9f0492fSopenharmony_ci PARAM_CHECK(mutex != NULL, return -1, "Invalid mutex"); 186d9f0492fSopenharmony_ci pthread_mutexattr_t mutexattr; 187d9f0492fSopenharmony_ci pthread_mutexattr_init(&mutexattr); 188d9f0492fSopenharmony_ci pthread_mutexattr_setpshared(&mutexattr, PTHREAD_PROCESS_SHARED); 189d9f0492fSopenharmony_ci pthread_mutex_init(&mutex->mutex, &mutexattr); 190d9f0492fSopenharmony_ci return 0; 191d9f0492fSopenharmony_ci} 192d9f0492fSopenharmony_ciINIT_LOCAL_API int ParamMutexPend(ParamMutex *mutex) 193d9f0492fSopenharmony_ci{ 194d9f0492fSopenharmony_ci PARAM_CHECK(mutex != NULL, return -1, "Invalid mutex"); 195d9f0492fSopenharmony_ci if (pthread_mutex_lock(&mutex->mutex) != 0) { 196d9f0492fSopenharmony_ci PARAM_LOGE("Failed to batch begin to save param errno %d", errno); 197d9f0492fSopenharmony_ci return errno; 198d9f0492fSopenharmony_ci } 199d9f0492fSopenharmony_ci return 0; 200d9f0492fSopenharmony_ci} 201d9f0492fSopenharmony_ciINIT_LOCAL_API int ParamMutexPost(ParamMutex *mutex) 202d9f0492fSopenharmony_ci{ 203d9f0492fSopenharmony_ci PARAM_CHECK(mutex != NULL, return -1, "Invalid mutex"); 204d9f0492fSopenharmony_ci pthread_mutex_unlock(&mutex->mutex); 205d9f0492fSopenharmony_ci return 0; 206d9f0492fSopenharmony_ci} 207d9f0492fSopenharmony_ci 208d9f0492fSopenharmony_ciINIT_LOCAL_API int ParamMutexDelete(ParamMutex *mutex) 209d9f0492fSopenharmony_ci{ 210d9f0492fSopenharmony_ci PARAM_CHECK(mutex != NULL, return -1, "Invalid lock"); 211d9f0492fSopenharmony_ci uint32_t ret = pthread_mutex_destroy(&mutex->mutex); 212d9f0492fSopenharmony_ci PARAM_CHECK(ret == 0, return -1, "Failed to mutex lock ret %d", ret); 213d9f0492fSopenharmony_ci return 0; 214d9f0492fSopenharmony_ci} 215d9f0492fSopenharmony_ci#endif 216d9f0492fSopenharmony_ci 217d9f0492fSopenharmony_ci#ifdef __LITEOS_M__ 218d9f0492fSopenharmony_ci__attribute__((weak)) void* GetSysParamMem(uint32_t spaceSize) 219d9f0492fSopenharmony_ci{ 220d9f0492fSopenharmony_ci return malloc(spaceSize); 221d9f0492fSopenharmony_ci} 222d9f0492fSopenharmony_ci 223d9f0492fSopenharmony_ci__attribute__((weak)) void FreeSysParamMem(void *mem) 224d9f0492fSopenharmony_ci{ 225d9f0492fSopenharmony_ci if (mem == NULL) { 226d9f0492fSopenharmony_ci return; 227d9f0492fSopenharmony_ci } 228d9f0492fSopenharmony_ci free(mem); 229d9f0492fSopenharmony_ci} 230d9f0492fSopenharmony_ci 231d9f0492fSopenharmony_ciINIT_LOCAL_API void *GetSharedMem(const char *fileName, MemHandle *handle, uint32_t spaceSize, int readOnly) 232d9f0492fSopenharmony_ci{ 233d9f0492fSopenharmony_ci PARAM_CHECK(spaceSize <= PARAM_WORKSPACE_MAX, return NULL, "Invalid spaceSize %u", spaceSize); 234d9f0492fSopenharmony_ci UNUSED(fileName); 235d9f0492fSopenharmony_ci UNUSED(handle); 236d9f0492fSopenharmony_ci UNUSED(readOnly); 237d9f0492fSopenharmony_ci return GetSysParamMem(spaceSize); 238d9f0492fSopenharmony_ci} 239d9f0492fSopenharmony_ci 240d9f0492fSopenharmony_ciINIT_LOCAL_API void FreeSharedMem(const MemHandle *handle, void *mem, uint32_t dataSize) 241d9f0492fSopenharmony_ci{ 242d9f0492fSopenharmony_ci PARAM_CHECK(mem != NULL && handle != NULL, return, "Invalid mem or handle"); 243d9f0492fSopenharmony_ci UNUSED(handle); 244d9f0492fSopenharmony_ci UNUSED(dataSize); 245d9f0492fSopenharmony_ci FreeSysParamMem(mem); 246d9f0492fSopenharmony_ci} 247d9f0492fSopenharmony_ci 248d9f0492fSopenharmony_ciINIT_LOCAL_API void paramMutexEnvInit(void) 249d9f0492fSopenharmony_ci{ 250d9f0492fSopenharmony_ci return; 251d9f0492fSopenharmony_ci} 252d9f0492fSopenharmony_ci 253d9f0492fSopenharmony_ciINIT_LOCAL_API int ParamRWMutexCreate(ParamRWMutex *lock) 254d9f0492fSopenharmony_ci{ 255d9f0492fSopenharmony_ci PARAM_CHECK(lock != NULL, return -1, "Invalid lock"); 256d9f0492fSopenharmony_ci uint32_t ret = LOS_MuxCreate(&lock->mutex); 257d9f0492fSopenharmony_ci PARAM_CHECK(ret == LOS_OK, return -1, "Failed to init mutex ret %d", ret); 258d9f0492fSopenharmony_ci return 0; 259d9f0492fSopenharmony_ci} 260d9f0492fSopenharmony_ci 261d9f0492fSopenharmony_ciINIT_LOCAL_API int ParamRWMutexWRLock(ParamRWMutex *lock) 262d9f0492fSopenharmony_ci{ 263d9f0492fSopenharmony_ci PARAM_CHECK(lock != NULL, return -1, "Invalid lock"); 264d9f0492fSopenharmony_ci uint32_t ret = LOS_MuxPend(lock->mutex, LOS_WAIT_FOREVER); 265d9f0492fSopenharmony_ci PARAM_CHECK(ret == LOS_OK, return -1, "Failed to mutex lock ret %d %d", ret, lock->mutex); 266d9f0492fSopenharmony_ci return 0; 267d9f0492fSopenharmony_ci} 268d9f0492fSopenharmony_ci 269d9f0492fSopenharmony_ciINIT_LOCAL_API int ParamRWMutexRDLock(ParamRWMutex *lock) 270d9f0492fSopenharmony_ci{ 271d9f0492fSopenharmony_ci PARAM_CHECK(lock != NULL, return -1, "Invalid lock"); 272d9f0492fSopenharmony_ci uint32_t ret = LOS_MuxPend(lock->mutex, LOS_WAIT_FOREVER); 273d9f0492fSopenharmony_ci PARAM_CHECK(ret == LOS_OK, return -1, "Failed to mutex lock ret %d %d", ret, lock->mutex); 274d9f0492fSopenharmony_ci return 0; 275d9f0492fSopenharmony_ci} 276d9f0492fSopenharmony_ci 277d9f0492fSopenharmony_ciINIT_LOCAL_API int ParamRWMutexUnlock(ParamRWMutex *lock) 278d9f0492fSopenharmony_ci{ 279d9f0492fSopenharmony_ci PARAM_CHECK(lock != NULL, return -1, "Invalid lock"); 280d9f0492fSopenharmony_ci uint32_t ret = LOS_MuxPost(lock->mutex); 281d9f0492fSopenharmony_ci PARAM_CHECK(ret == LOS_OK, return -1, "Failed to mutex lock ret %d %d", ret, lock->mutex); 282d9f0492fSopenharmony_ci return 0; 283d9f0492fSopenharmony_ci} 284d9f0492fSopenharmony_ci 285d9f0492fSopenharmony_ciINIT_LOCAL_API int ParamRWMutexDelete(ParamRWMutex *lock) 286d9f0492fSopenharmony_ci{ 287d9f0492fSopenharmony_ci PARAM_CHECK(lock != NULL, return -1, "Invalid lock"); 288d9f0492fSopenharmony_ci uint32_t ret = LOS_MuxDelete(lock->mutex); 289d9f0492fSopenharmony_ci PARAM_CHECK(ret == LOS_OK, return -1, "Failed to mutex lock ret %d %d", ret, lock->mutex); 290d9f0492fSopenharmony_ci return 0; 291d9f0492fSopenharmony_ci} 292d9f0492fSopenharmony_ci 293d9f0492fSopenharmony_ciINIT_LOCAL_API int ParamMutexCreate(ParamMutex *mutex) 294d9f0492fSopenharmony_ci{ 295d9f0492fSopenharmony_ci PARAM_CHECK(mutex != NULL, return -1, "Invalid lock"); 296d9f0492fSopenharmony_ci uint32_t ret = LOS_MuxCreate(&mutex->mutex); 297d9f0492fSopenharmony_ci PARAM_CHECK(ret == LOS_OK, return -1, "Failed to init mutex ret %d", ret); 298d9f0492fSopenharmony_ci return 0; 299d9f0492fSopenharmony_ci} 300d9f0492fSopenharmony_ci 301d9f0492fSopenharmony_ciINIT_LOCAL_API int ParamMutexPend(ParamMutex *mutex) 302d9f0492fSopenharmony_ci{ 303d9f0492fSopenharmony_ci PARAM_CHECK(mutex != NULL, return -1, "Invalid lock"); 304d9f0492fSopenharmony_ci uint32_t ret = LOS_MuxPend(mutex->mutex, LOS_WAIT_FOREVER); 305d9f0492fSopenharmony_ci PARAM_CHECK(ret == LOS_OK, return -1, "Failed to mutex lock ret %d %d", ret, mutex->mutex); 306d9f0492fSopenharmony_ci return 0; 307d9f0492fSopenharmony_ci} 308d9f0492fSopenharmony_ci 309d9f0492fSopenharmony_ciINIT_LOCAL_API int ParamMutexPost(ParamMutex *mutex) 310d9f0492fSopenharmony_ci{ 311d9f0492fSopenharmony_ci PARAM_CHECK(mutex != NULL, return -1, "Invalid lock"); 312d9f0492fSopenharmony_ci uint32_t ret = LOS_MuxPost(mutex->mutex); 313d9f0492fSopenharmony_ci PARAM_CHECK(ret == LOS_OK, return -1, "Failed to mutex lock ret %d %d", ret, mutex->mutex); 314d9f0492fSopenharmony_ci return 0; 315d9f0492fSopenharmony_ci} 316d9f0492fSopenharmony_ci 317d9f0492fSopenharmony_ciINIT_LOCAL_API int ParamMutexDelete(ParamMutex *mutex) 318d9f0492fSopenharmony_ci{ 319d9f0492fSopenharmony_ci PARAM_CHECK(mutex != NULL, return -1, "Invalid mutex"); 320d9f0492fSopenharmony_ci uint32_t ret = LOS_MuxDelete(mutex->mutex); 321d9f0492fSopenharmony_ci PARAM_CHECK(ret == LOS_OK, return -1, "Failed to delete mutex lock ret %d %d", ret, mutex->mutex); 322d9f0492fSopenharmony_ci return 0; 323d9f0492fSopenharmony_ci} 324d9f0492fSopenharmony_ci#endif 325d9f0492fSopenharmony_ci 326