Logo ROOT  
Reference Guide
TUUID.cxx
Go to the documentation of this file.
1 // @(#)root/base:$Id$
2 // Author: Fons Rademakers 30/9/2001
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2001, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 /** \class TUUID
13 \ingroup Base
14 
15 This class defines a UUID (Universally Unique IDentifier), also
16 known as GUIDs (Globally Unique IDentifier). A UUID is 128 bits
17 long, and if generated according to this algorithm, is either
18 guaranteed to be different from all other UUIDs/GUIDs generated
19 until 3400 A.D. or extremely likely to be different. UUIDs were
20 originally used in the Network Computing System (NCS) and
21 later in the Open Software Foundation's (OSF) Distributed Computing
22 Environment (DCE).
23 
24 \note In the way this UUID is constructed, when used outside of
25 their original concept (NCS), they are actually not Globally unique
26 and indeed multiple distinct concurrent processes are actually likely
27 to generate the same UUID. Technically this is because the UUID is
28 constructed only from the node information and time information.
29 To make a globally unique number, this needs to be combined with
30 TProcessUUID.
31 
32 Structure of universal unique IDs (UUIDs).
33 
34 Depending on the network data representation, the multi-
35 octet unsigned integer fields are subject to byte swapping
36 when communicated between dissimilar endian machines.
37 ~~~ {.cpp}
38 +-----------------------------------+
39 | low 32 bits of time | 0-3 .fTimeLow
40 +-------------------------------+----
41 | mid 16 bits of time | 4-5 .fTimeMid
42 +-------+-----------------------+
43 | vers. | hi 12 bits of time | 6-7 .fTimeHiAndVersion
44 +-------+-------+---------------+
45 |Res | clkSeqHi | 8 .fClockSeqHiAndReserved
46 +---------------+
47 | clkSeqLow | 9 .fClockSeqLow
48 +---------------+------------------+
49 | node ID | 10-15 .fNode
50 +----------------------------------+
51 ~~~
52 
53 The adjusted time stamp is split into three fields, and the
54 clockSeq is split into two fields.
55 
56 The timestamp is a 60-bit value. For UUID version 1, this
57 is represented by Coordinated Universal Time (UTC/GMT) as
58 a count of 100-nanosecond intervals since 00:00:00.00,
59 15 October 1582 (the date of Gregorian reform to the
60 Christian calendar).
61 
62 The version number is multiplexed in the 4 most significant
63 bits of the 'fTimeHiAndVersion' field. There are two defined
64 versions:
65 ~~~ {.cpp}
66  MSB <---
67 Version 4-Bit Code Description
68 ------------------------------------------------------------
69 | 1 0 0 0 1 DCE version, as specified herein.
70 | 2 0 0 1 0 DCE Security version, with
71 | embedded POSIX UIDs.
72 | 3 0 0 1 1 node id is a random value
73 ------------------------------------------------------------
74 ~~~
75 
76 ## Clock Sequence
77 
78 The clock sequence value must be changed whenever:
79 
80  The UUID generator detects that the local value of UTC
81  has gone backward; this may be due to re-syncing of the system
82  clock.
83 
84 While a node is operational, the UUID service always saves
85 the last UTC used to create a UUID. Each time a new UUID
86 is created, the current UTC is compared to the saved value
87 and if either the current value is less or the saved value
88 was lost, then the clock sequence is incremented modulo
89 16,384, thus avoiding production of duplicated UUIDs.
90 
91 The clock sequence must be initialized to a random number
92 to minimize the correlation across system. This provides
93 maximum protection against node identifiers that may move
94 or switch from system to system rapidly.
95 
96 ## Clock Adjustment
97 
98 UUIDs may be created at a rate greater than the system clock
99 resolution. Therefore, the system must also maintain an
100 adjustment value to be added to the lower-order bits of the
101 time. Logically, each time the system clock ticks, the
102 adjustment value is cleared. Every time a UUID is generated,
103 the current adjustment value is read and incremented, and
104 then added to the UTC time field of the UUID.
105 
106 ## Clock Overrun
107 
108 The 100-nanosecond granularity of time should prove sufficient
109 even for bursts of UUID production in the next generation of
110 high-performance multiprocessors. If a system overruns the
111 clock adjustment by requesting too many UUIDs within a single
112 system clock tick, the UUID generator will stall until the
113 system clock catches up.
114 */
115 
116 #include "TROOT.h"
117 #include "TDatime.h"
118 #include "TUUID.h"
119 #include "TBuffer.h"
120 #include "TError.h"
121 #include "TSystem.h"
122 #include "TInetAddress.h"
123 #include "TMD5.h"
124 #include "Bytes.h"
125 #include "TVirtualMutex.h"
126 #include "ThreadLocalStorage.h"
127 #include <string.h>
128 #include <stdlib.h>
129 #ifdef R__WIN32
130 #include "Windows4Root.h"
131 #include <Iphlpapi.h>
132 #include <process.h>
133 #define getpid() _getpid()
134 #define srandom(seed) srand(seed)
135 #define random() rand()
136 #else
137 #include <unistd.h>
138 #include <sys/time.h>
139 #if defined(R__LINUX) && !defined(R__WINGCC)
140 #include <sys/sysinfo.h>
141 #endif
142 #include <ifaddrs.h>
143 #include <netinet/in.h>
144 #endif
145 #include <chrono>
146 
147 ClassImp(TUUID);
148 
149 ////////////////////////////////////////////////////////////////////////////////
150 /// Create a UUID.
151 
153 {
154  TTHREAD_TLS(uuid_time_t) time_last;
155  TTHREAD_TLS(UShort_t) clockseq(0);
156  TTHREAD_TLS(Bool_t) firstTime(kTRUE);
157  uuid_time_t *time_last_ptr = TTHREAD_TLS_PTR(time_last);
158 
159  if (firstTime) {
160  R__LOCKGUARD(gROOTMutex); // rand and random are not thread safe.
161 
162  UInt_t seed;
163  if (gSystem) {
164  // try to get a unique seed per process
165  seed = (UInt_t)(Long64_t(gSystem->Now()) + gSystem->GetPid());
166  } else {
167  using namespace std::chrono;
168  system_clock::time_point today = system_clock::now();
169  seed = (UInt_t)(system_clock::to_time_t ( today )) + ::getpid();
170  }
171  srandom(seed);
172  GetCurrentTime(time_last_ptr);
173  clockseq = 1+(UShort_t)(65536*random()/(RAND_MAX+1.0));
174  firstTime = kFALSE;
175  }
176 
177  uuid_time_t timestamp;
178 
179  // get current time
180  GetCurrentTime(&timestamp);
181 
182  // if clock went backward change clockseq
183  if (CmpTime(&timestamp, time_last_ptr) == -1) {
184  clockseq = (clockseq + 1) & 0x3FFF;
185  if (clockseq == 0) clockseq++;
186  }
187 
188  Format(clockseq, timestamp);
189 
190  time_last = timestamp;
191  fUUIDIndex = 1<<30;
192 }
193 
194 ////////////////////////////////////////////////////////////////////////////////
195 /// delete this TUUID
196 
198 {
199  //gROOT->GetUUIDs()->RemoveUUID(fUUIDIndex);
200 }
201 
202 ////////////////////////////////////////////////////////////////////////////////
203 /// Compare two time values.
204 
206 {
207  if (t1->high < t2->high) return -1;
208  if (t1->high > t2->high) return 1;
209  if (t1->low < t2->low) return -1;
210  if (t1->low > t2->low) return 1;
211  return 0;
212 }
213 
214 ////////////////////////////////////////////////////////////////////////////////
215 /// Set this UUID to the value specified in uuid ((which must be in
216 /// TUUID::AsString() format).
217 
218 void TUUID::SetFromString(const char *uuid)
219 {
220  // Format is tttttttt-tttt-cccc-cccc-nnnnnnnnnnnn.
221  Long_t timeLo;
222  int timeMid;
223  int timeHiAndVersion;
224  int clockSeqHiAndRes;
225  int clockSeqLo;
226  int node[6];
227 
228  sscanf(uuid, "%8lx-%4x-%4x-%2x%2x-%2x%2x%2x%2x%2x%2x",
229  &timeLo,
230  &timeMid,
231  &timeHiAndVersion,
232  &clockSeqHiAndRes,
233  &clockSeqLo,
234  &node[0], &node[1], &node[2], &node[3], &node[4], &node[5]);
235 
236  // Note that we're going through this agony because scanf is
237  // defined to know only to scan into "int"s or "long"s.
238  fTimeLow = (UInt_t) timeLo;
239  fTimeMid = (UShort_t) timeMid;
240  fTimeHiAndVersion = (UShort_t) timeHiAndVersion;
241  fClockSeqHiAndReserved = (UChar_t) clockSeqHiAndRes;
242  fClockSeqLow = (UChar_t) clockSeqLo;
243  fNode[0] = (UChar_t) node[0];
244  fNode[1] = (UChar_t) node[1];
245  fNode[2] = (UChar_t) node[2];
246  fNode[3] = (UChar_t) node[3];
247  fNode[4] = (UChar_t) node[4];
248  fNode[5] = (UChar_t) node[5];
249  fUUIDIndex = 1<<30;
250 }
251 
252 ////////////////////////////////////////////////////////////////////////////////
253 /// Initialize a TUUID with uuid (which must be in TUUID::AsString() format).
254 
255 TUUID::TUUID(const char *uuid)
256 {
257  fTimeLow = 0;
258  fTimeMid = 0;
259  fTimeHiAndVersion = 0;
261  fClockSeqLow = 0;
262  fNode[0] = 0;
263  fUUIDIndex = 0;
264 
265  if (!uuid || !*uuid)
266  Error("TUUID", "null string not allowed");
267  else
268  SetFromString(uuid);
269 }
270 
271 ////////////////////////////////////////////////////////////////////////////////
272 /// Stream UUID into output buffer.
273 
274 void TUUID::FillBuffer(char *&buffer)
275 {
276  Version_t version = TUUID::Class_Version();
277  tobuf(buffer, version);
278  tobuf(buffer, fTimeLow);
279  tobuf(buffer, fTimeMid);
280  tobuf(buffer, fTimeHiAndVersion);
281  tobuf(buffer, fClockSeqHiAndReserved);
282  tobuf(buffer, fClockSeqLow);
283  for (Int_t i = 0; i < 6; i++)
284  tobuf(buffer, fNode[i]);
285 }
286 
287 ////////////////////////////////////////////////////////////////////////////////
288 /// Stream UUID from input buffer.
289 
290 void TUUID::ReadBuffer(char *&buffer)
291 {
292  Version_t version;
293  frombuf(buffer, &version);
294  frombuf(buffer, &fTimeLow);
295  frombuf(buffer, &fTimeMid);
296  frombuf(buffer, &fTimeHiAndVersion);
298  frombuf(buffer, &fClockSeqLow);
299  for (Int_t i = 0; i < 6; i++)
300  frombuf(buffer, &fNode[i]);
301 }
302 
303 ////////////////////////////////////////////////////////////////////////////////
304 /// Stream UUID from input buffer.
305 /// This function is for the exclusive use of TDirectory::Streamer() to
306 /// read a non-versioned version of TUUID.
307 
309 {
310  b >> fTimeLow;
311  b >> fTimeMid;
312  b >> fTimeHiAndVersion;
314  b >> fClockSeqLow;
315  for (UInt_t i = 0; i < 6; i++) {
316  b >> fNode[i];
317  }
318 }
319 
320 ////////////////////////////////////////////////////////////////////////////////
321 /// Make a UUID from timestamp, clockseq and node id.
322 
324 {
325  fTimeLow = ts.low;
326  fTimeMid = (UShort_t)(ts.high & 0xFFFF);
327  fTimeHiAndVersion = (UShort_t)((ts.high >> 16) & 0x0FFF);
328  fTimeHiAndVersion |= (1 << 12);
329  fClockSeqLow = clockseq & 0xFF;
330  fClockSeqHiAndReserved = (clockseq & 0x3F00) >> 8;
331  fClockSeqHiAndReserved |= 0x80;
333 }
334 
335 ////////////////////////////////////////////////////////////////////////////////
336 /// Get current time as 60 bit 100ns ticks since whenever.
337 /// Compensate for the fact that real clock resolution is less
338 /// than 100ns.
339 
341 {
342  const UShort_t uuids_per_tick = 1024;
343 
344  TTHREAD_TLS(uuid_time_t) time_last;
345  TTHREAD_TLS(UShort_t) uuids_this_tick(0);
346  TTHREAD_TLS(Bool_t) init(kFALSE);
347 
348  uuid_time_t *time_last_ptr = TTHREAD_TLS_PTR(time_last);
349 
350  if (!init) {
351  GetSystemTime(time_last_ptr);
352  uuids_this_tick = uuids_per_tick;
353  init = kTRUE;
354  }
355 
356  uuid_time_t time_now;
357 
358  while (1) {
359  GetSystemTime(&time_now);
360 
361  // if clock reading changed since last UUID generated
362  if (CmpTime(time_last_ptr, &time_now)) {
363  // reset count of uuid's generated with this clock reading
364  uuids_this_tick = 0;
365  break;
366  }
367  if (uuids_this_tick < uuids_per_tick) {
368  uuids_this_tick++;
369  break;
370  }
371  // going too fast for our clock; spin
372  }
373 
374  time_last = time_now;
375 
376  if (uuids_this_tick != 0) {
377  if (time_now.low & 0x80000000) {
378  time_now.low += uuids_this_tick;
379  if (!(time_now.low & 0x80000000))
380  time_now.high++;
381  } else
382  time_now.low += uuids_this_tick;
383  }
384 
385  timestamp->high = time_now.high;
386  timestamp->low = time_now.low;
387 }
388 
389 ////////////////////////////////////////////////////////////////////////////////
390 /// Get system time with 100ns precision. Time is since Oct 15, 1582.
391 
393 {
394 #ifdef R__WIN32
395  ULARGE_INTEGER time;
396  GetSystemTimeAsFileTime((FILETIME *)&time);
397  // NT keeps time in FILETIME format which is 100ns ticks since
398  // Jan 1, 1601. UUIDs use time in 100ns ticks since Oct 15, 1582.
399  // The difference is 17 Days in Oct + 30 (Nov) + 31 (Dec)
400  // + 18 years and 5 leap days.
401  time.QuadPart +=
402  (unsigned __int64) (1000*1000*10) // seconds
403  * (unsigned __int64) (60 * 60 * 24) // days
404  * (unsigned __int64) (17+30+31+365*18+5); // # of days
405 
406  timestamp->high = time.HighPart;
407  timestamp->low = time.LowPart;
408 #else
409  struct timeval tp;
410  gettimeofday(&tp, 0);
411  // Offset between UUID formatted times and Unix formatted times.
412  // UUID UTC base time is October 15, 1582.
413  // Unix base time is January 1, 1970.
414  ULong64_t uuid_time = ((ULong64_t)tp.tv_sec * 10000000) + (tp.tv_usec * 10) +
415  0x01B21DD213814000LL;
416  timestamp->high = (UInt_t) (uuid_time >> 32);
417  timestamp->low = (UInt_t) (uuid_time & 0xFFFFFFFF);
418 #endif
419 }
420 
421 ////////////////////////////////////////////////////////////////////////////////
422 /// Get node identifier. Try first to get network address, if no
423 /// network interface try random info based on some machine parameters.
424 
426 {
427  static UInt_t adr = 0;
428 
429  if (gSystem) {
430 #ifndef R__WIN32
431  if (!adr) {
432  UInt_t addr = 0;
433 
434  struct ifaddrs *ifAddrStruct = nullptr;
435  struct ifaddrs *ifa = nullptr;
436 
437  if (getifaddrs(&ifAddrStruct) != 0) {
438  adr = 1;
439  } else {
440  for (ifa = ifAddrStruct; ifa != NULL; ifa = ifa->ifa_next) {
441  if (!ifa->ifa_addr) {
442  continue;
443  }
444  if (ifa->ifa_addr->sa_family != AF_INET) { // check only IP4
445  continue;
446  }
447  if (strncmp(ifa->ifa_name,"lo",2) == 0) { // skip loop back.
448  continue;
449  }
450  addr = ntohl(((struct sockaddr_in *)ifa->ifa_addr)->sin_addr.s_addr);
451  break;
452  }
453  }
454 
455  if (ifAddrStruct != nullptr)
456  freeifaddrs(ifAddrStruct);
457 
458  if (addr)
459  adr = addr;
460  else
461  adr = 1; // illegal address
462  }
463 #else
464  // this way to get the machine's IP address is needed because
465  // GetHostByName() on Win32 contacts the DNS which we don't want
466  // as firewall tools like ZoneAlarm are likely to catch it and
467  // alarm the user
468  if (!adr) {
469  PIP_ADAPTER_INFO ainfo = (PIP_ADAPTER_INFO) malloc(sizeof(IP_ADAPTER_INFO));
470  ULONG buflen = sizeof(IP_ADAPTER_INFO);
471  DWORD stat = GetAdaptersInfo(ainfo, &buflen);
472  if (stat == ERROR_BUFFER_OVERFLOW) {
473  free(ainfo);
474  ainfo = (PIP_ADAPTER_INFO) malloc(buflen);
475  stat = GetAdaptersInfo(ainfo, &buflen);
476  }
477  if (stat != ERROR_SUCCESS)
478  adr = 1; // illegal address
479  else {
480  // take address of first adapter
481  PIP_ADAPTER_INFO adapter = ainfo;
482  int a, b, c, d;
483  sscanf(adapter->IpAddressList.IpAddress.String, "%d.%d.%d.%d",
484  &a, &b, &c, &d);
485  adr = (a << 24) | (b << 16) | (c << 8) | d;
486  }
487  free(ainfo);
488  }
489 #endif
490  if (adr > 2) {
491  memcpy(fNode, &adr, 4);
492  fNode[4] = 0xbe;
493  fNode[5] = 0xef;
494  return;
495  }
496  }
497  static UChar_t seed[16];
498  if (adr < 2) {
499  GetRandomInfo(seed);
500  seed[0] |= 0x80;
501  if (gSystem) adr = 2; // illegal address
502  }
503  memcpy(fNode, seed, sizeof(fNode));
504  fTimeHiAndVersion |= (3 << 12); // version == 3: random node info
505 }
506 
507 ////////////////////////////////////////////////////////////////////////////////
508 /// Get random info based on some machine parameters.
509 
511 {
512 #ifdef R__WIN32
513  struct randomness {
514  MEMORYSTATUS m;
515  SYSTEM_INFO s;
516  FILETIME t;
517  LARGE_INTEGER pc;
518  DWORD tc;
519  DWORD l;
520  char hostname[MAX_COMPUTERNAME_LENGTH + 1];
521  };
522  randomness r;
523  memset(&r, 0, sizeof(r)); // zero also padding bytes
524 
525  // memory usage stats
526  GlobalMemoryStatus(&r.m);
527  // random system stats
528  GetSystemInfo(&r.s);
529  // 100ns resolution time of day
530  GetSystemTimeAsFileTime(&r.t);
531  // high resolution performance counter
532  QueryPerformanceCounter(&r.pc);
533  // milliseconds since last boot
534  r.tc = GetTickCount();
535  r.l = MAX_COMPUTERNAME_LENGTH + 1;
536  GetComputerName(r.hostname, &r.l);
537 #else
538  struct randomness {
539 #if defined(R__LINUX) && !defined(R__WINGCC)
540  struct sysinfo s;
541 #endif
542  struct timeval t;
543  char hostname[257];
544  };
545  randomness r;
546  memset(&r, 0, sizeof(r)); // zero also padding bytes
547 
548 #if defined(R__LINUX) && !defined(R__WINGCC)
549  sysinfo(&r.s);
550 #endif
551  gettimeofday(&r.t, 0);
552  gethostname(r.hostname, 256);
553 #endif
554  TMD5 md5;
555  md5.Update((UChar_t *)&r, sizeof(randomness));
556  md5.Final(seed);
557 }
558 
559 ////////////////////////////////////////////////////////////////////////////////
560 /// Print UUID.
561 
562 void TUUID::Print() const
563 {
564  printf("%s\n", AsString());
565 }
566 
567 ////////////////////////////////////////////////////////////////////////////////
568 /// Return UUID as string. Copy string immediately since it will be reused.
569 
570 const char *TUUID::AsString() const
571 {
572  static char uuid[40];
573 
574  snprintf(uuid,40, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
576  fClockSeqLow, fNode[0], fNode[1], fNode[2], fNode[3], fNode[4],
577  fNode[5]);
578 
579  return uuid;
580 }
581 
582 ////////////////////////////////////////////////////////////////////////////////
583 /// Compute 16-bit hash value of the UUID.
584 
586 {
587  Short_t c0 = 0, c1 = 0, x, y;
588  char *c = (char *) &fTimeLow;
589 
590  // For speed lets unroll the following loop:
591  // for (i = 0; i < 16; i++) {
592  // c0 += *c++;
593  // c1 += c0;
594  // }
595 
596  c0 += *c++; c1 += c0;
597  c0 += *c++; c1 += c0;
598  c0 += *c++; c1 += c0;
599  c0 += *c++; c1 += c0;
600 
601  c0 += *c++; c1 += c0;
602  c0 += *c++; c1 += c0;
603  c0 += *c++; c1 += c0;
604  c0 += *c++; c1 += c0;
605 
606  c0 += *c++; c1 += c0;
607  c0 += *c++; c1 += c0;
608  c0 += *c++; c1 += c0;
609  c0 += *c++; c1 += c0;
610 
611  c0 += *c++; c1 += c0;
612  c0 += *c++; c1 += c0;
613  c0 += *c++; c1 += c0;
614  c0 += *c++; c1 += c0;
615 
616  // Calculate the value for "First octet" of the hash
617  x = -c1 % 255;
618  if (x < 0)
619  x += 255;
620 
621  // Calculate the value for "second octet" of the hash
622  y = (c1 - c0) % 255;
623  if (y < 0)
624  y += 255;
625 
626  return UShort_t((y << 8) + x);
627 }
628 
629 ////////////////////////////////////////////////////////////////////////////////
630 /// Compare two UUIDs "lexically" and return
631 /// - -1 this is lexically before u
632 /// - 0 this is equal to u
633 /// - 1 this is lexically after u
634 
635 Int_t TUUID::Compare(const TUUID &u) const
636 {
637 #define CHECK(f1, f2) if (f1 != f2) return f1 < f2 ? -1 : 1;
643  for (int i = 0; i < 6; i++) {
644  if (fNode[i] < u.fNode[i])
645  return -1;
646  if (fNode[i] > u.fNode[i])
647  return 1;
648  }
649  return 0;
650 }
651 
652 ////////////////////////////////////////////////////////////////////////////////
653 /// Get address of host encoded in UUID. If host id is not an ethernet
654 /// address, but random info, then the returned TInetAddress is not valid.
655 
657 {
658  if ((fTimeHiAndVersion >> 12) == 1) {
659  UInt_t addr;
660  memcpy(&addr, fNode, 4);
661  return TInetAddress("????", addr, 0);
662  }
663  return TInetAddress();
664 }
665 
666 ////////////////////////////////////////////////////////////////////////////////
667 /// Get time from UUID.
668 
670 {
671  TDatime dt;
672  uuid_time_t ts;
673 
674  ts.low = fTimeLow;
675  ts.high = (UInt_t)fTimeMid;
676  ts.high |= (UInt_t)((fTimeHiAndVersion & 0x0FFF) << 16);
677 
678  // Offset between UUID formatted times and Unix formatted times.
679  // UUID UTC base time is October 15, 1582.
680  // Unix base time is January 1, 1970.
681  ULong64_t high = ts.high;
682  ULong64_t uuid_time = (high << 32) + ts.low;
683  uuid_time -= 0x01B21DD213814000LL;
684  uuid_time /= 10000000LL;
685  UInt_t tt = (UInt_t) uuid_time;
686  dt.Set(tt);
687 
688  return dt;
689 }
690 
691 ////////////////////////////////////////////////////////////////////////////////
692 /// Return uuid in specified buffer (16 byte = 128 bits).
693 
694 void TUUID::GetUUID(UChar_t uuid[16]) const
695 {
696  memcpy(uuid, &fTimeLow, 16);
697 }
698 
699 ////////////////////////////////////////////////////////////////////////////////
700 /// Set this UUID to the value specified in uuid ((which must be in
701 /// TUUID::AsString() format).
702 
703 void TUUID::SetUUID(const char *uuid)
704 {
705  if (!uuid || !*uuid)
706  Error("SetUUID", "null string not allowed");
707  else
708  SetFromString(uuid);
709 }
710 
711 ////////////////////////////////////////////////////////////////////////////////
712 /// Input operator. Delegate to Streamer.
713 
714 TBuffer &operator<<(TBuffer &buf, const TUUID &uuid)
715 {
716  R__ASSERT( buf.IsWriting() );
717 
718  const_cast<TUUID&>(uuid).Streamer(buf);
719  return buf;
720 }
TUUID::GetNodeIdentifier
void GetNodeIdentifier()
Get node identifier.
Definition: TUUID.cxx:425
c
#define c(i)
Definition: RSha256.hxx:101
TUUID::uuid_time_t
Definition: TUUID.h:53
l
auto * l
Definition: textangle.C:4
TUUID::Hash
UShort_t Hash() const
Compute 16-bit hash value of the UUID.
Definition: TUUID.cxx:585
m
auto * m
Definition: textangle.C:8
TUUID::fTimeLow
UInt_t fTimeLow
index in the list of UUIDs in TProcessUUID
Definition: TUUID.h:46
TUUID::FillBuffer
void FillBuffer(char *&buffer)
Stream UUID into output buffer.
Definition: TUUID.cxx:274
TUUID::TUUID
TUUID()
Create a UUID.
Definition: TUUID.cxx:152
Windows4Root.h
TUUID::uuid_time_t::low
UInt_t low
Definition: TUUID.h:55
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
tt
auto * tt
Definition: textangle.C:16
Version_t
short Version_t
Definition: RtypesCore.h:65
snprintf
#define snprintf
Definition: civetweb.c:1540
TUUID::~TUUID
virtual ~TUUID()
delete this TUUID
Definition: TUUID.cxx:197
TUUID::GetCurrentTime
void GetCurrentTime(uuid_time_t *timestamp)
Get current time as 60 bit 100ns ticks since whenever.
Definition: TUUID.cxx:340
UShort_t
unsigned short UShort_t
Definition: RtypesCore.h:40
TUUID::ReadBuffer
void ReadBuffer(char *&buffer)
Stream UUID from input buffer.
Definition: TUUID.cxx:290
ClassImp
#define ClassImp(name)
Definition: Rtypes.h:364
TDatime.h
tobuf
void tobuf(char *&buf, Bool_t x)
Definition: Bytes.h:55
r
ROOT::R::TRInterface & r
Definition: Object.C:4
Long64_t
long long Long64_t
Definition: RtypesCore.h:73
BatchHelpers::init
EvaluateInfo init(std::vector< RooRealProxy > parameters, std::vector< ArrayWrapper * > wrappers, std::vector< double * > arrays, size_t begin, size_t batchSize)
TMD5::Final
void Final()
MD5 finalization, ends an MD5 message-digest operation, writing the the message digest and zeroizing ...
Definition: TMD5.cxx:167
TGeant4Unit::s
static constexpr double s
Definition: TGeant4SystemOfUnits.h:162
operator<<
TBuffer & operator<<(TBuffer &buf, const TUUID &uuid)
Input operator. Delegate to Streamer.
Definition: TUUID.cxx:714
TUUID::CmpTime
Int_t CmpTime(uuid_time_t *t1, uuid_time_t *t2)
Compare two time values.
Definition: TUUID.cxx:205
TGeant4Unit::pc
static constexpr double pc
Definition: TGeant4SystemOfUnits.h:130
x
Double_t x[n]
Definition: legend1.C:17
TMD5::Update
void Update(const UChar_t *buf, UInt_t len)
Update TMD5 object to reflect the concatenation of another buffer full of bytes.
Definition: TMD5.cxx:108
TUUID::GetTime
TDatime GetTime() const
Get time from UUID.
Definition: TUUID.cxx:669
TBuffer
Buffer base class used for serializing objects.
Definition: TBuffer.h:43
b
#define b(i)
Definition: RSha256.hxx:100
bool
TDatime::Set
void Set()
Set Date/Time to current time as reported by the system.
Definition: TDatime.cxx:289
TUUID::fUUIDIndex
UInt_t fUUIDIndex
Definition: TUUID.h:45
TROOT.h
TUUID.h
malloc
#define malloc
Definition: civetweb.c:1536
TBuffer.h
TSystem.h
gROOTMutex
R__EXTERN TVirtualMutex * gROOTMutex
Definition: TROOT.h:61
TSystem::GetPid
virtual int GetPid()
Get process id.
Definition: TSystem.cxx:708
TUUID::fTimeHiAndVersion
UShort_t fTimeHiAndVersion
Definition: TUUID.h:48
TBuffer::IsWriting
Bool_t IsWriting() const
Definition: TBuffer.h:87
a
auto * a
Definition: textangle.C:12
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:92
Long_t
long Long_t
Definition: RtypesCore.h:54
TInetAddress.h
R__LOCKGUARD
#define R__LOCKGUARD(mutex)
Definition: TVirtualMutex.h:104
UInt_t
unsigned int UInt_t
Definition: RtypesCore.h:46
TSystem::Now
virtual TTime Now()
Get current time in milliseconds since 0:00 Jan 1 1995.
Definition: TSystem.cxx:464
y
Double_t y[n]
Definition: legend1.C:17
TUUID
This class defines a UUID (Universally Unique IDentifier), also known as GUIDs (Globally Unique IDent...
Definition: TUUID.h:42
TMD5
This code implements the MD5 message-digest algorithm.
Definition: TMD5.h:44
Short_t
short Short_t
Definition: RtypesCore.h:39
TVirtualMutex.h
unsigned int
TUUID::StreamerV1
void StreamerV1(TBuffer &b)
Stream UUID from input buffer.
Definition: TUUID.cxx:308
gSystem
R__EXTERN TSystem * gSystem
Definition: TSystem.h:559
CHECK
#define CHECK(f1, f2)
ULong64_t
unsigned long long ULong64_t
Definition: RtypesCore.h:74
TUUID::fNode
UChar_t fNode[6]
Definition: TUUID.h:51
TUUID::Compare
Int_t Compare(const TUUID &u) const
Compare two UUIDs "lexically" and return.
Definition: TUUID.cxx:635
TUUID::fClockSeqLow
UChar_t fClockSeqLow
Definition: TUUID.h:50
TUUID::SetUUID
void SetUUID(const char *uuid_str)
Set this UUID to the value specified in uuid ((which must be in TUUID::AsString() format).
Definition: TUUID.cxx:703
TUUID::uuid_time_t::high
UInt_t high
Definition: TUUID.h:54
TUUID::Format
void Format(UShort_t clockseq, uuid_time_t ts)
Make a UUID from timestamp, clockseq and node id.
Definition: TUUID.cxx:323
R__ASSERT
#define R__ASSERT(e)
Definition: TError.h:120
t1
auto * t1
Definition: textangle.C:20
frombuf
void frombuf(char *&buf, Bool_t *x)
Definition: Bytes.h:278
UChar_t
unsigned char UChar_t
Definition: RtypesCore.h:38
TUUID::GetHostAddress
TInetAddress GetHostAddress() const
Get address of host encoded in UUID.
Definition: TUUID.cxx:656
Bytes.h
d
#define d(i)
Definition: RSha256.hxx:102
TUUID::AsString
const char * AsString() const
Return UUID as string. Copy string immediately since it will be reused.
Definition: TUUID.cxx:570
TMD5.h
TDatime
This class stores the date and time with a precision of one second in an unsigned 32 bit word (950130...
Definition: TDatime.h:37
TUUID::GetRandomInfo
void GetRandomInfo(UChar_t seed[16])
Get random info based on some machine parameters.
Definition: TUUID.cxx:510
free
#define free
Definition: civetweb.c:1539
TUUID::fTimeMid
UShort_t fTimeMid
Definition: TUUID.h:47
TInetAddress
This class represents an Internet Protocol (IP) address.
Definition: TInetAddress.h:36
TUUID::fClockSeqHiAndReserved
UChar_t fClockSeqHiAndReserved
Definition: TUUID.h:49
ThreadLocalStorage.h
TUUID::Print
void Print() const
Print UUID.
Definition: TUUID.cxx:562
TUUID::GetSystemTime
void GetSystemTime(uuid_time_t *timestamp)
Get system time with 100ns precision. Time is since Oct 15, 1582.
Definition: TUUID.cxx:392
int
TUUID::SetFromString
void SetFromString(const char *uuid_str)
Set this UUID to the value specified in uuid ((which must be in TUUID::AsString() format).
Definition: TUUID.cxx:218
Error
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
Definition: TError.cxx:187
TError.h
c1
return c1
Definition: legend1.C:41
TUUID::GetUUID
void GetUUID(UChar_t uuid[16]) const
Return uuid in specified buffer (16 byte = 128 bits).
Definition: TUUID.cxx:694