32 #include <sys/types.h> 65 fd = open (
"/dev/urandom", O_RDONLY);
73 fcntl (fd, F_SETFD, FD_CLOEXEC);
75 srand (getpid () +
time (NULL));
82 for (
int i = 0; i < 16; ++i)
83 ((
unsigned char*)luid)[i] = (
unsigned char)(rand()>>7);
87 if (read (fd, luid, 16) < 16)
94 while (!*(((intptr_t*)luid)+1));
101 memcpy (dest, src, 16);
108 return !memcmp (luida, luidb, 16);
114 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.