static void ActivityRootCreate()

in src/LttngActivityHelpers.c [52:75]


static void ActivityRootCreate(struct lttngh_ActivityRoot *pNewRoot) {
  uint32_t timeBits;
  struct timespec tv;

  clock_gettime(CLOCK_MONOTONIC, &tv);
  timeBits = ((uint32_t)tv.tv_sec << 8) |  // Low 24 bits of seconds.
             ((uint32_t)tv.tv_nsec >> 22); // Top 8 bits of nanoseconds.

  // Distinguish by timestamp in case PID rolls over.
  pNewRoot->Root0 = timeBits;

  // Distinguish by address of lttngh_ActivityIdCreate in case multiple
  // generators exist in the process (i.e. from different .so libraries).
  // TODO: Remove this when LttngHelpers is made into a .so library.
  pNewRoot->Root0 ^= (uint32_t)(uintptr_t)&lttngh_ActivityIdCreate;

  // Distinguish by PID so different processes get different activity IDs.
  // Use little-endian to reduce conflict with version field.
  pNewRoot->Root1 = HostToLittleEndian32((uint32_t)getpid());

  // Since this isn't really a GUID, set the GUID version bits to 0
  // (invalid version).
  pNewRoot->Root1 &= HostToBigEndian32(0xffff0fff);
}