TRF Internal System Functions
Defines
-
TRF__LOOPS
-
trfPBMaxSize
-
trf__RetIfNeg(x)
Returns the error code if negative.
-
trf__ProtoStringValid(ptr)
Functions
-
static inline int trf__CreateCQ(PTRFXFabric ctx, PTRFTCQFabric *tcq, struct fi_cq_attr *attr, void *context)
-
static inline int trf__DestroyCQ(PTRFTCQFabric tcq)
-
static inline int_fast64_t trf__DecrementCQ(PTRFTCQFabric tcq, uint64_t n)
Decrement number of available CQ entries.
- Parameters:
tcq – Pointer to the CQ
n – Number of entries to decrement
- Returns:
Number of remaining entries. 0 if insufficient.
-
static inline int_fast64_t trf__IncrementCQ(PTRFTCQFabric tcq, uint64_t n)
Increment number of available CQ entries.
- Parameters:
tcq – Pointer to the CQ
n – Number of entries to increment
-
int trf__CheckSessionID(PTRFContext ctx, uint64_t session)
Check the number of times a session ID has been used.
- Parameters:
ctx – Server context
session – Session ID
- Returns:
Index where the session ID is used. -1 if not used.
-
int trf__AllocSessionForClient(PTRFContext ctx, uint64_t session_id, PTRFContext *ctx_out)
Allocate resouces for an incoming session on ther server side with a specific cookie.
Allocates a resouces for an incoming session on the server side with a specific cookie, The cookie must not be in use; use the function trf__CheckSessionID() to verify
- Parameters:
ctx – Context
session – Session ID
ctx_out – Pointer to the context item inserted into ctx
- Returns:
0 on success, negative error code on failurey.
-
static inline uint64_t trf__Rand64()
Generate an 64-bit random integer.
- Returns:
A random integer.
-
static inline uint8_t trf__HammingWeight64(uint64_t x)
Calculate the Hamming Weight (ones count) of a 64-bit integer.
- Parameters:
x – 64-bit integer
- Returns:
Hamming Weight
-
static inline char *trfStrdup(char *str)
Simple string duplication function for standard C.
- Parameters:
str – String to duplicate
- Returns:
Pointer to the duplicated string stored in the heap.
-
static inline int trfSleep(uint32_t ms)
Sleep for a given number of milliseconds.
- Parameters:
ms – Number of milliseconds to sleep. Note: A value of zero will not suspend thread execution across all operating systems.
- Returns:
0 on success, negative error code on failure. On Windows, this function always returns 0. On Linux, signals which occur during the sleep return -EINTR.
-
static inline int trfNanoSleep(int64_t ns)
High resolution sleep function.
- Parameters:
ns – Number of nanoseconds to sleep.
Note: A value of zero will not suspend thread execution across all operating systems. While this function may be useful for very specific use cases, it should be noted that sleeps have their own context switch and TLB flush overhead, and may not present any benefit over using the regular trfSleep() function.
- Returns:
0 on success, negative error code on failure.
On Windows, this function always returns 0. On Linux, signals which occur during the sleep return -EINTR.
-
static inline void trf__GetDelay(struct timespec *ts, struct timespec *ts_out, uint64_t delay_ms)
Return a timespec corresponding to a delay in milliseconds after the input timespec.
- Parameters:
ts – Timespec to start from
ts_out – Output timespec
delay_ms – Delay in milliseconds
-
static inline int trf__RemainingMS(struct timespec *ts)
-
static inline int trf__HasPassed(clockid_t clock, struct timespec *ts)
Determine whether a timespec is in the past.
- Parameters:
clock – Clock to use
ts – Timespec to check
- Returns:
1 if ts in the past, 0 otherwise Negative error code on failure