API参考
载入中...
搜索中...
未找到
Bsl_sal

System Abstraction Layer 更多...

Bsl_sal 的协作图:

struct  MemCallback
struct  BSL_SAL_OnceControl
 Thread run-once control type 更多...
struct  BSL_TIME
 Basic time data structure definition. 更多...

宏定义

#define BSL_SAL_DECLARE_THREAD_ONCE(name)
 Macro to declare thread run-once control variable

类型定义

typedef struct MemCallback BSL_SAL_MemCallback
typedef void * BSL_SAL_ThreadLockHandle
typedef void * BSL_SAL_ThreadId
typedef void * BSL_SAL_Mutex
typedef void * BSL_SAL_CondVar
typedef void(* BSL_SAL_ThreadInitRoutine) (void)
 The user registers the function structure for thread-related operations.
typedef int32_t(* BslThreadRunOnce) (BSL_SAL_OnceControl *onceControl, BSL_SAL_ThreadInitRoutine initFunc)
 Run the init Func command only once.
typedef int32_t(* BslThreadCreate) (BSL_SAL_ThreadId *thread, void *(*startFunc) (void *), void *arg)
 Create a thread.
typedef void(* BslThreadClose) (BSL_SAL_ThreadId thread)
 Close the thread.
typedef int32_t(* BslCreateCondVar) (BSL_SAL_CondVar *condVar)
 Create a condition variable.
typedef int32_t(* BslCondSignal) (BSL_SAL_CondVar condVar)
 The waiting time ends or the signal is obtained.
typedef int32_t(* BslCondTimedwaitMs) (BSL_SAL_Mutex condMutex, BSL_SAL_CondVar condVar, int32_t timeout)
 The waiting time ends or the signal is obtained.
typedef int32_t(* BslDeleteCondVar) (BSL_SAL_CondVar condVar)
 Delete a condition variable.
typedef int64_t BslUnixTime
 Unix Time structure definition.
typedef BslUnixTime(* BslTimeFunc) (void)
 Prototype of the callback function for obtaining the time
typedef int32_t(* BslSalSockAddrNew) (BSL_SAL_SockAddr *sockAddr)
 Create a BSL_SAL_SockAddr
typedef void(* BslSalSockAddrFree) (BSL_SAL_SockAddr sockAddr)
 Release the UIO_Addr object.
typedef int32_t(* BslSalSockAddrGetFamily) (const BSL_SAL_SockAddr sockAddr)
 Obtain the UIO_Addr protocal family
typedef uint32_t(* BslSalSockAddrSize) (const BSL_SAL_SockAddr sockAddr)
 Obtain the size of the BSL_SAL_SockAddr address.
typedef void(* BslSalSockAddrCopy) (BSL_SAL_SockAddr dst, const BSL_SAL_SockAddr src)
 Copy the BSL_SAL_SockAddr address.
typedef int32_t(* BslSalNetWrite) (int32_t fd, const void *buf, uint32_t len, int32_t *err)
 Write data to file descriptor.
typedef int32_t(* BslSalNetRead) (int32_t fd, void *buf, uint32_t len, int32_t *err)
 Read data from file descriptor.
typedef int64_t(* BslSalNetLSeek) (int32_t fd, int64_t offset, uint32_t origin)
 Seek interface.
typedef int32_t(* BslSalNetOpen) (const char *path, int32_t flag)
 Close file descriptor.
typedef int32_t(* BslSalNetClose) (int32_t fd)
 Close file descriptor.
typedef int32_t(* BslSalSocket) (int32_t af, int32_t type, int32_t protocol)
 Socket creation interface.
typedef int32_t(* BslSalSockClose) (int32_t sockId)
 Socket close interface.
typedef int32_t(* BslSalSetSockopt) (int32_t sockId, int32_t level, int32_t name, const void *val, int32_t len)
 Set the socket.
typedef int32_t(* BslSalGetSockopt) (int32_t sockId, int32_t level, int32_t name, void *val, int32_t *len)
 Get socket.
typedef int32_t(* BslSalGetSockName) (int32_t sockId, BSL_SAL_SockAddr addr, size_t *len)
 Get socket.
typedef int32_t(* BslSalSockListen) (int32_t sockId, int32_t backlog)
 Listen socket.
typedef int32_t(* BslSalSockBind) (int32_t sockId, BSL_SAL_SockAddr addr, size_t len)
 Binding a socket.
typedef int32_t(* BslSalSockConnect) (int32_t sockId, BSL_SAL_SockAddr addr, size_t len)
 Initiate a connection.
typedef int32_t(* BslSalSockAccept) (int32_t sockId, BSL_SAL_SockAddr addr, size_t *len)
 Initiate a accept.
typedef int32_t(* BslSalSockSend) (int32_t sockId, const void *msg, size_t len, int32_t flags)
 Send a message.
typedef int32_t(* BslSalSockRecv) (int32_t sockfd, void *buff, size_t len, int32_t flags)
 Receive the message
typedef int32_t(* BslSalNetSendTo) (int32_t sock, const void *buf, size_t len, int32_t flags, void *address, int32_t addrLen, int32_t *err)
 Same as linux function "sendto"
typedef int32_t(* BslSalNetRecvFrom) (int32_t sock, void *buf, size_t len, int32_t flags, void *address, int32_t *addrLen, int32_t *err)
 Same as linux function "recvfrom"
typedef int32_t(* BslSelect) (int32_t nfds, void *readfds, void *writefds, void *exceptfds, void *timeout)
 Same as linux function "select"
typedef int32_t(* BslIoctlSocket) (int32_t sockId, long cmd, unsigned long *arg)
 Same as linux function "ioctl"
typedef int32_t(* BslGetErrno) (void)
 return "errno"
typedef int32_t(* BslSetBlockMode) (int32_t fd, int32_t isBlock)
 Set block mode.
typedef int32_t(* BslSocketWait) (int32_t fd, int32_t forRead, int64_t maxTime)
 Wait for the socket to read and write data within the period specified by maxTime.
typedef int32_t(* BslSocketError) (int32_t fd)
 Get the error code of the socket.
typedef BslUnixTime(* BslGetUtcTime) (void)
 Obtains the current UTC time
typedef int32_t(* BslGetBslTime) (BSL_TIME *bslTime)
 Obtains the current system time. The time type is BSL_TIME.
typedef int32_t(* BslUtcTimeToBslTime) (int64_t utcTime, BSL_TIME *sysTime)
 Convert the utc time to BSL_TIME.
typedef void(* BslSleep) (uint32_t time)
 Sets the program to sleep for a specified time, in seconds.
typedef long(* BslTick) (void)
 Obtain the number of ticks that the system has experienced since startup.
typedef long(* BslTicksPerSec) (void)
 Obtain the number of system ticks per second.
typedef uint64_t(* BslGetTimeInNS) (void)
 Obtain the system time in nanoseconds.
typedef int32_t(* BslSalFileOpen) (bsl_sal_file_handle *stream, const char *path, const char *mode)
 Open the file.
typedef int32_t(* BslSalFileRead) (bsl_sal_file_handle stream, void *buffer, size_t size, size_t num, size_t *len)
 Read the file.
typedef int32_t(* BslSalFileWrite) (bsl_sal_file_handle stream, const void *buffer, size_t size, size_t num)
 Write the file
typedef void(* BslSalFileClose) (bsl_sal_file_handle stream)
 Close the file.
typedef int32_t(* BslSalFileLength) (const char *path, size_t *len)
 Obtain the file length.
typedef bool(* BslSalFileError) (bsl_sal_file_handle stream)
 Test the error indicator for the given stream.
typedef int32_t(* BslSalFileTell) (bsl_sal_file_handle stream, long *pos)
 Get the current file position in stream.
typedef int32_t(* BslSalFileSeek) (bsl_sal_file_handle stream, long offset, int32_t origin)
 Change the current file position associated with stream to a new location within the file.
typedef char *(* BslSalFGets) (bsl_sal_file_handle stream, char *buf, int32_t readLen)
 Read a line from the stream and store it into the buffer.
typedef bool(* BslSalFPuts) (bsl_sal_file_handle stream, const char *buf)
 Write a string to the specified stream.
typedef bool(* BslSalFlush) (bsl_sal_file_handle stream)
 Flush cache buffer associated with the specified output stream.
typedef int32_t(* BslSalFeof) (bsl_sal_file_handle stream)
 Indicate whether the end-of-file flag is set for the given stream.
typedef int32_t(* BslSalFSetAttr) (bsl_sal_file_handle stream, int cmd, const void *arg)
 Set the attributes associated with the terminal referred to by the open stream.
typedef int32_t(* BslSalFGetAttr) (bsl_sal_file_handle stream, void *arg)
 Get the attributes associated with the terminal referred to by the open stream.
typedef int32_t(* BslDlOpen) (const char *fileName, void **handle)
 Loading dynamic libraries.
typedef int32_t(* BslDlClose) (void *handle)
 Close dynamic library.
typedef int32_t(* BslDlSym) (void *handle, const char *funcName, void **func)
 Get function symbol from dynamic library.
typedef int32_t(* BslSalLoadLib) (const char *fileName, void **handle)
 Loading dynamic libraries.
typedef int32_t(* BslSalUnLoadLib) (void *handle)
 Close dynamic library.
typedef int32_t(* BslSalGetFunc) (void *handle, const char *funcName, void **func)
 Get function symbol from dynamic library.

函数

void * BSL_SAL_Malloc (uint32_t size)
 Allocate memory space.
void * BSL_SAL_Calloc (uint32_t num, uint32_t size)
 Allocate and clear the memory space.
void * BSL_SAL_Dump (const void *src, uint32_t size)
 Duplicate the memory space.
void BSL_SAL_Free (void *value)
 Release the specified memory.
void * BSL_SAL_Realloc (void *addr, uint32_t newSize, uint32_t oldSize)
 Memory expansion
