From 56c6523e15176ecb5eadeda803d7e54c165d69ca Mon Sep 17 00:00:00 2001 From: Peter McGoron Date: Fri, 7 Apr 2023 19:49:53 +0000 Subject: [PATCH] rerun test suite --- Makefile | 7 ++++--- asm/ffi.py | 15 +++++---------- creole.c | 20 ++++++++++++++------ 3 files changed, 23 insertions(+), 19 deletions(-) diff --git a/Makefile b/Makefile index d65fe98..35e4bfa 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,14 @@ test: test_asm c_test/encode_decode c_test/creole +CFLAGS=-DCREOLE_TEST asm/libcreole.so: creole.c creole.h - $(CC) -Wall -fPIC -c creole.c -o c_test/creole.o + $(CC) $(CFLAGS) -Wall -fPIC -c creole.c -o c_test/creole.o $(CC) -shared -o asm/libcreole.so c_test/creole.o test_asm: asm/libcreole.so cd asm && python3 test.py -f c_test/encode_decode: c_test/encode_decode.c creole.c creole.h - $(CC) creole.c c_test/encode_decode.c -Wall -pedantic -std=c89 -g -fopenmp -o c_test/encode_decode + $(CC) $(CFLAGS) creole.c c_test/encode_decode.c -Wall -pedantic -std=c99 -g -fopenmp -o c_test/encode_decode # c_test/encode_decode c_test/creole: c_test/creole.c creole.c creole.h c_test/greatest.h - $(CC) -g c_test/creole.c -Wall -pedantic -std=c89 -o c_test/creole + $(CC) $(CFLAGS) -g c_test/creole.c -Wall -pedantic -std=c99 -o c_test/creole c_test/creole diff --git a/asm/ffi.py b/asm/ffi.py index e7903af..11c6f39 100644 --- a/asm/ffi.py +++ b/asm/ffi.py @@ -60,7 +60,7 @@ class Reader: class CEnv(Structure): _fields_ = [ - ("dats", POINTER(POINTER(c_ubyte))), + ("dats", POINTER(CReader)), ("datlen", c_size_t), ("reg", POINTER(c_uint)), ("reglen", c_size_t), @@ -68,7 +68,8 @@ class CEnv(Structure): ("stkptr", c_size_t), ("stklen", c_size_t), ("r_current", CReader), - ("r_start", CReader) + ("r_start", CReader), + ("fd", c_int) ] class RegisterOverflowError(Exception): @@ -116,13 +117,7 @@ class Environment: def getdat(self, n): if n >= self.cenv.datlen or n < 0: raise DataOverflowError(n) - rdr = CReader() - rdr.p = self.cenv.dats[n] - # Python does not allow for direct pointer arithmetic - rdr_p_v = addressof(rdr.p.contents) - r_start_p_v = addressof(self.cenv.r_start.p) - - rdr.left = self.cenv.r_start.left - (rdr_p_v - r_start_p_v) + rdr = self.cenv.dats[n] l = [] w = CWord() @@ -143,7 +138,7 @@ class Environment: def __init__(self, prog=None, reglen=32, datlen=32, stklen=4096, prglen=4096): cenv = CEnv() - cenv.dats = (POINTER(c_ubyte) * datlen)() + cenv.dats = (CReader * datlen)() cenv.datlen = datlen cenv.reglen = reglen diff --git a/creole.c b/creole.c index 474d205..0ade012 100644 --- a/creole.c +++ b/creole.c @@ -12,13 +12,15 @@ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include -#include -#include "creole.h" -#include "access.h" -#include "control_loop_cmds.h" -#include "sock.h" +#ifndef CREOLE_TEST +# include +# include +# include "access.h" +# include "control_loop_cmds.h" +# include "sock.h" +#endif +#include "creole.h" /************************************************************************* * Static information ************************************************************************/ @@ -556,6 +558,8 @@ int creole_jump(struct creole_env *env, creole_word off) return 1; } +#ifndef CREOLE_TEST + static size_t load_into_array(const struct creole_reader *start, creole_word *buf, size_t buflen) { @@ -608,6 +612,7 @@ upsilon_senddat(struct creole_env *env, creole_word db) return sock_write_buf(env->fd, &bp); } +#endif /* CREOLE_TEST */ /* Upsilon interface */ @@ -719,6 +724,7 @@ enum creole_run_ret creole_step(struct creole_env *env, creole_word *sc) return CREOLE_JUMP_OVERFLOW; break; +#ifndef CREOLE_TEST case CREOLE_READ_ADC: check(read_val(env, &ins, 0, &a0)); @@ -857,6 +863,8 @@ enum creole_run_ret creole_step(struct creole_env *env, creole_word *sc) check(creole_push(env, dac_switch(a0, a1, K_FOREVER))); break; +#endif /* CREOLE_TEST */ + default: rcode = CREOLE_STEP_UNKNOWN_OPCODE; break;