Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate misc commits from #440 #442

Merged
merged 5 commits into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ SUBDIR += src
SUBDIR += tests/capture
SUBDIR += tests/complement
SUBDIR += tests/gen
SUBDIR += tests/idmap
SUBDIR += tests/intersect
#SUBDIR += tests/ir # XXX: fragile due to state numbering
SUBDIR += tests/eclosure
Expand Down
10 changes: 8 additions & 2 deletions fuzz/run_fuzzer
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ BUILD=../build
FUZZER=${BUILD}/fuzz/fuzzer
SEEDS=${BUILD}/fuzz/fuzzer_seeds

ARG=$1

SECONDS=${SECONDS:-60}
WORKERS=${WORKERS:-4}
SEEDS=${SEEDS:-seeds}
Expand All @@ -25,5 +27,9 @@ if [ ! -d "${SEEDS}" ]; then
mkdir -p "${SEEDS}"
fi

echo "\n==== ${FUZZER}"
${FUZZER} -jobs=${WORKERS} -workers=${WORKERS} -max_total_time=${SECONDS} ${SEEDS}
if [ -z "${ARG}" ]; then
echo "\n==== ${FUZZER}"
exec ${FUZZER} -jobs=${WORKERS} -workers=${WORKERS} -max_total_time=${SECONDS} ${SEEDS}
else
exec ${FUZZER} ${ARG}
fi
58 changes: 58 additions & 0 deletions include/adt/idmap.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#ifndef IDMAP_H
#define IDMAP_H

/* Mapping between one fsm_state_t and a set of
* unsigned IDs. The implementation assumes that both
* IDs are sequentially assigned and don't need a sparse
* mapping -- it will handle 10 -> [1, 3, 47] well, but
* not 1000000 -> [14, 524288, 1073741823]. */

#include <stdlib.h>

#include "fsm/fsm.h"
#include "fsm/alloc.h"

struct idmap; /* Opaque handle. */

struct idmap *
idmap_new(const struct fsm_alloc *alloc);

void
idmap_free(struct idmap *m);

/* Associate a value with a state (if not already present.)
* Returns 1 on success, or 0 on allocation failure. */
int
idmap_set(struct idmap *m, fsm_state_t state_id, unsigned value);

/* How many values are associated with an ID? */
size_t
idmap_get_value_count(const struct idmap *m, fsm_state_t state_id);

/* Get the values associated with an ID.
*
* Returns 1 on success and writes them into the buffer, in ascending
* order, with the count in *written (if non-NULL).
*
* Returns 0 on error (insufficient buffer space). */
int
idmap_get(const struct idmap *m, fsm_state_t state_id,
size_t buf_size, unsigned *buf, size_t *written);

/* Iterator callback. */
typedef void
idmap_iter_fun(fsm_state_t state_id, unsigned value, void *opaque);

/* Iterate over the ID map. State IDs may be yielded out of order,
* values will be in ascending order. */
void
idmap_iter(const struct idmap *m,
idmap_iter_fun *cb, void *opaque);

/* Iterate over the values associated with a single state
* (in ascending order). */
void
idmap_iter_for_state(const struct idmap *m, fsm_state_t state_id,
idmap_iter_fun *cb, void *opaque);

#endif
1 change: 1 addition & 0 deletions src/adt/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

SRC += src/adt/alloc.c
SRC += src/adt/bitmap.c
SRC += src/adt/idmap.c
SRC += src/adt/internedstateset.c
SRC += src/adt/priq.c
SRC += src/adt/path.c
Expand Down
Loading
Loading