fixed -L directory order in lib/Makefile.am to avoid linking to libmoo-xxx shared objects when MOO_ENABLE_STATIC_MODULE is on and $(libdir) contains libmoo-xxx files - place the module build directory in front of other library directories.

fixed problems when MOO_OOCH_IS_BCH
This commit is contained in:
hyunghwan.chung 2017-02-03 06:28:12 +00:00
parent ea6d48eb0e
commit 54a2128713
12 changed files with 118 additions and 31 deletions

View File

@ -5,7 +5,11 @@ CPPFLAGS_ALL_COMMON = \
-I$(abs_srcdir) \
-I$(includedir)
if ENABLE_STATIC_MODULE
LDFLAGS_ALL_COMMON = -L$(abs_builddir)/../mod -L$(abs_builddir) -L$(libdir)
else
LDFLAGS_ALL_COMMON = -L$(abs_builddir) -L$(libdir)
endif
##################################################
# MAIN LIBRARY
@ -59,8 +63,11 @@ libmoo_la_LDFLAGS = $(LDFLAGS_LIB_COMMON)
libmoo_la_LIBADD = $(LIBADD_LIB_COMMON)
if ENABLE_STATIC_MODULE
libmoo_la_LDFLAGS += -L$(abs_builddir)/../mod
libmoo_la_LIBADD += -lmoo-ffi -lmoo-console -lmoo-stdio
libmoo_la_DEPENDENCIES = \
$(abs_builddir)/../mod/libmoo-ffi.la \
$(abs_builddir)/../mod/libmoo-console.la \
$(abs_builddir)/../mod/libmoo-stdio.la
endif
bin_PROGRAMS = moo

View File

@ -93,8 +93,10 @@ host_triplet = @host@
# to the first number in -version-info above
@WIN32_TRUE@am__append_1 = -DMOO_DEFAULT_MODPREFIX=\"libmoo-\" -DMOO_DEFAULT_MODPOSTFIX=\"-1\"
@WIN32_FALSE@am__append_2 = -DMOO_DEFAULT_MODPREFIX=\"$(libdir)/libmoo-\" -DMOO_DEFAULT_MODPOSTFIX=\"\"
@ENABLE_STATIC_MODULE_TRUE@am__append_3 = -L$(abs_builddir)/../mod
@ENABLE_STATIC_MODULE_TRUE@am__append_4 = -lmoo-ffi -lmoo-console -lmoo-stdio
@ENABLE_STATIC_MODULE_TRUE@am__append_3 = -lmoo-ffi -lmoo-console -lmoo-stdio
@ENABLE_STATIC_MODULE_FALSE@libmoo_la_DEPENDENCIES = \
@ENABLE_STATIC_MODULE_FALSE@ $(am__DEPENDENCIES_2) \
@ENABLE_STATIC_MODULE_FALSE@ $(am__DEPENDENCIES_1)
bin_PROGRAMS = moo$(EXEEXT)
subdir = lib
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
@ -144,7 +146,6 @@ am__installdirs = "$(DESTDIR)$(pkglibdir)" "$(DESTDIR)$(bindir)" \
LTLIBRARIES = $(pkglib_LTLIBRARIES)
am__DEPENDENCIES_1 =
am__DEPENDENCIES_2 = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
libmoo_la_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1)
am_libmoo_la_OBJECTS = libmoo_la-bigint.lo libmoo_la-comp.lo \
libmoo_la-debug.lo libmoo_la-decode.lo libmoo_la-dic.lo \
libmoo_la-err.lo libmoo_la-exec.lo libmoo_la-logfmt.lo \
@ -400,7 +401,8 @@ CPPFLAGS_ALL_COMMON = \
-I$(abs_srcdir) \
-I$(includedir)
LDFLAGS_ALL_COMMON = -L$(abs_builddir) -L$(libdir)
@ENABLE_STATIC_MODULE_FALSE@LDFLAGS_ALL_COMMON = -L$(abs_builddir) -L$(libdir)
@ENABLE_STATIC_MODULE_TRUE@LDFLAGS_ALL_COMMON = -L$(abs_builddir)/../mod -L$(abs_builddir) -L$(libdir)
##################################################
# MAIN LIBRARY
@ -438,8 +440,13 @@ libmoo_la_SOURCES = \
utl.c
libmoo_la_CPPFLAGS = $(CPPFLAGS_LIB_COMMON)
libmoo_la_LDFLAGS = $(LDFLAGS_LIB_COMMON) $(am__append_3)
libmoo_la_LIBADD = $(LIBADD_LIB_COMMON) $(am__append_4)
libmoo_la_LDFLAGS = $(LDFLAGS_LIB_COMMON)
libmoo_la_LIBADD = $(LIBADD_LIB_COMMON) $(am__append_3)
@ENABLE_STATIC_MODULE_TRUE@libmoo_la_DEPENDENCIES = \
@ENABLE_STATIC_MODULE_TRUE@ $(abs_builddir)/../mod/libmoo-ffi.la \
@ENABLE_STATIC_MODULE_TRUE@ $(abs_builddir)/../mod/libmoo-console.la \
@ENABLE_STATIC_MODULE_TRUE@ $(abs_builddir)/../mod/libmoo-stdio.la
moo_SOURCES = main.c
moo_CPPFLAGS = $(CPPFLAGS_LIB_COMMON)
moo_LDFLAGS = $(LDFLAGS_LIB_COMMON)

