![]() |
API参考
|
System Abstraction Layer 更多...

类 | |
| 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
| #define BSL_SAL_DECLARE_THREAD_ONCE | ( | name | ) |
Macro to declare thread run-once control variable
Uses platform-native once mechanism (pthread_once on POSIX).
Usage:
| typedef void* BSL_SAL_CondVar |
Condition handle, the corresponding structure is provided by the user during registration.
| typedef struct MemCallback BSL_SAL_MemCallback |
Registrable function structure for memory allocation/release.
| typedef void* BSL_SAL_Mutex |
mutex
| typedef void* BSL_SAL_ThreadId |
Thread handle, the corresponding structure is provided by the user during registration.
| typedef void(* BSL_SAL_ThreadInitRoutine) (void) |
The user registers the function structure for thread-related operations.
run once: Use the initialization callback.
| typedef void* BSL_SAL_ThreadLockHandle |
Thread lock handle, the corresponding structure is provided by the user during registration.
| typedef int32_t(* BslCondSignal) (BSL_SAL_CondVar condVar) |
The waiting time ends or the signal is obtained.
| condVar | [IN] Condition variable |
| BSL_SUCCESS,success. | |
| Otherwise,failure. |
| typedef int32_t(* BslCondTimedwaitMs) (BSL_SAL_Mutex condMutex, BSL_SAL_CondVar condVar, int32_t timeout) |
The waiting time ends or the signal is obtained.
| condMutex | [IN] Mutex |
| condVar | [IN] Condition variable |
| timeout | [IN] Time |
| BSL_SUCCESS,success. | |
| Otherwise,failure. |
| typedef int32_t(* BslCreateCondVar) (BSL_SAL_CondVar *condVar) |
Create a condition variable.
| condVar | [IN] Condition variable |
| BSL_SUCCESS,success. | |
| Otherwise,failure. |
| typedef int32_t(* BslDeleteCondVar) (BSL_SAL_CondVar condVar) |
Delete a condition variable.
| condVar | [IN] Condition variable |
| BSL_SUCCESS,success. | |
| Otherwise,failure. |
| typedef int32_t(* BslDlClose) (void *handle) |
Close dynamic library.
Close dynamic library.
| handle | [IN] Dynamic library handle |
| BSL_SUCCESS | Succeeded. |
| BSL_SAL_ERR_DL_UNLOAAD_FAIL | Failed to unload the library. |
| 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_SUCCESS | Succeeded. |
| BSL_SAL_ERR_DL_NOT_FOUND | Library file not found. |
| BSL_SAL_DL_NO_REG_FUNC | Failed to load the library. |
| 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_SUCCESS | Succeeded. |
| BSL_SAL_ERR_DL_NON_FUNCTION | Symbol found but is not a function. |
| BSL_SAL_ERR_DL_LOOKUP_METHOD | Failed to lookup the function. |
| 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. |
| typedef int32_t(* BslGetErrno) (void) |
return "errno"
| typedef uint64_t(* BslGetTimeInNS) (void) |
Obtain the system time in nanoseconds.
| typedef BslUnixTime(* BslGetUtcTime) (void) |
Obtains the current UTC time
Definition of the time callback interface.
| 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. |
| 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. |
| 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. |
| 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. |
| typedef void(* BslSalFileClose) (bsl_sal_file_handle stream) |
Close the file.
| stream | [IN] The file handle representing the file to be closed. |
| 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. |
| 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. |
| 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. |
| 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. |
| 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. |
| 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. |
| 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. |
| 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. |
| 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. |
| 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. |
| 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_SUCCESS | Succeeded. |
| BSL_SAL_ERR_DL_NON_FUNCTION | Symbol found but is not a function. |
| BSL_SAL_ERR_DL_LOOKUP_METHOD | Failed to lookup the function. |
| 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. |
| 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. |
| 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_SUCCESS | Succeeded. |
| BSL_SAL_ERR_DL_NOT_FOUND | Library file not found. |
| BSL_SAL_ERR_DL_LOAD_FAIL | Failed to load the library. |
| typedef int32_t(* BslSalNetClose) (int32_t fd) |
Close file descriptor.
| fd | [IN] File descriptor. |
| typedef int64_t(* BslSalNetLSeek) (int32_t fd, int64_t offset, uint32_t origin) |
Seek interface.
| 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. |
| typedef int32_t(* BslSalNetOpen) (const char *path, int32_t flag) |
Close file descriptor.
| path | [IN] File path. |
| flag | [IN] open mode. |
| typedef int32_t(* BslSalNetRead) (int32_t fd, void *buf, uint32_t len, int32_t *err) |
Read data from file descriptor.
| fd | [IN] File descriptor. |
| buffer | [OUT] The read data buffer. |
| len | [IN] The len which want to read. |
| err | [OUT] The IO errno. |
| 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). |
| 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). |
| 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.
| fd | [IN] File descriptor. |
| buffer | [IN] The write data buffer. |
| len | [IN] The len which want to write. |
| err | [OUT] The IO errno. |
| 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. |
| 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. |
| 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 |
| typedef void(* BslSalSockAddrFree) (BSL_SAL_SockAddr sockAddr) |
Release the UIO_Addr object.
| uioAddr | [IN] UIO_Addr object |
| typedef int32_t(* BslSalSockAddrGetFamily) (const BSL_SAL_SockAddr sockAddr) |
Obtain the UIO_Addr protocal family
| sockAddr | [IN] UIO_Addr object |
| Return | 0 if the address is not valid. |
| Return | SAL_IPV4 if the address is IPv4. |
| Return | SAL_IPV6 if the address is IPv6. |
| typedef int32_t(* BslSalSockAddrNew) (BSL_SAL_SockAddr *sockAddr) |
Create a BSL_SAL_SockAddr
| 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 |
| Address | size, if the address is not valid, return 0 |
| 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. |
| typedef int32_t(* BslSalSockClose) (int32_t sockId) |
Socket close interface.
| sockId | [IN] The identifier of the socket to be closed. |
| 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. |
| 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. |
| 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. |
| 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. |
| 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. |
| typedef int32_t(* BslSalUnLoadLib) (void *handle) |
Close dynamic library.
Close dynamic library.
| handle | [IN] Dynamic library handle |
| BSL_SUCCESS | Succeeded. |
| BSL_SAL_ERR_DL_UNLOAAD_FAIL | Failed to unload the library. |
| 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. |
| 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. |
| typedef void(* BslSleep) (uint32_t time) |
Sets the program to sleep for a specified time, in seconds.
| time | [IN] Sleep time. |
| typedef int32_t(* BslSocketError) (int32_t fd) |
Get the error code of the socket.
| fd | [IN] The file descriptor of the socket to query. |
| 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. |
| typedef void(* BslThreadClose) (BSL_SAL_ThreadId thread) |
Close the thread.
| thread | [IN] Thread ID |
| typedef int32_t(* BslThreadCreate) (BSL_SAL_ThreadId *thread, void *(*startFunc)(void *), void *arg) |
Create a thread.
| thread | [IN/OUT] Thread ID |
| startFunc | [IN] Thread function |
| arg | [IN] Thread function parameters |
| BSL_SUCCESS,success. | |
| Otherwise,failure. |
| 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. |
| 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 BslUnixTime(* BslTimeFunc) (void) |
Prototype of the callback function for obtaining the time
Prototype definition of the callback function for obtaining the time.
| 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. |
| int32_t BSL_SAL_Atoi | ( | const char * | str | ) |
Convert string to number
Convert string to number
| str | [IN] String to be converted. |
| If | the conversion is successful, the corresponding number is returned; Otherwise, the value 0 is returned. |
| 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.
| funcType | [IN] Type of the callback function to be controlled |
| funcCb | [IN] Pointer to the callback function |
| BSL_SUCCESS | Callback function controlled successfully |
| BSL_SAL_ERR_BAD_PARAM | Invalid function type or callback pointer |
| Other | error codes specific to the SAL module |
| 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 | [IN] Number of allocated memory. |
| size | [IN] Size of each memory. |
| If | the application is successful, returned the pointer pointing to the memory. |
| If | the application failed, return NULL. |
| 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 |
| 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 |
| 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.
| condVar | [IN] Condition variable |
| BSL_SUCCESS,succeeded. | |
| BSL_SAL_ERR_UNKNOWN,function | failure |
| BSL_SAL_ERR_BAD_PARAM,parameter | error. The value of condVar is NULL. |
| 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.
| condMutex | [IN] Mutex |
| condVar | [IN] Condition variable |
| timeout | [IN] Time |
| BSL_SUCCESS,succeeded. | |
| BSL_SAL_ERR_UNKNOWN,fails. | |
| BSL_SAL_ERR_BAD_PARAM,parameter | error. The value of condMutex or condVar is null. |
| int32_t BSL_SAL_CreateCondVar | ( | BSL_SAL_CondVar * | condVar | ) |
Create a condition variable.
Create a condition variable.
| condVar | [IN] Condition variable |
| BSL_SUCCESS,created | successfully. |
| BSL_SAL_ERR_UNKNOWN,failed | to create a condition variable. |
| BSL_SAL_ERR_BAD_PARAM,parameter | error. The value of condVar is NULL. |
| BslUnixTime BSL_SAL_CurrentSysTimeGet | ( | void | ) |
Obtain the Unix time.
Obtain the Unix time.
| Return | the Unix time. |
| 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 |
| BslTimeCmpResult | Comparison 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 |
Compare two dates, accurate to microseconds.
Compare two dates, accurate to microseconds
| dateA | [IN] Time |
| dateB | [IN] Time |
| #BslTimeCmpResult | Comparison 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 |
| 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.
| dateTime | [IN] Date and time |
| utcTime | [OUT] UTC time |
| BSL_SUCCESS,time | is successfully converted. |
| BSL_INTERNAL_EXCEPTION,an | exception occurred when obtaining the time. |
| int32_t BSL_SAL_DeleteCondVar | ( | BSL_SAL_CondVar | condVar | ) |
Delete a condition variable.
Delete a condition variable.
| condVar | [IN] Condition variable |
| BSL_SUCCESS,Succeeded | in deleting the condition variable. |
| BSL_SAL_ERR_UNKNOWN,Failed | to delete the condition variable. |
| BSL_SAL_ERR_BAD_PARAM,parameter | error. The value of condVar is NULL. |
| void * BSL_SAL_Dump | ( | const void * | src, |
| uint32_t | size ) |
Duplicate the memory space.
| src | Source memory address |
| size | Total memory size |
| If | the allocation is successful, returned the pointer pointing to the memory. |
| If | the allocation failed, return NULL. |
| void BSL_SAL_FileClose | ( | bsl_sal_file_handle | stream | ) |
Close the file.
Close the file.
| stream | [IN] File handle |
| NA |
| int32_t BSL_SAL_FileLength | ( | const char * | path, |
| size_t * | len ) |
Obtain the file length.
Obtain the file length.
| path | [IN] File path |
| len | [OUT] File length |
| BSL_SUCCESS,succeeded | |
| BSL_SAL_ERR_UNKNOWN,fails | |
| BSL_NULL_INPUT,parameter | error |
| 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.
| stream | [OUT] File handle |
| path | [IN] File path |
| mode | [IN] Reading mode |
| BSL_SUCCESS,succeeded. | |
| BSL_SAL_ERR_FILE_OPEN,failed | to be opened. |
| BSL_NULL_INPUT,parameter | error. |
| 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'.
| 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,Incorrect | parameter |
| int32_t BSL_SAL_FileWrite | ( | bsl_sal_file_handle | stream, |
| const void * | buffer, | ||
| size_t | size, | ||
| size_t | num ) |
Write a file
Write File
| 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,parameter | error |
| void BSL_SAL_Free | ( | void * | value | ) |
Release the specified memory.
Release the specified memory.
| value | [IN] Pointer to the memory space to be released. |
| 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.
| handle | [IN] Handle of the loaded library. |
| funcName | [IN] Name of the function. |
| func | [OUT] Pointer to store the address of the function. |
| If | the operation is successful, BSL_SUCCESS is returned; Otherwise, an error code is returned. |
| int32_t BSL_SAL_GetPid | ( | void | ) |
Obtain the process ID.
Obtain the process ID.
| Process | ID |
| 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
| 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 |
| If | the operation succeeds, BSL_SUCCESS is returned |
| int32_t BSL_SAL_Ioctlsocket | ( | int32_t | sockId, |
| long | cmd, | ||
| unsigned long * | arg ) |
Device control interface function
Device control interface function
| sockId | [IN] Socket file descriptor ID |
| cmd | [IN] Interaction protocol |
| arg | [IN] Parameter |
| If | the operation succeeds, BSL_SUCCESS is returned. |
| If | the operation fails, BSL_SAL_ERR_NET_IOCTL is returned. |
| 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.
| cmd | [IN] Command specifying the conversion format. |
| fileName | [IN] Original filename. |
| name | [OUT] Pointer to store the converted full name. |
| If | the operation is successful, BSL_OK is returned; Otherwise, an error code is returned. |
| int32_t BSL_SAL_LoadLib | ( | const char * | fileName, |
| void ** | handle ) |
Load a dynamic library for dl.
Load a dynamic library for dl.
| fileName | [IN] Name of the file to be loaded. |
| handle | [OUT] Pointer to store the handle of the loaded library. |
| If | the operation is successful, BSL_SUCCESS is returned; Otherwise, an error code is returned. |
| void * BSL_SAL_Malloc | ( | uint32_t | size | ) |
Allocate memory space.
Allocate memory space.
| size | [IN] Size of the allocated memory |
| If | the application is successful, returned the pointer pointing to the memory. |
| If | the application failed, return NULL. |
| 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.
| str | [IN] String |
| character | [IN] Character to be searched for |
| count | [IN] Range to be found |
| If | a character is found, the position of the character is returned; Otherwise, NULL is returned. |
| void * BSL_SAL_Realloc | ( | void * | addr, |
| uint32_t | newSize, | ||
| uint32_t | oldSize ) |
Memory expansion
Memory expansion function.
| 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. |
| NULL | indicates failed, return NULL. |
| int32_t BSL_SAL_Select | ( | int32_t | nfds, |
| void * | readfds, | ||
| void * | writefds, | ||
| void * | exceptfds, | ||
| void * | timeout ) |
Check the socket descriptor.
Check the socket descriptor.
| 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. |
| If | the operation succeeds, Number of ready descriptors are returned; |
| If | the operation fails, a negative value is returned; |
| If | the operation times out, 0 is returned |
| 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
| 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 |
| If | the operation succeeds, BSL_SUCCESS is returned |
| If | the operation fails, BSL_SAL_ERR_NET_SETSOCKOPT is returned. |
| void BSL_SAL_Sleep | ( | uint32_t | time | ) |
Sleep the current thread
Sleep the current thread
| time | [IN] Sleep time |
| int32_t BSL_SAL_SockBind | ( | int32_t | sockId, |
| BSL_SAL_SockAddr | addr, | ||
| size_t | len ) |
Binding a socket
Binding Socket
| sockId | [IN] Socket file descriptor ID |
| addr | [IN] Specify the address. |
| len | [IN] Address length |
| If | the operation succeeds, BSL_SUCCESS is returned. |
| If | the operation fails, BSL_SAL_ERR_NET_BIND is returned. |
| int32_t BSL_SAL_SockClose | ( | int32_t | sockId | ) |
Close the socket
Close the socket
| sockId | [IN] Socket file descriptor ID |
| If | the operation succeeds, BSL_SUCCESS is returned. |
| If | the operation fails, BSL_SAL_ERR_NET_SOCKCLOSE is returned. |
| int32_t BSL_SAL_SockConnect | ( | int32_t | sockId, |
| BSL_SAL_SockAddr | addr, | ||
| size_t | len ) |
Initiate a connection.
Initiate a connection.
| sockId | [IN] Socket file descriptor ID |
| addr | [IN] Address to be connected |
| len | [IN] Address length |
| If | the operation succeeds, BSL_SUCCESS is returned |
| If | the operation fails, BSL_SAL_ERR_NET_CONNECT is returned. |
| int32_t BSL_SAL_Socket | ( | int32_t | af, |
| int32_t | type, | ||
| int32_t | protocol ) |
Socket creation interface
Socket creation interface.
| af | [IN] Socket specifies the protocol set. |
| type | [IN] Socket type |
| protocol | [IN] Protocol type |
| If | the creation is successful, a non-negative value is returned. |
| Otherwise,a | negative value is returned. |
| int32_t BSL_SAL_SockGetLastSocketError | ( | void | ) |
Obtain the last error corresponding to the socket.
Obtain the last error corresponding to the socket.
| Return | the corresponding error. |
| int32_t BSL_SAL_SockListen | ( | int32_t | sockId, |
| int32_t | backlog ) |
Listening socket
Listen socket
| sockId | [IN] Socket file descriptor ID |
| backlog | [IN] Length of the receiving queue |
| If | the operation succeeds, BSL_SUCCESS is returned. |
| If | the operation fails, BSL_SAL_ERR_NET_LISTEN is returned. |
| int32_t BSL_SAL_SockRecv | ( | int32_t | sockfd, |
| void * | buff, | ||
| size_t | len, | ||
| int32_t | flags ) |
Receive the message.
Receive information
| 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. |
| 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. |
| int32_t BSL_SAL_SockSend | ( | int32_t | sockId, |
| const void * | msg, | ||
| size_t | len, | ||
| int32_t | flags ) |
Send a message.
Send messages
| sockId | [IN] Socket file descriptor ID |
| msg | [IN] Message sent |
| len | [IN] Information length |
| flags | [IN] is generally set to 0. |
| 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. |
| int32_t BSL_SAL_StrcaseCmp | ( | const char * | str1, |
| const char * | str2 ) |
String comparison
String comparison
| str1 | [IN] First string to be compared. |
| str2 | [IN] Second string to be compared. |
| If | the parameter is abnormal, BSL_NULL_INPUT is returned. |
| If | the strings are the same, 0 is returned; Otherwise, the difference between different characters is returned. |
| 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.
| string | [IN] String to obtain the length. |
| count | [IN] Maximum length |
| If | the parameter is abnormal, return 0. |
| If | the length of a string is greater than the count, return count. Otherwise, the actual length of the string is returned. |
| 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 |
| int32_t BSL_SAL_SysTimeGet | ( | BSL_TIME * | sysTime | ) |
Obtain the system time.
Obtain the system time.
| sysTime | [out] Time |
| BSL_SUCCESS,obtained | the time successfully. |
| BSL_SAL_ERR_BAD_PARAM,the | value of cb is null. |
| BSL_INTERNAL_EXCEPTION,an | exception occurred when obtaining the time. |
| void BSL_SAL_ThreadClose | ( | BSL_SAL_ThreadId | thread | ) |
Close the thread.
Close the thread.
| thread | [IN] Thread ID |
| int32_t BSL_SAL_ThreadCreate | ( | BSL_SAL_ThreadId * | thread, |
| void *(* | startFunc )(void *), | ||
| void * | arg ) |
Create a thread.
Create a thread.
| thread | [IN/OUT] Thread ID |
| startFunc | [IN] Thread function |
| arg | [IN] Thread function parameters |
| BSL_SUCCESS,created | successfully. |
| BSL_SAL_ERR_UNKNOWN,Failed | to create a thread. |
| BSL_SAL_ERR_BAD_PARAM,parameter | error. |
| uint64_t BSL_SAL_ThreadGetId | ( | void | ) |
Obtain the thread ID.
Obtain the thread ID.
| Thread | ID |
| void BSL_SAL_ThreadLockFree | ( | BSL_SAL_ThreadLockHandle | lock | ) |
Release the thread lock.
Release the thread lock.
| lock | [IN] Lock handle. |
| int32_t BSL_SAL_ThreadLockNew | ( | BSL_SAL_ThreadLockHandle * | lock | ) |
Create a thread lock.
Create a thread lock.
| lock | [IN/OUT] Lock handle |
| BSL_SUCCESS,created | successfully. |
| BSL_MALLOC_FAIL,memory | space is insufficient and failed to apply for process lock space. |
| BSL_SAL_ERR_UNKNOWN,thread | lock initialization failed. |
| BSL_SAL_ERR_BAD_PARAM,parameter | error, the value of lock is NULL. |
| int32_t BSL_SAL_ThreadReadLock | ( | BSL_SAL_ThreadLockHandle | lock | ) |
Lock the read operation.
Lock the read operation.
| lock | [IN] Lock handle |
| BSL_SUCCESS,succeeded. | |
| BSL_SAL_ERR_UNKNOWN,operation | failed. |
| BSL_SAL_ERR_BAD_PARAM,parameter | error. The value of lock is NULL. |
| 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).
| onceControl | [IN] Once control variable initialized with BSL_SAL_ONCE_INIT. |
| initFunc | [IN] Initialization function. |
| BSL_SUCCESS,succeeded. | |
| BSL_SAL_ERR_BAD_PARAM,input | parameter is abnormal. |
| BSL_SAL_ERR_UNKNOWN,the | default run once failed. |
| int32_t BSL_SAL_ThreadUnlock | ( | BSL_SAL_ThreadLockHandle | lock | ) |
Unlock
Unlock
| lock | [IN] Lock handle |
| BSL_SUCCESS,succeeded. | |
| BSL_SAL_ERR_UNKNOWN | operation failed. |
| BSL_SAL_ERR_BAD_PARAM | parameter error. The value of lock is NULL. |
| int32_t BSL_SAL_ThreadWriteLock | ( | BSL_SAL_ThreadLockHandle | lock | ) |
Lock the write operation.
Lock the write operation.
| lock | [IN] Lock handle |
| BSL_SUCCESS,succeeded. | |
| BSL_SAL_ERR_UNKNOWN,operation | failed. |
| BSL_SAL_ERR_BAD_PARAM,parameter | error. The value of lock is NULL. |
| long BSL_SAL_Tick | ( | void | ) |
Obtain the number of ticks that the system has experienced since startup.
Obtain the system time.
| Number | of ticks |
| long BSL_SAL_TicksPerSec | ( | void | ) |
Obtain the number of system ticks per second.
Obtain the system time.
| Number | of ticks per second |
| uint64_t BSL_SAL_TIME_GetNSec | ( | void | ) |
Get the system time in nanoseconds.
| The | time in nanoseconds. |
| int32_t BSL_SAL_UnLoadLib | ( | void * | handle | ) |
Unload a dynamic library for dl.
Unload a dynamic library for dl.
| handle | [IN] Handle of the library to be unloaded. |
| If | the operation is successful, BSL_SUCCESS is returned; Otherwise, an error code is returned. |
| 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.
| utcTime | [IN] UTC time |
| sysTime | [OUT] BslSysTime Time |
| BSL_SUCCESS,time | is converted successfully |
| BSL_SAL_ERR_BAD_PARAM,the | value of utcTime exceeds the upper limit or the value of sysTime is null. |
| 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. |
| int32_t(* PidCallback::pfGetId) (void) |
Obtain the process ID.
Obtain the process ID.
| Process | ID |
| 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,Memory | allocation failure. |
| uint64_t(* ThreadCallback::pfThreadGetId) (void) |
Obtain the thread ID.
Obtain the thread ID.
| Thread | ID |
| 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 |
| int32_t(* ThreadCallback::pfThreadLockNew) (BSL_SAL_ThreadLockHandle *lock) |
Create a thread lock.
Create a thread lock.
| lock | [IN/OUT] Lock handle |
| BSL_SUCCESS,created | successfully. |
| BSL_MALLOC_FAIL,memory | space is insufficient and thread lock space cannot be applied for. |
| BSL_SAL_ERR_UNKNOWN,thread | lock initialization failed. |
| BSL_SAL_ERR_BAD_PARAM,parameter | error. The value of lock is NULL. |
| 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,operation | failed. |
| BSL_SAL_ERR_BAD_PARAM,parameter | error. The value of lock is NULL. |
| int32_t(* ThreadCallback::pfThreadUnlock) (BSL_SAL_ThreadLockHandle lock) |
Unlock
Unlock
| lock | [IN] Lock handle |
| BSL_SUCCESS,succeeded. | |
| BSL_SAL_ERR_UNKNOWN,operation | failed. |
| BSL_SAL_ERR_BAD_PARAM,parameter | error. The value of lock is NULL. |
| 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,operation | failed. |
| BSL_SAL_ERR_BAD_PARAM,parameter | error. The value of lock is NULL. |