void BSL_SAL_CleanseData (void *ptr, uint32_t size)
 Set sensitive information to zero.
void BSL_SAL_ClearFree (void *ptr, uint32_t size)
 Clear sensitive information and release memory.
int32_t BSL_SAL_ThreadLockNew (BSL_SAL_ThreadLockHandle *lock)
 Create a thread lock.
int32_t BSL_SAL_ThreadReadLock (BSL_SAL_ThreadLockHandle lock)
 Lock the read operation.
int32_t BSL_SAL_ThreadWriteLock (BSL_SAL_ThreadLockHandle lock)
 Lock the write operation.
int32_t BSL_SAL_ThreadUnlock (BSL_SAL_ThreadLockHandle lock)
 Unlock
void BSL_SAL_ThreadLockFree (BSL_SAL_ThreadLockHandle lock)
 Release the thread lock.
uint64_t BSL_SAL_ThreadGetId (void)
 Obtain the thread ID.
int32_t BSL_SAL_GetPid (void)
 Obtain the process ID.
int32_t BSL_SAL_ThreadRunOnce (BSL_SAL_OnceControl *onceControl, BSL_SAL_ThreadInitRoutine initFunc)
 Execute only once.
int32_t BSL_SAL_ThreadCreate (BSL_SAL_ThreadId *thread, void *(*startFunc)(void *), void *arg)
 Create a thread.
void BSL_SAL_ThreadClose (BSL_SAL_ThreadId thread)
 Close the thread.
int32_t BSL_SAL_CreateCondVar (BSL_SAL_CondVar *condVar)
 Create a condition variable.
int32_t BSL_SAL_CondSignal (BSL_SAL_CondVar condVar)
 The waiting time ends or the signal is obtained.
int32_t BSL_SAL_CondTimedwaitMs (BSL_SAL_Mutex condMutex, BSL_SAL_CondVar condVar, int32_t timeout)
 The waiting time ends or the signal is obtained.
int32_t BSL_SAL_DeleteCondVar (BSL_SAL_CondVar condVar)
 Delete a condition variable.
int32_t BSL_SAL_FileOpen (bsl_sal_file_handle *stream, const char *path, const char *mode)
 Open a file.
void BSL_SAL_FileClose (bsl_sal_file_handle stream)
 Close the file.
int32_t BSL_SAL_FileRead (bsl_sal_file_handle stream, void *buffer, size_t size, size_t num, size_t *len)
 Read the file.
int32_t BSL_SAL_FileWrite (bsl_sal_file_handle stream, const void *buffer, size_t size, size_t num)
 Write a file
int32_t BSL_SAL_FileLength (const char *path, size_t *len)
 Obtain the file length.
void BSL_SAL_SysTimeFuncReg (BslTimeFunc func)
 Interface for registering the function for obtaining the system time You can use this API to register the system time obtaining function.
int32_t BSL_SAL_DateTimeCompare (const BSL_TIME *dateA, const BSL_TIME *dateB, int64_t *diffSec)
 Compare Two Dates
int32_t BSL_SAL_SysTimeGet (BSL_TIME *sysTime)
 Obtain the system time.
BslUnixTime BSL_SAL_CurrentSysTimeGet (void)
 Obtain the Unix time.
int32_t BSL_SAL_DateToUtcTimeConvert (const BSL_TIME *dateTime, int64_t *utcTime)
 Convert the date in the BslSysTime format to the UTC time format.
int32_t BSL_SAL_UtcTimeToDateConvert (int64_t utcTime, BSL_TIME *sysTime)
 Convert the date in the BslUnixTime format to the BslSysTime format.
int32_t BSL_SAL_DateTimeCompareByUs (const BSL_TIME *dateA, const BSL_TIME *dateB)
 Compare two dates, accurate to microseconds.
void BSL_SAL_Sleep (uint32_t time)
 Sleep the current thread
long BSL_SAL_Tick (void)
 Obtain the number of ticks that the system has experienced since startup.
long BSL_SAL_TicksPerSec (void)
 Obtain the number of system ticks per second.
uint64_t BSL_SAL_TIME_GetNSec (void)
 Get the system time in nanoseconds.
int32_t BSL_SAL_Socket (int32_t af, int32_t type, int32_t protocol)
 Socket creation interface
int32_t BSL_SAL_SockClose (int32_t sockId)
 Close the socket
int32_t BSL_SAL_SetSockopt (int32_t sockId, int32_t level, int32_t name, const void *val, int32_t len)
 Set the socket
int32_t BSL_SAL_GetSockopt (int32_t sockId, int32_t level, int32_t name, void *val, int32_t *len)
 Get the socket
int32_t BSL_SAL_SockListen (int32_t sockId, int32_t backlog)
 Listening socket
int32_t BSL_SAL_SockBind (int32_t sockId, BSL_SAL_SockAddr addr, size_t len)
 Binding a socket
int32_t BSL_SAL_SockConnect (int32_t sockId, BSL_SAL_SockAddr addr, size_t len)
 Initiate a connection.
int32_t BSL_SAL_SockSend (int32_t sockId, const void *msg, size_t len, int32_t flags)
 Send a message.
int32_t BSL_SAL_SockRecv (int32_t sockfd, void *buff, size_t len, int32_t flags)
 Receive the message.
int32_t BSL_SAL_CallBack_Ctrl (BSL_SAL_CB_FUNC_TYPE funcType, void *funcCb)
 Control callback functions for SAL (System Abstraction Layer).
int32_t BSL_SAL_Select (int32_t nfds, void *readfds, void *writefds, void *exceptfds, void *timeout)
 Check the socket descriptor.
int32_t BSL_SAL_Ioctlsocket (int32_t sockId, long cmd, unsigned long *arg)
 Device control interface function
int32_t BSL_SAL_SockGetLastSocketError (void)
 Obtain the last error corresponding to the socket.
int32_t BSL_SAL_StrcaseCmp (const char *str1, const char *str2)
 String comparison
void * BSL_SAL_Memchr (const char *str, int32_t character, size_t count)
 Search for the corresponding character position in a string.
int32_t BSL_SAL_Atoi (const char *str)
 Convert string to number
uint32_t BSL_SAL_Strnlen (const char *string, uint32_t count)
 Obtain the length of a given string.
int32_t BSL_SAL_LoadLib (const char *fileName, void **handle)
 Load a dynamic library for dl.
int32_t BSL_SAL_UnLoadLib (void *handle)
 Unload a dynamic library for dl.
int32_t BSL_SAL_GetFuncAddress (void *handle, const char *funcName, void **func)
 Get the address of the initialization function for dl.
int32_t BSL_SAL_LibNameFormat (BSL_SAL_LibFmtCmd cmd, const char *fileName, char **name)
 Convert filename to full library path for dl.

变量

int32_t(* ThreadCallback::pfThreadLockNew )(BSL_SAL_ThreadLockHandle *lock)
 Create a thread lock.
void(* ThreadCallback::pfThreadLockFree )(BSL_SAL_ThreadLockHandle lock)
 Release the thread lock.
int32_t(* ThreadCallback::pfThreadReadLock )(BSL_SAL_ThreadLockHandle lock)
 Lock the read operation.
int32_t(* ThreadCallback::pfThreadWriteLock )(BSL_SAL_ThreadLockHandle lock)
 Lock the write operation.
int32_t(* ThreadCallback::pfThreadUnlock )(BSL_SAL_ThreadLockHandle lock)
 Unlock
uint64_t(* ThreadCallback::pfThreadGetId )(void)
 Obtain the thread ID.
int32_t(* PidCallback::pfGetId )(void)
 Obtain the process ID.
void *(* MemCallback::pfMalloc )(uint32_t size)
 Allocate a memory block.
void(* MemCallback::pfFree )(void *addr)
 Reclaim a memory block allocated by pfMalloc.

详细描述

System Abstraction Layer

宏定义说明

◆ BSL_SAL_DECLARE_THREAD_ONCE

#define BSL_SAL_DECLARE_THREAD_ONCE ( name)
值:
static BSL_SAL_OnceControl name = BSL_SAL_ONCE_INIT
Thread run-once control type
定义 bsl_sal.h:47

Macro to declare thread run-once control variable

Uses platform-native once mechanism (pthread_once on POSIX).

Usage:

BSL_SAL_ThreadRunOnce(&g_myOnce, MyInitFunction);
int32_t BSL_SAL_ThreadRunOnce(BSL_SAL_OnceControl *onceControl, BSL_SAL_ThreadInitRoutine initFunc)
Execute only once.
定义 sal_threadlock.c:111
#define BSL_SAL_DECLARE_THREAD_ONCE(name)
Macro to declare thread run-once control variable
定义 bsl_sal.h:303

类型定义说明

◆ BSL_SAL_CondVar

typedef void* BSL_SAL_CondVar

Condition handle, the corresponding structure is provided by the user during registration.

◆ BSL_SAL_MemCallback

Registrable function structure for memory allocation/release.

◆ BSL_SAL_Mutex

typedef void* BSL_SAL_Mutex

mutex

◆ BSL_SAL_ThreadId

typedef void* BSL_SAL_ThreadId

Thread handle, the corresponding structure is provided by the user during registration.

◆ BSL_SAL_ThreadInitRoutine

typedef void(* BSL_SAL_ThreadInitRoutine) (void)

The user registers the function structure for thread-related operations.

run once: Use the initialization callback.

注意
Thread safe : Thread-safe function. Blocking risk : No blocking. Time consuming : Not time-consuming. This function should not be a cancel, otherwise the default implementation of run once seems to have never been called.

◆ BSL_SAL_ThreadLockHandle

typedef void* BSL_SAL_ThreadLockHandle

Thread lock handle, the corresponding structure is provided by the user during registration.

◆ BslCondSignal

typedef int32_t(* BslCondSignal) (BSL_SAL_CondVar condVar)

