openHiTLS API openHiTLS 0.1.0-Alpha1
结构体 | 类型定义 | 函数 | 变量
Bsl_sal

System Abstraction Layer 更多...

Bsl_sal 的协作图:

结构体

struct  MemCallback
 
struct  ThreadCallback
 
struct  BSL_TIME
 Basic time data structure definition. 更多...
 

类型定义

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 struct ThreadCallback BSL_SAL_ThreadCallback
 
typedef void(* BSL_SAL_ThreadInitRoutine) (void)
 run once: Use the initialization callback.
 
typedef int64_t BslUnixTime
 Unix Time structure definition.
 
typedef BslUnixTime(* BslTimeFunc) (void)
 Prototype of the callback function for obtaining the time
 

函数

int32_t BSL_SAL_RegMemCallback (BSL_SAL_MemCallback *cb)
 Interface for registering memory-related callback functions
 
int32_t BSL_SAL_RegThreadCallback (BSL_SAL_ThreadCallback *cb)
 Interface for registering thread-related callback functions.
 
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_ThreadRunOnce (uint32_t *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.
 
uint32_t BSL_SAL_DateTimeCompare (const BSL_TIME *dateA, const BSL_TIME *dateB, int64_t *diffSec)
 Compare Two Dates
 
uint32_t BSL_SAL_SysTimeGet (BSL_TIME *sysTime)
 Obtain the system time.
 
BslUnixTime BSL_SAL_CurrentSysTimeGet (void)
 Obtain the Unix time.
 
uint32_t BSL_SAL_DateToUtcTimeConvert (const BSL_TIME *dateTime, int64_t *utcTime)
 Convert the date in the BslSysTime format to the UTC time format.
 
uint32_t BSL_SAL_UtcTimeToDateConvert (int64_t utcTime, BSL_TIME *sysTime)
 Convert the date in the BslUnixTime format to the BslSysTime format.
 
uint32_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.
 
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, uint32_t len)
 Set 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_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.
 

变量

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

详细描述

System Abstraction Layer