summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2023-01-10 15:36:47 -0800
committerVito Caputo <vcaputo@pengaru.com>2023-01-10 23:51:44 -0800
commitd0a302aff0b3da86aa32b3cfea177ec41cc6488d (patch)
tree5d828fb08fc21e2fd98736f9c720a698768f5fb1
parent36e06f2ce3f2789bf51dc156820cdf85dc859b55 (diff)
til_module_context: hash the path
The purpose of the context path is to aid in locating the context instance. The initial application of this will be in service of the taps, which require their module's path as a sort of containing directory of the tap name. It'd be convenient to simply add the path hash with the tap hash to produce the tap's "absolute path" hash when looking up in the hash table.
-rw-r--r--src/til_module_context.c3
-rw-r--r--src/til_module_context.h3
2 files changed, 6 insertions, 0 deletions
diff --git a/src/til_module_context.c b/src/til_module_context.c
index 5dffa73..9767d96 100644
--- a/src/til_module_context.c
+++ b/src/til_module_context.c
@@ -1,8 +1,10 @@
#include <assert.h>
#include <errno.h>
+#include <stdint.h>
#include <stdlib.h>
#include "til.h"
+#include "til_jenkins.h"
#include "til_module_context.h"
@@ -41,6 +43,7 @@ void * til_module_context_new(size_t size, unsigned seed, unsigned ticks, unsign
module_context->ticks = ticks;
module_context->n_cpus = n_cpus;
module_context->path = path;
+ module_context->path_hash = til_jenkins((uint8_t *)path, strlen(path));
return module_context;
}
diff --git a/src/til_module_context.h b/src/til_module_context.h
index d017a99..b2caf28 100644
--- a/src/til_module_context.h
+++ b/src/til_module_context.h
@@ -1,6 +1,8 @@
#ifndef _TIL_MODULE_CONTEXT_H
#define _TIL_MODULE_CONTEXT_H
+#include <stdint.h>
+
typedef struct til_module_context_t til_module_context_t;
typedef struct til_module_t til_module_t;
@@ -10,6 +12,7 @@ struct til_module_context_t {
unsigned ticks;
unsigned n_cpus;
char *path; /* for locating this instance of the module, NOT a file path */
+ uint32_t path_hash;
};
void * til_module_context_new(size_t size, unsigned seed, unsigned ticks, unsigned n_cpus, char *path);
© All Rights Reserved