The waiting time ends or the signal is obtained.

注意
Thread safe : Thread-safe function. Blocking risk : No blocking. Time consuming : Not time-consuming.
参数
condVar[IN] Condition variable
返回值
BSL_SUCCESS,success.
Otherwise,failure.

◆ BslCondTimedwaitMs

typedef int32_t(* BslCondTimedwaitMs) (BSL_SAL_Mutex condMutex, BSL_SAL_CondVar condVar, int32_t timeout)

The waiting time ends or the signal is obtained.

注意
Thread safe : Thread-safe function. Blocking risk : No blocking. Time consuming : Not time-consuming.
参数
condMutex[IN] Mutex
condVar[IN] Condition variable
timeout[IN] Time
返回值
BSL_SUCCESS,success.
Otherwise,failure.

◆ BslCreateCondVar

typedef int32_t(* BslCreateCondVar) (BSL_SAL_CondVar *condVar)

Create a condition variable.

注意
Thread safe : Thread-safe function. Blocking risk : No blocking. Time consuming : Not time-consuming.
参数
condVar[IN] Condition variable
返回值
BSL_SUCCESS,success.
Otherwise,failure.

◆ BslDeleteCondVar

typedef int32_t(* BslDeleteCondVar) (BSL_SAL_CondVar condVar)

Delete a condition variable.

注意
Thread safe : Thread-safe function. Blocking risk : No blocking. Time consuming : Not time-consuming.
参数
condVar[IN] Condition variable
返回值
BSL_SUCCESS,success.
Otherwise,failure.

◆ BslDlClose

typedef int32_t(* BslDlClose) (void *handle)

Close dynamic library.

Close dynamic library.

参数
handle[IN] Dynamic library handle
返回值
BSL_SUCCESSSucceeded.
BSL_SAL_ERR_DL_UNLOAAD_FAILFailed to unload the library.
注意
Thread safe : Thread-safe function. Blocking risk : No blocking. Time consuming : Not time-consuming.

◆ BslDlOpen

typedef int32_t(* BslDlOpen) (const char *fileName, void **handle)

Loading dynamic libraries.

Loading dynamic libraries.

参数
fileName[IN] Path of dl
handle[OUT] Dynamic library handle
返回值
BSL_SUCCESSSucceeded.
BSL_SAL_ERR_DL_NOT_FOUNDLibrary file not found.
BSL_SAL_DL_NO_REG_FUNCFailed to load the library.
注意
Thread safe : Thread-safe function. Blocking risk : No blocking. Time consuming : Not time-consuming.

◆ BslDlSym

typedef int32_t(* BslDlSym) (void *handle, const char *funcName, void **func)

Get function symbol from dynamic library.

Get function symbol from dynamic library.

参数
handle[IN] Dynamic library handle
funcName[IN] Function name
func[OUT] Function pointer
返回值
BSL_SUCCESSSucceeded.
BSL_SAL_ERR_DL_NON_FUNCTIONSymbol found but is not a function.
BSL_SAL_ERR_DL_LOOKUP_METHODFailed to lookup the function.
注意
Thread safe : Thread-safe function. Blocking risk : No blocking. Time consuming : Not time-consuming.

◆ BslGetBslTime

typedef int32_t(* BslGetBslTime) (BSL_TIME *bslTime)

Obtains the current system time. The time type is BSL_TIME.

参数
bslTime[IN/OUT] Pointer to the BSL_TIME structure.
返回
Error code in bsl_errno.h.
注意
Thread safe : Thread-safe function. Blocking risk : No blocking. Time consuming : Not time-consuming.

◆ BslGetErrno

typedef int32_t(* BslGetErrno) (void)

return "errno"

返回
#BSL_SUCCESS£¬success. Otherwise, failure.
注意
Thread safe : Thread-safe function. Blocking risk : No blocking. Time consuming : Not time-consuming.

◆ BslGetTimeInNS

typedef uint64_t(* BslGetTimeInNS) (void)

Obtain the system time in nanoseconds.

返回
Returns the time in nanoseconds; returns 0 if the operation fails.
注意
Thread safe : Thread-safe function. Blocking risk : No blocking. Time consuming : Not time-consuming.

◆ BslGetUtcTime

typedef BslUnixTime(* BslGetUtcTime) (void)

Obtains the current UTC time

Definition of the time callback interface.

返回
Return the utc time.
注意
Thread safe : Thread-safe function. Blocking risk : No blocking. Time consuming : Not time-consuming.

◆ BslIoctlSocket

typedef int32_t(* BslIoctlSocket) (int32_t sockId, long cmd, unsigned long *arg)

Same as linux function "ioctl"

参数
sockId[IN] Identifier of the socket to operate on.
cmd[IN] IOCTL command code.
arg[IN] Pointer to argument buffer.
返回
#BSL_SUCCESS£¬success. Otherwise, failure.
注意
Thread safe : Thread-safe function. Blocking risk : No blocking. Time consuming : Not time-consuming.

◆ BslSalFeof

typedef int32_t(* BslSalFeof) (bsl_sal_file_handle stream)

Indicate whether the end-of-file flag is set for the given stream.

参数
stream[IN] The file handle representing the stream to check.
返回
If successful, return BSL_SUCCESS. Otherwise, see bsl_errno.h.
注意
Thread safe : Thread-safe function. Blocking risk : No blocking. Time consuming : Not time-consuming.

◆ BslSalFGetAttr

typedef int32_t(* BslSalFGetAttr) (bsl_sal_file_handle stream, void *arg)

Get the attributes associated with the terminal referred to by the open stream.

参数
stream[IN] The file handle representing the stream to check.
arg[OUT] A pointer to store the retrieved attributes.
返回
If successful, BSL_SUCCESS is returned. If fail to get, BSL_SAL_ERR_FILE_GET_ATTR is returned. If parameter error, BSL_NULL_INPUT is returned
注意
Thread safe : Thread-safe function. Blocking risk : No blocking. Time consuming : Not time-consuming.

◆ BslSalFGets

typedef char *(* BslSalFGets) (bsl_sal_file_handle stream, char *buf, int32_t readLen)

Read a line from the stream and store it into the buffer.

参数
stream[IN] The file handle representing the stream to read from.
buf[OUT] The buffer where the read data will be stored.
readLen[IN] The maximum number of characters to read.
返回
If successful, the same read buffer is returned. Otherwise, return NULL.
注意
Thread safe : Thread-safe function. Blocking risk : No blocking. Time consuming : Not time-consuming.

◆ BslSalFileClose

typedef void(* BslSalFileClose) (bsl_sal_file_handle stream)

Close the file.

参数
stream[IN] The file handle representing the file to be closed.
返回
NA
注意
Thread safe : Thread-safe function. Blocking risk : No blocking. Time consuming : Not time-consuming.

◆ BslSalFileError

typedef bool(* BslSalFileError) (bsl_sal_file_handle stream)

Test the error indicator for the given stream.

参数
stream[IN] The file handle representing the stream to check.
返回
If the error indicator associated with the stream was set or the stream is null, false is returned. Otherwise, true is returned.
注意
Thread safe : Thread-safe function. Blocking risk : No blocking. Time consuming : Not time-consuming.

◆ BslSalFileLength

typedef int32_t(* BslSalFileLength) (const char *path, size_t *len)

Obtain the file length.

参数
path[IN] The path to the file whose length needs to be obtained.
len[OUT] A pointer to store the length of the file.
返回
If the file length is obtained successfully, BSL_SUCCESS is returned. If the file read fails, BSL_SAL_ERR_FILE_LENGTH is returned. If parameter error, BSL_NULL_INPUT is returned.
注意
Thread safe : Thread-safe function. Blocking risk : No blocking. Time consuming : Not time-consuming.

◆ BslSalFileOpen

typedef int32_t(* BslSalFileOpen) (bsl_sal_file_handle *stream, const char *path, const char *mode)

Open the file.

Definition of the file callback interface.

参数
stream[OUT] A pointer to the file handle that will be initialized upon successful opening of the file.
path[IN] A string specifying the path to the file to be opened.
mode[IN] A string specifying the access mode for the file.
返回
If the operation succeeds, BSL_SUCCESS is returned. If the file open fails, BSL_SAL_ERR_FILE_OPEN is returned. If parameter error, BSL_NULL_INPUT is returned.
注意
Thread safe : Thread-safe function. Blocking risk : No blocking. Time consuming : Not time-consuming.

◆ BslSalFileRead

typedef int32_t(* BslSalFileRead) (bsl_sal_file_handle stream, void *buffer, size_t size, size_t num, size_t *len)

Read the file.

参数
stream[IN] The file handle representing the file to be read.
buffer[OUT] A pointer to the buffer where the read data will be stored.
size[IN] The size of each element in the buffer (in bytes).
num[IN] The number of elements in the buffer.
len[OUT] A pointer to a variable where the actual number of bytes read will be stored.
返回
If the file is successfully read, BSL_SUCCESS is returned. If the file read fails, BSL_SAL_ERR_FILE_READ is returned. If parameter error, BSL_NULL_INPUT is returned.
注意
Thread safe : Not thread-safe function. Blocking risk : No blocking. Time consuming : Not time-consuming.

◆ BslSalFileSeek

typedef int32_t(* BslSalFileSeek) (bsl_sal_file_handle stream, long offset, int32_t origin)

Change the current file position associated with stream to a new location within the file.

参数
stream[IN] The file handle representing the stream to modify.
offset[IN] The number of bytes to move the file pointer from the origin.
origin[IN] The reference point for the new file position.
返回
If successful, BSL_SUCCESS is returned. If fail to change the file position, BSL_SAL_ERR_FILE_SEEK is returned. If parameter error, BSL_NULL_INPUT is returned.
注意
Thread safe : Thread-safe function. Blocking risk : No blocking. Time consuming : Not time-consuming.

