mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
cherry picked (v)strap functions from opal-async branch
This commit is contained in:
parent
84686ffacb
commit
51a1b42f46
2 changed files with 28 additions and 0 deletions
|
@ -68,6 +68,15 @@ void epoch_reset();
|
|||
*/
|
||||
void print(enum log_level lvl, const char *fmt, ...);
|
||||
|
||||
/** Safely append a format string to an existing string.
|
||||
*
|
||||
* This function is similar to strlcat() from BSD.
|
||||
*/
|
||||
int strap(char *dest, size_t size, const char *fmt, ...);
|
||||
|
||||
/** Variable arguments (stdarg) version of strap() */
|
||||
int vstrap(char *dest, size_t size, const char *fmt, va_list va);
|
||||
|
||||
/** Convert integer to cpu_set_t.
|
||||
*
|
||||
* @param set A cpu bitmask
|
||||
|
|
|
@ -35,6 +35,25 @@ void epoch_reset()
|
|||
clock_gettime(CLOCK_REALTIME, &epoch);
|
||||
}
|
||||
|
||||
int strap(char *dest, size_t size, const char *fmt, ...)
|
||||
{
|
||||
int ret;
|
||||
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
ret = vstrap(dest, size, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int vstrap(char *dest, size_t size, const char *fmt, va_list ap)
|
||||
{
|
||||
int len = strlen(dest);
|
||||
|
||||
return vsnprintf(dest + len, size - len, fmt, ap);
|
||||
}
|
||||
|
||||
void print(enum log_level lvl, const char *fmt, ...)
|
||||
{
|
||||
struct timespec ts;
|
||||
|
|
Loading…
Add table
Reference in a new issue