MCPcopy Create free account
hub / github.com/F-Stack/f-stack / BMK_initStatic_timedFnState

Function BMK_initStatic_timedFnState

freebsd/contrib/zstd/programs/benchfn.c:170–182  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

168void BMK_freeTimedFnState(BMK_timedFnState_t* state) { free(state); }
169
170BMK_timedFnState_t*
171BMK_initStatic_timedFnState(void* buffer, size_t size, unsigned total_ms, unsigned run_ms)
172{
173 typedef char check_size[ 2 * (sizeof(BMK_timedFnState_shell) >= sizeof(struct BMK_timedFnState_s)) - 1]; /* static assert : a compilation failure indicates that BMK_timedFnState_shell is not large enough */
174 typedef struct { check_size c; BMK_timedFnState_t tfs; } tfs_align; /* force tfs to be aligned at its next best position */
175 size_t const tfs_alignment = offsetof(tfs_align, tfs); /* provides the minimal alignment restriction for BMK_timedFnState_t */
176 BMK_timedFnState_t* const r = (BMK_timedFnState_t*)buffer;
177 if (buffer == NULL) return NULL;
178 if (size < sizeof(struct BMK_timedFnState_s)) return NULL;
179 if ((size_t)buffer % tfs_alignment) return NULL; /* buffer must be properly aligned */
180 BMK_resetTimedFnState(r, total_ms, run_ms);
181 return r;
182}
183
184void BMK_resetTimedFnState(BMK_timedFnState_t* timedFnState, unsigned total_ms, unsigned run_ms)
185{

Callers

nothing calls this directly

Calls 1

BMK_resetTimedFnStateFunction · 0.85

Tested by

no test coverage detected