◆ BslSalFileTell

typedef int32_t(* BslSalFileTell) (bsl_sal_file_handle stream, long *pos)

Get the current file position in stream.

参数
stream[IN] The file handle representing the stream to check.
pos[OUT] A pointer to store the current file position.
返回
If the file position is obtained successfully, BSL_SUCCESS is returned. If fail to get the file position, BSL_SAL_ERR_FILE_TELL is returned. If parameter error, BSL_NULL_INPUT is returned.
注意
Thread safe : Thread-safe function. Blocking risk : No blocking. Time consuming : Not time-consuming.

◆ BslSalFileWrite

typedef int32_t(* BslSalFileWrite) (bsl_sal_file_handle stream, const void *buffer, size_t size, size_t num)

Write the file

参数
stream[IN] The file handle representing the file to be written.
buffer[IN] A pointer to the buffer containing the data to be written.
size[IN] The size of each element in the buffer (in bytes).
num[IN] The number of elements in the buffer.
返回
If the file is successfully write, BSL_SUCCESS is returned. If the file read fails, BSL_SAL_ERR_FILE_WRITE is returned. If parameter error, BSL_NULL_INPUT is returned.
注意
Thread safe : Not thread-safe function. Blocking risk : No blocking. Time consuming : Not time-consuming.

◆ BslSalFlush

typedef bool(* BslSalFlush) (bsl_sal_file_handle stream)

Flush cache buffer associated with the specified output stream.

参数
stream[IN] The file handle representing the stream to flush.
返回
If successful, return true. Otherwise, return false.
注意
Thread safe : Thread-safe function. Blocking risk : No blocking. Time consuming : Not time-consuming.

◆ BslSalFPuts

typedef bool(* BslSalFPuts) (bsl_sal_file_handle stream, const char *buf)

Write a string to the specified stream.

参数
stream[IN] The file handle representing the stream to write to.
buf[IN] The string to write to the stream.
返回
If successful, return true. Otherwise, return false.
注意
Thread safe : Thread-safe function. Blocking risk : No blocking. Time consuming : Not time-consuming.

◆ BslSalFSetAttr

typedef int32_t(* BslSalFSetAttr) (bsl_sal_file_handle stream, int cmd, const void *arg)

Set the attributes associated with the terminal referred to by the open stream.

参数
stream[IN] The file handle representing the stream to modify.
cmd[IN] The command specifying which attribute to set.
arg[IN] The argument providing the value for the attribute.
返回
If successful, BSL_SUCCESS is returned. If fail to set, BSL_SAL_ERR_FILE_SET_ATTR is returned. If parameter error, BSL_NULL_INPUT is returned.
注意
Thread safe : Thread-safe function. Blocking risk : No blocking. Time consuming : Not time-consuming.

◆ BslSalGetFunc

typedef int32_t(* BslSalGetFunc) (void *handle, const char *funcName, void **func)

Get function symbol from dynamic library.

Get function symbol from dynamic library.

参数
handle[IN] Dynamic library handle
funcName[IN] Function name
func[OUT] Function pointer
返回值
BSL_SUCCESSSucceeded.
BSL_SAL_ERR_DL_NON_FUNCTIONSymbol found but is not a function.
BSL_SAL_ERR_DL_LOOKUP_METHODFailed to lookup the function.

◆ BslSalGetSockName

typedef int32_t(* BslSalGetSockName) (int32_t sockId, BSL_SAL_SockAddr addr, size_t *len)

Get socket.

参数
sockId[IN] The identifier of the socket.
addr[OUT] A pointer to store the obtained local protocol address.
len[OUT] A pointer to store the the length of the addr buffer when calling, and the returned value includes the size of the actual address structure.
返回
If the operation succeeds, BSL_SUCCESS is returned. If the operation fails, BSL_SAL_ERR_NET_GETSOCKNAME is returned.
注意
Thread safe : Thread-safe function. Blocking risk : No blocking. Time consuming : Not time-consuming.

◆ BslSalGetSockopt

typedef int32_t(* BslSalGetSockopt) (int32_t sockId, int32_t level, int32_t name, void *val, int32_t *len)

Get socket.

参数
sockId[IN] The identifier of the socket.
level[IN] The option level.
name[IN] The specific option name.
val[OUT] A pointer to store the value of the option.
len[OUT] A pointer to store the length of the value.
返回
If the operation succeeds, BSL_SUCCESS is returned. If the operation fails, BSL_SAL_ERR_NET_GETSOCKOPT is returned.
注意
Thread safe : Thread-safe function. Blocking risk : No blocking. Time consuming : Not time-consuming.

◆ BslSalLoadLib

typedef int32_t(* BslSalLoadLib) (const char *fileName, void **handle)

Loading dynamic libraries.

Loading dynamic libraries.

参数
fileName[IN] Path of dl
handle[OUT] Dynamic library handle
返回值
BSL_SUCCESSSucceeded.
BSL_SAL_ERR_DL_NOT_FOUNDLibrary file not found.
BSL_SAL_ERR_DL_LOAD_FAILFailed to load the library.

◆ BslSalNetClose

typedef int32_t(* BslSalNetClose) (int32_t fd)

Close file descriptor.

Description: Close file descriptor.
参数
fd[IN] File descriptor.
返回
Error code in bsl_errno.h.
注意
Thread safe : Thread-safe function. Blocking risk : No blocking. Time consuming : Not time-consuming.

◆ BslSalNetLSeek

typedef int64_t(* BslSalNetLSeek) (int32_t fd, int64_t offset, uint32_t origin)

Seek interface.

Description: Offsets the file read/write position to a certain position.
参数
fd[IN] File descriptor.
offset[IN] The offset from the start position.
origin[IN] The start position. One of SAL_NET_SEEK_SET, SAL_NET_SEEK_CUR and SAL_NET_SEEK_END.
返回
If succeed, return the new read/write position. Otherwise, return -1.
注意
Thread safe : Thread-safe function. Blocking risk : No blocking. Time consuming : Not time-consuming.

◆ BslSalNetOpen

typedef int32_t(* BslSalNetOpen) (const char *path, int32_t flag)

Close file descriptor.

Description: Close file descriptor.
参数
path[IN] File path.
flag[IN] open mode.
返回
Error code in bsl_errno.h.
注意
Thread safe : Thread-safe function. Blocking risk : No blocking. Time consuming : Not time-consuming.

◆ BslSalNetRead

typedef int32_t(* BslSalNetRead) (int32_t fd, void *buf, uint32_t len, int32_t *err)

Read data from file descriptor.

Description: Attempt to read len bytes from the the file associated with the open file descriptor to the buffer.
参数
fd[IN] File descriptor.
buffer[OUT] The read data buffer.
len[IN] The len which want to read.
err[OUT] The IO errno.
返回
Return the number of bytes actually read from the file. Otherwise, -1 shall be returned and errno set to indicate the error.
注意
Thread safe : Thread-safe function. Blocking risk : It may be blocked. Time consuming : Not time-consuming.

◆ BslSalNetRecvFrom

typedef int32_t(* BslSalNetRecvFrom) (int32_t sock, void *buf, size_t len, int32_t flags, void *address, int32_t *addrLen, int32_t *err)

Same as linux function "recvfrom"

参数
sock[IN] Socket descriptor.
buf[IN] Pointer to the buffer containing the data to send.
len[IN] Length of the data to send (in bytes).
flags[IN] Flags for modifying the operation
address[IN] Destination address structure.
addrLen[IN] Length of the address structure.
err[OUT] Pointer to store the error code (if non-NULL).
返回
#BSL_SUCCESS£¬success. Otherwise, failure.
注意
Thread safe : Thread-safe function. Blocking risk : It may be blocked. Time consuming : Not time-consuming.

◆ BslSalNetSendTo

typedef int32_t(* BslSalNetSendTo) (int32_t sock, const void *buf, size_t len, int32_t flags, void *address, int32_t addrLen, int32_t *err)

Same as linux function "sendto"

参数
sock[IN] Socket descriptor.
buf[IN] Pointer to the buffer containing the data to send.
len[IN] Length of the data to send (in bytes).
flags[IN] Flags for modifying the operation
address[IN] Destination address structure.
addrLen[IN] Length of the address structure.
err[OUT] Pointer to store the error code (if non-NULL).
返回
#BSL_SUCCESS£¬success. Otherwise, failure.
注意
Thread safe : Thread-safe function. Blocking risk : It may be blocked. Time consuming : Not time-consuming.

◆ BslSalNetWrite

typedef int32_t(* BslSalNetWrite) (int32_t fd, const void *buf, uint32_t len, int32_t *err)

Write data to file descriptor.

Definition of the net callback interface.

Description: Attempt to write len bytes from the buffer to the file associated with the open file descriptor.
参数
fd[IN] File descriptor.
buffer[IN] The write data buffer.
len[IN] The len which want to write.
err[OUT] The IO errno.
返回
Return the number of bytes actually written to the file. Otherwise, -1 shall be returned and errno set to indicate the error.
注意
Thread safe : Thread-safe function. Blocking risk : It may be blocked. Time consuming : Not time-consuming.

◆ BslSalSetSockopt

typedef int32_t(* BslSalSetSockopt) (int32_t sockId, int32_t level, int32_t name, const void *val, int32_t len)

Set the socket.

参数
sockId[IN] The identifier of the socket.
level[IN] The option level.
name[IN] The specific option name.
val[IN] A pointer to the value to set for the option.
len[IN] The length of the value pointed to by val.
返回
If the operation succeeds, BSL_SUCCESS is returned If the operation fails, BSL_SAL_ERR_NET_SETSOCKOPT is returned.
注意
Thread safe : Thread-safe function. Blocking risk : No blocking. Time consuming : Not time-consuming.

◆ BslSalSockAccept