View File

@ -4538,7 +4538,6 @@ static int compile_if_expression (moo_t* moo)
moo_oow_pool_chunk_t* jumptoend_chunk;
moo_oow_t i, j;
moo_oow_t jumptonext, precondpos, postcondpos, endoftrueblock;
int falseblock;
moo_ioloc_t if_loc, brace_loc;
MOO_ASSERT (moo, TOKEN_TYPE(moo) == MOO_IOTOK_IF);
@ -6191,7 +6190,7 @@ static int __compile_pooldic_definition (moo_t* moo)
/*if (!MOO_IN_SMOOI_RANGE(tally)) ERROR??*/
/* i use mthdic_oop[0] when compling #pooldic. it's not a real method dictionary.
* i just use it not to declare another field into the compiler */
* i just use it to avoid declaring another field into the compiler */
moo->c->cls.pooldic_oop = moo_makedic (moo, moo->_pool_dictionary, MOO_ALIGN(tally + 10, POOL_DICTIONARY_SIZE_ALIGN));
if (!moo->c->cls.pooldic_oop) return -1;

View File

@ -8,7 +8,9 @@ ASSUME CS:PROG_CODE
PUBLIC _halt_cpu
_halt_cpu PROC NEAR
HLT ; this will cause #GP(0) as it's privileged. TODO: find a way to raise privilege level.
; HLT ; this will cause #GP(0) as it's privileged. TODO: find a way to raise privilege level.
;MOV AX, CS
;AND AX, 3
RET
_halt_cpu ENDP

View File

@ -2,7 +2,10 @@
# Intel 386(tm)/486(tm) C Code Builder(tm) Kit, Version 1.0
#
CFLAGS := /D__DOS__ /DMOO_ENABLE_STATIC_MODULE /DNDEBUG
# /zmod486 - 80486 instructions
# /zfloatsync - FPU is operand-synchronized with the CPU
# /m create map file
CFLAGS := /D__DOS__ /DMOO_ENABLE_STATIC_MODULE /DNDEBUG /g /zmod486 /m
LDFLAGS := /xnovm /xregion=12m
SRCS := \

View File

