Create a unique ID based on process identifiers arranged as indicated by a printf-style format string.
358 if (
unlikely(fmt == NULL || strlen(fmt) == 0) )
362 gettimeofday(&now, NULL);
363 u64 tstamp =
static_cast<u64> (now.tv_sec) * 10e+5 + now.tv_usec;
366 string *retval = NULL;
372 for (
u32 i = 0, len = strlen(fmt);
likely(i < len); i++) {
374 if (
likely(ch !=
'%') ) {
380 throw exception(
"invalid format '%s' (at %d: no specifier)", fmt, ++i);
389 retval->append(
path);
393 retval->append(basename(
path));
397 retval->append(
"%x", getpid());
401 retval->append(
"%lx", pthread_self());
405 retval->append(
"%lx", tstamp);
409 const i8 err[] =
"invalid format '%s' (at %d: unknown specifier '%c')";
410 throw exception(err, fmt, i, ch);
static const i8 * exec_path()
Get the absolute path of the executable.
char i8
8-bit signed integer
unsigned long long u64
64-bit unsigned integer
string(u32=0)
Object constructor.
#define likely(expr)
Offer a hint (positive) to the pipeline branch predictor.
virtual const i8 * path() const
Get the output file path.
unsigned int u32
32-bit unsigned integer
#define unlikely(expr)
Offer a hint (negative) to the pipeline branch predictor.
#define __D_ASSERT(x)
Assertion macro.