cproc

Unnamed repository; edit this file 'description' to name the repository.
git clone git://git.nihaljere.xyz/cproc
Log | Files | Refs | Submodules | README | LICENSE

commit 08bb1a3d64dc288c56c74f06a5b89952e287ac91
parent d02201ec74d5d6f54bf1980317be45e1e5aef21c
Author: Michael Forney <mforney@mforney.org>
Date:   Wed, 17 Apr 2019 20:09:38 -0700

Merge map.h and tree.h into util.h

Diffstat:
Mdecl.c | 1-
Mdeps.mk | 10+++++-----
Mmap.c | 1-
Dmap.h | 12------------
Mqbe.c | 2--
Mscope.c | 1-
Mtree.c | 1-
Dtree.h | 8--------
Mutil.h | 25+++++++++++++++++++++++++
9 files changed, 30 insertions(+), 31 deletions(-)

diff --git a/decl.c b/decl.c @@ -8,7 +8,6 @@ #include <string.h> #include "util.h" #include "cc.h" -#include "map.h" static struct list tentativedefns = {&tentativedefns, &tentativedefns}; diff --git a/deps.mk b/deps.mk @@ -1,18 +1,18 @@ $(objdir)/driver.o: driver.c util.h config.h $(objdir)/util.o: util.c util.h -$(objdir)/decl.o: decl.c util.h cc.h map.h +$(objdir)/decl.o: decl.c util.h cc.h $(objdir)/eval.o: eval.c util.h cc.h $(objdir)/expr.o: expr.c util.h cc.h $(objdir)/init.o: init.c util.h cc.h $(objdir)/main.o: main.c util.h arg.h cc.h -$(objdir)/map.o: map.c util.h map.h +$(objdir)/map.o: map.c util.h $(objdir)/pp.o: pp.c util.h cc.h $(objdir)/scan.o: scan.c util.h cc.h -$(objdir)/scope.o: scope.c util.h cc.h map.h +$(objdir)/scope.o: scope.c util.h cc.h $(objdir)/siphash.o: siphash.c $(objdir)/stmt.o: stmt.c util.h cc.h $(objdir)/token.o: token.c util.h cc.h -$(objdir)/tree.o: tree.c util.h tree.h +$(objdir)/tree.o: tree.c util.h $(objdir)/type.o: type.c util.h cc.h $(objdir)/util.o: util.c util.h -$(objdir)/qbe.o: qbe.c util.h cc.h map.h tree.h ops.h +$(objdir)/qbe.o: qbe.c util.h cc.h ops.h diff --git a/map.c b/map.c @@ -4,7 +4,6 @@ #include <stdlib.h> #include <string.h> #include "util.h" -#include "map.h" struct map { size_t len, cap; diff --git a/map.h b/map.h @@ -1,12 +0,0 @@ -struct mapkey { - uint64_t hash; - const char *str; - size_t len; -}; - -void mapkey(struct mapkey *, const char *, size_t); - -struct map *mkmap(size_t); -void delmap(struct map *, void(void *)); -void **mapput(struct map *, struct mapkey *); -void *mapget(struct map *, struct mapkey *); diff --git a/qbe.c b/qbe.c @@ -7,8 +7,6 @@ #include <inttypes.h> #include "util.h" #include "cc.h" -#include "map.h" -#include "tree.h" struct name { char *str; diff --git a/scope.c b/scope.c @@ -4,7 +4,6 @@ #include <string.h> #include "util.h" #include "cc.h" -#include "map.h" struct scope filescope; diff --git a/tree.c b/tree.c @@ -3,7 +3,6 @@ #include <stddef.h> #include <stdint.h> #include "util.h" -#include "tree.h" #define MAXH (sizeof(void *) * 8 * 3 / 2) diff --git a/tree.h b/tree.h @@ -1,8 +0,0 @@ -struct treenode { - uint64_t key; - void *child[2]; - int height; - _Bool new; /* set by treeinsert if this node was newly allocated */ -}; - -void *treeinsert(void **, uint64_t, size_t); diff --git a/util.h b/util.h @@ -7,6 +7,19 @@ struct array { size_t len, cap; }; +struct mapkey { + uint64_t hash; + const char *str; + size_t len; +}; + +struct treenode { + uint64_t key; + void *child[2]; + int height; + _Bool new; /* set by treeinsert if this node was newly allocated */ +}; + extern char *argv0; #define LEN(a) (sizeof(a) / sizeof((a)[0])) @@ -31,3 +44,15 @@ void *arrayadd(struct array *, size_t); void arrayaddptr(struct array *, void *); void arrayaddbuf(struct array *, const void *, size_t); #define arrayforeach(a, m) for (m = (a)->val; m != (void *)((char *)(a)->val + (a)->len); ++m) + +/* map */ + +void mapkey(struct mapkey *, const char *, size_t); +struct map *mkmap(size_t); +void delmap(struct map *, void(void *)); +void **mapput(struct map *, struct mapkey *); +void *mapget(struct map *, struct mapkey *); + +/* tree */ + +void *treeinsert(void **, uint64_t, size_t);