typedef int32_t(* BslSalSockAccept) (int32_t sockId, BSL_SAL_SockAddr addr, size_t *len)

Initiate a accept.

参数
sockId[IN] The identifier of the socket to use for the accept.
addr[IN] A pointer to the socket address structure accept the remote host's address.
len[IN] The size of the socket address structure.
返回
If the operation succeeds, BSL_SUCCESS is returned If the operation fails, BSL_SAL_ERR_NET_ACCEPT is returned.
注意
Thread safe : Thread-safe function. Blocking risk : It may be blocked. Time consuming : Not time-consuming.

◆ BslSalSockAddrCopy

typedef void(* BslSalSockAddrCopy) (BSL_SAL_SockAddr dst, const BSL_SAL_SockAddr src)

Copy the BSL_SAL_SockAddr address.

参数
src[IN] Source address
dst[OUT] Destination address

◆ BslSalSockAddrFree

typedef void(* BslSalSockAddrFree) (BSL_SAL_SockAddr sockAddr)

Release the UIO_Addr object.

参数
uioAddr[IN] UIO_Addr object

◆ BslSalSockAddrGetFamily

typedef int32_t(* BslSalSockAddrGetFamily) (const BSL_SAL_SockAddr sockAddr)

Obtain the UIO_Addr protocal family

参数
sockAddr[IN] UIO_Addr object
返回值
Return0 if the address is not valid.
ReturnSAL_IPV4 if the address is IPv4.
ReturnSAL_IPV6 if the address is IPv6.

◆ BslSalSockAddrNew

typedef int32_t(* BslSalSockAddrNew) (BSL_SAL_SockAddr *sockAddr)

Create a BSL_SAL_SockAddr

返回
New BSL_SAL_SockAddr object

◆ BslSalSockAddrSize

typedef uint32_t(* BslSalSockAddrSize) (const BSL_SAL_SockAddr sockAddr)

Obtain the size of the BSL_SAL_SockAddr address.

Only for internal use

参数
sockAddr[IN] UIO object
返回值
Addresssize, if the address is not valid, return 0

◆ BslSalSockBind

typedef int32_t(* BslSalSockBind) (int32_t sockId, BSL_SAL_SockAddr addr, size_t len)

Binding a socket.

参数
sockId[IN] The identifier of the socket to bind.
addr[IN] A pointer to the socket address structure.
len[IN] The size of the socket address structure.
返回
If the operation succeeds, BSL_SUCCESS is returned. If the operation fails, BSL_SAL_ERR_NET_BIND is returned.
注意
Thread safe : Thread-safe function. Blocking risk : It may be blocked. Time consuming : Not time-consuming.

◆ BslSalSockClose

typedef int32_t(* BslSalSockClose) (int32_t sockId)

Socket close interface.

参数
sockId[IN] The identifier of the socket to be closed.
返回
If the operation succeeds, BSL_SUCCESS is returned. If the operation fails, BSL_SAL_ERR_NET_SOCKCLOSE is returned.
注意
Thread safe : Thread-safe function. Blocking risk : No blocking. Time consuming : Not time-consuming.

◆ BslSalSockConnect

typedef int32_t(* BslSalSockConnect) (int32_t sockId, BSL_SAL_SockAddr addr, size_t len)

Initiate a connection.

参数
sockId[IN] The identifier of the socket to use for the connection.
addr[IN] A pointer to the socket address structure containing the remote host's address.
len[IN] The size of the socket address structure.
返回
If the operation succeeds, BSL_SUCCESS is returned If the operation fails, BSL_SAL_ERR_NET_CONNECT is returned.
注意
Thread safe : Thread-safe function. Blocking risk : It may be blocked. Time consuming : Not time-consuming.

◆ BslSalSocket

typedef int32_t(* BslSalSocket) (int32_t af, int32_t type, int32_t protocol)

Socket creation interface.

参数
af[IN] The address family.
type[IN] The socket type.
protocol[IN] The protocol to be used.
返回
If the creation is successful, a non-negative value is returned. Otherwise, a negative value is returned.
注意
Thread safe : Thread-safe function. Blocking risk : No blocking. Time consuming : Not time-consuming.

◆ BslSalSockListen

typedef int32_t(* BslSalSockListen) (int32_t sockId, int32_t backlog)

Listen socket.

参数
sockId[IN] The identifier of the socket to listen on.
backlog[IN] The maximum number of pending connections.
返回
If the operation succeeds, BSL_SUCCESS is returned. If the operation fails, BSL_SAL_ERR_NET_LISTEN is returned.
注意
Thread safe : Thread-safe function. Blocking risk : It may be blocked. Time consuming : time-consuming.

◆ BslSalSockRecv

typedef int32_t(* BslSalSockRecv) (int32_t sockfd, void *buff, size_t len, int32_t flags)

Receive the message

参数
sockId[IN] The identifier of the socket to send the message on.
buff[IN] A buffer to store the received data.
len[IN] The length of the message data.
flags[IN] Flags that modify the behavior of the send operation.
返回
If the operation succeeds, the received data length is returned. If the operation fails, a negative value is returned. If the operation times out or the peer end disables the function, the value 0 is returned.
注意
Thread safe : Thread-safe function. Blocking risk : It may be blocked. Time consuming : time-consuming.

◆ BslSalSockSend

typedef int32_t(* BslSalSockSend) (int32_t sockId, const void *msg, size_t len, int32_t flags)

Send a message.

参数
sockId[IN] Identifier of the socket to send the message on.
msg[IN] Pointer to the message data buffer.
len[IN] Length of the message data to send.
flags[IN] Flags to modify the send operation behavior.
返回
If the operation succeeds, the length of the sent data is returned. If the operation fails, a negative value is returned. If the operation times out or the peer end disables the function, the value 0 is returned.
注意
Thread safe : Thread-safe function. Blocking risk : It may be blocked. Time consuming : time-consuming.

◆ BslSalUnLoadLib

typedef int32_t(* BslSalUnLoadLib) (void *handle)

Close dynamic library.

Close dynamic library.

参数
handle[IN] Dynamic library handle
返回值
BSL_SUCCESSSucceeded.
BSL_SAL_ERR_DL_UNLOAAD_FAILFailed to unload the library.

◆ BslSelect

typedef int32_t(* BslSelect) (int32_t nfds, void *readfds, void *writefds, void *exceptfds, void *timeout)

Same as linux function "select"

参数
nfds[IN] Maximum file descriptor value to monitor.
readfds[IN] Pointer to read file descriptor set.
writefds[IN] Pointer to write file descriptor set.
exceptfds[IN] Pointer to exception file descriptor set.
timeout[IN] Pointer to timeout structure.
返回
#BSL_SUCCESS£¬success. Otherwise, failure.
注意
Thread safe : Thread-safe function. Blocking risk : No blocking. Time consuming : Not time-consuming.

◆ BslSetBlockMode

typedef int32_t(* BslSetBlockMode) (int32_t fd, int32_t isBlock)

Set block mode.

参数
fd[IN] The file descriptor to set the block mode for.
isBlock[IN] Indicating whether to set the file descriptor to block mode or non-blocking mode.
返回
If the operation succeeds, BSL_SUCCESS is returned. If the file open fails, BSL_SAL_ERR_NET_NOBLOCK is returned.
注意
Thread safe : Thread-safe function. Blocking risk : No blocking. Time consuming : Not time-consuming.

◆ BslSleep

typedef void(* BslSleep) (uint32_t time)

Sets the program to sleep for a specified time, in seconds.

参数
time[IN] Sleep time.
注意
Thread safe : Thread-safe function. Blocking risk : It may be blocked. Time consuming : time-consuming.

◆ BslSocketError

typedef int32_t(* BslSocketError) (int32_t fd)

Get the error code of the socket.

参数
fd[IN] The file descriptor of the socket to query.
返回
#BSL_SUCCESS£¬success. Otherwise, failure.
注意
Thread safe : Thread-safe function. Blocking risk : No blocking. Time consuming : Not time-consuming.

◆ BslSocketWait

typedef int32_t(* BslSocketWait) (int32_t fd, int32_t forRead, int64_t maxTime)

Wait for the socket to read and write data within the period specified by maxTime.

参数
fd[IN] The file descriptor of the socket to wait on.
forRead[IN] A flag indicating whether to wait for the socket to be readable (1) or writable (0).
maxTime[IN] The maximum amount of time (in microseconds) to wait before returning.
返回
#BSL_SUCCESS£¬success. Otherwise, failure.
注意
Thread safe : Thread-safe function. Blocking risk : It may be blocked. Time consuming : time-consuming.

◆ BslThreadClose

typedef void(* BslThreadClose) (BSL_SAL_ThreadId thread)

Close the thread.

注意
Thread safe : Thread-safe function. Blocking risk : No blocking. Time consuming : Not time-consuming.
参数
thread[IN] Thread ID

◆ BslThreadCreate

typedef int32_t(* BslThreadCreate) (BSL_SAL_ThreadId *thread, void *(*startFunc)(void *), void *arg)

Create a thread.

注意
Thread safe : Thread-safe function. Blocking risk : No blocking. Time consuming : Not time-consuming.
参数
thread[IN/OUT] Thread ID
startFunc[IN] Thread function
arg[IN] Thread function parameters
返回值
BSL_SUCCESS,success.
Otherwise,failure.

◆ BslThreadRunOnce

typedef int32_t(* BslThreadRunOnce) (BSL_SAL_OnceControl *onceControl, BSL_SAL_ThreadInitRoutine initFunc)

Run the init Func command only once.

参数
onceControl[IN] Record the execution status.
initFunc[IN] Initialization function.
返回值
BSL_SUCCESS,success.
Otherwise,failure.
注意
Thread safe : Thread-safe function. Blocking risk : No blocking. Time consuming : Not time-consuming.

◆ BslTick

typedef long(* BslTick) (void)

