odyssey/sources/id.h

39 lines
586 B
C
Raw Normal View History

2017-06-20 13:33:20 +00:00
#ifndef OD_ID_H
#define OD_ID_H
/*
2017-07-05 12:42:49 +00:00
* Odissey.
2017-06-20 13:33:20 +00:00
*
2017-07-05 12:42:49 +00:00
* Advanced PostgreSQL connection pooler.
2017-06-20 13:33:20 +00:00
*/
typedef struct od_id od_id_t;
typedef struct od_idmgr od_idmgr_t;
#define OD_ID_SEEDMAX 6
2017-06-20 13:33:20 +00:00
struct od_id
{
uint8_t id[OD_ID_SEEDMAX * 2];
2017-06-20 13:33:20 +00:00
};
struct od_idmgr
{
uint64_t seq;
uint8_t seed[OD_ID_SEEDMAX];
2017-06-20 13:33:20 +00:00
pid_t pid;
uid_t uid;
};
void od_idmgr_init(od_idmgr_t*);
int od_idmgr_seed(od_idmgr_t*);
2017-06-20 13:33:20 +00:00
void od_idmgr_generate(od_idmgr_t*, od_id_t*);
static inline int
od_idmgr_cmp(od_id_t *a, od_id_t *b)
{
2017-06-20 15:43:46 +00:00
return memcmp(a->id, b->id, sizeof(a->id)) == 0;
}
2017-06-20 13:33:20 +00:00
#endif /* OD_ID_H */