23 #include <sys/types.h> 56 fd = open (
"/dev/urandom", O_RDONLY);
64 fcntl (fd, F_SETFD, FD_CLOEXEC);
66 srand (getpid () +
time (NULL));
73 for (
int i = 0; i < 16; ++i)
74 ((
unsigned char*)luid)[i] = (
unsigned char)(rand()>>7);
78 if (read (fd, luid, 16) < 16)
85 while (!*(((intptr_t*)luid)+1));
92 memcpy (dest, src, 16);
99 return !memcmp (luida, luidb, 16);
105 return *(
size_t*)luid;
size_t lumiera_uid_hash(const lumiera_uid *luid)
Generate a hash sum over an luid.
Common functions for handling of time values.
void * lumiera_uid_ptr_get(const lumiera_uid *luid)
Retrieve a generic pointer stored in a luid.
Lumiera unique object identifier.
void lumiera_uid_gen(lumiera_uid *luid)
Generate a new luid.
void lumiera_uid_copy(lumiera_uid *dest, lumiera_uid *src)
Copy an luid.
int lumiera_uid_eq(const lumiera_uid *luida, const lumiera_uid *luidb)
Test 2 luid's for equality.
unsigned char lumiera_uid[16]
storage for a Lumiera unique ID, based on a 128bit random number
void lumiera_uid_set_ptr(lumiera_uid *luid, void *ptr)
Store a generic pointer in a luid.