Obtain the number of ticks that the system has experienced since startup.

返回
Return tick for success and -1 for failure.
注意
Thread safe : Thread-safe function. Blocking risk : No blocking. Time consuming : Not time-consuming.

◆ BslTicksPerSec

typedef long(* BslTicksPerSec) (void)

Obtain the number of system ticks per second.

返回
Return number of ticks per secone for success and -1 for failure.
注意
Thread safe : Thread-safe function. Blocking risk : No blocking. Time consuming : Not time-consuming.

◆ BslTimeFunc

typedef BslUnixTime(* BslTimeFunc) (void)

Prototype of the callback function for obtaining the time

Prototype definition of the callback function for obtaining the time.

◆ BslUtcTimeToBslTime

typedef int32_t(* BslUtcTimeToBslTime) (int64_t utcTime, BSL_TIME *sysTime)

Convert the utc time to BSL_TIME.

参数
utcTime[IN] UTC time.
bslTime[IN/OUT] Pointer to the BSL_TIME structure.
返回
Error code in bsl_errno.h.
注意
Thread safe : Thread-safe function. Blocking risk : No blocking. Time consuming : Not time-consuming.

函数说明

◆ BSL_SAL_Atoi()

int32_t BSL_SAL_Atoi ( const char * str)

Convert string to number

Convert string to number

注意
None.
参数
str[IN] String to be converted.
返回值
Ifthe conversion is successful, the corresponding number is returned; Otherwise, the value 0 is returned.

◆ BSL_SAL_CallBack_Ctrl()

int32_t BSL_SAL_CallBack_Ctrl ( BSL_SAL_CB_FUNC_TYPE funcType,
void * funcCb )

Control callback functions for SAL (System Abstraction Layer).

This function is used to control and register callback functions for different SAL modules such as network, time, and file operations.

注意
None
参数
funcType[IN] Type of the callback function to be controlled
funcCb[IN] Pointer to the callback function
返回值
BSL_SUCCESSCallback function controlled successfully
BSL_SAL_ERR_BAD_PARAMInvalid function type or callback pointer
Othererror codes specific to the SAL module

◆ BSL_SAL_Calloc()

void * BSL_SAL_Calloc ( uint32_t num,
uint32_t size )

Allocate and clear the memory space.

Allocate and clear the memory space. The maximum size of UINT32_MAX is allocated.

注意
num*size should not have overflow wrap.
参数
num[IN] Number of allocated memory.
size[IN] Size of each memory.
返回值
Ifthe application is successful, returned the pointer pointing to the memory.
Ifthe application failed, return NULL.

◆ BSL_SAL_CleanseData()

void BSL_SAL_CleanseData ( void * ptr,
uint32_t size )

Set sensitive information to zero.

参数
ptr[IN] Memory to be zeroed
size[IN] Length of the memory to be zeroed out

◆ BSL_SAL_ClearFree()

void BSL_SAL_ClearFree ( void * ptr,
uint32_t size )

Clear sensitive information and release memory.

参数
ptr[IN] Pointer to the memory to be released
size[IN] Length of the memory to be zeroed out

◆ BSL_SAL_CondSignal()

int32_t BSL_SAL_CondSignal ( BSL_SAL_CondVar condVar)

The waiting time ends or the signal is obtained.

The waiting time ends or the signal is obtained.

注意
None
参数
condVar[IN] Condition variable
返回值
BSL_SUCCESS,succeeded.
BSL_SAL_ERR_UNKNOWN,functionfailure
BSL_SAL_ERR_BAD_PARAM,parametererror. The value of condVar is NULL.

◆ BSL_SAL_CondTimedwaitMs()

int32_t BSL_SAL_CondTimedwaitMs ( BSL_SAL_Mutex condMutex,
BSL_SAL_CondVar condVar,
int32_t timeout )

The waiting time ends or the signal is obtained.

The waiting time ends or the signal is obtained.

注意
None
参数
condMutex[IN] Mutex
condVar[IN] Condition variable
timeout[IN] Time
返回值
BSL_SUCCESS,succeeded.
BSL_SAL_ERR_UNKNOWN,fails.
BSL_SAL_ERR_BAD_PARAM,parametererror. The value of condMutex or condVar is null.

◆ BSL_SAL_CreateCondVar()

int32_t BSL_SAL_CreateCondVar ( BSL_SAL_CondVar * condVar)

Create a condition variable.

Create a condition variable.

注意
none
参数
condVar[IN] Condition variable
返回值
BSL_SUCCESS,createdsuccessfully.
BSL_SAL_ERR_UNKNOWN,failedto create a condition variable.
BSL_SAL_ERR_BAD_PARAM,parametererror. The value of condVar is NULL.

◆ BSL_SAL_CurrentSysTimeGet()

BslUnixTime BSL_SAL_CurrentSysTimeGet ( void )

Obtain the Unix time.

Obtain the Unix time.

返回值
Returnthe Unix time.

◆ BSL_SAL_DateTimeCompare()

int32_t BSL_SAL_DateTimeCompare ( const BSL_TIME * dateA,
const BSL_TIME * dateB,
int64_t * diffSec )

Compare Two Dates

参数
dateA[IN] The first date
dateB[IN] The second date
diffSeconds[OUT] Number of seconds between two dates
返回值
BslTimeCmpResultComparison result of two dates
#BSL_TIME_CMP_ERROR- Error in comparison
#BSL_TIME_CMP_EQUAL- The two dates are consistent.
#BSL_TIME_DATE_BEFORE- The first date is before the second date.
#BSL_TIME_DATE_AFTER- The first date is after the second

◆ BSL_SAL_DateTimeCompareByUs()

int32_t BSL_SAL_DateTimeCompareByUs ( const BSL_TIME * dateA,
const BSL_TIME * dateB )

Compare two dates, accurate to microseconds.

Compare two dates, accurate to microseconds

注意
None
参数
dateA[IN] Time
dateB[IN] Time
返回值
#BslTimeCmpResultComparison result of two dates
#BSL_TIME_CMP_ERROR- An error occurred in the comparison.
#BSL_TIME_CMP_EQUAL- The two dates are consistent.
#BSL_TIME_DATE_BEFORE- The first date is on the second
#BSL_TIME_DATE_AFTER - The first date is after the second

◆ BSL_SAL_DateToUtcTimeConvert()

int32_t BSL_SAL_DateToUtcTimeConvert ( const BSL_TIME * dateTime,
int64_t * utcTime )

Convert the date in the BslSysTime format to the UTC time format.

Convert the date in the BslSysTime format to the UTC time format.

注意
None
参数
dateTime[IN] Date and time
utcTime[OUT] UTC time
返回值
BSL_SUCCESS,timeis successfully converted.
BSL_INTERNAL_EXCEPTION,anexception occurred when obtaining the time.

◆ BSL_SAL_DeleteCondVar()

int32_t BSL_SAL_DeleteCondVar ( BSL_SAL_CondVar condVar)

Delete a condition variable.

Delete a condition variable.

注意
none
参数
condVar[IN] Condition variable
返回值
BSL_SUCCESS,Succeededin deleting the condition variable.
BSL_SAL_ERR_UNKNOWN,Failedto delete the condition variable.
BSL_SAL_ERR_BAD_PARAM,parametererror. The value of condVar is NULL.

◆ BSL_SAL_Dump()

void * BSL_SAL_Dump ( const void * src,
uint32_t size )

Duplicate the memory space.

参数
srcSource memory address
sizeTotal memory size
返回值
Ifthe allocation is successful, returned the pointer pointing to the memory.
Ifthe allocation failed, return NULL.

◆ BSL_SAL_FileClose()

void BSL_SAL_FileClose ( bsl_sal_file_handle stream)

Close the file.

Close the file.

注意
none
参数
stream[IN] File handle
返回值
NA

◆ BSL_SAL_FileLength()

int32_t BSL_SAL_FileLength ( const char * path,
size_t * len )

Obtain the file length.

Obtain the file length.

注意
none
参数
path[IN] File path
len[OUT] File length
返回值
BSL_SUCCESS,succeeded
BSL_SAL_ERR_UNKNOWN,fails
BSL_NULL_INPUT,parametererror

◆ BSL_SAL_FileOpen()

int32_t BSL_SAL_FileOpen ( bsl_sal_file_handle * stream,
const char * path,
const char * mode )

Open a file.

Open the file and ensure that the entered path is standardized.

注意
None
参数
stream[OUT] File handle
path[IN] File path
mode[IN] Reading mode
返回值
BSL_SUCCESS,succeeded.
BSL_SAL_ERR_FILE_OPEN,failedto be opened.
BSL_NULL_INPUT,parametererror.

◆ BSL_SAL_FileRead()

int32_t BSL_SAL_FileRead ( bsl_sal_file_handle stream,
void * buffer,
size_t size,
size_t num,
size_t * len )

Read the file.

Read the file. The actual memory of the interface is 1 more than the real length of the read file, which is used to add '\0' after the end of the read file content, and the outgoing parameter len is the real data length, excluding '\0'.

注意
none
参数
stream[IN] File handle
buffer[IN] Buffer for reading data
size[IN] The unit of reading.
num[IN] Number of data records to be read
len[OUT] Read the data length.
返回值
BSL_SUCCESS,succeeded.
BSL_SAL_ERR_UNKNOWN,fails.
BSL_NULL_INPUT,Incorrectparameter

◆ BSL_SAL_FileWrite()

int32_t BSL_SAL_FileWrite ( bsl_sal_file_handle stream,
const void * buffer,
size_t size,
size_t num )

Write a file

Write File

注意
none
参数
stream[IN] File handle
buffer[IN] Data to be written
size[IN] Write the unit
num[IN] Number of written data
返回值
BSL_SUCCESS,succeeded
BSL_SAL_ERR_UNKNOWN,fails
BSL_NULL_INPUT,parametererror

