diff --git a/libc3/bool.c b/libc3/bool.c
index 0149b87..1cf528b 100644
--- a/libc3/bool.c
+++ b/libc3/bool.c
@@ -11,11 +11,11 @@
* AUTHOR BE CONSIDERED LIABLE FOR THE USE AND PERFORMANCE OF
* THIS SOFTWARE.
*/
+#include "bool.h"
#include "buf.h"
#include "buf_inspect.h"
-#include "hash.h"
-s8 bool_compare (bool a, bool b)
+s8 bool_compare (e_bool a, e_bool b)
{
if (! a && b)
return -1;
@@ -24,13 +24,7 @@ s8 bool_compare (bool a, bool b)
return 1;
}
-t_hash_context * bool_hash_update (t_hash_context *context, e_bool x)
-{
- bool b = x ? 1 : 0;
- return hash_update(context, &b, sizeof(b));
-}
-
-s_str * bool_inspect (bool x, s_str *dest)
+s_str * bool_inspect (e_bool x, s_str *dest)
{
sw size;
s_buf tmp;
diff --git a/libc3/bool.h b/libc3/bool.h
index 8d392af..c82a494 100644
--- a/libc3/bool.h
+++ b/libc3/bool.h
@@ -20,12 +20,10 @@
#ifndef BOOL_H
#define BOOL_H
-#include "hash.h"
#include "types.h"
/* Observers */
-s8 bool_compare (e_bool a, e_bool b);
-t_hash_context * bool_hash_update (t_hash_context *context, bool b);
-s_str * bool_inspect (e_bool b, s_str *dest);
+s8 bool_compare (e_bool a, e_bool b);
+s_str * bool_inspect (e_bool b, s_str *dest);
#endif /* SYM_H */
diff --git a/libc3/buf.h b/libc3/buf.h
index 1b634ee..0fa3b96 100644
--- a/libc3/buf.h
+++ b/libc3/buf.h
@@ -37,6 +37,8 @@
buf_init((buf), false, (size), p); \
} while (0)
+#define BUF_SIZE 1024
+
extern const sw buf_u8_to_hex_size;
extern const sw buf_inspect_str_byte_size;
@@ -93,6 +95,7 @@ sw buf_read_integer (s_buf *buf, s_integer *dst);
sw buf_refill (s_buf *buf, sw size);
sw buf_refill_compact (s_buf *buf);
s_buf * buf_restore (s_buf *buf, const s_buf *save);
+sw buf_seek (s_buf *buf, sw offset, u8 whence);
sw buf_str_to_hex (s_buf *buf, const s_str *src);
sw buf_str_to_hex_size (const s_str *src);
sw buf_u8_to_hex (s_buf *buf, u8 x);
diff --git a/libc3/buf_file.c b/libc3/buf_file.c
index fd075d5..587d9e8 100644
--- a/libc3/buf_file.c
+++ b/libc3/buf_file.c
@@ -25,6 +25,7 @@ typedef struct buf_file {
sw buf_file_open_r_refill (s_buf *buf);
sw buf_file_open_w_flush (s_buf *buf);
+sw buf_file_open_w_seek (s_buf *buf, sw offset, u8 whence);
void buf_file_close (s_buf *buf)
{
@@ -92,6 +93,7 @@ s_buf * buf_file_open_w (s_buf *buf, FILE *fp)
errx(1, "buf_file_open_w: out of memory");
buf_file->fp = fp;
buf->flush = buf_file_open_w_flush;
+ buf->seek = buf_file_open_w_seek;
buf->user_ptr = buf_file;
return buf;
}
@@ -128,3 +130,20 @@ sw buf_file_open_w_flush (s_buf *buf)
}
return size;
}
+
+sw buf_file_open_w_seek (s_buf *buf, sw offset, u8 whence)
+{
+ s_buf_file *buf_file;
+ sw r;
+ assert(buf);
+ assert(! buf->save);
+ assert(buf->user_ptr);
+ buf_file = buf->user_ptr;
+ if ((r = buf_flush(buf)) < 0)
+ return r;
+ if (fseek(buf_file->fp, offset, whence)) {
+ warn("buf_file_open_w_seek: fseek");
+ return -1;
+ }
+ return 0;
+}
diff --git a/libc3/c3.h b/libc3/c3.h
index b77f486..0ec6bfe 100644
--- a/libc3/c3.h
+++ b/libc3/c3.h
@@ -23,31 +23,22 @@
#include "buf_save.h"
#include "call.h"
#include "character.h"
+#include "compare.h"
#include "debug.h"
#include "env.h"
#include "eval.h"
-#include "f32.h"
-#include "f64.h"
#include "fact.h"
#include "facts.h"
#include "fn.h"
+#include "hash.h"
#include "ident.h"
#include "integer.h"
#include "list.h"
-#include "ptag.h"
#include "ptr.h"
#include "quote.h"
-#include "s8.h"
-#include "s16.h"
-#include "s32.h"
-#include "s64.h"
#include "str.h"
#include "tag.h"
#include "tuple.h"
-#include "u8.h"
-#include "u16.h"
-#include "u32.h"
-#include "u64.h"
#include "ucd.h"
/* libc3 */
diff --git a/libc3/call.c b/libc3/call.c
index 6cefeee..0100db6 100644
--- a/libc3/call.c
+++ b/libc3/call.c
@@ -25,20 +25,6 @@ void call_clean (s_call *call)
list_delete(call->arguments);
}
-s8 call_compare (const s_call *a, const s_call *b)
-{
- s8 r;
- if (a == b)
- return 0;
- if (!a)
- return -1;
- if (!b)
- return 1;
- if ((r = ident_compare(&a->ident, &b->ident)))
- return r;
- return list_compare(a->arguments, b->arguments);
-}
-
s_call * call_copy (const s_call *src, s_call *dest)
{
assert(src);
@@ -48,14 +34,6 @@ s_call * call_copy (const s_call *src, s_call *dest)
return dest;
}
-t_hash_context * call_hash_update (t_hash_context *context,
- const s_call *x)
-{
- assert(x);
- ident_hash_update(context, &x->ident);
- return list_hash_update(context, x->arguments);
-}
-
s_call * call_init_1 (s_call *call, const s8 *p)
{
s_buf buf;
diff --git a/libc3/call.h b/libc3/call.h
index 6e862a0..16d4c83 100644
--- a/libc3/call.h
+++ b/libc3/call.h
@@ -14,16 +14,11 @@
#ifndef CALL_H
#define CALL_H
-#include "hash.h"
#include "types.h"
-void call_clean (s_call *call);
-s_call * call_init_1 (s_call *call, const s8 *p);
-
-s8 call_compare (const s_call *a, const s_call *b);
-s_call * call_copy (const s_call *src, s_call *dest);
-t_hash_context * call_hash_update (t_hash_context *context,
- const s_call *call);
-s_str * call_inspect (const s_call *call, s_str *dest);
+void call_clean (s_call *call);
+s_call * call_init_1 (s_call *call, const s8 *p);
+s_call * call_copy (const s_call *src, s_call *dest);
+s_str * call_inspect (const s_call *call, s_str *dest);
#endif /* CALL_H */
diff --git a/libc3/character.c b/libc3/character.c
index 2819513..5644889 100644
--- a/libc3/character.c
+++ b/libc3/character.c
@@ -35,12 +35,6 @@ s8 character_compare (character a, character b)
return 1;
}
-t_hash_context * character_hash_update (t_hash_context *context,
- character x)
-{
- return hash_update(context, &x, sizeof(x));
-}
-
e_bool character_is_digit (character c)
{
return ('0' <= c && c <= '9');
diff --git a/libc3/character.h b/libc3/character.h
index ea60850..615653a 100644
--- a/libc3/character.h
+++ b/libc3/character.h
@@ -17,18 +17,17 @@
#include "hash.h"
#include "types.h"
-character character_1 (const s8 *p);
-s8 character_compare (character a, character b);
-t_hash_context * character_hash_update (t_hash_context *context,
- character c);
-e_bool character_is_digit (character c);
-e_bool character_is_lowercase (character c);
-e_bool character_is_printable (character c);
-e_bool character_is_space (character c);
-e_bool character_is_uppercase (character c);
-sw character_read (s_buf *buf, character *c);
-sw character_write (s_buf *buf, character c);
-sw character_utf8 (character c, s8 *dest);
-sw character_utf8_size (character c);
+character character_1 (const s8 *p);
+s8 character_compare (character a, character b);
+void character_hash_update (character c, t_hash *hash);
+e_bool character_is_digit (character c);
+e_bool character_is_lowercase (character c);
+e_bool character_is_printable (character c);
+e_bool character_is_space (character c);
+e_bool character_is_uppercase (character c);
+sw character_read (s_buf *buf, character *c);
+sw character_write (s_buf *buf, character c);
+sw character_utf8 (character c, s8 *dest);
+sw character_utf8_size (character c);
#endif /* CHARACTER_H */
diff --git a/libc3/compare.c b/libc3/compare.c
new file mode 100644
index 0000000..f697a86
--- /dev/null
+++ b/libc3/compare.c
@@ -0,0 +1,49 @@
+/* c3
+ * Copyright 2022 kmx.io <contact@kmx.io>
+ *
+ * Permission is hereby granted to use this software excepted
+ * on Apple computers granted the above copyright notice and
+ * this permission paragraph are included in all copies and
+ * substantial portions of this software.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS-IS" WITHOUT ANY GUARANTEE OF
+ * PURPOSE AND PERFORMANCE. IN NO EVENT WHATSOEVER SHALL THE
+ * AUTHOR BE CONSIDERED LIABLE FOR THE USE AND PERFORMANCE OF
+ * THIS SOFTWARE.
+ */
+#include "compare.h"
+
+#define COMPARE_DEF(type) \
+ s8 compare_##type (type a, type b) \
+ { \
+ if (a < b) \
+ return -1; \
+ if (a > b) \
+ return 1; \
+ return 0; \
+ } \
+
+s8 compare_call (const s_call *a, const s_call *b)
+{
+ s8 r;
+ if (a == b)
+ return 0;
+ if (!a)
+ return -1;
+ if (!b)
+ return 1;
+ if ((r = compare_ident(&a->ident, &b->ident)))
+ return r;
+ return compare_list(a->arguments, b->arguments);
+}
+
+COMPARE_DEF(f32);
+COMPARE_DEF(f64);
+COMPARE_DEF(s8);
+COMPARE_DEF(s16);
+COMPARE_DEF(s32);
+COMPARE_DEF(s64);
+COMPARE_DEF(u8);
+COMPARE_DEF(u16);
+COMPARE_DEF(u32);
+COMPARE_DEF(u64);
diff --git a/libc3/compare.h b/libc3/compare.h
new file mode 100644
index 0000000..1d8f6e0
--- /dev/null
+++ b/libc3/compare.h
@@ -0,0 +1,46 @@
+/* c3
+ * Copyright 2022 kmx.io <contact@kmx.io>
+ *
+ * Permission is hereby granted to use this software excepted
+ * on Apple computers granted the above copyright notice and
+ * this permission paragraph are included in all copies and
+ * substantial portions of this software.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS-IS" WITHOUT ANY GUARANTEE OF
+ * PURPOSE AND PERFORMANCE. IN NO EVENT WHATSOEVER SHALL THE
+ * AUTHOR BE CONSIDERED LIABLE FOR THE USE AND PERFORMANCE OF
+ * THIS SOFTWARE.
+ */
+#ifndef COMPARE_H
+#define COMPARE_H
+
+#include "types.h"
+
+#define COMPARE_PROTOTYPE(type) \
+ s8 compare_##type (type a, type b)
+
+s8 compare_call (const s_call *a, const s_call *b);
+COMPARE_PROTOTYPE(f32);
+COMPARE_PROTOTYPE(f64);
+s8 compare_fact (const s_fact *a, const s_fact *b);
+s8 compare_fact_pos (const s_fact *a, const s_fact *b);
+s8 compare_fact_osp (const s_fact *a, const s_fact *b);
+s8 compare_fact_unbound_var_count (const s_fact *a,
+ const s_fact *b);
+s8 compare_ident (const s_ident *a, const s_ident *b);
+s8 compare_integer (const s_integer *a, const s_integer *b);
+s8 compare_integer_s64 (const s_integer *a, s64 b);
+s8 compare_integer_u64 (const s_integer *a, u64 b);
+s8 compare_ptag (const p_tag a, const p_tag b);
+s8 compare_quote (const p_quote a, const p_quote b);
+COMPARE_PROTOTYPE(s8);
+COMPARE_PROTOTYPE(s16);
+COMPARE_PROTOTYPE(s32);
+COMPARE_PROTOTYPE(s64);
+s8 compare_tuple (const s_tuple *a, const s_tuple *b);
+COMPARE_PROTOTYPE(u8);
+COMPARE_PROTOTYPE(u16);
+COMPARE_PROTOTYPE(u32);
+COMPARE_PROTOTYPE(u64);
+
+#endif /* COMPARE_H */
diff --git a/libc3/f32.c b/libc3/f32.c
deleted file mode 100644
index e097bb2..0000000
--- a/libc3/f32.c
+++ /dev/null
@@ -1,33 +0,0 @@
-/* c3
- * Copyright 2022 kmx.io <contact@kmx.io>
- *
- * Permission is hereby granted to use this software excepted
- * on Apple computers granted the above copyright notice and
- * this permission paragraph are included in all copies and
- * substantial portions of this software.
- *
- * THIS SOFTWARE IS PROVIDED "AS-IS" WITHOUT ANY GUARANTEE OF
- * PURPOSE AND PERFORMANCE. IN NO EVENT WHATSOEVER SHALL THE
- * AUTHOR BE CONSIDERED LIABLE FOR THE USE AND PERFORMANCE OF
- * THIS SOFTWARE.
- */
-#include <float.h>
-#include <math.h>
-#include <string.h>
-#include "f32.h"
-
-s8 f32_compare (f32 a, f32 b)
-{
- if (fabs(a - b) <= FLT_EPSILON)
- return 0;
- if (a < b)
- return -1;
- if (a > b)
- return 1;
- return memcmp(&a, &b, sizeof(f32));
-}
-
-t_hash_context * f32_hash_update (t_hash_context *context, f32 x)
-{
- return hash_update(context, &x, sizeof(x));
-}
diff --git a/libc3/f32.h b/libc3/f32.h
deleted file mode 100644
index 8e6c3bf..0000000
--- a/libc3/f32.h
+++ /dev/null
@@ -1,23 +0,0 @@
-/* c3
- * Copyright 2022 kmx.io <contact@kmx.io>
- *
- * Permission is hereby granted to use this software excepted
- * on Apple computers granted the above copyright notice and
- * this permission paragraph are included in all copies and
- * substantial portions of this software.
- *
- * THIS SOFTWARE IS PROVIDED "AS-IS" WITHOUT ANY GUARANTEE OF
- * PURPOSE AND PERFORMANCE. IN NO EVENT WHATSOEVER SHALL THE
- * AUTHOR BE CONSIDERED LIABLE FOR THE USE AND PERFORMANCE OF
- * THIS SOFTWARE.
- */
-#ifndef F32_H
-#define F32_H
-
-#include "hash.h"
-#include "types.h"
-
-s8 f32_compare (f32 a, f32 b);
-t_hash_context * f32_hash_update (t_hash_context *context, f32 x);
-
-#endif /* F32_H */
diff --git a/libc3/f64.c b/libc3/f64.c
deleted file mode 100644
index 782060f..0000000
--- a/libc3/f64.c
+++ /dev/null
@@ -1,33 +0,0 @@
-/* c3
- * Copyright 2022 kmx.io <contact@kmx.io>
- *
- * Permission is hereby granted to use this software excepted
- * on Apple computers granted the above copyright notice and
- * this permission paragraph are included in all copies and
- * substantial portions of this software.
- *
- * THIS SOFTWARE IS PROVIDED "AS-IS" WITHOUT ANY GUARANTEE OF
- * PURPOSE AND PERFORMANCE. IN NO EVENT WHATSOEVER SHALL THE
- * AUTHOR BE CONSIDERED LIABLE FOR THE USE AND PERFORMANCE OF
- * THIS SOFTWARE.
- */
-#include <float.h>
-#include <math.h>
-#include <string.h>
-#include "f64.h"
-
-s8 f64_compare (f64 a, f64 b)
-{
- if (fabs(a - b) <= DBL_EPSILON)
- return 0;
- if (a < b)
- return -1;
- if (a > b)
- return 1;
- return memcmp(&a, &b, sizeof(f64));
-}
-
-t_hash_context * f64_hash_update (t_hash_context *context, f64 x)
-{
- return hash_update(context, &x, sizeof(x));
-}
diff --git a/libc3/f64.h b/libc3/f64.h
deleted file mode 100644
index 9ff3814..0000000
--- a/libc3/f64.h
+++ /dev/null
@@ -1,23 +0,0 @@
-/* c3
- * Copyright 2022 kmx.io <contact@kmx.io>
- *
- * Permission is hereby granted to use this software excepted
- * on Apple computers granted the above copyright notice and
- * this permission paragraph are included in all copies and
- * substantial portions of this software.
- *
- * THIS SOFTWARE IS PROVIDED "AS-IS" WITHOUT ANY GUARANTEE OF
- * PURPOSE AND PERFORMANCE. IN NO EVENT WHATSOEVER SHALL THE
- * AUTHOR BE CONSIDERED LIABLE FOR THE USE AND PERFORMANCE OF
- * THIS SOFTWARE.
- */
-#ifndef F64_H
-#define F64_H
-
-#include "hash.h"
-#include "types.h"
-
-s8 f64_compare (f64 a, f64 b);
-t_hash_context * f64_hash_update (t_hash_context *context, f64 x);
-
-#endif /* F64_H */
diff --git a/libc3/fact.c b/libc3/fact.c
index 4bc50b4..7c4b594 100644
--- a/libc3/fact.c
+++ b/libc3/fact.c
@@ -18,7 +18,6 @@
#include "hash.h"
#include "fact.h"
#include "tag.h"
-#include "u8.h"
s8 fact_compare (const s_fact *a, const s_fact *b)
{
@@ -107,21 +106,13 @@ s_fact * fact_copy (const s_fact *src, s_fact *dest)
return dest;
}
-uw fact_hash (const s_fact *fact)
+uw fact_hash_uw (const s_fact *fact)
{
- t_hash_context context;
+ t_hash hash;
assert(fact);
- hash_init(&context);
- fact_hash_update(&context, fact);
- return hash_result(&context);
-}
-
-t_hash_context * fact_hash_update (t_hash_context *context,
- const s_fact *fact)
-{
- tag_hash_update(context, fact->subject);
- tag_hash_update(context, fact->predicate);
- return tag_hash_update(context, fact->object);
+ hash_init(&hash);
+ fact_hash_update(&hash, fact);
+ return hash_to_uw(&hash);
}
s_fact * fact_init (s_fact *fact, const s_tag *subject,
diff --git a/libc3/fact.h b/libc3/fact.h
index 10fbf86..f965319 100644
--- a/libc3/fact.h
+++ b/libc3/fact.h
@@ -14,7 +14,6 @@
#ifndef FACT_H
#define FACT_H
-#include "hash.h"
#include "types.h"
/* Stack-allocation compatible functions */
@@ -23,15 +22,8 @@ s_fact * fact_init (s_fact *fact, const s_tag *subject,
const s_tag *predicate, const s_tag *object);
/* Observers */
-s8 fact_compare (const s_fact *a, const s_fact *b);
-s8 fact_compare_pos (const s_fact *a, const s_fact *b);
-s8 fact_compare_osp (const s_fact *a, const s_fact *b);
-s8 fact_compare_unbound_var_count (const s_fact *a,
- const s_fact *b);
-s_fact * fact_copy (const s_fact *src, s_fact *dest);
-t_hash_context * fact_hash_update (t_hash_context *context,
- const s_fact *fact);
-uw fact_hash (const s_fact *x);
-s_str * fact_inspect (const s_fact *fact, s_str *dest);
+s_fact * fact_copy (const s_fact *src, s_fact *dest);
+uw fact_hash_uw (const s_fact *x);
+s_str * fact_inspect (const s_fact *fact, s_str *dest);
#endif /* FACT_H */
diff --git a/libc3/facts.c b/libc3/facts.c
index 0488356..1f083fb 100644
--- a/libc3/facts.c
+++ b/libc3/facts.c
@@ -13,6 +13,7 @@
*/
#include <assert.h>
#include <err.h>
+#include <errno.h>
#include <stdlib.h>
#include "buf.h"
#include "buf_file.h"
@@ -90,6 +91,24 @@ sw facts_dump (const s_facts *facts, s_buf *buf)
tag_init_var(&subject);
tag_init_var(&predicate);
tag_init_var(&object);
+ if ((r = buf_write_1(buf,
+ "%{module: C3.Facts,\n"
+ " version: 0x0000000000000001,\n"
+ " count: 0x")) < 0)
+ return r;
+ result += r;
+ if ((r = buf_inspect_u64_hex(buf, facts_count(facts))) < 0)
+ return r;
+ result += r;
+ if ((r = buf_write_1(buf, ",\n digest: 0x")) < 0)
+ return r;
+ result += r;
+ if ((r = buf_inspect_u64_hex(buf, digest)) < 0)
+ return r;
+ result += r;
+ if ((r = buf_write_1(buf, "}\n")) < 0)
+ return r;
+ result += r;
facts_with_0(facts, &cursor, &subject, &predicate, &object);
while ((fact = facts_cursor_next(&cursor))) {
if ((r = facts_log_add(buf, fact)) < 0)
@@ -249,6 +268,83 @@ s_facts * facts_new (s_buf *log)
return facts_init(n, log);
}
+sw facts_open_buf (s_facts *facts, s_buf *buf)
+{
+ u64 count;
+ u64 digest;
+ u64 dump_pos;
+ u64 log_pos;
+ sw r;
+ if ((r = buf_read_1(buf,
+ "%{module: C3.Facts,\n"
+ " version: 0x0000000000000001,\n"
+ " count: 0x")) < 0)
+ return r;
+ if ((r = buf_parse_u64_hex(buf, &count)) < 0)
+ return r;
+ if ((r = buf_read_1(buf, ",\n digest: 0x")) < 0)
+ return r;
+ if ((r = buf_parse_u64_hex(buf, &digest)) < 0)
+ return r;
+ if ((r = buf_read_1(buf, ",\n dump: 0x")) < 0)
+ return r;
+ if ((r = buf_parse_u64_hex(buf, &dump_pos)) < 0)
+ return r;
+ if ((r = buf_read_1(buf, ",\n log: 0x")) < 0)
+ return r;
+ if ((r = buf_parse_u64_hex(buf, &log_pos)) < 0)
+ return r;
+ if ((r = buf_read_1(buf, "}\n")) < 0)
+ return r;
+ if ((r = buf_seek(buf, dump_pos, SEEK_SET)) < 0)
+ return r;
+ if ((r = facts_open_buf_read_dump(facts, buf, count, digest)) < 0)
+ return r;
+ if ((r = buf_seek(buf, log_pos, SEEK_SET)) < 0)
+ return r;
+ if ((r = facts_load(facts, buf)) < 0)
+ return r;
+ return 0;
+}
+
+sw facts_open_file (s_facts *facts, const s8 *path)
+{
+ FILE *fp;
+ s_buf in;
+ s_buf *out;
+ sw r;
+ BUF_INIT_ALLOCA(&in, BUF_SIZE);
+ if (! (fp = fopen(path, "rb"))) {
+ if (errno == ENOENT) {
+ if (! (fp = fopen(path, "wb"))) {
+ warn("fopen: %s", path);
+ return -1;
+ }
+ if (facts_count(facts))
+ /* TODO: clear facts
+ facts_close(facts);
+ facts_remove_all(facts);
+ */
+ warnx("facts_open_file: not supported");
+ return -1;
+ }
+ out = buf_new_alloc(BUF_SIZE);
+ buf_file_open_w(out, fp);
+ if ((r = facts_save_header(facts, out, 0xda39a3ee5e6b4b0d, 100,
+ 100)) != 100) {
+ warnx("facts_open_file: invalid header (%x)", r);
+ buf_flush(out);
+ facts->log = out;
+ return r;
+ }
+ fp = fopen(path, "wb"
+ return -1;
+ }
+ buf_file_open_r(&in, fp);
+ if ((r = facts_open_buf(facts, &in)) < 0)
+ return r;
+}
+
s_tag * facts_ref_tag (s_facts *facts, const s_tag *tag)
{
s_set_item__tag *item;
@@ -282,7 +378,11 @@ e_bool facts_remove_fact (s_facts *facts, const s_fact *fact)
return false;
}
-sw facts_save (s_facts *facts, const s8 *path)
+sw buf_seek (s_buf *buf, s64 pos, u8 rel);
+{
+}
+
+sw facts_save_file (s_facts *facts, const s8 *path)
{
s_buf *buf;
u64 digest = 0;
@@ -309,8 +409,7 @@ sw facts_save (s_facts *facts, const s8 *path)
goto ko;
result += r;
log_pos = result;
- buf_flush(buf);
- fseek(fp, 0, SEEK_SET);
+ buf_seek(buf, 0, SEEK_SET);
if ((r = facts_save_header(facts, buf, digest, dump_pos,
log_pos)) < 0)
goto ko;
@@ -328,7 +427,10 @@ sw facts_save_header (const s_facts *facts, s_buf *buf, u64 digest,
{
sw r;
sw result = 0;
- if ((r = buf_write_1(buf, "%{count: 0x")) < 0)
+ if ((r = buf_write_1(buf,
+ "%{module: C3.Facts,\n"
+ " version: 0x0000000000000001,\n"
+ " count: 0x")) < 0)
return r;
result += r;
if ((r = buf_inspect_u64_hex(buf, facts_count(facts))) < 0)
@@ -340,18 +442,24 @@ sw facts_save_header (const s_facts *facts, s_buf *buf, u64 digest,
if ((r = buf_inspect_u64_hex(buf, digest)) < 0)
return r;
result += r;
- if ((r = buf_write_1(buf, ",\n dump: 0x")) < 0)
+ if ((r = buf_write_1(buf, ",\n dump: 0x")) < 0)
return r;
result += r;
if ((r = buf_inspect_u64_hex(buf, dump_pos)) < 0)
return r;
result += r;
- if ((r = buf_write_1(buf, ",\n log: 0x")) < 0)
+ if ((r = buf_write_1(buf, ",\n log: 0x")) < 0)
return r;
result += r;
if ((r = buf_inspect_u64_hex(buf, log_pos)) < 0)
return r;
result += r;
+ if ((r = buf_write_1(buf, ",\n log_count: 0x")) < 0)
+ return r;
+ result += r;
+ if ((r = buf_inspect_u64_hex(buf, facts->log_count)) < 0)
+ return r;
+ result += r;
if ((r = buf_write_1(buf, "}\n")) < 0)
return r;
result += r;
diff --git a/libc3/facts.h b/libc3/facts.h
index e7707fc..3d0736a 100644
--- a/libc3/facts.h
+++ b/libc3/facts.h
@@ -39,7 +39,7 @@ sw facts_load_file (s_facts *facts, const s8 *path);
sw facts_open_file (s_facts *facts, const s8 *path);
s_tag * facts_ref_tag (s_facts *facts, const s_tag *tag);
e_bool facts_remove_fact (s_facts *facts, const s_fact *fact);
-sw facts_save (s_facts *facts, const s8 *path);
+sw facts_save_file (s_facts *facts, const s8 *path);
e_bool facts_unref_tag (s_facts *facts, const s_tag *tag);
/* Observers */
diff --git a/libc3/hash.c b/libc3/hash.c
index f4b4b14..415c877 100644
--- a/libc3/hash.c
+++ b/libc3/hash.c
@@ -17,32 +17,145 @@
#include "hash.h"
#include "str.h"
-t_hash_context * hash_init (t_hash_context *context)
-{
- assert(context);
- SHA1Init(context);
- return context;
-}
+#define HASH_UPDATE_DEF(type) \
+ void hash_update_##type (t_hash *hash, type x) ! \
+ { \
+ hash_update(hash, &x, sizeof(x)); \
+ } \
-t_hash_context * hash_update (t_hash_context *context,
- const void *data, uw size)
+void hash_init (t_hash *hash)
{
- assert(context);
- assert(data);
- SHA1Update(context, data, size);
- return context;
+ assert(hash);
+ SHA1Init(hash);
}
-uw hash_result (t_hash_context *context)
+uw hash_to_uw (p_hash hash)
{
u8 digest[SHA1_DIGEST_LENGTH];
- SHA1Final(digest, context);
+ SHA1Final(digest, hash);
return *((uw *) digest);
}
-u64 hash_result_u64 (t_hash_context *context)
+u64 hash_to_u64 (p_hash hash)
{
u8 digest[SHA1_DIGEST_LENGTH];
- SHA1Final(digest, context);
+ SHA1Final(digest, hash);
return *((u64 *) digest);
}
+
+void hash_update (t_hash *hash, const void *data, uw size)
+{
+ assert(hash);
+ assert(data);
+ SHA1Update(hash, data, size);
+}
+
+void hash_update_bool (t_hash *hash, e_bool x)
+{
+ bool b = x ? 1 : 0;
+ hash_update(hash, &b, sizeof(b));
+}
+
+
+void hash_update_call (t_hash *hash, const s_call *call);
+{
+ assert(hash);
+ assert(call);
+ hash_update_ident(hash, &call->ident);
+ hash_update_list(hash, call->arguments);
+}
+
+HASH_UPDATE_DEF(character)
+
+void hash_update_fact (t_hash *hash, const s_fact *fact)
+{
+ const u8 type = 3;
+ hash_update(hash, &type, sizeof(type));
+ hash_update_tag(hash, fact->subject);
+ hash_update_tag(hash, fact->predicate);
+ hash_update_tag(hash, fact->object);
+}
+
+void hash_update_ident (t_hash *hash, const s_ident *ident)
+{
+ assert(hash);
+ assert(ident);
+ hash_update_u8(hash, '_');
+ hash_update_sym(hash, ident->sym);
+}
+
+/* FIXME: circular lists */
+void hash_update_list (t_hash *hash, const s_list *list)
+{
+ const s_list *last;
+ const u8 type = 2;
+ if (list) {
+ while (list) {
+ hash_update(hash, &type, sizeof(type));
+ hash_update_tag(hash, &list->tag);
+ last = list;
+ list = list_next(list);
+ }
+ return hash_update_tag(hash, &last->next);
+ }
+ return hash;
+}
+
+HASH_UPDATE_DEF(s8);
+HASH_UPDATE_DEF(s16);
+HASH_UPDATE_DEF(s32);
+HASH_UPDATE_DEF(s64);
+
+void hash_update_sym (t_hash *hash, const s_sym *sym);
+{
+ assert(hash);
+ assert(src);
+ hash_update_u8(hash, ':');
+ hash_update_str(hash, &src->str);
+}
+
+void hash_update_tag (t_hash *hash, const s_tag *tag)
+{
+ assert(tag);
+ hash_update_u64(hash, tag->type.type);
+ switch (tag->type.type) {
+ case TAG_VOID: break;
+ case TAG_BOOL: hash_update_bool(hash, tag->data.bool); break;
+ case TAG_CALL:
+ case TAG_CALL_FN:
+ case TAG_CALL_MACRO:
+ hash_update_call(hash, &tag->data.call); break;
+ case TAG_CHARACTER:
+ hash_update_character(hash, tag->data.character); break;
+ case TAG_F32: hash_update_f32(hash, tag->data.f32); break;
+ case TAG_F64: hash_update_f64(hash, tag->data.f64); break;
+ case TAG_FN: hash_update_u64(hash, (u64) tag); break;
+ case TAG_IDENT: hash_update_ident(hash, &tag->data.ident); break;
+ case TAG_INTEGER:
+ hash_update_integer(hash, &tag->data.integer); break;
+ case TAG_LIST: hash_update_list(hash, tag->data.list); break;
+ case TAG_PTAG: hash_update_ptag(hash, tag->data.ptag); break;
+ case TAG_QUOTE: hash_update_quote(hash, tag->data.quote); break;
+ case TAG_S8: hash_update_s8(hash, tag->data.s8); break;
+ case TAG_S16: hash_update_s16(hash, tag->data.s16); break;
+ case TAG_S32: hash_update_s32(hash, tag->data.s32); break;
+ case TAG_S64: hash_update_s64(hash, tag->data.s64); break;
+ case TAG_STR: hash_update_str(hash, &tag->data.str); break;
+ case TAG_SYM: hash_update_sym(hash, tag->data.sym); break;
+ case TAG_TUPLE: hash_update_tuple(hash, &tag->data.tuple); break;
+ case TAG_U8: hash_update_u8(hash, tag->data.u8); break;
+ case TAG_U16: hash_update_u16(hash, tag->data.u16); break;
+ case TAG_U32: hash_update_u32(hash, tag->data.u32); break;
+ case TAG_U64: hash_update_u64(hash, tag->data.u64); break;
+ case TAG_VAR:
+ assert(! "var hash update");
+ errx(1, "var hash update");
+ return NULL;
+ }
+ return hash;
+}
+
+HASH_UPDATE_DEF(u8);
+HASH_UPDATE_DEF(u16);
+HASH_UPDATE_DEF(u32);
+HASH_UPDATE_DEF(u64);
diff --git a/libc3/hash.h b/libc3/hash.h
index e616cdc..412f551 100644
--- a/libc3/hash.h
+++ b/libc3/hash.h
@@ -14,18 +14,34 @@
#ifndef HASH_H
#define HASH_H
-#include <sys/types.h>
-#include "sha1.h"
#include "types.h"
-#define HASH_SIZE SHA1_DIGEST_LENGTH
+#define HASH_UPDATE_PROTOTYPE(type) \
+ void hash_update_##type (t_hash *hash, type x)
-typedef SHA1_CTX t_hash_context;
-
-t_hash_context * hash_init (t_hash_context *context);
-t_hash_context * hash_update (t_hash_context *context,
- const void *data, uw size);
-uw hash_result (t_hash_context *context);
-u64 hash_result_u64 (t_hash_context *context);
+void hash_init (t_hash *hash);
+uw hash_to_uw (t_hash *hash);
+u64 hash_to_u64 (t_hash *hash);
+void hash_update (t_hash *hash, const void *data, uw size);
+void hash_update_bool (t_hash *hash, e_bool b);
+void hash_update_call (t_hash *hash, const s_call *call);
+void hash_update_fact (t_hash *hash, const s_fact *fact);
+HASH_UPDATE_PROTOTYPE(f32);
+HASH_UPDATE_PROTOTYPE(f64);
+void hash_update_ident (t_hash *hash, const s_ident *ident);
+void hash_update_integer (t_hash *hash, const s_integer *i);
+void hash_update_list (t_hash *hash, const s_list *list);
+void hash_update_ptag (t_hash *hash, const p_tag ptag);
+void hash_update_quote (t_hash *hash, const p_quote x);
+HASH_UPDATE_PROTOTYPE(s8);
+HASH_UPDATE_PROTOTYPE(s16);
+HASH_UPDATE_PROTOTYPE(s32);
+HASH_UPDATE_PROTOTYPE(s64);
+void hash_update_tag (t_hash *hash, const s_tag *tag);
+void hash_update_tuple (t_hash *hash, const s_tuple *tuple);
+HASH_UPDATE_PROTOTYPE(u8);
+HASH_UPDATE_PROTOTYPE(u16);
+HASH_UPDATE_PROTOTYPE(u32);
+HASH_UPDATE_PROTOTYPE(u64);
#endif /* HASH_H */
diff --git a/libc3/ident.c b/libc3/ident.c
index 27fd9d6..62966e6 100644
--- a/libc3/ident.c
+++ b/libc3/ident.c
@@ -17,7 +17,6 @@
#include "character.h"
#include "str.h"
#include "sym.h"
-#include "u8.h"
e_bool ident_character_is_reserved (character c)
{
@@ -82,15 +81,6 @@ e_bool ident_has_reserved_characters (const s_ident *ident)
return false;
}
-t_hash_context * ident_hash_update (t_hash_context *context,
- const s_ident *ident)
-{
- assert(context);
- assert(ident);
- u8_hash_update(context, '_');
- return sym_hash_update(context, ident->sym);
-}
-
s_ident * ident_init (s_ident *ident, const s_sym *sym)
{
assert(ident);
diff --git a/libc3/ident.h b/libc3/ident.h
index 587eba7..1b1c659 100644
--- a/libc3/ident.h
+++ b/libc3/ident.h
@@ -28,9 +28,6 @@ s_ident * ident_init_1 (s_ident *ident, const s8 *p);
/* Returns true iff c is an ident reserved character. */
e_bool ident_character_is_reserved (character c);
-/* Compare two idents. Returns -1 if a < b, 0 if a = b, 1 if a > b. */
-s8 ident_compare (const s_ident *a, const s_ident *b);
-
s_ident * ident_copy (const s_ident *src, s_ident *dest);
/* Returns true iff c is an ident reserved character as first. */
@@ -39,9 +36,6 @@ e_bool ident_first_character_is_reserved (character c);
/* Returns true iff ident contains reserved characters. */
e_bool ident_has_reserved_characters (const s_ident *ident);
-t_hash_context * ident_hash_update (t_hash_context *context,
- const s_ident *ident);
-
s_ident * ident_init (s_ident *ident, const s_sym *sym);
s_str * ident_inspect (const s_ident *ident, s_str *dest);
diff --git a/libc3/integer.h b/libc3/integer.h
index 686973e..2602ab1 100644
--- a/libc3/integer.h
+++ b/libc3/integer.h
@@ -22,7 +22,6 @@
#include <stdarg.h>
#include <stdio.h>
-#include "hash.h"
#include "types.h"
#define MP_IS_ZERO(a) ((a)->used == 0)
@@ -70,12 +69,6 @@ s_integer * integer_new_copy (const s_integer *a);
/* Observers */
uw integer_bits (const s_integer *i);
uw integer_bytes (const s_integer *i);
-s8 integer_compare (const s_integer *a,
- const s_integer *b);
-s8 integer_compare_s64 (const s_integer *a, s64 b);
-s8 integer_compare_u64 (const s_integer *a, u64 b);
-t_hash_context * integer_hash_update (t_hash_context *context,
- const s_integer *i);
e_bool integer_is_negative (const s_integer *i);
e_bool integer_is_zero (const s_integer *i);
s8 integer_to_s8 (const s_integer *i);
diff --git a/libc3/list.c b/libc3/list.c
index 93e4e7a..e660c08 100644
--- a/libc3/list.c
+++ b/libc3/list.c
@@ -100,24 +100,6 @@ void list_delete_all (s_list *list)
list = list_delete(list);
}
-/* FIXME: dotted lists, circular lists */
-t_hash_context * list_hash_update (t_hash_context *context,
- const s_list *x)
-{
- const s_list *last;
- if (x) {
- while (x) {
- const u8 two = 2;
- hash_update(context, &two, sizeof(two));
- tag_hash_update(context, &x->tag);
- last = x;
- x = list_next(x);
- }
- return tag_hash_update(context, &last->next);
- }
- return context;
-}
-
s_list * list_init (s_list *list)
{
assert(list);
diff --git a/libc3/list.h b/libc3/list.h
index 47bdd2f..cca17be 100644
--- a/libc3/list.h
+++ b/libc3/list.h
@@ -38,14 +38,12 @@ s_list * list_delete (s_list *list);
void list_delete_all (s_list *list);
/* Observers */
-s8 list_compare (const s_list *a, const s_list *b);
-s_list * list_copy (const s_list *src, s_list **dest);
-t_hash_context * list_hash_update (t_hash_context *context,
- const s_list *list);
-sw list_length (const s_list *list);
-s_list * list_next (const s_list *list);
-s_tuple * list_to_tuple_reverse (s_list *list, s_tuple *tuple);
+s8 list_compare (const s_list *a, const s_list *b);
+s_list * list_copy (const s_list *src, s_list **dest);
+sw list_length (const s_list *list);
+s_list * list_next (const s_list *list);
+s_tuple * list_to_tuple_reverse (s_list *list, s_tuple *tuple);
/* Call str_delete after use. */
-s_str * list_inspect (const s_list *x, s_str *dest);
+s_str * list_inspect (const s_list *list, s_str *dest);
#endif /* STR_H */
diff --git a/libc3/ptag.c b/libc3/ptag.c
deleted file mode 100644
index ef38f60..0000000
--- a/libc3/ptag.c
+++ /dev/null
@@ -1,33 +0,0 @@
-/* c3
- * Copyright 2022 kmx.io <contact@kmx.io>
- *
- * Permission is hereby granted to use this software excepted
- * on Apple computers granted the above copyright notice and
- * this permission paragraph are included in all copies and
- * substantial portions of this software.
- *
- * THIS SOFTWARE IS PROVIDED "AS-IS" WITHOUT ANY GUARANTEE OF
- * PURPOSE AND PERFORMANCE. IN NO EVENT WHATSOEVER SHALL THE
- * AUTHOR BE CONSIDERED LIABLE FOR THE USE AND PERFORMANCE OF
- * THIS SOFTWARE.
- */
-#include <assert.h>
-#include "ptag.h"
-
-s8 ptag_compare (const p_tag a, const p_tag b)
-{
- if (a == b)
- return 0;
- if (a < b)
- return -1;
- if (a > b)
- return 1;
- assert(! "error");
- return -2;
-}
-
-t_hash_context * ptag_hash_update (t_hash_context *context,
- const p_tag ptag)
-{
- return hash_update(context, &ptag, sizeof(ptag));
-}
diff --git a/libc3/ptag.h b/libc3/ptag.h
deleted file mode 100644
index bb42b86..0000000
--- a/libc3/ptag.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/* c3
- * Copyright 2022 kmx.io <contact@kmx.io>
- *
- * Permission is hereby granted to use this software excepted
- * on Apple computers granted the above copyright notice and
- * this permission paragraph are included in all copies and
- * substantial portions of this software.
- *
- * THIS SOFTWARE IS PROVIDED "AS-IS" WITHOUT ANY GUARANTEE OF
- * PURPOSE AND PERFORMANCE. IN NO EVENT WHATSOEVER SHALL THE
- * AUTHOR BE CONSIDERED LIABLE FOR THE USE AND PERFORMANCE OF
- * THIS SOFTWARE.
- */
-#ifndef PTAG_H
-#define PTAG_H
-
-#include "hash.h"
-#include "types.h"
-
-s8 ptag_compare (const p_tag a, const p_tag b);
-t_hash_context * ptag_hash_update (t_hash_context *context,
- const p_tag ptag);
-
-#endif /* PTAG_H */
diff --git a/libc3/quote.h b/libc3/quote.h
index 33417ea..c1cb71b 100644
--- a/libc3/quote.h
+++ b/libc3/quote.h
@@ -14,13 +14,9 @@
#ifndef QUOTE_H
#define QUOTE_H
-#include "hash.h"
#include "types.h"
void quote_clean (p_quote quote);
-s8 quote_compare (const p_quote a, const p_quote b);
p_quote quote_copy (const p_quote src, p_quote *dest);
-t_hash_context * quote_hash_update (t_hash_context *context,
- const p_quote x);
#endif /* QUOTE_H */
diff --git a/libc3/sources.mk b/libc3/sources.mk
index 3a7656e..bdc330a 100644
--- a/libc3/sources.mk
+++ b/libc3/sources.mk
@@ -1,3 +1,3 @@
# sources.mk generated by update_sources
-SOURCES = arg.c binding.c bool.c buf.c buf_file.c buf_inspect.c buf_parse.c buf_parse_c.c buf_save.c c3.c call.c character.c debug.c env.c error.c error_handler.c eval.c f32.c f64.c fact.c facts.c facts_cursor.c facts_spec.c facts_spec_cursor.c facts_with.c facts_with_cursor.c fn.c frame.c hash.c ident.c integer.c list.c ptag.c ptr.c quote.c s16.c s32.c s64.c s8.c set__fact.c set__tag.c set_cursor__fact.c set_cursor__tag.c set_item__fact.c set_item__tag.c skiplist__fact.c skiplist_node__fact.c str.c sym.c tag.c tuple.c u16.c u32.c u64.c u8.c ucd.c
-LO_SOURCES = arg.c binding.c bool.c buf.c buf_file.c buf_inspect.c buf_parse.c buf_parse_c.c buf_save.c c3.c call.c character.c debug.c env.c error.c error_handler.c eval.c f32.c f64.c fact.c facts.c facts_cursor.c facts_spec.c facts_spec_cursor.c facts_with.c facts_with_cursor.c fn.c frame.c hash.c ident.c integer.c list.c ptag.c ptr.c quote.c s16.c s32.c s64.c s8.c set__fact.c set__tag.c set_cursor__fact.c set_cursor__tag.c set_item__fact.c set_item__tag.c skiplist__fact.c skiplist_node__fact.c str.c sym.c tag.c tuple.c u16.c u32.c u64.c u8.c ucd.c ../libtommath/bn_cutoffs.c ../libtommath/bn_deprecated.c ../libtommath/bn_mp_2expt.c ../libtommath/bn_mp_abs.c ../libtommath/bn_mp_add.c ../libtommath/bn_mp_add_d.c ../libtommath/bn_mp_addmod.c ../libtommath/bn_mp_and.c ../libtommath/bn_mp_clamp.c ../libtommath/bn_mp_clear.c ../libtommath/bn_mp_clear_multi.c ../libtommath/bn_mp_cmp.c ../libtommath/bn_mp_cmp_d.c ../libtommath/bn_mp_cmp_mag.c ../libtommath/bn_mp_cnt_lsb.c ../libtommath/bn_mp_complement.c ../libtommath/bn_mp_copy.c ../libtommath/bn_mp_count_bits.c ../libtommath/bn_mp_decr.c ../libtommath/bn_mp_div.c ../libtommath/bn_mp_div_2.c ../libtommath/bn_mp_div_2d.c ../libtommath/bn_mp_div_3.c ../libtommath/bn_mp_div_d.c ../libtommath/bn_mp_dr_is_modulus.c ../libtommath/bn_mp_dr_reduce.c ../libtommath/bn_mp_dr_setup.c ../libtommath/bn_mp_error_to_string.c ../libtommath/bn_mp_exch.c ../libtommath/bn_mp_expt_u32.c ../libtommath/bn_mp_exptmod.c ../libtommath/bn_mp_exteuclid.c ../libtommath/bn_mp_fread.c ../libtommath/bn_mp_from_sbin.c ../libtommath/bn_mp_from_ubin.c ../libtommath/bn_mp_fwrite.c ../libtommath/bn_mp_gcd.c ../libtommath/bn_mp_get_double.c ../libtommath/bn_mp_get_i32.c ../libtommath/bn_mp_get_i64.c ../libtommath/bn_mp_get_l.c ../libtommath/bn_mp_get_ll.c ../libtommath/bn_mp_get_mag_u32.c ../libtommath/bn_mp_get_mag_u64.c ../libtommath/bn_mp_get_mag_ul.c ../libtommath/bn_mp_get_mag_ull.c ../libtommath/bn_mp_grow.c ../libtommath/bn_mp_incr.c ../libtommath/bn_mp_init.c ../libtommath/bn_mp_init_copy.c ../libtommath/bn_mp_init_i32.c ../libtommath/bn_mp_init_i64.c ../libtommath/bn_mp_init_l.c ../libtommath/bn_mp_init_ll.c ../libtommath/bn_mp_init_multi.c ../libtommath/bn_mp_init_set.c ../libtommath/bn_mp_init_size.c ../libtommath/bn_mp_init_u32.c ../libtommath/bn_mp_init_u64.c ../libtommath/bn_mp_init_ul.c ../libtommath/bn_mp_init_ull.c ../libtommath/bn_mp_invmod.c ../libtommath/bn_mp_is_square.c ../libtommath/bn_mp_iseven.c ../libtommath/bn_mp_isodd.c ../libtommath/bn_mp_kronecker.c ../libtommath/bn_mp_lcm.c ../libtommath/bn_mp_log_u32.c ../libtommath/bn_mp_lshd.c ../libtommath/bn_mp_mod.c ../libtommath/bn_mp_mod_2d.c ../libtommath/bn_mp_mod_d.c ../libtommath/bn_mp_montgomery_calc_normalization.c ../libtommath/bn_mp_montgomery_reduce.c ../libtommath/bn_mp_montgomery_setup.c ../libtommath/bn_mp_mul.c ../libtommath/bn_mp_mul_2.c ../libtommath/bn_mp_mul_2d.c ../libtommath/bn_mp_mul_d.c ../libtommath/bn_mp_mulmod.c ../libtommath/bn_mp_neg.c ../libtommath/bn_mp_or.c ../libtommath/bn_mp_pack.c ../libtommath/bn_mp_pack_count.c ../libtommath/bn_mp_prime_fermat.c ../libtommath/bn_mp_prime_frobenius_underwood.c ../libtommath/bn_mp_prime_is_prime.c ../libtommath/bn_mp_prime_miller_rabin.c ../libtommath/bn_mp_prime_next_prime.c ../libtommath/bn_mp_prime_rabin_miller_trials.c ../libtommath/bn_mp_prime_rand.c ../libtommath/bn_mp_prime_strong_lucas_selfridge.c ../libtommath/bn_mp_radix_size.c ../libtommath/bn_mp_radix_smap.c ../libtommath/bn_mp_rand.c ../libtommath/bn_mp_read_radix.c ../libtommath/bn_mp_reduce.c ../libtommath/bn_mp_reduce_2k.c ../libtommath/bn_mp_reduce_2k_l.c ../libtommath/bn_mp_reduce_2k_setup.c ../libtommath/bn_mp_reduce_2k_setup_l.c ../libtommath/bn_mp_reduce_is_2k.c ../libtommath/bn_mp_reduce_is_2k_l.c ../libtommath/bn_mp_reduce_setup.c ../libtommath/bn_mp_root_u32.c ../libtommath/bn_mp_rshd.c ../libtommath/bn_mp_sbin_size.c ../libtommath/bn_mp_set.c ../libtommath/bn_mp_set_i32.c ../libtommath/bn_mp_set_i64.c ../libtommath/bn_mp_set_l.c ../libtommath/bn_mp_set_ll.c ../libtommath/bn_mp_set_u32.c ../libtommath/bn_mp_set_u64.c ../libtommath/bn_mp_set_ul.c ../libtommath/bn_mp_set_ull.c ../libtommath/bn_mp_shrink.c ../libtommath/bn_mp_signed_rsh.c ../libtommath/bn_mp_sqr.c ../libtommath/bn_mp_sqrmod.c ../libtommath/bn_mp_sqrt.c ../libtommath/bn_mp_sqrtmod_prime.c ../libtommath/bn_mp_sub.c ../libtommath/bn_mp_sub_d.c ../libtommath/bn_mp_submod.c ../libtommath/bn_mp_to_radix.c ../libtommath/bn_mp_to_sbin.c ../libtommath/bn_mp_to_ubin.c ../libtommath/bn_mp_ubin_size.c ../libtommath/bn_mp_unpack.c ../libtommath/bn_mp_xor.c ../libtommath/bn_mp_zero.c ../libtommath/bn_prime_tab.c ../libtommath/bn_s_mp_add.c ../libtommath/bn_s_mp_balance_mul.c ../libtommath/bn_s_mp_exptmod.c ../libtommath/bn_s_mp_exptmod_fast.c ../libtommath/bn_s_mp_get_bit.c ../libtommath/bn_s_mp_invmod_fast.c ../libtommath/bn_s_mp_invmod_slow.c ../libtommath/bn_s_mp_karatsuba_mul.c ../libtommath/bn_s_mp_karatsuba_sqr.c ../libtommath/bn_s_mp_montgomery_reduce_fast.c ../libtommath/bn_s_mp_mul_digs.c ../libtommath/bn_s_mp_mul_digs_fast.c ../libtommath/bn_s_mp_mul_high_digs.c ../libtommath/bn_s_mp_mul_high_digs_fast.c ../libtommath/bn_s_mp_prime_is_divisible.c ../libtommath/bn_s_mp_rand_jenkins.c ../libtommath/bn_s_mp_reverse.c ../libtommath/bn_s_mp_sqr.c ../libtommath/bn_s_mp_sqr_fast.c ../libtommath/bn_s_mp_sub.c ../libtommath/bn_s_mp_toom_mul.c ../libtommath/bn_s_mp_toom_sqr.c
+SOURCES = arg.c binding.c bool.c buf.c buf_file.c buf_inspect.c buf_parse.c buf_parse_c.c buf_save.c c3.c call.c character.c compare.c debug.c env.c error.c error_handler.c eval.c fact.c facts.c facts_cursor.c facts_spec.c facts_spec_cursor.c facts_with.c facts_with_cursor.c fn.c frame.c hash.c ident.c integer.c list.c ptr.c quote.c s16.c s32.c s64.c s8.c set__fact.c set__tag.c set_cursor__fact.c set_cursor__tag.c set_item__fact.c set_item__tag.c skiplist__fact.c skiplist_node__fact.c str.c sym.c tag.c tuple.c ucd.c
+LO_SOURCES = arg.c binding.c bool.c buf.c buf_file.c buf_inspect.c buf_parse.c buf_parse_c.c buf_save.c c3.c call.c character.c compare.c debug.c env.c error.c error_handler.c eval.c fact.c facts.c facts_cursor.c facts_spec.c facts_spec_cursor.c facts_with.c facts_with_cursor.c fn.c frame.c hash.c ident.c integer.c list.c ptr.c quote.c s16.c s32.c s64.c s8.c set__fact.c set__tag.c set_cursor__fact.c set_cursor__tag.c set_item__fact.c set_item__tag.c skiplist__fact.c skiplist_node__fact.c str.c sym.c tag.c tuple.c ucd.c ../libtommath/bn_cutoffs.c ../libtommath/bn_deprecated.c ../libtommath/bn_mp_2expt.c ../libtommath/bn_mp_abs.c ../libtommath/bn_mp_add.c ../libtommath/bn_mp_add_d.c ../libtommath/bn_mp_addmod.c ../libtommath/bn_mp_and.c ../libtommath/bn_mp_clamp.c ../libtommath/bn_mp_clear.c ../libtommath/bn_mp_clear_multi.c ../libtommath/bn_mp_cmp.c ../libtommath/bn_mp_cmp_d.c ../libtommath/bn_mp_cmp_mag.c ../libtommath/bn_mp_cnt_lsb.c ../libtommath/bn_mp_complement.c ../libtommath/bn_mp_copy.c ../libtommath/bn_mp_count_bits.c ../libtommath/bn_mp_decr.c ../libtommath/bn_mp_div.c ../libtommath/bn_mp_div_2.c ../libtommath/bn_mp_div_2d.c ../libtommath/bn_mp_div_3.c ../libtommath/bn_mp_div_d.c ../libtommath/bn_mp_dr_is_modulus.c ../libtommath/bn_mp_dr_reduce.c ../libtommath/bn_mp_dr_setup.c ../libtommath/bn_mp_error_to_string.c ../libtommath/bn_mp_exch.c ../libtommath/bn_mp_expt_u32.c ../libtommath/bn_mp_exptmod.c ../libtommath/bn_mp_exteuclid.c ../libtommath/bn_mp_fread.c ../libtommath/bn_mp_from_sbin.c ../libtommath/bn_mp_from_ubin.c ../libtommath/bn_mp_fwrite.c ../libtommath/bn_mp_gcd.c ../libtommath/bn_mp_get_double.c ../libtommath/bn_mp_get_i32.c ../libtommath/bn_mp_get_i64.c ../libtommath/bn_mp_get_l.c ../libtommath/bn_mp_get_ll.c ../libtommath/bn_mp_get_mag_u32.c ../libtommath/bn_mp_get_mag_u64.c ../libtommath/bn_mp_get_mag_ul.c ../libtommath/bn_mp_get_mag_ull.c ../libtommath/bn_mp_grow.c ../libtommath/bn_mp_incr.c ../libtommath/bn_mp_init.c ../libtommath/bn_mp_init_copy.c ../libtommath/bn_mp_init_i32.c ../libtommath/bn_mp_init_i64.c ../libtommath/bn_mp_init_l.c ../libtommath/bn_mp_init_ll.c ../libtommath/bn_mp_init_multi.c ../libtommath/bn_mp_init_set.c ../libtommath/bn_mp_init_size.c ../libtommath/bn_mp_init_u32.c ../libtommath/bn_mp_init_u64.c ../libtommath/bn_mp_init_ul.c ../libtommath/bn_mp_init_ull.c ../libtommath/bn_mp_invmod.c ../libtommath/bn_mp_is_square.c ../libtommath/bn_mp_iseven.c ../libtommath/bn_mp_isodd.c ../libtommath/bn_mp_kronecker.c ../libtommath/bn_mp_lcm.c ../libtommath/bn_mp_log_u32.c ../libtommath/bn_mp_lshd.c ../libtommath/bn_mp_mod.c ../libtommath/bn_mp_mod_2d.c ../libtommath/bn_mp_mod_d.c ../libtommath/bn_mp_montgomery_calc_normalization.c ../libtommath/bn_mp_montgomery_reduce.c ../libtommath/bn_mp_montgomery_setup.c ../libtommath/bn_mp_mul.c ../libtommath/bn_mp_mul_2.c ../libtommath/bn_mp_mul_2d.c ../libtommath/bn_mp_mul_d.c ../libtommath/bn_mp_mulmod.c ../libtommath/bn_mp_neg.c ../libtommath/bn_mp_or.c ../libtommath/bn_mp_pack.c ../libtommath/bn_mp_pack_count.c ../libtommath/bn_mp_prime_fermat.c ../libtommath/bn_mp_prime_frobenius_underwood.c ../libtommath/bn_mp_prime_is_prime.c ../libtommath/bn_mp_prime_miller_rabin.c ../libtommath/bn_mp_prime_next_prime.c ../libtommath/bn_mp_prime_rabin_miller_trials.c ../libtommath/bn_mp_prime_rand.c ../libtommath/bn_mp_prime_strong_lucas_selfridge.c ../libtommath/bn_mp_radix_size.c ../libtommath/bn_mp_radix_smap.c ../libtommath/bn_mp_rand.c ../libtommath/bn_mp_read_radix.c ../libtommath/bn_mp_reduce.c ../libtommath/bn_mp_reduce_2k.c ../libtommath/bn_mp_reduce_2k_l.c ../libtommath/bn_mp_reduce_2k_setup.c ../libtommath/bn_mp_reduce_2k_setup_l.c ../libtommath/bn_mp_reduce_is_2k.c ../libtommath/bn_mp_reduce_is_2k_l.c ../libtommath/bn_mp_reduce_setup.c ../libtommath/bn_mp_root_u32.c ../libtommath/bn_mp_rshd.c ../libtommath/bn_mp_sbin_size.c ../libtommath/bn_mp_set.c ../libtommath/bn_mp_set_i32.c ../libtommath/bn_mp_set_i64.c ../libtommath/bn_mp_set_l.c ../libtommath/bn_mp_set_ll.c ../libtommath/bn_mp_set_u32.c ../libtommath/bn_mp_set_u64.c ../libtommath/bn_mp_set_ul.c ../libtommath/bn_mp_set_ull.c ../libtommath/bn_mp_shrink.c ../libtommath/bn_mp_signed_rsh.c ../libtommath/bn_mp_sqr.c ../libtommath/bn_mp_sqrmod.c ../libtommath/bn_mp_sqrt.c ../libtommath/bn_mp_sqrtmod_prime.c ../libtommath/bn_mp_sub.c ../libtommath/bn_mp_sub_d.c ../libtommath/bn_mp_submod.c ../libtommath/bn_mp_to_radix.c ../libtommath/bn_mp_to_sbin.c ../libtommath/bn_mp_to_ubin.c ../libtommath/bn_mp_ubin_size.c ../libtommath/bn_mp_unpack.c ../libtommath/bn_mp_xor.c ../libtommath/bn_mp_zero.c ../libtommath/bn_prime_tab.c ../libtommath/bn_s_mp_add.c ../libtommath/bn_s_mp_balance_mul.c ../libtommath/bn_s_mp_exptmod.c ../libtommath/bn_s_mp_exptmod_fast.c ../libtommath/bn_s_mp_get_bit.c ../libtommath/bn_s_mp_invmod_fast.c ../libtommath/bn_s_mp_invmod_slow.c ../libtommath/bn_s_mp_karatsuba_mul.c ../libtommath/bn_s_mp_karatsuba_sqr.c ../libtommath/bn_s_mp_montgomery_reduce_fast.c ../libtommath/bn_s_mp_mul_digs.c ../libtommath/bn_s_mp_mul_digs_fast.c ../libtommath/bn_s_mp_mul_high_digs.c ../libtommath/bn_s_mp_mul_high_digs_fast.c ../libtommath/bn_s_mp_prime_is_divisible.c ../libtommath/bn_s_mp_rand_jenkins.c ../libtommath/bn_s_mp_reverse.c ../libtommath/bn_s_mp_sqr.c ../libtommath/bn_s_mp_sqr_fast.c ../libtommath/bn_s_mp_sub.c ../libtommath/bn_s_mp_toom_mul.c ../libtommath/bn_s_mp_toom_sqr.c
diff --git a/libc3/sources.sh b/libc3/sources.sh
index ff27642..205275e 100644
--- a/libc3/sources.sh
+++ b/libc3/sources.sh
@@ -1,3 +1,3 @@
# sources.sh generated by update_sources
-SOURCES='arg.c binding.c bool.c buf.c buf_file.c buf_inspect.c buf_parse.c buf_parse_c.c buf_save.c c3.c call.c character.c debug.c env.c error.c error_handler.c eval.c f32.c f64.c fact.c facts.c facts_cursor.c facts_spec.c facts_spec_cursor.c facts_with.c facts_with_cursor.c fn.c frame.c hash.c ident.c integer.c list.c ptag.c ptr.c quote.c s16.c s32.c s64.c s8.c set__fact.c set__tag.c set_cursor__fact.c set_cursor__tag.c set_item__fact.c set_item__tag.c skiplist__fact.c skiplist_node__fact.c str.c sym.c tag.c tuple.c u16.c u32.c u64.c u8.c ucd.c '
-LO_SOURCES='arg.c binding.c bool.c buf.c buf_file.c buf_inspect.c buf_parse.c buf_parse_c.c buf_save.c c3.c call.c character.c debug.c env.c error.c error_handler.c eval.c f32.c f64.c fact.c facts.c facts_cursor.c facts_spec.c facts_spec_cursor.c facts_with.c facts_with_cursor.c fn.c frame.c hash.c ident.c integer.c list.c ptag.c ptr.c quote.c s16.c s32.c s64.c s8.c set__fact.c set__tag.c set_cursor__fact.c set_cursor__tag.c set_item__fact.c set_item__tag.c skiplist__fact.c skiplist_node__fact.c str.c sym.c tag.c tuple.c u16.c u32.c u64.c u8.c ucd.c ../libtommath/bn_cutoffs.c ../libtommath/bn_deprecated.c ../libtommath/bn_mp_2expt.c ../libtommath/bn_mp_abs.c ../libtommath/bn_mp_add.c ../libtommath/bn_mp_add_d.c ../libtommath/bn_mp_addmod.c ../libtommath/bn_mp_and.c ../libtommath/bn_mp_clamp.c ../libtommath/bn_mp_clear.c ../libtommath/bn_mp_clear_multi.c ../libtommath/bn_mp_cmp.c ../libtommath/bn_mp_cmp_d.c ../libtommath/bn_mp_cmp_mag.c ../libtommath/bn_mp_cnt_lsb.c ../libtommath/bn_mp_complement.c ../libtommath/bn_mp_copy.c ../libtommath/bn_mp_count_bits.c ../libtommath/bn_mp_decr.c ../libtommath/bn_mp_div.c ../libtommath/bn_mp_div_2.c ../libtommath/bn_mp_div_2d.c ../libtommath/bn_mp_div_3.c ../libtommath/bn_mp_div_d.c ../libtommath/bn_mp_dr_is_modulus.c ../libtommath/bn_mp_dr_reduce.c ../libtommath/bn_mp_dr_setup.c ../libtommath/bn_mp_error_to_string.c ../libtommath/bn_mp_exch.c ../libtommath/bn_mp_expt_u32.c ../libtommath/bn_mp_exptmod.c ../libtommath/bn_mp_exteuclid.c ../libtommath/bn_mp_fread.c ../libtommath/bn_mp_from_sbin.c ../libtommath/bn_mp_from_ubin.c ../libtommath/bn_mp_fwrite.c ../libtommath/bn_mp_gcd.c ../libtommath/bn_mp_get_double.c ../libtommath/bn_mp_get_i32.c ../libtommath/bn_mp_get_i64.c ../libtommath/bn_mp_get_l.c ../libtommath/bn_mp_get_ll.c ../libtommath/bn_mp_get_mag_u32.c ../libtommath/bn_mp_get_mag_u64.c ../libtommath/bn_mp_get_mag_ul.c ../libtommath/bn_mp_get_mag_ull.c ../libtommath/bn_mp_grow.c ../libtommath/bn_mp_incr.c ../libtommath/bn_mp_init.c ../libtommath/bn_mp_init_copy.c ../libtommath/bn_mp_init_i32.c ../libtommath/bn_mp_init_i64.c ../libtommath/bn_mp_init_l.c ../libtommath/bn_mp_init_ll.c ../libtommath/bn_mp_init_multi.c ../libtommath/bn_mp_init_set.c ../libtommath/bn_mp_init_size.c ../libtommath/bn_mp_init_u32.c ../libtommath/bn_mp_init_u64.c ../libtommath/bn_mp_init_ul.c ../libtommath/bn_mp_init_ull.c ../libtommath/bn_mp_invmod.c ../libtommath/bn_mp_is_square.c ../libtommath/bn_mp_iseven.c ../libtommath/bn_mp_isodd.c ../libtommath/bn_mp_kronecker.c ../libtommath/bn_mp_lcm.c ../libtommath/bn_mp_log_u32.c ../libtommath/bn_mp_lshd.c ../libtommath/bn_mp_mod.c ../libtommath/bn_mp_mod_2d.c ../libtommath/bn_mp_mod_d.c ../libtommath/bn_mp_montgomery_calc_normalization.c ../libtommath/bn_mp_montgomery_reduce.c ../libtommath/bn_mp_montgomery_setup.c ../libtommath/bn_mp_mul.c ../libtommath/bn_mp_mul_2.c ../libtommath/bn_mp_mul_2d.c ../libtommath/bn_mp_mul_d.c ../libtommath/bn_mp_mulmod.c ../libtommath/bn_mp_neg.c ../libtommath/bn_mp_or.c ../libtommath/bn_mp_pack.c ../libtommath/bn_mp_pack_count.c ../libtommath/bn_mp_prime_fermat.c ../libtommath/bn_mp_prime_frobenius_underwood.c ../libtommath/bn_mp_prime_is_prime.c ../libtommath/bn_mp_prime_miller_rabin.c ../libtommath/bn_mp_prime_next_prime.c ../libtommath/bn_mp_prime_rabin_miller_trials.c ../libtommath/bn_mp_prime_rand.c ../libtommath/bn_mp_prime_strong_lucas_selfridge.c ../libtommath/bn_mp_radix_size.c ../libtommath/bn_mp_radix_smap.c ../libtommath/bn_mp_rand.c ../libtommath/bn_mp_read_radix.c ../libtommath/bn_mp_reduce.c ../libtommath/bn_mp_reduce_2k.c ../libtommath/bn_mp_reduce_2k_l.c ../libtommath/bn_mp_reduce_2k_setup.c ../libtommath/bn_mp_reduce_2k_setup_l.c ../libtommath/bn_mp_reduce_is_2k.c ../libtommath/bn_mp_reduce_is_2k_l.c ../libtommath/bn_mp_reduce_setup.c ../libtommath/bn_mp_root_u32.c ../libtommath/bn_mp_rshd.c ../libtommath/bn_mp_sbin_size.c ../libtommath/bn_mp_set.c ../libtommath/bn_mp_set_i32.c ../libtommath/bn_mp_set_i64.c ../libtommath/bn_mp_set_l.c ../libtommath/bn_mp_set_ll.c ../libtommath/bn_mp_set_u32.c ../libtommath/bn_mp_set_u64.c ../libtommath/bn_mp_set_ul.c ../libtommath/bn_mp_set_ull.c ../libtommath/bn_mp_shrink.c ../libtommath/bn_mp_signed_rsh.c ../libtommath/bn_mp_sqr.c ../libtommath/bn_mp_sqrmod.c ../libtommath/bn_mp_sqrt.c ../libtommath/bn_mp_sqrtmod_prime.c ../libtommath/bn_mp_sub.c ../libtommath/bn_mp_sub_d.c ../libtommath/bn_mp_submod.c ../libtommath/bn_mp_to_radix.c ../libtommath/bn_mp_to_sbin.c ../libtommath/bn_mp_to_ubin.c ../libtommath/bn_mp_ubin_size.c ../libtommath/bn_mp_unpack.c ../libtommath/bn_mp_xor.c ../libtommath/bn_mp_zero.c ../libtommath/bn_prime_tab.c ../libtommath/bn_s_mp_add.c ../libtommath/bn_s_mp_balance_mul.c ../libtommath/bn_s_mp_exptmod.c ../libtommath/bn_s_mp_exptmod_fast.c ../libtommath/bn_s_mp_get_bit.c ../libtommath/bn_s_mp_invmod_fast.c ../libtommath/bn_s_mp_invmod_slow.c ../libtommath/bn_s_mp_karatsuba_mul.c ../libtommath/bn_s_mp_karatsuba_sqr.c ../libtommath/bn_s_mp_montgomery_reduce_fast.c ../libtommath/bn_s_mp_mul_digs.c ../libtommath/bn_s_mp_mul_digs_fast.c ../libtommath/bn_s_mp_mul_high_digs.c ../libtommath/bn_s_mp_mul_high_digs_fast.c ../libtommath/bn_s_mp_prime_is_divisible.c ../libtommath/bn_s_mp_rand_jenkins.c ../libtommath/bn_s_mp_reverse.c ../libtommath/bn_s_mp_sqr.c ../libtommath/bn_s_mp_sqr_fast.c ../libtommath/bn_s_mp_sub.c ../libtommath/bn_s_mp_toom_mul.c ../libtommath/bn_s_mp_toom_sqr.c '
+SOURCES='arg.c binding.c bool.c buf.c buf_file.c buf_inspect.c buf_parse.c buf_parse_c.c buf_save.c c3.c call.c character.c compare.c debug.c env.c error.c error_handler.c eval.c fact.c facts.c facts_cursor.c facts_spec.c facts_spec_cursor.c facts_with.c facts_with_cursor.c fn.c frame.c hash.c ident.c integer.c list.c ptr.c quote.c s16.c s32.c s64.c s8.c set__fact.c set__tag.c set_cursor__fact.c set_cursor__tag.c set_item__fact.c set_item__tag.c skiplist__fact.c skiplist_node__fact.c str.c sym.c tag.c tuple.c ucd.c '
+LO_SOURCES='arg.c binding.c bool.c buf.c buf_file.c buf_inspect.c buf_parse.c buf_parse_c.c buf_save.c c3.c call.c character.c compare.c debug.c env.c error.c error_handler.c eval.c fact.c facts.c facts_cursor.c facts_spec.c facts_spec_cursor.c facts_with.c facts_with_cursor.c fn.c frame.c hash.c ident.c integer.c list.c ptr.c quote.c s16.c s32.c s64.c s8.c set__fact.c set__tag.c set_cursor__fact.c set_cursor__tag.c set_item__fact.c set_item__tag.c skiplist__fact.c skiplist_node__fact.c str.c sym.c tag.c tuple.c ucd.c ../libtommath/bn_cutoffs.c ../libtommath/bn_deprecated.c ../libtommath/bn_mp_2expt.c ../libtommath/bn_mp_abs.c ../libtommath/bn_mp_add.c ../libtommath/bn_mp_add_d.c ../libtommath/bn_mp_addmod.c ../libtommath/bn_mp_and.c ../libtommath/bn_mp_clamp.c ../libtommath/bn_mp_clear.c ../libtommath/bn_mp_clear_multi.c ../libtommath/bn_mp_cmp.c ../libtommath/bn_mp_cmp_d.c ../libtommath/bn_mp_cmp_mag.c ../libtommath/bn_mp_cnt_lsb.c ../libtommath/bn_mp_complement.c ../libtommath/bn_mp_copy.c ../libtommath/bn_mp_count_bits.c ../libtommath/bn_mp_decr.c ../libtommath/bn_mp_div.c ../libtommath/bn_mp_div_2.c ../libtommath/bn_mp_div_2d.c ../libtommath/bn_mp_div_3.c ../libtommath/bn_mp_div_d.c ../libtommath/bn_mp_dr_is_modulus.c ../libtommath/bn_mp_dr_reduce.c ../libtommath/bn_mp_dr_setup.c ../libtommath/bn_mp_error_to_string.c ../libtommath/bn_mp_exch.c ../libtommath/bn_mp_expt_u32.c ../libtommath/bn_mp_exptmod.c ../libtommath/bn_mp_exteuclid.c ../libtommath/bn_mp_fread.c ../libtommath/bn_mp_from_sbin.c ../libtommath/bn_mp_from_ubin.c ../libtommath/bn_mp_fwrite.c ../libtommath/bn_mp_gcd.c ../libtommath/bn_mp_get_double.c ../libtommath/bn_mp_get_i32.c ../libtommath/bn_mp_get_i64.c ../libtommath/bn_mp_get_l.c ../libtommath/bn_mp_get_ll.c ../libtommath/bn_mp_get_mag_u32.c ../libtommath/bn_mp_get_mag_u64.c ../libtommath/bn_mp_get_mag_ul.c ../libtommath/bn_mp_get_mag_ull.c ../libtommath/bn_mp_grow.c ../libtommath/bn_mp_incr.c ../libtommath/bn_mp_init.c ../libtommath/bn_mp_init_copy.c ../libtommath/bn_mp_init_i32.c ../libtommath/bn_mp_init_i64.c ../libtommath/bn_mp_init_l.c ../libtommath/bn_mp_init_ll.c ../libtommath/bn_mp_init_multi.c ../libtommath/bn_mp_init_set.c ../libtommath/bn_mp_init_size.c ../libtommath/bn_mp_init_u32.c ../libtommath/bn_mp_init_u64.c ../libtommath/bn_mp_init_ul.c ../libtommath/bn_mp_init_ull.c ../libtommath/bn_mp_invmod.c ../libtommath/bn_mp_is_square.c ../libtommath/bn_mp_iseven.c ../libtommath/bn_mp_isodd.c ../libtommath/bn_mp_kronecker.c ../libtommath/bn_mp_lcm.c ../libtommath/bn_mp_log_u32.c ../libtommath/bn_mp_lshd.c ../libtommath/bn_mp_mod.c ../libtommath/bn_mp_mod_2d.c ../libtommath/bn_mp_mod_d.c ../libtommath/bn_mp_montgomery_calc_normalization.c ../libtommath/bn_mp_montgomery_reduce.c ../libtommath/bn_mp_montgomery_setup.c ../libtommath/bn_mp_mul.c ../libtommath/bn_mp_mul_2.c ../libtommath/bn_mp_mul_2d.c ../libtommath/bn_mp_mul_d.c ../libtommath/bn_mp_mulmod.c ../libtommath/bn_mp_neg.c ../libtommath/bn_mp_or.c ../libtommath/bn_mp_pack.c ../libtommath/bn_mp_pack_count.c ../libtommath/bn_mp_prime_fermat.c ../libtommath/bn_mp_prime_frobenius_underwood.c ../libtommath/bn_mp_prime_is_prime.c ../libtommath/bn_mp_prime_miller_rabin.c ../libtommath/bn_mp_prime_next_prime.c ../libtommath/bn_mp_prime_rabin_miller_trials.c ../libtommath/bn_mp_prime_rand.c ../libtommath/bn_mp_prime_strong_lucas_selfridge.c ../libtommath/bn_mp_radix_size.c ../libtommath/bn_mp_radix_smap.c ../libtommath/bn_mp_rand.c ../libtommath/bn_mp_read_radix.c ../libtommath/bn_mp_reduce.c ../libtommath/bn_mp_reduce_2k.c ../libtommath/bn_mp_reduce_2k_l.c ../libtommath/bn_mp_reduce_2k_setup.c ../libtommath/bn_mp_reduce_2k_setup_l.c ../libtommath/bn_mp_reduce_is_2k.c ../libtommath/bn_mp_reduce_is_2k_l.c ../libtommath/bn_mp_reduce_setup.c ../libtommath/bn_mp_root_u32.c ../libtommath/bn_mp_rshd.c ../libtommath/bn_mp_sbin_size.c ../libtommath/bn_mp_set.c ../libtommath/bn_mp_set_i32.c ../libtommath/bn_mp_set_i64.c ../libtommath/bn_mp_set_l.c ../libtommath/bn_mp_set_ll.c ../libtommath/bn_mp_set_u32.c ../libtommath/bn_mp_set_u64.c ../libtommath/bn_mp_set_ul.c ../libtommath/bn_mp_set_ull.c ../libtommath/bn_mp_shrink.c ../libtommath/bn_mp_signed_rsh.c ../libtommath/bn_mp_sqr.c ../libtommath/bn_mp_sqrmod.c ../libtommath/bn_mp_sqrt.c ../libtommath/bn_mp_sqrtmod_prime.c ../libtommath/bn_mp_sub.c ../libtommath/bn_mp_sub_d.c ../libtommath/bn_mp_submod.c ../libtommath/bn_mp_to_radix.c ../libtommath/bn_mp_to_sbin.c ../libtommath/bn_mp_to_ubin.c ../libtommath/bn_mp_ubin_size.c ../libtommath/bn_mp_unpack.c ../libtommath/bn_mp_xor.c ../libtommath/bn_mp_zero.c ../libtommath/bn_prime_tab.c ../libtommath/bn_s_mp_add.c ../libtommath/bn_s_mp_balance_mul.c ../libtommath/bn_s_mp_exptmod.c ../libtommath/bn_s_mp_exptmod_fast.c ../libtommath/bn_s_mp_get_bit.c ../libtommath/bn_s_mp_invmod_fast.c ../libtommath/bn_s_mp_invmod_slow.c ../libtommath/bn_s_mp_karatsuba_mul.c ../libtommath/bn_s_mp_karatsuba_sqr.c ../libtommath/bn_s_mp_montgomery_reduce_fast.c ../libtommath/bn_s_mp_mul_digs.c ../libtommath/bn_s_mp_mul_digs_fast.c ../libtommath/bn_s_mp_mul_high_digs.c ../libtommath/bn_s_mp_mul_high_digs_fast.c ../libtommath/bn_s_mp_prime_is_divisible.c ../libtommath/bn_s_mp_rand_jenkins.c ../libtommath/bn_s_mp_reverse.c ../libtommath/bn_s_mp_sqr.c ../libtommath/bn_s_mp_sqr_fast.c ../libtommath/bn_s_mp_sub.c ../libtommath/bn_s_mp_toom_mul.c ../libtommath/bn_s_mp_toom_sqr.c '
diff --git a/libc3/str.h b/libc3/str.h
index bd81c24..b5f4b34 100644
--- a/libc3/str.h
+++ b/libc3/str.h
@@ -52,31 +52,30 @@ s_str * str_new_vf (const char *fmt, va_list ap);
void str_delete (s_str *str);
/* Observers */
-character str_character_escape (character c);
-e_bool str_character_is_reserved (character c);
-sw str_compare (const s_str *a, const s_str *b);
-s_str * str_copy (const s_str *src, s_str *dest);
-e_bool str_has_reserved_characters (const s_str *str);
-t_hash_context * str_hash_update (t_hash_context *context,
- const s_str *src);
-s_str * str_inspect (const s_str *x, s_str *dest);
-sw str_peek_bool (const s_str *src, bool *p);
-sw str_peek_character (const s_str *src, character *p);
-sw str_peek_f32 (const s_str *src, f32 *p);
-sw str_peek_f64 (const s_str *src, f64 *p);
-sw str_peek_s8 (const s_str *src, s8 *p);
-sw str_peek_s16 (const s_str *src, s16 *p);
-sw str_peek_s32 (const s_str *src, s32 *p);
-sw str_peek_s64 (const s_str *src, s64 *p);
-sw str_peek_str (const s_str *src, s_str *p);
-sw str_peek_sym (const s_str *src, s_sym *p);
-sw str_peek_u8 (const s_str *src, u8 *p);
-sw str_peek_u16 (const s_str *src, u16 *p);
-sw str_peek_u32 (const s_str *src, u32 *p);
-sw str_peek_u64 (const s_str *src, u64 *p);
-s_str * str_to_hex (const s_str *src, s_str *dest);
-s_ident * str_to_ident (const s_str *src, s_ident *dest);
-const s_sym * str_to_sym (const s_str *src);
+character str_character_escape (character c);
+e_bool str_character_is_reserved (character c);
+sw str_compare (const s_str *a, const s_str *b);
+s_str * str_copy (const s_str *src, s_str *dest);
+e_bool str_has_reserved_characters (const s_str *str);
+void str_hash_update (const s_str *src, t_hash *hash);
+s_str * str_inspect (const s_str *x, s_str *dest);
+sw str_peek_bool (const s_str *src, bool *p);
+sw str_peek_character (const s_str *src, character *p);
+sw str_peek_f32 (const s_str *src, f32 *p);
+sw str_peek_f64 (const s_str *src, f64 *p);
+sw str_peek_s8 (const s_str *src, s8 *p);
+sw str_peek_s16 (const s_str *src, s16 *p);
+sw str_peek_s32 (const s_str *src, s32 *p);
+sw str_peek_s64 (const s_str *src, s64 *p);
+sw str_peek_str (const s_str *src, s_str *p);
+sw str_peek_sym (const s_str *src, s_sym *p);
+sw str_peek_u8 (const s_str *src, u8 *p);
+sw str_peek_u16 (const s_str *src, u16 *p);
+sw str_peek_u32 (const s_str *src, u32 *p);
+sw str_peek_u64 (const s_str *src, u64 *p);
+s_str * str_to_hex (const s_str *src, s_str *dest);
+s_ident * str_to_ident (const s_str *src, s_ident *dest);
+const s_sym * str_to_sym (const s_str *src);
/* Modifiers */
sw str_read (s_str *str, u8 *p);
diff --git a/libc3/sym.c b/libc3/sym.c
index 6edceb7..7ffc544 100644
--- a/libc3/sym.c
+++ b/libc3/sym.c
@@ -20,7 +20,6 @@
#include "character.h"
#include "str.h"
#include "sym.h"
-#include "u8.h"
void sym_delete (s_sym *sym);
s_str * sym_inspect_reserved (const s_sym *sym, s_str *dest);
@@ -110,15 +109,6 @@ e_bool sym_has_reserved_characters (const s_sym *sym)
return false;
}
-t_hash_context * sym_hash_update (t_hash_context *context,
- const s_sym *src)
-{
- assert(context);
- assert(src);
- u8_hash_update(context, ':');
- return str_hash_update(context, &src->str);
-}
-
s_str * sym_inspect (const s_sym *sym, s_str *dest)
{
sw size;
diff --git a/libc3/sym.h b/libc3/sym.h
index 4e87a5d..9eeae90 100644
--- a/libc3/sym.h
+++ b/libc3/sym.h
@@ -44,8 +44,7 @@ const s_sym * sym_find (const s_str *src);
e_bool sym_has_reserved_characters (const s_sym *sym);
-t_hash_context * sym_hash_update (t_hash_context *context,
- const s_sym *src);
+void sym_hash_update (const s_sym *sym, t_hash *hash);
s_str * sym_inspect (const s_sym *sym, s_str *dest);
diff --git a/libc3/tag.c b/libc3/tag.c
index f81b719..ed08a51 100644
--- a/libc3/tag.c
+++ b/libc3/tag.c
@@ -225,55 +225,22 @@ s_tag * tag_f64 (s_tag *tag, f64 x)
return tag_init_f64(tag, x);
}
-uw tag_hash (const s_tag *tag)
+u64 tag_hash_u64 (const s_tag *tag)
{
- t_hash_context context;
+ t_hash hash;
assert(tag);
- hash_init(&context);
- tag_hash_update(&context, tag);
- return hash_result(&context);
+ hash_init(&hash);
+ tag_hash_update(tag, &hash);
+ return hash_to_u64(&hash);
}
-t_hash_context * tag_hash_update (t_hash_context *context,
- const s_tag *tag)
+uw tag_hash_uw (const s_tag *tag)
{
+ t_hash hash;
assert(tag);
- u64_hash_update(context, tag->type.type);
- switch (tag->type.type) {
- case TAG_VOID: break;
- case TAG_BOOL: bool_hash_update(context, tag->data.bool); break;
- case TAG_CALL:
- case TAG_CALL_FN:
- case TAG_CALL_MACRO:
- call_hash_update(context, &tag->data.call); break;
- case TAG_CHARACTER:
- character_hash_update(context, tag->data.character); break;
- case TAG_F32: f32_hash_update(context, tag->data.f32); break;
- case TAG_F64: f64_hash_update(context, tag->data.f64); break;
- case TAG_FN: u64_hash_update(context, (u64) tag); break;
- case TAG_IDENT: ident_hash_update(context, &tag->data.ident); break;
- case TAG_INTEGER:
- integer_hash_update(context, &tag->data.integer); break;
- case TAG_LIST: list_hash_update(context, tag->data.list); break;
- case TAG_PTAG: ptag_hash_update(context, tag->data.ptag); break;
- case TAG_QUOTE: quote_hash_update(context, tag->data.quote); break;
- case TAG_S8: s8_hash_update(context, tag->data.s8); break;
- case TAG_S16: s16_hash_update(context, tag->data.s16); break;
- case TAG_S32: s32_hash_update(context, tag->data.s32); break;
- case TAG_S64: s64_hash_update(context, tag->data.s64); break;
- case TAG_STR: str_hash_update(context, &tag->data.str); break;
- case TAG_SYM: sym_hash_update(context, tag->data.sym); break;
- case TAG_TUPLE: tuple_hash_update(context, &tag->data.tuple); break;
- case TAG_U8: u8_hash_update(context, tag->data.u8); break;
- case TAG_U16: u16_hash_update(context, tag->data.u16); break;
- case TAG_U32: u32_hash_update(context, tag->data.u32); break;
- case TAG_U64: u64_hash_update(context, tag->data.u64); break;
- case TAG_VAR:
- assert(! "var hash update");
- errx(1, "var hash update");
- return NULL;
- }
- return context;
+ hash_init(&hash);
+ tag_hash_update(tag, &hash);
+ return hash_to_uw(&hash);
}
s_tag * tag_ident (s_tag *tag, const s_ident *x)
diff --git a/libc3/tag.h b/libc3/tag.h
index 3c7f3c6..5ef2733 100644
--- a/libc3/tag.h
+++ b/libc3/tag.h
@@ -22,7 +22,6 @@
#include <stdarg.h>
#include <stdio.h>
-#include "hash.h"
#include "../libffi/ffi.h"
#include "types.h"
@@ -88,17 +87,16 @@ s_tag * tag_new_var ();
void tag_delete (s_tag *tag);
/* Observers */
-s8 tag_compare (const s_tag *a, const s_tag *b);
-uw tag_hash (const s_tag *tag);
-t_hash_context * tag_hash_update (t_hash_context *context,
- const s_tag *tag);
-s_str * tag_inspect (const s_tag *tag, s_str *dest);
-e_bool tag_is_bound_var (const s_tag *tag);
-e_bool tag_is_number (const s_tag *tag);
-e_bool tag_is_unbound_var (const s_tag *tag);
-s8 tag_number_compare (const s_tag *a, const s_tag *b);
-sw tag_size (const s_tag *tag);
-sw tag_type_size (e_tag_type type);
+s8 tag_compare (const s_tag *a, const s_tag *b);
+u64 tag_hash_u64 (const s_tag *tag);
+uw tag_hash_uw (const s_tag *tag);
+s_str * tag_inspect (const s_tag *tag, s_str *dest);
+e_bool tag_is_bound_var (const s_tag *tag);
+e_bool tag_is_number (const s_tag *tag);
+e_bool tag_is_unbound_var (const s_tag *tag);
+s8 tag_number_compare (const s_tag *a, const s_tag *b);
+sw tag_size (const s_tag *tag);
+sw tag_type_size (e_tag_type type);
/* Modifiers */
s_tag * tag_1 (s_tag *tag, const s8 *p);
diff --git a/libc3/tuple.h b/libc3/tuple.h
index 5bfaef3..8ce3393 100644
--- a/libc3/tuple.h
+++ b/libc3/tuple.h
@@ -39,10 +39,7 @@ void tuple_delete (s_tuple *tuple);
s_tuple * tuple_1 (s_tuple *tuple, const s8 *p);
/* Observers */
-s8 tuple_compare (const s_tuple *a, const s_tuple *b);
s_tuple * tuple_copy (const s_tuple *src, s_tuple *dest);
-t_hash_context * tuple_hash_update (t_hash_context *context,
- const s_tuple *tuple);
s_list * tuple_to_list (const s_tuple *tuple, s_list **list);
/* Call str_delete after use. */
diff --git a/libc3/types.h b/libc3/types.h
index bf012df..ddb10e7 100644
--- a/libc3/types.h
+++ b/libc3/types.h
@@ -18,6 +18,7 @@
#include <setjmp.h>
#include <stdio.h>
#include <sys/types.h>
+#include <sha1.h>
#include "../libtommath/tommath.h"
/* Basic integer types. */
@@ -113,8 +114,9 @@ typedef union tag_data u_tag_data;
typedef union tag_type u_tag_type;
/* typedefs */
-typedef s32 character;
+typedef s32 character;
typedef s_tag **p_facts_spec;
+typedef SHA1_CTX t_hash;
typedef s_tag *p_quote;
typedef const s_tag *p_tag;
typedef const s_tag *p_var;
@@ -213,6 +215,7 @@ struct buf {
sw (*refill) (s_buf *buf);
uw rpos;
s_buf_save *save;
+ sw (*seek) (s_buf *buf, sw offset, u8 whence);
uw size;
void *user_ptr;
u64 wpos;
@@ -365,6 +368,8 @@ struct facts {
s_skiplist__fact *index_pos;
s_skiplist__fact *index_osp;
s_buf *log;
+ u64 log_count;
+ t_hash log_hash;
};
struct facts_cursor {
diff --git a/libc3/u16.c b/libc3/u16.c
deleted file mode 100644
index b124d45..0000000
--- a/libc3/u16.c
+++ /dev/null
@@ -1,28 +0,0 @@
-/* c3
- * Copyright 2022 kmx.io <contact@kmx.io>
- *
- * Permission is hereby granted to use this software excepted
- * on Apple computers granted the above copyright notice and
- * this permission paragraph are included in all copies and
- * substantial portions of this software.
- *
- * THIS SOFTWARE IS PROVIDED "AS-IS" WITHOUT ANY GUARANTEE OF
- * PURPOSE AND PERFORMANCE. IN NO EVENT WHATSOEVER SHALL THE
- * AUTHOR BE CONSIDERED LIABLE FOR THE USE AND PERFORMANCE OF
- * THIS SOFTWARE.
- */
-#include "u16.h"
-
-s8 u16_compare (u16 a, u16 b)
-{
- if (a < b)
- return -1;
- if (a > b)
- return 1;
- return 0;
-}
-
-t_hash_context * u16_hash_update (t_hash_context *context, u16 x)
-{
- return hash_update(context, &x, sizeof(x));
-}
diff --git a/libc3/u16.h b/libc3/u16.h
deleted file mode 100644
index d7ac4d2..0000000
--- a/libc3/u16.h
+++ /dev/null
@@ -1,23 +0,0 @@
-/* c3
- * Copyright 2022 kmx.io <contact@kmx.io>
- *
- * Permission is hereby granted to use this software excepted
- * on Apple computers granted the above copyright notice and
- * this permission paragraph are included in all copies and
- * substantial portions of this software.
- *
- * THIS SOFTWARE IS PROVIDED "AS-IS" WITHOUT ANY GUARANTEE OF
- * PURPOSE AND PERFORMANCE. IN NO EVENT WHATSOEVER SHALL THE
- * AUTHOR BE CONSIDERED LIABLE FOR THE USE AND PERFORMANCE OF
- * THIS SOFTWARE.
- */
-#ifndef U16_H
-#define U16_H
-
-#include "hash.h"
-#include "types.h"
-
-s8 u16_compare (u16 a, u16 b);
-t_hash_context * u16_hash_update (t_hash_context *context, u16 i);
-
-#endif /* U16_H */
diff --git a/libc3/u32.c b/libc3/u32.c
deleted file mode 100644
index e40f23e..0000000
--- a/libc3/u32.c
+++ /dev/null
@@ -1,28 +0,0 @@
-/* c3
- * Copyright 2022 kmx.io <contact@kmx.io>
- *
- * Permission is hereby granted to use this software excepted
- * on Apple computers granted the above copyright notice and
- * this permission paragraph are included in all copies and
- * substantial portions of this software.
- *
- * THIS SOFTWARE IS PROVIDED "AS-IS" WITHOUT ANY GUARANTEE OF
- * PURPOSE AND PERFORMANCE. IN NO EVENT WHATSOEVER SHALL THE
- * AUTHOR BE CONSIDERED LIABLE FOR THE USE AND PERFORMANCE OF
- * THIS SOFTWARE.
- */
-#include "u32.h"
-
-s8 u32_compare (u32 a, u32 b)
-{
- if (a < b)
- return -1;
- if (a > b)
- return 1;
- return 0;
-}
-
-t_hash_context * u32_hash_update (t_hash_context *context, u32 x)
-{
- return hash_update(context, &x, sizeof(x));
-}
diff --git a/libc3/u32.h b/libc3/u32.h
deleted file mode 100644
index 0ecf311..0000000
--- a/libc3/u32.h
+++ /dev/null
@@ -1,23 +0,0 @@
-/* c3
- * Copyright 2022 kmx.io <contact@kmx.io>
- *
- * Permission is hereby granted to use this software excepted
- * on Apple computers granted the above copyright notice and
- * this permission paragraph are included in all copies and
- * substantial portions of this software.
- *
- * THIS SOFTWARE IS PROVIDED "AS-IS" WITHOUT ANY GUARANTEE OF
- * PURPOSE AND PERFORMANCE. IN NO EVENT WHATSOEVER SHALL THE
- * AUTHOR BE CONSIDERED LIABLE FOR THE USE AND PERFORMANCE OF
- * THIS SOFTWARE.
- */
-#ifndef U32_H
-#define U32_H
-
-#include "hash.h"
-#include "types.h"
-
-s8 u32_compare (u32 a, u32 b);
-t_hash_context * u32_hash_update (t_hash_context *context, u32 i);
-
-#endif /* U32_H */
diff --git a/libc3/u64.c b/libc3/u64.c
deleted file mode 100644
index a7f3748..0000000
--- a/libc3/u64.c
+++ /dev/null
@@ -1,28 +0,0 @@
-/* c3
- * Copyright 2022 kmx.io <contact@kmx.io>
- *
- * Permission is hereby granted to use this software excepted
- * on Apple computers granted the above copyright notice and
- * this permission paragraph are included in all copies and
- * substantial portions of this software.
- *
- * THIS SOFTWARE IS PROVIDED "AS-IS" WITHOUT ANY GUARANTEE OF
- * PURPOSE AND PERFORMANCE. IN NO EVENT WHATSOEVER SHALL THE
- * AUTHOR BE CONSIDERED LIABLE FOR THE USE AND PERFORMANCE OF
- * THIS SOFTWARE.
- */
-#include "u64.h"
-
-s8 u64_compare (u64 a, u64 b)
-{
- if (a < b)
- return -1;
- if (a > b)
- return 1;
- return 0;
-}
-
-t_hash_context * u64_hash_update (t_hash_context *context, u64 x)
-{
- return hash_update(context, &x, sizeof(x));
-}
diff --git a/libc3/u64.h b/libc3/u64.h
deleted file mode 100644
index b2e42cd..0000000
--- a/libc3/u64.h
+++ /dev/null
@@ -1,23 +0,0 @@
-/* c3
- * Copyright 2022 kmx.io <contact@kmx.io>
- *
- * Permission is hereby granted to use this software excepted
- * on Apple computers granted the above copyright notice and
- * this permission paragraph are included in all copies and
- * substantial portions of this software.
- *
- * THIS SOFTWARE IS PROVIDED "AS-IS" WITHOUT ANY GUARANTEE OF
- * PURPOSE AND PERFORMANCE. IN NO EVENT WHATSOEVER SHALL THE
- * AUTHOR BE CONSIDERED LIABLE FOR THE USE AND PERFORMANCE OF
- * THIS SOFTWARE.
- */
-#ifndef U64_H
-#define U64_H
-
-#include "hash.h"
-#include "types.h"
-
-s8 u64_compare (u64 a, u64 b);
-t_hash_context * u64_hash_update (t_hash_context *context, u64 i);
-
-#endif /* U64_H */
diff --git a/libc3/u8.c b/libc3/u8.c
deleted file mode 100644
index 89b9688..0000000
--- a/libc3/u8.c
+++ /dev/null
@@ -1,28 +0,0 @@
-/* c3
- * Copyright 2022 kmx.io <contact@kmx.io>
- *
- * Permission is hereby granted to use this software excepted
- * on Apple computers granted the above copyright notice and
- * this permission paragraph are included in all copies and
- * substantial portions of this software.
- *
- * THIS SOFTWARE IS PROVIDED "AS-IS" WITHOUT ANY GUARANTEE OF
- * PURPOSE AND PERFORMANCE. IN NO EVENT WHATSOEVER SHALL THE
- * AUTHOR BE CONSIDERED LIABLE FOR THE USE AND PERFORMANCE OF
- * THIS SOFTWARE.
- */
-#include "u8.h"
-
-s8 u8_compare (u8 a, u8 b)
-{
- if (a < b)
- return -1;
- if (a > b)
- return 1;
- return 0;
-}
-
-t_hash_context * u8_hash_update (t_hash_context *context, u8 x)
-{
- return hash_update(context, &x, sizeof(x));
-}
diff --git a/libc3/u8.h b/libc3/u8.h
deleted file mode 100644
index adcf658..0000000
--- a/libc3/u8.h
+++ /dev/null
@@ -1,23 +0,0 @@
-/* c3
- * Copyright 2022 kmx.io <contact@kmx.io>
- *
- * Permission is hereby granted to use this software excepted
- * on Apple computers granted the above copyright notice and
- * this permission paragraph are included in all copies and
- * substantial portions of this software.
- *
- * THIS SOFTWARE IS PROVIDED "AS-IS" WITHOUT ANY GUARANTEE OF
- * PURPOSE AND PERFORMANCE. IN NO EVENT WHATSOEVER SHALL THE
- * AUTHOR BE CONSIDERED LIABLE FOR THE USE AND PERFORMANCE OF
- * THIS SOFTWARE.
- */
-#ifndef U8_H
-#define U8_H
-
-#include "hash.h"
-#include "types.h"
-
-s8 u8_compare (u8 a, u8 b);
-t_hash_context * u8_hash_update (t_hash_context *context, u8 i);
-
-#endif /* U8_H */