API参考
载入中...
搜索中...
未找到
sal_lockimpl.h
1/*
2 * This file is part of the openHiTLS project.
3 *
4 * openHiTLS is licensed under the Mulan PSL v2.
5 * You can use this software according to the terms and conditions of the Mulan PSL v2.
6 * You may obtain a copy of Mulan PSL v2 at:
7 *
8 * http://license.coscl.org.cn/MulanPSL2
9 *
10 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
11 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
12 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
13 * See the Mulan PSL v2 for more details.
14 */
15
16#ifndef SAL_LOCKIMPL_H
17#define SAL_LOCKIMPL_H
18
19#include <stdint.h>
20#include "hitls_build.h"
21#include "bsl_sal.h"
22
23#ifdef __cplusplus
24extern "C" {
25#endif // __cplusplus
26
27typedef struct ThreadCallback {
41
51
64
77
90
99 uint64_t (*pfThreadGetId)(void);
100} BSL_SAL_ThreadCallback;
101
102int32_t SAL_ThreadCallBack_Ctrl(BSL_SAL_CB_FUNC_TYPE type, void *funcCb);
103
104typedef struct {
105 BslThreadRunOnce pfThreadRunOnce;
106 BslThreadCreate pfThreadCreate;
107 BslThreadClose pfThreadClose;
108 BslCreateCondVar pfCreateCondVar;
109 BslCondSignal pfCondSignal;
110 BslCondTimedwaitMs pfCondTimedwaitMs;
111 BslDeleteCondVar pfDeleteCondVar;
113
114typedef struct PidCallback {
123 int32_t (*pfGetId)(void);
124} BSL_SAL_PidCallback;
125
126#ifdef HITLS_BSL_SAL_PID
127int32_t SAL_PidCallBack_Ctrl(BSL_SAL_CB_FUNC_TYPE type, void *funcCb);
128#endif
129
130#if defined(HITLS_BSL_SAL_LINUX) || defined(HITLS_BSL_SAL_DARWIN)
131#ifdef HITLS_BSL_SAL_LOCK
132int32_t SAL_RwLockNew(BSL_SAL_ThreadLockHandle *lock);
133
134int32_t SAL_RwReadLock(BSL_SAL_ThreadLockHandle rwLock);
135
136int32_t SAL_RwWriteLock(BSL_SAL_ThreadLockHandle rwLock);
137
138int32_t SAL_RwUnlock(BSL_SAL_ThreadLockHandle rwLock);
139
140void SAL_RwLockFree(BSL_SAL_ThreadLockHandle rwLock);
141#endif
142
143#ifdef HITLS_BSL_SAL_PID
144int32_t SAL_GetPid(void);
145#endif
146
147#ifdef HITLS_BSL_SAL_THREAD
148uint64_t SAL_GetThreadId(void);
149
150int32_t SAL_ThreadCreate(BSL_SAL_ThreadId *thread, void *(*startFunc)(void *), void *arg);
151
152void SAL_ThreadClose(BSL_SAL_ThreadId thread);
153
154int32_t SAL_CreateCondVar(BSL_SAL_CondVar *condVar);
155
156int32_t SAL_CondSignal(BSL_SAL_CondVar condVar);
157
158int32_t SAL_CondTimedwaitMs(BSL_SAL_Mutex condMutex, BSL_SAL_CondVar condVar, int32_t timeout);
159
160int32_t SAL_DeleteCondVar(BSL_SAL_CondVar condVar);
161#endif
162
163int32_t SAL_PthreadRunOnce(BSL_SAL_OnceControl *onceControl, BSL_SAL_ThreadInitRoutine initFunc);
164#endif
165
166#ifdef __cplusplus
167}
168#endif // __cplusplus
169
170#endif // SAL_LOCKIMPL_H
int32_t(* pfThreadWriteLock)(BSL_SAL_ThreadLockHandle lock)
Lock the write operation.
定义 sal_lockimpl.h:76
int32_t(* BslCondTimedwaitMs)(BSL_SAL_Mutex condMutex, BSL_SAL_CondVar condVar, int32_t timeout)
The waiting time ends or the signal is obtained.
定义 bsl_sal.h:187
void * BSL_SAL_CondVar
定义 bsl_sal.h:84
int32_t(* BslCreateCondVar)(BSL_SAL_CondVar *condVar)
Create a condition variable.
定义 bsl_sal.h:158
int32_t(* pfThreadLockNew)(BSL_SAL_ThreadLockHandle *lock)
Create a thread lock.
定义 sal_lockimpl.h:40
int32_t(* pfThreadUnlock)(BSL_SAL_ThreadLockHandle lock)
Unlock
定义 sal_lockimpl.h:89
int32_t(* BslThreadRunOnce)(BSL_SAL_OnceControl *onceControl, BSL_SAL_ThreadInitRoutine initFunc)
Run the init Func command only once.
定义 bsl_sal.h:116
void(* pfThreadLockFree)(BSL_SAL_ThreadLockHandle lock)
Release the thread lock.
定义 sal_lockimpl.h:50
int32_t(* pfThreadReadLock)(BSL_SAL_ThreadLockHandle lock)
Lock the read operation.
定义 sal_lockimpl.h:63
int32_t(* pfGetId)(void)
Obtain the process ID.
定义 sal_lockimpl.h:123
void(* BslThreadClose)(BSL_SAL_ThreadId thread)
Close the thread.
定义 bsl_sal.h:144
int32_t(* BslThreadCreate)(BSL_SAL_ThreadId *thread, void *(*startFunc)(void *), void *arg)
Create a thread.
定义 bsl_sal.h:132
void(* BSL_SAL_ThreadInitRoutine)(void)
The user registers the function structure for thread-related operations.
定义 bsl_sal.h:101
void * BSL_SAL_ThreadLockHandle
定义 bsl_sal.h:63
void * BSL_SAL_Mutex
定义 bsl_sal.h:77
int32_t(* BslCondSignal)(BSL_SAL_CondVar condVar)
The waiting time ends or the signal is obtained.
定义 bsl_sal.h:172
uint64_t(* pfThreadGetId)(void)
Obtain the thread ID.
定义 sal_lockimpl.h:99
int32_t(* BslDeleteCondVar)(BSL_SAL_CondVar condVar)
Delete a condition variable.
定义 bsl_sal.h:201
void * BSL_SAL_ThreadId
定义 bsl_sal.h:70
Thread run-once control type
定义 bsl_sal.h:47
定义 sal_lockimpl.h:104
定义 sal_lockimpl.h:114
定义 sal_lockimpl.h:27