◆ BSL_SAL_Free()

void BSL_SAL_Free ( void * value)

Release the specified memory.

Release the specified memory.

注意
NONE.
参数
value[IN] Pointer to the memory space to be released.

◆ BSL_SAL_GetFuncAddress()

int32_t BSL_SAL_GetFuncAddress ( void * handle,
const char * funcName,
void ** func )

Get the address of the initialization function for dl.

Get the address of the initialization function for dl.

注意
None.
参数
handle[IN] Handle of the loaded library.
funcName[IN] Name of the function.
func[OUT] Pointer to store the address of the function.
返回值
Ifthe operation is successful, BSL_SUCCESS is returned; Otherwise, an error code is returned.

◆ BSL_SAL_GetPid()

int32_t BSL_SAL_GetPid ( void )

Obtain the process ID.

Obtain the process ID.

注意
none
返回值
ProcessID

◆ BSL_SAL_GetSockopt()

int32_t BSL_SAL_GetSockopt ( int32_t sockId,
int32_t level,
int32_t name,
void * val,
int32_t * len )

Get the socket

Get the socket

注意
none
参数
sockId[IN] Socket file descriptor ID
level[IN] Level of the option to be set. SAL_PROTO_IP_LEVEL: ipv4 level SAL_PROTO_IPV6_LEVEL: ipv6 level
name[IN] Options to be set SAL_MTU_OPTION: ipv4 mtu option SAL_IPV6_MTU_OPTION: ipv6 mtu option
val[OUT] Value of the option
len[OUT] val Length
返回值
Ifthe operation succeeds, BSL_SUCCESS is returned

◆ BSL_SAL_Ioctlsocket()

int32_t BSL_SAL_Ioctlsocket ( int32_t sockId,
long cmd,
unsigned long * arg )

Device control interface function

Device control interface function

注意
None
参数
sockId[IN] Socket file descriptor ID
cmd[IN] Interaction protocol
arg[IN] Parameter
返回值
Ifthe operation succeeds, BSL_SUCCESS is returned.
Ifthe operation fails, BSL_SAL_ERR_NET_IOCTL is returned.

◆ BSL_SAL_LibNameFormat()

int32_t BSL_SAL_LibNameFormat ( BSL_SAL_LibFmtCmd cmd,
const char * fileName,
char ** name )

Convert filename to full library path for dl.

Convert filename to full library name for dl according to the specified format and directory.

注意
None.
参数
cmd[IN] Command specifying the conversion format.
fileName[IN] Original filename.
name[OUT] Pointer to store the converted full name.
返回值
Ifthe operation is successful, BSL_OK is returned; Otherwise, an error code is returned.

◆ BSL_SAL_LoadLib()

int32_t BSL_SAL_LoadLib ( const char * fileName,
void ** handle )

Load a dynamic library for dl.

Load a dynamic library for dl.

注意
None.
参数
fileName[IN] Name of the file to be loaded.
handle[OUT] Pointer to store the handle of the loaded library.
返回值
Ifthe operation is successful, BSL_SUCCESS is returned; Otherwise, an error code is returned.

◆ BSL_SAL_Malloc()

void * BSL_SAL_Malloc ( uint32_t size)

Allocate memory space.

Allocate memory space.

注意
None
参数
size[IN] Size of the allocated memory
返回值
Ifthe application is successful, returned the pointer pointing to the memory.
Ifthe application failed, return NULL.

◆ BSL_SAL_Memchr()

void * BSL_SAL_Memchr ( const char * str,
int32_t character,
size_t count )

Search for the corresponding character position in a string.

Search for the corresponding character position in a string.

注意
None.
参数
str[IN] String
character[IN] Character to be searched for
count[IN] Range to be found
返回值
Ifa character is found, the position of the character is returned; Otherwise, NULL is returned.

◆ BSL_SAL_Realloc()

void * BSL_SAL_Realloc ( void * addr,
uint32_t newSize,
uint32_t oldSize )

Memory expansion

Memory expansion function.

注意
None.
参数
addr[IN] Original memory address.
newSize[IN] Extended memory size.
oldSize[IN] Memory size before expansion.
返回值
void*indicates successful, the extended memory address is returned.
NULLindicates failed, return NULL.

◆ BSL_SAL_Select()

int32_t BSL_SAL_Select ( int32_t nfds,
void * readfds,
void * writefds,
void * exceptfds,
void * timeout )

Check the socket descriptor.

Check the socket descriptor.

注意
None
参数
nfds[IN] Total number of file descriptors that are listened on
readfds[IN] Readable file descriptor (optional)
writefds[IN] Descriptor of a writable file. This parameter is optional.
exceptfds[IN] Exception file descriptor (optional)
timeout[IN] Set the timeout interval.
返回值
Ifthe operation succeeds, Number of ready descriptors are returned;
Ifthe operation fails, a negative value is returned;
Ifthe operation times out, 0 is returned

◆ BSL_SAL_SetSockopt()

int32_t BSL_SAL_SetSockopt ( int32_t sockId,
int32_t level,
int32_t name,
const void * val,
int32_t len )

Set the socket

Set the socket

注意
none
参数
sockId[IN] Socket file descriptor ID
level[IN] Level of the option to be set.
name[IN] Options to be set
val[IN] Value of the option.
len[IN] val Length
返回值
Ifthe operation succeeds, BSL_SUCCESS is returned
Ifthe operation fails, BSL_SAL_ERR_NET_SETSOCKOPT is returned.

◆ BSL_SAL_Sleep()

void BSL_SAL_Sleep ( uint32_t time)

Sleep the current thread

Sleep the current thread

注意
none
参数
time[IN] Sleep time

◆ BSL_SAL_SockBind()

int32_t BSL_SAL_SockBind ( int32_t sockId,
BSL_SAL_SockAddr addr,
size_t len )

Binding a socket

Binding Socket

注意
None
参数
sockId[IN] Socket file descriptor ID
addr[IN] Specify the address.
len[IN] Address length
返回值
Ifthe operation succeeds, BSL_SUCCESS is returned.
Ifthe operation fails, BSL_SAL_ERR_NET_BIND is returned.

◆ BSL_SAL_SockClose()

int32_t BSL_SAL_SockClose ( int32_t sockId)

Close the socket

Close the socket

注意
none
参数
sockId[IN] Socket file descriptor ID
返回值
Ifthe operation succeeds, BSL_SUCCESS is returned.
Ifthe operation fails, BSL_SAL_ERR_NET_SOCKCLOSE is returned.

◆ BSL_SAL_SockConnect()

int32_t BSL_SAL_SockConnect ( int32_t sockId,
BSL_SAL_SockAddr addr,
size_t len )

Initiate a connection.

Initiate a connection.

注意
none
参数
sockId[IN] Socket file descriptor ID
addr[IN] Address to be connected
len[IN] Address length
返回值
Ifthe operation succeeds, BSL_SUCCESS is returned
Ifthe operation fails, BSL_SAL_ERR_NET_CONNECT is returned.

◆ BSL_SAL_Socket()

int32_t BSL_SAL_Socket ( int32_t af,
int32_t type,
int32_t protocol )

Socket creation interface

Socket creation interface.

注意
none
参数
af[IN] Socket specifies the protocol set.
type[IN] Socket type
protocol[IN] Protocol type
返回值
Ifthe creation is successful, a non-negative value is returned.
Otherwise,anegative value is returned.

◆ BSL_SAL_SockGetLastSocketError()

int32_t BSL_SAL_SockGetLastSocketError ( void )

Obtain the last error corresponding to the socket.

Obtain the last error corresponding to the socket.

注意
none
返回值
Returnthe corresponding error.

◆ BSL_SAL_SockListen()

int32_t BSL_SAL_SockListen ( int32_t sockId,
int32_t backlog )

Listening socket

Listen socket

注意
none
参数
sockId[IN] Socket file descriptor ID
backlog[IN] Length of the receiving queue
返回值
Ifthe operation succeeds, BSL_SUCCESS is returned.
Ifthe operation fails, BSL_SAL_ERR_NET_LISTEN is returned.

◆ BSL_SAL_SockRecv()

int32_t BSL_SAL_SockRecv ( int32_t sockfd,
void * buff,
size_t len,
int32_t flags )

Receive the message.

Receive information

注意
none
参数
sockfd[IN] Socket file descriptor ID
buff[IN] Buffer for receiving information
len[IN] Length of the buffer
flags[IN] is generally set to 0.
返回值
Ifthe operation succeeds, the received data length is returned.
Ifthe operation fails, a negative value is returned.
Ifthe operation times out or the peer end disables the function, the value 0 is returned.

◆ BSL_SAL_SockSend()

int32_t BSL_SAL_SockSend ( int32_t sockId,
const void * msg,
size_t len,
int32_t flags )

Send a message.

Send messages

注意
none
参数
sockId[IN] Socket file descriptor ID
msg[IN] Message sent
len[IN] Information length
flags[IN] is generally set to 0.
返回值
Ifthe operation succeeds, the length of the sent data is returned.
Ifthe operation fails, a negative value is returned.
Ifthe operation times out or the peer end disables the function, the value 0 is returned.

◆ BSL_SAL_StrcaseCmp()

int32_t BSL_SAL_StrcaseCmp ( const char * str1,
const char * str2 )

String comparison

String comparison

注意
None.
参数
str1[IN] First string to be compared.
str2[IN] Second string to be compared.
返回值
Ifthe parameter is abnormal, BSL_NULL_INPUT is returned.
Ifthe strings are the same, 0 is returned; Otherwise, the difference between different characters is returned.

◆ BSL_SAL_Strnlen()

uint32_t BSL_SAL_Strnlen ( const char * string,
uint32_t count )

Obtain the length of a given string.

Obtain the length of a given string.