@ -157,7 +157,7 @@ static const moo_bch_t* get_base_name (const moo_bch_t* path)
static MOO_INLINE moo_ooi_t open_input (moo_t* moo, moo_ioarg_t* arg)
{
xtn_t* xtn = moo_getxtn(moo);
bb_t* bb;
bb_t* bb = MOO_NULL;
/* TOOD: support predefined include directory as well */
@ -167,7 +167,11 @@ static MOO_INLINE moo_ooi_t open_input (moo_t* moo, moo_ioarg_t* arg)
moo_oow_t ucslen, bcslen, parlen;
const moo_bch_t* fn, * fb;
if (moo_convootobcstr (moo, arg->name, &ucslen, MOO_NULL, &bcslen) <= -1) return -1;
#if defined(MOO_OOCH_IS_UCH)
if (moo_convootobcstr (moo, arg->name, &ucslen, MOO_NULL, &bcslen) <= -1) goto oops;
#else
bcslen = moo_countbcstr (arg->name);
#endif
fn = ((bb_t*)arg->includer->handle)->fn;
@ -175,11 +179,15 @@ static MOO_INLINE moo_ooi_t open_input (moo_t* moo, moo_ioarg_t* arg)
parlen = fb - fn;
bb = moo_callocmem (moo, MOO_SIZEOF(*bb) + (MOO_SIZEOF(moo_bch_t) * (parlen + bcslen + 1)));
if (!bb) return -1;
if (!bb) goto oops;
bb->fn = (moo_bch_t*)(bb + 1);
moo_copybchars (bb->fn, fn, parlen);
#if defined(MOO_OOCH_IS_UCH)
moo_convootobcstr (moo, arg->name, &ucslen, &bb->fn[parlen], &bcslen);
#else
moo_copybcstr (&bb->fn[parlen], bcslen + 1, arg->name);
#endif
}
else
{
@ -189,7 +197,7 @@ static MOO_INLINE moo_ooi_t open_input (moo_t* moo, moo_ioarg_t* arg)
pathlen = moo_countbcstr (xtn->source_path);
bb = moo_callocmem (moo, MOO_SIZEOF(*bb) + (MOO_SIZEOF(moo_bch_t) * (pathlen + 1)));
if (!bb) return -1;
if (!bb) goto oops;
bb->fn = (moo_bch_t*)(bb + 1);
moo_copybcstr (bb->fn, pathlen + 1, xtn->source_path);
@ -203,13 +211,16 @@ static MOO_INLINE moo_ooi_t open_input (moo_t* moo, moo_ioarg_t* arg)
if (!bb->fp)
{
fclose (bb->fp);
moo_freemem (moo, bb);
moo_seterrnum (moo, MOO_EIOERR);
return -1;
goto oops;
}
arg->handle = bb;
return 0;
oops:
if (bb) moo_freemem (moo, bb);
return -1;
}
static MOO_INLINE moo_ooi_t close_input (moo_t* moo, moo_ioarg_t* arg)
@ -254,12 +265,18 @@ static MOO_INLINE moo_ooi_t read_input (moo_t* moo, moo_ioarg_t* arg)
}
while (bb->len < MOO_COUNTOF(bb->buf) && x != '\r' && x != '\n');
#if defined(MOO_OOCH_IS_UCH)
bcslen = bb->len;
ucslen = MOO_COUNTOF(arg->buf);
x = moo_convbtooochars (moo, bb->buf, &bcslen, arg->buf, &ucslen);
if (x <= -1 && ucslen <= 0) return -1;
/* if ucslen is greater than 0, i see that some characters have been
* converted properly */
#else
bcslen = (bb->len < MOO_COUNTOF(arg->buf))? bb->len: MOO_COUNTOF(arg->buf);
ucslen = bcslen;
moo_copybchars (arg->buf, bb->buf, bcslen);
#endif
remlen = bb->len - bcslen;
if (remlen > 0) memmove (bb->buf, &bb->buf[bcslen], remlen);
@ -303,7 +320,11 @@ static void* dl_open (moo_t* moo, const moo_ooch_t* name, int flags)
len = moo_copybcstr (buf, MOO_COUNTOF(buf), MOO_DEFAULT_PFMODPREFIX);
bcslen = MOO_COUNTOF(buf) - len;
#if defined(MOO_OOCH_IS_UCH)
if (moo_convootobcstr (moo, name, &ucslen, &buf[len], &bcslen) <= -1) return MOO_NULL;
#else
bcslen = moo_copybcstr (&buf[len], bcslen, name);
#endif
moo_copybcstr (&buf[bcslen + len], MOO_COUNTOF(buf) - bcslen - len, MOO_DEFAULT_PFMODPOSTFIX);
@ -324,8 +345,12 @@ static void* dl_open (moo_t* moo, const moo_ooch_t* name, int flags)
else
{
/* opening a raw shared object */
#if defined(MOO_OOCH_IS_UCH)
bcslen = MOO_COUNTOF(buf);
if (moo_convootobcstr (moo, name, &ucslen, buf, &bcslen) <= -1) return MOO_NULL;
#else
bcslen = moo_copybcstr (buf, MOO_COUNTOF(buf), name);
#endif
if (moo_findbchar (buf, bcslen, '.'))
{
@ -376,7 +401,11 @@ static void* dl_getsym (moo_t* moo, void* handle, const moo_ooch_t* name)
buf[0] = '_';
bcslen = MOO_COUNTOF(buf) - 2;
#if defined(MOO_OOCH_IS_UCH)
moo_convootobcstr (moo, name, &ucslen, &buf[1], &bcslen); /* TODO: error check */
#else
bcslen = moo_copybcstr (&buf[1], bcslen, name);
#endif
symname = &buf[1];
sym = lt_dlsym (handle, symname);
if (!sym)
@ -402,6 +431,8 @@ static void* dl_getsym (moo_t* moo, void* handle, const moo_ooch_t* name)
return sym;
#else
/* TODO: IMPLEMENT THIS */
MOO_DEBUG2 (moo, "Dynamic loading not implemented - Cannot loaded module symbol %s from handle %p\n", symname, handle);
moo_seterrnum (moo, MOO_ENOIMPL);
return MOO_NULL;
#endif
}
@ -481,6 +512,7 @@ if (mask & MOO_LOG_GC) return; /* don't show gc logs */
#endif
write_all (1, ts, tslen);
#if defined(MOO_OOCH_IS_UCH)
msgidx = 0;
while (len > 0)
{
@ -514,6 +546,10 @@ if (mask & MOO_LOG_GC) return; /* don't show gc logs */
break;
}
}
#else
write_all (1, msg, len);
#endif
#endif
}
@ -730,11 +766,15 @@ int main (int argc, char* argv[])
printf ("ERROR: ");
if (synerr.loc.file)
{
#if defined(MOO_OOCH_IS_UCH)
bcslen = MOO_COUNTOF(bcs);
if (moo_convootobcstr (moo, synerr.loc.file, &ucslen, bcs, &bcslen) >= 0)
{
printf ("%.*s ", (int)bcslen, bcs);
}
#else
printf ("%s ", synerr.loc.file);
#endif
}
else
{
@ -745,20 +785,28 @@ int main (int argc, char* argv[])
(unsigned long int)synerr.loc.line, (unsigned long int)synerr.loc.colm);
bcslen = MOO_COUNTOF(bcs);
#if defined(MOO_OOCH_IS_UCH)
if (moo_convootobcstr (moo, moo_synerrnumtoerrstr(synerr.num), &ucslen, bcs, &bcslen) >= 0)
{
printf (" [%.*s]", (int)bcslen, bcs);
}
#else
printf (" [%s]", moo_synerrnumtoerrstr(synerr.num));
#endif
if (synerr.tgt.len > 0)
{
bcslen = MOO_COUNTOF(bcs);
ucslen = synerr.tgt.len;
#if defined(MOO_OOCH_IS_UCH)
if (moo_convootobchars (moo, synerr.tgt.ptr, &ucslen, bcs, &bcslen) >= 0)
{
printf (" [%.*s]", (int)bcslen, bcs);
}
#else
printf (" [%.*s]", (int)synerr.tgt.len, synerr.tgt.ptr);
#endif
}
printf ("\n");

