2023-08-17 11:45:59 -04:00
|
|
|
/* _,.---._ .-._ .--.-. ,--.--------.
|
|
|
|
* _,..---._ ,-.' , - `. /==/ \ .-._/==/ //==/, - , -\
|
|
|
|
* /==/, - \ /==/_, , - \|==|, \/ /, |==\ -\\==\.-. - ,-./
|
|
|
|
* |==| _ _\==| .=. |==|- \| | \==\- \`--`\==\- \
|
|
|
|
* |==| .=. |==|_ : ;=: - |==| , | -| `--`-' \==\_ \
|
|
|
|
* |==|,| | -|==| , '=' |==| - _ | |==|- |
|
|
|
|
* |==| '=' /\==\ - ,_ /|==| /\ , | |==|, |
|
|
|
|
* |==|-, _`/ '.='. - .' /==/, | |- | /==/ -/
|
|
|
|
* `-.`.____.' `--`--'' `--`./ `--` `--`--`
|
|
|
|
* _ __ ,---. .-._ .=-.-. _,.----.
|
|
|
|
* .-`.' ,`..--.' \ /==/ \ .-._ /==/_ /.' .' - \
|
|
|
|
* /==/, - \==\-/\ \ |==|, \/ /, /==|, |/==/ , ,-'
|
|
|
|
* |==| _ .=. /==/-|_\ | |==|- \| ||==| ||==|- | .
|
|
|
|
* |==| , '=',\==\, - \ |==| , | -||==|- ||==|_ `-' \
|
|
|
|
* |==|- '..'/==/ - ,| |==| - _ ||==| ,||==| _ , |
|
|
|
|
* |==|, | /==/- /\ - \|==| /\ , ||==|- |\==\. /
|
|
|
|
* /==/ - | \==\ _.\=\.-'/==/, | |- |/==/. / `-.`.___.-'
|
|
|
|
* `--`---' `--` `--`./ `--``--`-`
|
|
|
|
*
|
|
|
|
* @(#)Copyright (c) 2023, Nathan D. Fisher.
|
|
|
|
*
|
|
|
|
* This is free software. It comes with NO WARRANTY.
|
|
|
|
* Permission to use, modify and distribute this source code
|
|
|
|
* is granted subject to the following conditions.
|
|
|
|
* 1/ that the above copyright notice and this notice
|
|
|
|
* are preserved in all copies and that due credit be given
|
|
|
|
* to the author.
|
|
|
|
* 2/ that any changes to this code are clearly commented
|
|
|
|
* as such so that the author does not get blamed for bugs
|
|
|
|
* other than his own.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef HAGGIS_LINKMAP
|
|
|
|
#define HAGGIS_LINKMAP 1
|
|
|
|
|
|
|
|
#include "haggis.h"
|
|
|
|
#include <pthread.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
|
|
|
#define HAGGIS_BUCKETS_BASE 64
|
|
|
|
|
2023-08-17 23:26:53 -04:00
|
|
|
typedef struct __bucket {
|
2023-08-17 11:45:59 -04:00
|
|
|
union {
|
|
|
|
ino_t val;
|
|
|
|
u8 bytes[sizeof(ino_t)];
|
2023-08-17 23:26:53 -04:00
|
|
|
} key;
|
2023-08-17 11:45:59 -04:00
|
|
|
uint64_t hash;
|
2023-08-17 23:26:53 -04:00
|
|
|
char * path;
|
|
|
|
struct __bucket * next;
|
|
|
|
} haggis_bucket;
|
2023-08-17 11:45:59 -04:00
|
|
|
|
|
|
|
typedef struct {
|
2023-08-18 00:23:02 -04:00
|
|
|
pthread_mutex_t mutex;
|
2023-08-17 11:45:59 -04:00
|
|
|
size_t len;
|
|
|
|
size_t capacity;
|
2023-08-17 23:26:53 -04:00
|
|
|
haggis_bucket *buckets;
|
2023-08-17 11:45:59 -04:00
|
|
|
} haggis_linkmap;
|
|
|
|
|
|
|
|
#endif // !HAGGIS_LINKMAP
|