Logo ROOT   6.10/09
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 #else
123 #include <unistd.h>
124 #include <sys/time.h>
125 #if defined(R__LINUX) && !defined(R__WINGCC)
126 #include <sys/sysinfo.h>
127 #endif
128 #endif
129 #include <chrono>
130 
132 
133 ////////////////////////////////////////////////////////////////////////////////
134 /// Create a UUID.
135 
137 {
138  TTHREAD_TLS(uuid_time_t) time_last;
139  TTHREAD_TLS(UShort_t) clockseq(0);
140  TTHREAD_TLS(Bool_t) firstTime(kTRUE);
141  uuid_time_t *time_last_ptr = TTHREAD_TLS_PTR(time_last);
142 
143  if (firstTime) {
144  R__LOCKGUARD2(gROOTMutex); // rand and random are not thread safe.
145 
146  UInt_t seed;
147  if (gSystem) {
148  // try to get a unique seed per process
149  seed = (UInt_t)(Long64_t(gSystem->Now()) + gSystem->GetPid());
150  } else {
151  using namespace std::chrono;
152  system_clock::time_point today = system_clock::now();
153  seed = (UInt_t)(system_clock::to_time_t ( today )) + ::getpid();
154  }
155 #ifdef R__WIN32
156  srand(seed);
157 #else
158  srandom(seed);
159 #endif
160  GetCurrentTime(time_last_ptr);
161 #ifdef R__WIN32
162  clockseq = 1+(UShort_t)(65536*rand()/(RAND_MAX+1.0));
163 #else
164  clockseq = 1+(UShort_t)(65536*random()/(RAND_MAX+1.0));
165 #endif
166  firstTime = kFALSE;
167  }
168 
169  uuid_time_t timestamp;
170 
171  // get current time
172  GetCurrentTime(&timestamp);
173 
174  // if clock went backward change clockseq
175  if (CmpTime(&timestamp, time_last_ptr) == -1) {
176  clockseq = (clockseq + 1) & 0x3FFF;
177  if (clockseq == 0) clockseq++;
178  }
179 
180  Format(clockseq, timestamp);
181 
182  time_last = timestamp;
183  fUUIDIndex = 1<<30;
184 }
185 
186 ////////////////////////////////////////////////////////////////////////////////
187 /// delete this TUUID
188 
190 {
191  //gROOT->GetUUIDs()->RemoveUUID(fUUIDIndex);
192 }
193 
194 ////////////////////////////////////////////////////////////////////////////////
195 /// Compare two time values.
196 
198 {
199  if (t1->high < t2->high) return -1;
200  if (t1->high > t2->high) return 1;
201  if (t1->low < t2->low) return -1;
202  if (t1->low > t2->low) return 1;
203  return 0;
204 }
205 
206 ////////////////////////////////////////////////////////////////////////////////
207 /// Set this UUID to the value specified in uuid ((which must be in
208 /// TUUID::AsString() format).
209 
210 void TUUID::SetFromString(const char *uuid)
211 {
212  // Format is tttttttt-tttt-cccc-cccc-nnnnnnnnnnnn.
213  Long_t timeLo;
214  int timeMid;
215  int timeHiAndVersion;
216  int clockSeqHiAndRes;
217  int clockSeqLo;
218  int node[6];
219 
220  sscanf(uuid, "%8lx-%4x-%4x-%2x%2x-%2x%2x%2x%2x%2x%2x",
221  &timeLo,
222  &timeMid,
223  &timeHiAndVersion,
224  &clockSeqHiAndRes,
225  &clockSeqLo,
226  &node[0], &node[1], &node[2], &node[3], &node[4], &node[5]);
227 
228  // Note that we're going through this agony because scanf is
229  // defined to know only to scan into "int"s or "long"s.
230  fTimeLow = (UInt_t) timeLo;
231  fTimeMid = (UShort_t) timeMid;
232  fTimeHiAndVersion = (UShort_t) timeHiAndVersion;
233  fClockSeqHiAndReserved = (UChar_t) clockSeqHiAndRes;
234  fClockSeqLow = (UChar_t) clockSeqLo;
235  fNode[0] = (UChar_t) node[0];
236  fNode[1] = (UChar_t) node[1];
237  fNode[2] = (UChar_t) node[2];
238  fNode[3] = (UChar_t) node[3];
239  fNode[4] = (UChar_t) node[4];
240  fNode[5] = (UChar_t) node[5];
241  fUUIDIndex = 1<<30;
242 }
243 
244 ////////////////////////////////////////////////////////////////////////////////
245 /// Initialize a TUUID with uuid (which must be in TUUID::AsString() format).
246 
247 TUUID::TUUID(const char *uuid)
248 {
249  fTimeLow = 0;
250  fTimeMid = 0;
251  fTimeHiAndVersion = 0;
252  fClockSeqHiAndReserved = 0;
253  fClockSeqLow = 0;
254  fNode[0] = 0;
255  fUUIDIndex = 0;
256 
257  if (!uuid || !*uuid)
258  Error("TUUID", "null string not allowed");
259  else
260  SetFromString(uuid);
261 }
262 
263 ////////////////////////////////////////////////////////////////////////////////
264 /// Stream UUID into output buffer.
265 
266 void TUUID::FillBuffer(char *&buffer)
267 {
268  Version_t version = TUUID::Class_Version();
269  tobuf(buffer, version);
270  tobuf(buffer, fTimeLow);
271  tobuf(buffer, fTimeMid);
272  tobuf(buffer, fTimeHiAndVersion);
273  tobuf(buffer, fClockSeqHiAndReserved);
274  tobuf(buffer, fClockSeqLow);
275  for (Int_t i = 0; i < 6; i++)
276  tobuf(buffer, fNode[i]);
277 }
278 
279 ////////////////////////////////////////////////////////////////////////////////
280 /// Stream UUID from input buffer.
281 
282 void TUUID::ReadBuffer(char *&buffer)
283 {
284  Version_t version;
285  frombuf(buffer, &version);
286  frombuf(buffer, &fTimeLow);
287  frombuf(buffer, &fTimeMid);
288  frombuf(buffer, &fTimeHiAndVersion);
289  frombuf(buffer, &fClockSeqHiAndReserved);
290  frombuf(buffer, &fClockSeqLow);
291  for (Int_t i = 0; i < 6; i++)
292  frombuf(buffer, &fNode[i]);
293 }
294 
295 ////////////////////////////////////////////////////////////////////////////////
296 /// Stream UUID from input buffer.
297 /// This function is for the exclusive use of TDirectory::Streamer() to
298 /// read a non-versioned version of TUUID.
299 
301 {
302  b >> fTimeLow;
303  b >> fTimeMid;
304  b >> fTimeHiAndVersion;
305  b >> fClockSeqHiAndReserved;
306  b >> fClockSeqLow;
307  for (UInt_t i = 0; i < 6; i++) {
308  b >> fNode[i];
309  }
310 }
311 
312 ////////////////////////////////////////////////////////////////////////////////
313 /// Make a UUID from timestamp, clockseq and node id.
314 
316 {
317  fTimeLow = ts.low;
318  fTimeMid = (UShort_t)(ts.high & 0xFFFF);
319  fTimeHiAndVersion = (UShort_t)((ts.high >> 16) & 0x0FFF);
320  fTimeHiAndVersion |= (1 << 12);
321  fClockSeqLow = clockseq & 0xFF;
322  fClockSeqHiAndReserved = (clockseq & 0x3F00) >> 8;
323  fClockSeqHiAndReserved |= 0x80;
324  GetNodeIdentifier();
325 }
326 
327 ////////////////////////////////////////////////////////////////////////////////
328 /// Get current time as 60 bit 100ns ticks since whenever.
329 /// Compensate for the fact that real clock resolution is less
330 /// than 100ns.
331 
333 {
334  const UShort_t uuids_per_tick = 1024;
335 
336  TTHREAD_TLS(uuid_time_t) time_last;
337  TTHREAD_TLS(UShort_t) uuids_this_tick(0);
338  TTHREAD_TLS(Bool_t) init(kFALSE);
339 
340  uuid_time_t *time_last_ptr = TTHREAD_TLS_PTR(time_last);
341 
342  if (!init) {
343  GetSystemTime(time_last_ptr);
344  uuids_this_tick = uuids_per_tick;
345  init = kTRUE;
346  }
347 
348  uuid_time_t time_now;
349 
350  while (1) {
351  GetSystemTime(&time_now);
352 
353  // if clock reading changed since last UUID generated
354  if (CmpTime(time_last_ptr, &time_now)) {
355  // reset count of uuid's generated with this clock reading
356  uuids_this_tick = 0;
357  break;
358  }
359  if (uuids_this_tick < uuids_per_tick) {
360  uuids_this_tick++;
361  break;
362  }
363  // going too fast for our clock; spin
364  }
365 
366  time_last = time_now;
367 
368  if (uuids_this_tick != 0) {
369  if (time_now.low & 0x80000000) {
370  time_now.low += uuids_this_tick;
371  if (!(time_now.low & 0x80000000))
372  time_now.high++;
373  } else
374  time_now.low += uuids_this_tick;
375  }
376 
377  timestamp->high = time_now.high;
378  timestamp->low = time_now.low;
379 }
380 
381 ////////////////////////////////////////////////////////////////////////////////
382 /// Get system time with 100ns precision. Time is since Oct 15, 1582.
383 
385 {
386 #ifdef R__WIN32
387  ULARGE_INTEGER time;
388  GetSystemTimeAsFileTime((FILETIME *)&time);
389  // NT keeps time in FILETIME format which is 100ns ticks since
390  // Jan 1, 1601. UUIDs use time in 100ns ticks since Oct 15, 1582.
391  // The difference is 17 Days in Oct + 30 (Nov) + 31 (Dec)
392  // + 18 years and 5 leap days.
393  time.QuadPart +=
394  (unsigned __int64) (1000*1000*10) // seconds
395  * (unsigned __int64) (60 * 60 * 24) // days
396  * (unsigned __int64) (17+30+31+365*18+5); // # of days
397 
398  timestamp->high = time.HighPart;
399  timestamp->low = time.LowPart;
400 #else
401  struct timeval tp;
402  gettimeofday(&tp, 0);
403  // Offset between UUID formatted times and Unix formatted times.
404  // UUID UTC base time is October 15, 1582.
405  // Unix base time is January 1, 1970.
406  ULong64_t uuid_time = ((ULong64_t)tp.tv_sec * 10000000) + (tp.tv_usec * 10) +
407  0x01B21DD213814000LL;
408  timestamp->high = (UInt_t) (uuid_time >> 32);
409  timestamp->low = (UInt_t) (uuid_time & 0xFFFFFFFF);
410 #endif
411 }
412 
413 ////////////////////////////////////////////////////////////////////////////////
414 /// Get node identifier. Try first to get network address, if no
415 /// network interface try random info based on some machine parameters.
416 
418 {
419  static UInt_t adr = 0;
420 
421  if (gSystem) {
422 #ifndef R__WIN32
423  if (!adr) {
425  if (addr.IsValid())
426  adr = addr.GetAddress();
427  else
428  adr = 1; // illegal address
429  }
430 #else
431  // this way to get the machine's IP address is needed because
432  // GetHostByName() on Win32 contacts the DNS which we don't want
433  // as firewall tools like ZoneAlarm are likely to catch it and
434  // alarm the user
435  if (!adr) {
436  PIP_ADAPTER_INFO ainfo = (PIP_ADAPTER_INFO) malloc(sizeof(IP_ADAPTER_INFO));
437  ULONG buflen = sizeof(IP_ADAPTER_INFO);
438  DWORD stat = GetAdaptersInfo(ainfo, &buflen);
439  if (stat == ERROR_BUFFER_OVERFLOW) {
440  free(ainfo);
441  ainfo = (PIP_ADAPTER_INFO) malloc(buflen);
442  stat = GetAdaptersInfo(ainfo, &buflen);
443  }
444  if (stat != ERROR_SUCCESS)
445  adr = 1; // illegal address
446  else {
447  // take address of first adapter
448  PIP_ADAPTER_INFO adapter = ainfo;
449  int a, b, c, d;
450  sscanf(adapter->IpAddressList.IpAddress.String, "%d.%d.%d.%d",
451  &a, &b, &c, &d);
452  adr = (a << 24) | (b << 16) | (c << 8) | d;
453  }
454  free(ainfo);
455  }
456 #endif
457  if (adr > 2) {
458  memcpy(fNode, &adr, 4);
459  fNode[4] = 0xbe;
460  fNode[5] = 0xef;
461  return;
462  }
463  }
464  static UChar_t seed[16];
465  if (adr < 2) {
466  GetRandomInfo(seed);
467  seed[0] |= 0x80;
468  if (gSystem) adr = 2; // illegal address
469  }
470  memcpy(fNode, seed, sizeof(fNode));
471  fTimeHiAndVersion |= (3 << 12); // version == 3: random node info
472 }
473 
474 ////////////////////////////////////////////////////////////////////////////////
475 /// Get random info based on some machine parameters.
476 
478 {
479 #ifdef R__WIN32
480  struct randomness {
481  MEMORYSTATUS m;
482  SYSTEM_INFO s;
483  FILETIME t;
484  LARGE_INTEGER pc;
485  DWORD tc;
486  DWORD l;
487  char hostname[MAX_COMPUTERNAME_LENGTH + 1];
488  };
489  randomness r;
490  memset(&r, 0, sizeof(r)); // zero also padding bytes
491 
492  // memory usage stats
493  GlobalMemoryStatus(&r.m);
494  // random system stats
495  GetSystemInfo(&r.s);
496  // 100ns resolution time of day
497  GetSystemTimeAsFileTime(&r.t);
498  // high resolution performance counter
499  QueryPerformanceCounter(&r.pc);
500  // milliseconds since last boot
501  r.tc = GetTickCount();
502  r.l = MAX_COMPUTERNAME_LENGTH + 1;
503  GetComputerName(r.hostname, &r.l);
504 #else
505  struct randomness {
506 #if defined(R__LINUX) && !defined(R__WINGCC)
507  struct sysinfo s;
508 #endif
509  struct timeval t;
510  char hostname[257];
511  };
512  randomness r;
513  memset(&r, 0, sizeof(r)); // zero also padding bytes
514 
515 #if defined(R__LINUX) && !defined(R__WINGCC)
516  sysinfo(&r.s);
517 #endif
518  gettimeofday(&r.t, 0);
519  gethostname(r.hostname, 256);
520 #endif
521  TMD5 md5;
522  md5.Update((UChar_t *)&r, sizeof(randomness));
523  md5.Final(seed);
524 }
525 
526 ////////////////////////////////////////////////////////////////////////////////
527 /// Print UUID.
528 
529 void TUUID::Print() const
530 {
531  printf("%s\n", AsString());
532 }
533 
534 ////////////////////////////////////////////////////////////////////////////////
535 /// Return UUID as string. Copy string immediately since it will be reused.
536 
537 const char *TUUID::AsString() const
538 {
539  static char uuid[40];
540 
541  snprintf(uuid,40, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
542  fTimeLow, fTimeMid, fTimeHiAndVersion, fClockSeqHiAndReserved,
543  fClockSeqLow, fNode[0], fNode[1], fNode[2], fNode[3], fNode[4],
544  fNode[5]);
545 
546  return uuid;
547 }
548 
549 ////////////////////////////////////////////////////////////////////////////////
550 /// Compute 16-bit hash value of the UUID.
551 
553 {
554  Short_t c0 = 0, c1 = 0, x, y;
555  char *c = (char *) &fTimeLow;
556 
557  // For speed lets unroll the following loop:
558  // for (i = 0; i < 16; i++) {
559  // c0 += *c++;
560  // c1 += c0;
561  // }
562 
563  c0 += *c++; c1 += c0;
564  c0 += *c++; c1 += c0;
565  c0 += *c++; c1 += c0;
566  c0 += *c++; c1 += c0;
567 
568  c0 += *c++; c1 += c0;
569  c0 += *c++; c1 += c0;
570  c0 += *c++; c1 += c0;
571  c0 += *c++; c1 += c0;
572 
573  c0 += *c++; c1 += c0;
574  c0 += *c++; c1 += c0;
575  c0 += *c++; c1 += c0;
576  c0 += *c++; c1 += c0;
577 
578  c0 += *c++; c1 += c0;
579  c0 += *c++; c1 += c0;
580  c0 += *c++; c1 += c0;
581  c0 += *c++; c1 += c0;
582 
583  // Calculate the value for "First octet" of the hash
584  x = -c1 % 255;
585  if (x < 0)
586  x += 255;
587 
588  // Calculate the value for "second octet" of the hash
589  y = (c1 - c0) % 255;
590  if (y < 0)
591  y += 255;
592 
593  return UShort_t((y << 8) + x);
594 }
595 
596 ////////////////////////////////////////////////////////////////////////////////
597 /// Compare two UUIDs "lexically" and return
598 /// - -1 this is lexically before u
599 /// - 0 this is equal to u
600 /// - 1 this is lexically after u
601 
602 Int_t TUUID::Compare(const TUUID &u) const
603 {
604 #define CHECK(f1, f2) if (f1 != f2) return f1 < f2 ? -1 : 1;
605  CHECK(fTimeLow, u.fTimeLow)
606  CHECK(fTimeMid, u.fTimeMid)
607  CHECK(fTimeHiAndVersion, u.fTimeHiAndVersion)
608  CHECK(fClockSeqHiAndReserved, u.fClockSeqHiAndReserved)
609  CHECK(fClockSeqLow, u.fClockSeqLow)
610  for (int i = 0; i < 6; i++) {
611  if (fNode[i] < u.fNode[i])
612  return -1;
613  if (fNode[i] > u.fNode[i])
614  return 1;
615  }
616  return 0;
617 }
618 
619 ////////////////////////////////////////////////////////////////////////////////
620 /// Get address of host encoded in UUID. If host id is not an ethernet
621 /// address, but random info, then the returned TInetAddress is not valid.
622 
624 {
625  if ((fTimeHiAndVersion >> 12) == 1) {
626  UInt_t addr;
627  memcpy(&addr, fNode, 4);
628  return TInetAddress("????", addr, 0);
629  }
630  return TInetAddress();
631 }
632 
633 ////////////////////////////////////////////////////////////////////////////////
634 /// Get time from UUID.
635 
637 {
638  TDatime dt;
639  uuid_time_t ts;
640 
641  ts.low = fTimeLow;
642  ts.high = (UInt_t)fTimeMid;
643  ts.high |= (UInt_t)((fTimeHiAndVersion & 0x0FFF) << 16);
644 
645  // Offset between UUID formatted times and Unix formatted times.
646  // UUID UTC base time is October 15, 1582.
647  // Unix base time is January 1, 1970.
648  ULong64_t high = ts.high;
649  ULong64_t uuid_time = (high << 32) + ts.low;
650  uuid_time -= 0x01B21DD213814000LL;
651  uuid_time /= 10000000LL;
652  UInt_t tt = (UInt_t) uuid_time;
653  dt.Set(tt);
654 
655  return dt;
656 }
657 
658 ////////////////////////////////////////////////////////////////////////////////
659 /// Return uuid in specified buffer (16 byte = 128 bits).
660 
661 void TUUID::GetUUID(UChar_t uuid[16]) const
662 {
663  memcpy(uuid, &fTimeLow, 16);
664 }
665 
666 ////////////////////////////////////////////////////////////////////////////////
667 /// Set this UUID to the value specified in uuid ((which must be in
668 /// TUUID::AsString() format).
669 
670 void TUUID::SetUUID(const char *uuid)
671 {
672  if (!uuid || !*uuid)
673  Error("SetUUID", "null string not allowed");
674  else
675  SetFromString(uuid);
676 }
677 
678 ////////////////////////////////////////////////////////////////////////////////
679 /// Input operator. Delegate to Streamer.
680 
681 TBuffer &operator<<(TBuffer &buf, const TUUID &uuid)
682 {
683  R__ASSERT( buf.IsWriting() );
684 
685  const_cast<TUUID&>(uuid).Streamer(buf);
686  return buf;
687 }
virtual ~TUUID()
delete this TUUID
Definition: TUUID.cxx:189
void frombuf(char *&buf, Bool_t *x)
Definition: Bytes.h:280
Bool_t IsWriting() const
Definition: TBuffer.h:82
virtual int GetPid()
Get process id.
Definition: TSystem.cxx:714
long long Long64_t
Definition: RtypesCore.h:69
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:136
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:282
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
TArc * a
Definition: textangle.C:12
R__EXTERN TVirtualMutex * gROOTMutex
Definition: TROOT.h:57
#define malloc
Definition: civetweb.c:818
TLatex * t1
Definition: textangle.C:20
Int_t CmpTime(uuid_time_t *t1, uuid_time_t *t2)
Compare two time values.
Definition: TUUID.cxx:197
TBuffer & operator<<(TBuffer &buf, const TUUID &uuid)
Input operator. Delegate to Streamer.
Definition: TUUID.cxx:681
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:636
Double_t x[n]
Definition: legend1.C:17
TText * tt
Definition: textangle.C:16
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:2267
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:470
TRandom2 r(17)
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:539
UInt_t GetAddress() const
Definition: TInetAddress.h:68
#define CHECK(f1, f2)
unsigned int UInt_t
Definition: RtypesCore.h:42
TMarker * m
Definition: textangle.C:8
short Short_t
Definition: RtypesCore.h:35
TLine * l
Definition: textangle.C:4
#define R__LOCKGUARD2(mutex)
const Bool_t kFALSE
Definition: RtypesCore.h:92
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:315
#define ClassImp(name)
Definition: Rtypes.h:336
static Int_t init()
virtual const char * HostName()
Return the system&#39;s host name.
Definition: TSystem.cxx:310
void StreamerV1(TBuffer &b)
Stream UUID from input buffer.
Definition: TUUID.cxx:300
unsigned long long ULong64_t
Definition: RtypesCore.h:70
#define free
Definition: civetweb.c:821
Double_t y[n]
Definition: legend1.C:17
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:537
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:670
UChar_t fClockSeqHiAndReserved
Definition: TUUID.h:49
Bool_t IsValid() const
Definition: TInetAddress.h:76
void GetRandomInfo(UChar_t seed[16])
Get random info based on some machine parameters.
Definition: TUUID.cxx:477
void GetNodeIdentifier()
Get node identifier.
Definition: TUUID.cxx:417
UShort_t Hash() const
Compute 16-bit hash value of the UUID.
Definition: TUUID.cxx:552
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:266
Int_t Compare(const TUUID &u) const
Compare two UUIDs "lexically" and return.
Definition: TUUID.cxx:602
UChar_t fClockSeqLow
Definition: TUUID.h:50
unsigned char UChar_t
Definition: RtypesCore.h:34
void Print() const
Print UUID.
Definition: TUUID.cxx:529
void GetSystemTime(uuid_time_t *timestamp)
Get system time with 100ns precision. Time is since Oct 15, 1582.
Definition: TUUID.cxx:384
const Bool_t kTRUE
Definition: RtypesCore.h:91
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:210
void GetUUID(UChar_t uuid[16]) const
Return uuid in specified buffer (16 byte = 128 bits).
Definition: TUUID.cxx:661
TInetAddress GetHostAddress() const
Get address of host encoded in UUID.
Definition: TUUID.cxx:623
void GetCurrentTime(uuid_time_t *timestamp)
Get current time as 60 bit 100ns ticks since whenever.
Definition: TUUID.cxx:332
This class stores the date and time with a precision of one second in an unsigned 32 bit word (950130...
Definition: TDatime.h:37
static char * Format(const char *format, va_list ap)
Format a string in a circular formatting buffer (using a printf style format descriptor).
Definition: TString.cxx:2409