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