注意
None.
参数
string[IN] String to obtain the length.
count[IN] Maximum length
返回值
Ifthe parameter is abnormal, return 0.
Ifthe length of a string is greater than the count, return count. Otherwise, the actual length of the string is returned.

◆ BSL_SAL_SysTimeFuncReg()

void BSL_SAL_SysTimeFuncReg ( BslTimeFunc func)

Interface for registering the function for obtaining the system time You can use this API to register the system time obtaining function.

This interface can be registered for multiple times. After the registration is successful, the registration cannot be NULL again. Description of the time range: Users can use the Linux system at most 2038 per year. The lower limit of the time is 1970 - 1 - 1 0: 0: 0. It is recommended that users use this minimum intersection, i.e., the bounds of years are 1970-1-1 0:0:0 ~ 2038-01-19 03:14:08.

参数
func[IN] Register the function for obtaining the system time

◆ BSL_SAL_SysTimeGet()

int32_t BSL_SAL_SysTimeGet ( BSL_TIME * sysTime)

Obtain the system time.

Obtain the system time.

注意
none
参数
sysTime[out] Time
返回值
BSL_SUCCESS,obtainedthe time successfully.
BSL_SAL_ERR_BAD_PARAM,thevalue of cb is null.
BSL_INTERNAL_EXCEPTION,anexception occurred when obtaining the time.

◆ BSL_SAL_ThreadClose()

void BSL_SAL_ThreadClose ( BSL_SAL_ThreadId thread)

Close the thread.

Close the thread.

注意
none
参数
thread[IN] Thread ID

◆ BSL_SAL_ThreadCreate()

int32_t BSL_SAL_ThreadCreate ( BSL_SAL_ThreadId * thread,
void *(* startFunc )(void *),
void * arg )

Create a thread.

Create a thread.

注意
none
参数
thread[IN/OUT] Thread ID
startFunc[IN] Thread function
arg[IN] Thread function parameters
返回值
BSL_SUCCESS,createdsuccessfully.
BSL_SAL_ERR_UNKNOWN,Failedto create a thread.
BSL_SAL_ERR_BAD_PARAM,parametererror.

◆ BSL_SAL_ThreadGetId()

uint64_t BSL_SAL_ThreadGetId ( void )

Obtain the thread ID.

Obtain the thread ID.

注意
none
返回值
ThreadID

◆ BSL_SAL_ThreadLockFree()

void BSL_SAL_ThreadLockFree ( BSL_SAL_ThreadLockHandle lock)

Release the thread lock.

Release the thread lock.

注意
By default, repeated release is prohibited.
参数
lock[IN] Lock handle.

◆ BSL_SAL_ThreadLockNew()

int32_t BSL_SAL_ThreadLockNew ( BSL_SAL_ThreadLockHandle * lock)

Create a thread lock.

Create a thread lock.

注意
none
参数
lock[IN/OUT] Lock handle
返回值
BSL_SUCCESS,createdsuccessfully.
BSL_MALLOC_FAIL,memoryspace is insufficient and failed to apply for process lock space.
BSL_SAL_ERR_UNKNOWN,threadlock initialization failed.
BSL_SAL_ERR_BAD_PARAM,parametererror, the value of lock is NULL.

◆ BSL_SAL_ThreadReadLock()

int32_t BSL_SAL_ThreadReadLock ( BSL_SAL_ThreadLockHandle lock)

Lock the read operation.

Lock the read operation.

注意
none
参数
lock[IN] Lock handle
返回值
BSL_SUCCESS,succeeded.
BSL_SAL_ERR_UNKNOWN,operationfailed.
BSL_SAL_ERR_BAD_PARAM,parametererror. The value of lock is NULL.

◆ BSL_SAL_ThreadRunOnce()

int32_t BSL_SAL_ThreadRunOnce ( BSL_SAL_OnceControl * onceControl,
BSL_SAL_ThreadInitRoutine initFunc )

Execute only once.

Run the init Func command only once in a thread-safe manner. Uses platform-native once mechanism (pthread_once on POSIX).

注意
The current version does not support registration.
参数
onceControl[IN] Once control variable initialized with BSL_SAL_ONCE_INIT.
initFunc[IN] Initialization function.
返回值
BSL_SUCCESS,succeeded.
BSL_SAL_ERR_BAD_PARAM,inputparameter is abnormal.
BSL_SAL_ERR_UNKNOWN,thedefault run once failed.

◆ BSL_SAL_ThreadUnlock()

int32_t BSL_SAL_ThreadUnlock ( BSL_SAL_ThreadLockHandle lock)

Unlock

Unlock

注意
unlock: Locks that have been unlocked are undefined behavior and are not allowed by default.
参数
lock[IN] Lock handle
返回值
BSL_SUCCESS,succeeded.
BSL_SAL_ERR_UNKNOWNoperation failed.
BSL_SAL_ERR_BAD_PARAMparameter error. The value of lock is NULL.

◆ BSL_SAL_ThreadWriteLock()

int32_t BSL_SAL_ThreadWriteLock ( BSL_SAL_ThreadLockHandle lock)

Lock the write operation.

Lock the write operation.

注意
none
参数
lock[IN] Lock handle
返回值
BSL_SUCCESS,succeeded.
BSL_SAL_ERR_UNKNOWN,operationfailed.
BSL_SAL_ERR_BAD_PARAM,parametererror. The value of lock is NULL.

◆ BSL_SAL_Tick()

long BSL_SAL_Tick ( void )

Obtain the number of ticks that the system has experienced since startup.

Obtain the system time.

注意
none
返回值
Numberof ticks

◆ BSL_SAL_TicksPerSec()

long BSL_SAL_TicksPerSec ( void )

Obtain the number of system ticks per second.

Obtain the system time.

注意
none
返回值
Numberof ticks per second

◆ BSL_SAL_TIME_GetNSec()

uint64_t BSL_SAL_TIME_GetNSec ( void )

Get the system time in nanoseconds.

注意
none
返回值
Thetime in nanoseconds.

◆ BSL_SAL_UnLoadLib()

int32_t BSL_SAL_UnLoadLib ( void * handle)

Unload a dynamic library for dl.

Unload a dynamic library for dl.

注意
None.
参数
handle[IN] Handle of the library to be unloaded.
返回值
Ifthe operation is successful, BSL_SUCCESS is returned; Otherwise, an error code is returned.

◆ BSL_SAL_UtcTimeToDateConvert()

int32_t BSL_SAL_UtcTimeToDateConvert ( int64_t utcTime,
BSL_TIME * sysTime )

Convert the date in the BslUnixTime format to the BslSysTime format.

Convert the date in the BslUnixTime format to the BslSysTime format.

注意
none
参数
utcTime[IN] UTC time
sysTime[OUT] BslSysTime Time
返回值
BSL_SUCCESS,timeis converted successfully
BSL_SAL_ERR_BAD_PARAM,thevalue of utcTime exceeds the upper limit or the value of sysTime is null.

变量说明

◆ pfFree

void(* MemCallback::pfFree) (void *addr)

Reclaim a memory block allocated by pfMalloc.

Reclaim a block of memory allocated by pfMalloc.

参数
addr[IN] Start address of the memory allocated by pfMalloc.

◆ pfGetId

int32_t(* PidCallback::pfGetId) (void)

Obtain the process ID.

Obtain the process ID.

返回值
ProcessID

◆ pfMalloc

void *(* MemCallback::pfMalloc) (uint32_t size)

Allocate a memory block.

Allocate a memory block.

参数
size[IN] Size of the allocated memory.
返回值
Not NULL, The start address of the allocated memory when memory is allocated successfully.
NULL,Memoryallocation failure.

◆ pfThreadGetId

uint64_t(* ThreadCallback::pfThreadGetId) (void)

Obtain the thread ID.

Obtain the thread ID.

返回值
ThreadID

◆ pfThreadLockFree

void(* ThreadCallback::pfThreadLockFree) (BSL_SAL_ThreadLockHandle lock)

Release the thread lock.

Release the thread lock. Ensure that the lock can be released when other threads obtain the lock.

参数
lock[IN] Lock handle

◆ pfThreadLockNew

int32_t(* ThreadCallback::pfThreadLockNew) (BSL_SAL_ThreadLockHandle *lock)

Create a thread lock.

Create a thread lock.

参数
lock[IN/OUT] Lock handle
返回值
BSL_SUCCESS,createdsuccessfully.
BSL_MALLOC_FAIL,memoryspace is insufficient and thread lock space cannot be applied for.
BSL_SAL_ERR_UNKNOWN,threadlock initialization failed.
BSL_SAL_ERR_BAD_PARAM,parametererror. The value of lock is NULL.

◆ pfThreadReadLock

int32_t(* ThreadCallback::pfThreadReadLock) (BSL_SAL_ThreadLockHandle lock)

Lock the read operation.

Lock the read operation.

参数
lock[IN] Lock handle
返回值
BSL_SUCCESS,succeeded.
BSL_SAL_ERR_UNKNOWN,operationfailed.
BSL_SAL_ERR_BAD_PARAM,parametererror. The value of lock is NULL.

◆ pfThreadUnlock

int32_t(* ThreadCallback::pfThreadUnlock) (BSL_SAL_ThreadLockHandle lock)

Unlock

Unlock

参数
lock[IN] Lock handle
返回值
BSL_SUCCESS,succeeded.
BSL_SAL_ERR_UNKNOWN,operationfailed.
BSL_SAL_ERR_BAD_PARAM,parametererror. The value of lock is NULL.

◆ pfThreadWriteLock

int32_t(* ThreadCallback::pfThreadWriteLock) (BSL_SAL_ThreadLockHandle lock)

Lock the write operation.

Lock the write operation.

参数
lock[IN] Lock handle
返回值
BSL_SUCCESS,succeeded.
BSL_SAL_ERR_UNKNOWN,operationfailed.
BSL_SAL_ERR_BAD_PARAM,parametererror. The value of lock is NULL.