From 108d071ef020d15e569868e997da1a4ea4b38626 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Sun, 8 May 2005 10:44:58 +0000 Subject: [PATCH] *** empty log message *** --- ase/stx/stx.c | 15 ++++++++++++++- ase/stx/stx.h | 6 +++--- ase/test/stx/makefile.in | 2 +- ase/test/stx/stx.c | 10 ++++++---- 4 files changed, 24 insertions(+), 9 deletions(-) diff --git a/ase/stx/stx.c b/ase/stx/stx.c index afa28fae..b03a19fd 100644 --- a/ase/stx/stx.c +++ b/ase/stx/stx.c @@ -1,10 +1,11 @@ /* - * $Id: stx.c,v 1.2 2005-05-08 10:31:24 bacon Exp $ + * $Id: stx.c,v 1.3 2005-05-08 10:44:58 bacon Exp $ */ #include #include #include +#include xp_stx_t* xp_stx_open (xp_stx_t* stx, xp_stx_word_t capacity) { @@ -33,4 +34,16 @@ void xp_stx_close (xp_stx_t* stx) if (stx->__malloced) xp_free (stx); } +int xp_stx_bootstrap (xp_stx_t* stx) +{ + stx->nil = xp_stx_memory_alloc (&stx->memory, 0); + stx->true = xp_stx_memory_alloc (&stx->memory, 0); + stx->false = xp_stx_memory_alloc (&stx->memory, 0); + + xp_assert (stx->nil == XP_STX_NIL); + xp_assert (stx->true == XP_STX_TRUE); + xp_assert (stx->false == XP_STX_FALSE); + + return 0; +} diff --git a/ase/stx/stx.h b/ase/stx/stx.h index 665544f7..d34b2733 100644 --- a/ase/stx/stx.h +++ b/ase/stx/stx.h @@ -1,5 +1,5 @@ /* - * $Id: stx.h,v 1.2 2005-05-08 10:31:24 bacon Exp $ + * $Id: stx.h,v 1.3 2005-05-08 10:44:58 bacon Exp $ */ #ifndef _XP_STX_STX_H_ @@ -115,8 +115,6 @@ struct xp_stx_t */ - - #ifdef __cplusplus extern "C" { #endif @@ -124,6 +122,8 @@ extern "C" { xp_stx_t* xp_stx_open (xp_stx_t* stx, xp_stx_word_t capacity); void xp_stx_close (xp_stx_t* stx); +int xp_stx_bootstrap (xp_stx_t* stx); + #ifdef __cplusplus } #endif diff --git a/ase/test/stx/makefile.in b/ase/test/stx/makefile.in index 30962c8b..162f2a58 100644 --- a/ase/test/stx/makefile.in +++ b/ase/test/stx/makefile.in @@ -3,7 +3,7 @@ OUTS = $(SRCS:.c=.x) CC = @CC@ CFLAGS = @CFLAGS@ -I@abs_top_builddir@ -LDFLAGS = @LDFLAGS@ -L@abs_top_builddir@/xp/bas -L@abs_top_builddir@/xp/lisp +LDFLAGS = @LDFLAGS@ -L@abs_top_builddir@/xp/bas -L@abs_top_builddir@/xp/stx LIBS = @LIBS@ -lxpstx -lxpbas all: $(OUTS) diff --git a/ase/test/stx/stx.c b/ase/test/stx/stx.c index 96edcee4..a8e58e8f 100644 --- a/ase/test/stx/stx.c +++ b/ase/test/stx/stx.c @@ -7,13 +7,15 @@ int xp_main () xp_stx_word_t i; if (xp_stx_open (&stx, 10) == XP_NULL) { - xp_printf (XP_TEXT("cannot open memory\n")); + xp_printf (XP_TEXT("cannot open stx\n")); return -1; } - stx.nil = xp_stx_memory_alloc(&stx.memory, 0); - stx.true = xp_stx_memory_alloc(&stx.memory, 0); - stx.false = xp_stx_memory_alloc(&stx.memory, 0); + if (xp_stx_bootstrap(&stx) == -1) { + xp_stx_close (&stx); + xp_printf (XP_TEXT("cannot bootstrap\n")); + return -1; + } xp_printf (XP_TEXT("stx.nil %d\n"), stx.nil); xp_printf (XP_TEXT("stx.true %d\n"), stx.true);