125#define getpid() _getpid()
126#define srandom(seed) srand(seed)
127#define random() rand()
131#if defined(R__LINUX) && !defined(R__WINGCC)
132#include <sys/sysinfo.h>
135#include <netinet/in.h>
149 uuid_time_t *time_last_ptr = TTHREAD_TLS_PTR(time_last);
159 using namespace std::chrono;
160 system_clock::time_point today = system_clock::now();
161 seed = (
UInt_t)(system_clock::to_time_t ( today )) + ::getpid();
165 clockseq = 1+(
UShort_t)(65536*random()/(RAND_MAX+1.0));
175 if (
CmpTime(×tamp, time_last_ptr) == -1) {
176 clockseq = (clockseq + 1) & 0x3FFF;
177 if (clockseq == 0) clockseq++;
180 Format(clockseq, timestamp);
182 time_last = timestamp;
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;
215 int timeHiAndVersion;
216 int clockSeqHiAndRes;
220 sscanf(uuid,
"%8lx-%4x-%4x-%2x%2x-%2x%2x%2x%2x%2x%2x",
226 &node[0], &node[1], &node[2], &node[3], &node[4], &node[5]);
258 Error(
"TUUID",
"null string not allowed");
268 Version_t version = TUUID::Class_Version();
269 tobuf(buffer, version);
275 for (
Int_t i = 0; i < 6; i++)
291 for (
Int_t i = 0; i < 6; i++)
307 for (
UInt_t i = 0; i < 6; i++) {
334 const UShort_t uuids_per_tick = 1024;
337 TTHREAD_TLS(
UShort_t) uuids_this_tick(0);
340 uuid_time_t *time_last_ptr = TTHREAD_TLS_PTR(time_last);
344 uuids_this_tick = uuids_per_tick;
354 if (
CmpTime(time_last_ptr, &time_now)) {
359 if (uuids_this_tick < uuids_per_tick) {
366 time_last = time_now;
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))
374 time_now.
low += uuids_this_tick;
378 timestamp->
low = time_now.
low;
388 GetSystemTimeAsFileTime((FILETIME *)&time);
394 (
unsigned __int64) (1000*1000*10)
395 * (
unsigned __int64) (60 * 60 * 24)
396 * (
unsigned __int64) (17+30+31+365*18+5);
398 timestamp->
high = time.HighPart;
399 timestamp->
low = time.LowPart;
402 gettimeofday(&tp, 0);
407 0x01B21DD213814000LL;
409 timestamp->
low = (
UInt_t) (uuid_time & 0xFFFFFFFF);
426 struct ifaddrs *ifAddrStruct =
nullptr;
427 struct ifaddrs *ifa =
nullptr;
429 if (getifaddrs(&ifAddrStruct) != 0) {
432 for (ifa = ifAddrStruct; ifa != NULL; ifa = ifa->ifa_next) {
433 if (!ifa->ifa_addr) {
436 if (ifa->ifa_addr->sa_family != AF_INET) {
439 if (strncmp(ifa->ifa_name,
"lo",2) == 0) {
442 addr = ntohl(((
struct sockaddr_in *)ifa->ifa_addr)->sin_addr.s_addr);
447 if (ifAddrStruct !=
nullptr)
448 freeifaddrs(ifAddrStruct);
461 PIP_ADAPTER_INFO ainfo = (PIP_ADAPTER_INFO)
malloc(
sizeof(IP_ADAPTER_INFO));
462 ULONG buflen =
sizeof(IP_ADAPTER_INFO);
463 DWORD stat = GetAdaptersInfo(ainfo, &buflen);
464 if (stat == ERROR_BUFFER_OVERFLOW) {
466 ainfo = (PIP_ADAPTER_INFO)
malloc(buflen);
467 stat = GetAdaptersInfo(ainfo, &buflen);
469 if (stat != ERROR_SUCCESS)
473 PIP_ADAPTER_INFO adapter = ainfo;
475 sscanf(adapter->IpAddressList.IpAddress.String,
"%d.%d.%d.%d",
477 adr = (
a << 24) | (
b << 16) | (
c << 8) |
d;
483 memcpy(
fNode, &adr, 4);
512 char hostname[MAX_COMPUTERNAME_LENGTH + 1];
515 memset(&
r, 0,
sizeof(
r));
518 GlobalMemoryStatus(&
r.m);
522 GetSystemTimeAsFileTime(&
r.t);
524 QueryPerformanceCounter(&
r.pc);
526 r.tc = GetTickCount();
527 r.l = MAX_COMPUTERNAME_LENGTH + 1;
528 GetComputerName(
r.hostname, &
r.l);
531#if defined(R__LINUX) && !defined(R__WINGCC)
538 memset(&
r, 0,
sizeof(
r));
540#if defined(R__LINUX) && !defined(R__WINGCC)
543 gettimeofday(&
r.t, 0);
544 gethostname(
r.hostname, 256);
564 static char uuid[40];
566 snprintf(uuid,40,
"%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
588 c0 += *
c++;
c1 += c0;
589 c0 += *
c++;
c1 += c0;
590 c0 += *
c++;
c1 += c0;
591 c0 += *
c++;
c1 += c0;
593 c0 += *
c++;
c1 += c0;
594 c0 += *
c++;
c1 += c0;
595 c0 += *
c++;
c1 += c0;
596 c0 += *
c++;
c1 += c0;
598 c0 += *
c++;
c1 += c0;
599 c0 += *
c++;
c1 += c0;
600 c0 += *
c++;
c1 += c0;
601 c0 += *
c++;
c1 += c0;
603 c0 += *
c++;
c1 += c0;
604 c0 += *
c++;
c1 += c0;
605 c0 += *
c++;
c1 += c0;
606 c0 += *
c++;
c1 += c0;
629#define CHECK(f1, f2) if (f1 != f2) return f1 < f2 ? -1 : 1;
635 for (
int i = 0; i < 6; i++) {
652 memcpy(&addr,
fNode, 4);
675 uuid_time -= 0x01B21DD213814000LL;
676 uuid_time /= 10000000LL;
698 Error(
"SetUUID",
"null string not allowed");
710 const_cast<TUUID&
>(uuid).Streamer(buf);
void frombuf(char *&buf, Bool_t *x)
void tobuf(char *&buf, Bool_t x)
unsigned long long ULong64_t
void Error(const char *location, const char *msgfmt,...)
R__EXTERN TVirtualMutex * gROOTMutex
R__EXTERN TSystem * gSystem
TBuffer & operator<<(TBuffer &buf, const TUUID &uuid)
Input operator. Delegate to Streamer.
#define R__LOCKGUARD(mutex)
Buffer base class used for serializing objects.
This class stores the date and time with a precision of one second in an unsigned 32 bit word (950130...
void Set()
Set Date/Time to current time as reported by the system.
This class represents an Internet Protocol (IP) address.
This code implements the MD5 message-digest algorithm.
void Update(const UChar_t *buf, UInt_t len)
Update TMD5 object to reflect the concatenation of another buffer full of bytes.
void Final()
MD5 finalization, ends an MD5 message-digest operation, writing the the message digest and zeroizing ...
virtual int GetPid()
Get process id.
virtual TTime Now()
Get current time in milliseconds since 0:00 Jan 1 1995.
This class defines a UUID (Universally Unique IDentifier), also known as GUIDs (Globally Unique IDent...
UChar_t fClockSeqHiAndReserved
void GetCurrentTime(uuid_time_t *timestamp)
Get current time as 60 bit 100ns ticks since whenever.
Int_t CmpTime(uuid_time_t *t1, uuid_time_t *t2)
Compare two time values.
void GetSystemTime(uuid_time_t *timestamp)
Get system time with 100ns precision. Time is since Oct 15, 1582.
virtual ~TUUID()
delete this TUUID
void ReadBuffer(char *&buffer)
Stream UUID from input buffer.
void SetFromString(const char *uuid_str)
Set this UUID to the value specified in uuid ((which must be in TUUID::AsString() format).
void Format(UShort_t clockseq, uuid_time_t ts)
Make a UUID from timestamp, clockseq and node id.
TDatime GetTime() const
Get time from UUID.
UInt_t fTimeLow
index in the list of UUIDs in TProcessUUID
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 SetUUID(const char *uuid_str)
Set this UUID to the value specified in uuid ((which must be in TUUID::AsString() format).
UShort_t Hash() const
Compute 16-bit hash value of the UUID.
UShort_t fTimeHiAndVersion
void GetRandomInfo(UChar_t seed[16])
Get random info based on some machine parameters.
void Print() const
Print UUID.
Int_t Compare(const TUUID &u) const
Compare two UUIDs "lexically" and return.
void FillBuffer(char *&buffer)
Stream UUID into output buffer.
void GetNodeIdentifier()
Get node identifier.
void StreamerV1(TBuffer &b)
Stream UUID from input buffer.
EvaluateInfo init(std::vector< RooRealProxy > parameters, std::vector< ArrayWrapper * > wrappers, std::vector< double * > arrays, size_t begin, size_t batchSize)
static constexpr double s
static constexpr double pc