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