View File

@ -308,11 +308,18 @@ struct moo_bcs_t
};
typedef struct moo_bcs_t moo_bcs_t;
typedef moo_uch_t moo_ooch_t;
typedef moo_uci_t moo_ooci_t;
typedef moo_ucs_t moo_oocs_t;
#define MOO_OOCH_IS_UCH
#if 0
typedef moo_bch_t moo_ooch_t;
typedef moo_bci_t moo_ooci_t;
typedef moo_bcs_t moo_oocs_t;
# define MOO_OOCH_IS_BCH
#else
typedef moo_uch_t moo_ooch_t;
typedef moo_uci_t moo_ooci_t;
typedef moo_ucs_t moo_oocs_t;
# define MOO_OOCH_IS_UCH
#endif
/* =========================================================================

View File

@ -401,8 +401,6 @@ moo_mod_data_t* moo_openmod (moo_t* moo, const moo_ooch_t* name, moo_oow_t namel
#if defined(MOO_ENABLE_STATIC_MODULE)
/* attempt to find a statically linked module */
/*TODO: CHANGE THIS PART */
/* TODO: binary search ... */
for (n = 0; n < MOO_COUNTOF(static_modtab); n++)
{

View File

@ -802,7 +802,7 @@ typedef int (*moo_mod_import_t) (
typedef moo_pfimpl_t (*moo_mod_query_t) (
moo_t* moo,
moo_mod_t* mod,
const moo_uch_t* name
const moo_ooch_t* name
);
typedef void (*moo_mod_unload_t) (

View File

@ -127,12 +127,14 @@ int moo_compbcharsbcstr (const moo_bch_t* str1, moo_oow_t len, const moo_bch_t*
void moo_copyuchars (moo_uch_t* dst, const moo_uch_t* src, moo_oow_t len)
{
/* take note of no forced null termination */
moo_oow_t i;
for (i = 0; i < len; i++) dst[i] = src[i];
}
void moo_copybchars (moo_bch_t* dst, const moo_bch_t* src, moo_oow_t len)
{
/* take note of no forced null termination */
moo_oow_t i;
for (i = 0; i < len; i++) dst[i] = src[i];
}

View File

@ -173,6 +173,7 @@ static moo_pfrc_t pf_write (moo_t* moo, moo_ooi_t nargs)
return MOO_PF_FAILURE;
}
#if defined(MOO_OOCH_IS_UCH)
ucspos = 0;
ucsrem = MOO_OBJ_GET_SIZE(oomsg);
while (ucsrem > 0)
@ -189,6 +190,9 @@ static moo_pfrc_t pf_write (moo_t* moo, moo_ooi_t nargs)
ucspos += ucslen;
ucsrem -= ucslen;
}
#else
write (con->fd, oomsg->slot, MOO_OBJ_GET_SIZE(oomsg)); /* TODO: error handling. incomplete write handling */
#endif
MOO_STACK_SETRETTORCV (moo, nargs); /* TODO: change return code */
return MOO_PF_SUCCESS;

View File

@ -142,6 +142,7 @@ static moo_pfrc_t __pf_puts (moo_t* moo, moo_ooi_t nargs, moo_oow_t limit)
}
else if (MOO_OOP_IS_POINTER(x) && MOO_OBJ_GET_FLAGS_TYPE(x) == MOO_OBJ_TYPE_CHAR)
{
#if defined(MOO_OOCH_IS_UCH)
int n;
moo_oow_t ucspos, ucsrem, ucslen, bcslen;
moo_bch_t bcs[1024]; /* TODO: choose a better buffer size */
@ -172,6 +173,15 @@ static moo_pfrc_t __pf_puts (moo_t* moo, moo_ooi_t nargs, moo_oow_t limit)
ucspos += ucslen;
ucsrem -= ucslen;
}
#else
puts_string:
if (fwrite (x->slot, 1, MOO_OBJ_GET_SIZE(x), rcv->fp) < MOO_OBJ_GET_SIZE(x))
{
moo_seterrnum (moo, moo_syserrtoerrnum(errno));
moo_seterrnum (moo, moo_syserrtoerrnum(errno));
goto softfail;
}
#endif
}
else
{