120 #include <Iphlpapi.h>
123 #include <sys/time.h>
124 #if defined(R__LINUX) && !defined(R__WINGCC)
125 #include <sys/sysinfo.h>
137 TTHREAD_TLS(uuid_time_t) time_last;
140 uuid_time_t *time_last_ptr = TTHREAD_TLS_PTR(time_last);
150 using namespace std::chrono;
151 system_clock::time_point today = system_clock::now();
152 seed = (
UInt_t)(system_clock::to_time_t ( today )) + ::getpid();
159 GetCurrentTime(time_last_ptr);
161 clockseq = 1+(
UShort_t)(65536*rand()/(RAND_MAX+1.0));
168 uuid_time_t timestamp;
171 GetCurrentTime(×tamp);
174 if (CmpTime(×tamp, time_last_ptr) == -1) {
175 clockseq = (clockseq + 1) & 0x3FFF;
176 if (clockseq == 0) clockseq++;
179 Format(clockseq, timestamp);
181 time_last = timestamp;
200 if (t1->
low < t2->
low)
return -1;
201 if (t1->
low > t2->
low)
return 1;
214 int timeHiAndVersion;
215 int clockSeqHiAndRes;
219 sscanf(uuid,
"%8lx-%4x-%4x-%2x%2x-%2x%2x%2x%2x%2x%2x",
225 &node[0], &node[1], &node[2], &node[3], &node[4], &node[5]);
257 Error(
"TUUID",
"null string not allowed");
267 Version_t version = TUUID::Class_Version();
268 tobuf(buffer, version);
274 for (
Int_t i = 0; i < 6; i++)
290 for (
Int_t i = 0; i < 6; i++)
306 for (
UInt_t i = 0; i < 6; i++) {
333 const UShort_t uuids_per_tick = 1024;
336 TTHREAD_TLS(
UShort_t) uuids_this_tick(0);
339 uuid_time_t *time_last_ptr = TTHREAD_TLS_PTR(time_last);
343 uuids_this_tick = uuids_per_tick;
353 if (
CmpTime(time_last_ptr, &time_now)) {
358 if (uuids_this_tick < uuids_per_tick) {
365 time_last = time_now;
367 if (uuids_this_tick != 0) {
368 if (time_now.
low & 0x80000000) {
369 time_now.
low += uuids_this_tick;
370 if (!(time_now.
low & 0x80000000))
373 time_now.
low += uuids_this_tick;
377 timestamp->
low = time_now.
low;
387 GetSystemTimeAsFileTime((FILETIME *)&time);
393 (
unsigned __int64) (1000*1000*10)
394 * (
unsigned __int64) (60 * 60 * 24)
395 * (
unsigned __int64) (17+30+31+365*18+5);
397 timestamp->
high = time.HighPart;
398 timestamp->
low = time.LowPart;
401 gettimeofday(&tp, 0);
406 0x01B21DD213814000LL;
408 timestamp->
low = (
UInt_t) (uuid_time & 0xFFFFFFFF);
435 PIP_ADAPTER_INFO ainfo = (PIP_ADAPTER_INFO)
malloc(
sizeof(IP_ADAPTER_INFO));
436 ULONG buflen =
sizeof(IP_ADAPTER_INFO);
437 DWORD stat = GetAdaptersInfo(ainfo, &buflen);
438 if (stat == ERROR_BUFFER_OVERFLOW) {
440 ainfo = (PIP_ADAPTER_INFO)
malloc(buflen);
441 stat = GetAdaptersInfo(ainfo, &buflen);
443 if (stat != ERROR_SUCCESS)
447 PIP_ADAPTER_INFO adapter = ainfo;
449 sscanf(adapter->IpAddressList.IpAddress.String,
"%d.%d.%d.%d",
451 adr = (a << 24) | (b << 16) | (c << 8) | d;
457 memcpy(
fNode, &adr, 4);
486 char hostname[MAX_COMPUTERNAME_LENGTH + 1];
489 memset(&r, 0,
sizeof(r));
492 GlobalMemoryStatus(&r.m);
496 GetSystemTimeAsFileTime(&r.t);
498 QueryPerformanceCounter(&r.pc);
500 r.tc = GetTickCount();
501 r.l = MAX_COMPUTERNAME_LENGTH + 1;
502 GetComputerName(r.hostname, &r.l);
505 #if defined(R__LINUX) && !defined(R__WINGCC)
512 memset(&r, 0,
sizeof(r));
514 #if defined(R__LINUX) && !defined(R__WINGCC)
517 gettimeofday(&r.t, 0);
518 gethostname(r.hostname, 256);
538 static char uuid[40];
540 snprintf(uuid,40,
"%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
562 c0 += *c++;
c1 += c0;
563 c0 += *c++;
c1 += c0;
564 c0 += *c++;
c1 += c0;
565 c0 += *c++;
c1 += c0;
567 c0 += *c++;
c1 += c0;
568 c0 += *c++;
c1 += c0;
569 c0 += *c++;
c1 += c0;
570 c0 += *c++;
c1 += c0;
572 c0 += *c++;
c1 += c0;
573 c0 += *c++;
c1 += c0;
574 c0 += *c++;
c1 += c0;
575 c0 += *c++;
c1 += c0;
577 c0 += *c++;
c1 += c0;
578 c0 += *c++;
c1 += c0;
579 c0 += *c++;
c1 += c0;
580 c0 += *c++;
c1 += c0;
603 #define CHECK(f1, f2) if (f1 != f2) return f1 < f2 ? -1 : 1;
609 for (
int i = 0; i < 6; i++) {
626 memcpy(&addr,
fNode, 4);
649 uuid_time -= 0x01B21DD213814000LL;
650 uuid_time /= 10000000LL;
672 Error(
"SetUUID",
"null string not allowed");
684 const_cast<TUUID&
>(uuid).Streamer(buf);
TDatime GetTime() const
Get time from UUID.
virtual ~TUUID()
delete this TUUID
void frombuf(char *&buf, Bool_t *x)
virtual int GetPid()
Get process id.
void Set()
Set Date/Time to current time as reported by the system.
void Final()
MD5 finalization, ends an MD5 message-digest operation, writing the the message digest and zeroizing ...
This class represents an Internet Protocol (IP) address.
void ReadBuffer(char *&buffer)
Stream UUID from input buffer.
UInt_t fTimeLow
index in the list of UUIDs in TProcessUUID
Buffer base class used for serializing objects.
R__EXTERN TVirtualMutex * gROOTMutex
Int_t CmpTime(uuid_time_t *t1, uuid_time_t *t2)
Compare two time values.
TBuffer & operator<<(TBuffer &buf, const TUUID &uuid)
Input operator. Delegate to Streamer.
This class defines a UUID (Universally Unique IDentifier), also known as GUIDs (Globally Unique IDent...
This code implements the MD5 message-digest algorithm.
UShort_t fTimeHiAndVersion
UChar_t mod R__LOCKGUARD2(gSrvAuthenticateMutex)
void Print() const
Print UUID.
void tobuf(char *&buf, Bool_t x)
virtual TInetAddress GetHostByName(const char *server)
Get Internet Protocol (IP) address of host.
void Error(const char *location, const char *msgfmt,...)
UInt_t GetAddress() const
virtual TTime Now()
Get current time in milliseconds since 0:00 Jan 1 1995.
void Update(const UChar_t *buf, UInt_t len)
Update TMD5 object to reflect the concatenation of another buffer full of bytes.
R__EXTERN TSystem * gSystem
UShort_t Hash() const
Compute 16-bit hash value of the UUID.
const char * AsString() const
Return UUID as string. Copy string immediately since it will be reused.
void GetUUID(UChar_t uuid[16]) const
Return uuid in specified buffer (16 byte = 128 bits).
TInetAddress GetHostAddress() const
Get address of host encoded in UUID.
void Format(UShort_t clockseq, uuid_time_t ts)
Make a UUID from timestamp, clockseq and node id.
virtual const char * HostName()
Return the system's host name.
void StreamerV1(TBuffer &b)
Stream UUID from input buffer.
unsigned long long ULong64_t
ClassImp(TMCParticle) void TMCParticle printf(": p=(%7.3f,%7.3f,%9.3f) ;", fPx, fPy, fPz)
ClassImp(TUUID) TUUID
Create a UUID.
void SetUUID(const char *uuid_str)
Set this UUID to the value specified in uuid ((which must be in TUUID::AsString() format)...
UChar_t fClockSeqHiAndReserved
Int_t Compare(const TUUID &u) const
Compare two UUIDs "lexically" and return.
void GetRandomInfo(UChar_t seed[16])
Get random info based on some machine parameters.
void GetNodeIdentifier()
Get node identifier.
void FillBuffer(char *&buffer)
Stream UUID into output buffer.
void GetSystemTime(uuid_time_t *timestamp)
Get system time with 100ns precision. Time is since Oct 15, 1582.
Vc_ALWAYS_INLINE_L T *Vc_ALWAYS_INLINE_R malloc(size_t n)
Allocates memory on the Heap with alignment and padding suitable for vectorized access.
void SetFromString(const char *uuid_str)
Set this UUID to the value specified in uuid ((which must be in TUUID::AsString() format)...
void GetCurrentTime(uuid_time_t *timestamp)
Get current time as 60 bit 100ns ticks since whenever.
This class stores the date and time with a precision of one second in an unsigned 32 bit word (950130...
static char * Format(const char *format, va_list ap)
Format a string in a circular formatting buffer (using a printf style format descriptor).