From f40b5fb0c12e31e0996941358f5750289cf3914d Mon Sep 17 00:00:00 2001 From: "hyunghwan.chung" Date: Thu, 3 Dec 2015 05:46:11 +0000 Subject: [PATCH] added stix-mac.h and made related changes --- stix/lib/bigint.c | 1 - stix/lib/debug.c | 4 +-- stix/lib/exec.c | 14 +++++----- stix/lib/main.c | 2 ++ stix/lib/stix-cmn.h | 2 ++ stix/lib/stix-mac.h | 63 +++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 77 insertions(+), 9 deletions(-) create mode 100644 stix/lib/stix-mac.h diff --git a/stix/lib/bigint.c b/stix/lib/bigint.c index 99fb20e..aca790d 100644 --- a/stix/lib/bigint.c +++ b/stix/lib/bigint.c @@ -1369,7 +1369,6 @@ static stix_uint8_t ooch_val_tab[] = stix_oop_t stix_strtoint (stix_t* stix, const stix_ooch_t* str, stix_oow_t len, int radix) { - //int neg = 0; int sign = 1; const stix_ooch_t* ptr, * start, * end; stix_lidw_t w, v; diff --git a/stix/lib/debug.c b/stix/lib/debug.c index c083c9f..cf99633 100644 --- a/stix/lib/debug.c +++ b/stix/lib/debug.c @@ -126,7 +126,7 @@ void print_object (stix_t* stix, stix_oop_t oop) STIX_ASSERT (STIX_OOP_IS_POINTER(oop)); c = (stix_oop_class_t)STIX_OBJ_GET_CLASS(oop); /*STIX_CLASSOF(stix, oop);*/ - if (c == stix->_large_negative_integer) + if ((stix_oop_t)c == stix->_large_negative_integer) { stix_oow_t i; printf ("-16r"); @@ -135,7 +135,7 @@ void print_object (stix_t* stix, stix_oop_t oop) printf ("%0*lX", (int)(STIX_SIZEOF(stix_liw_t) * 2), (unsigned long)((stix_oop_liword_t)oop)->slot[--i]); } } - else if (c == stix->_large_positive_integer) + else if ((stix_oop_t)c == stix->_large_positive_integer) { stix_oow_t i; printf ("16r"); diff --git a/stix/lib/exec.c b/stix/lib/exec.c index 1560a45..784ccd0 100644 --- a/stix/lib/exec.c +++ b/stix/lib/exec.c @@ -1021,7 +1021,7 @@ static int prim_block_new_process (stix_t* stix, stix_ooi_t nargs) if (nargs == 1) { - stix_oop_oop_t xarg; + stix_oop_t xarg; xarg = ACTIVE_STACK_GETTOP(stix); if (!STIX_ISTYPEOF(stix,xarg,STIX_OBJ_TYPE_OOP)) @@ -1438,7 +1438,7 @@ static int prim_ffi_open (stix_t* stix, stix_ooi_t nargs) } ACTIVE_STACK_POP (stix); -/* TODO: how to hold an address? as an integer???? or a byte array? */ +/* TODO: how to hold an address? as an integer???? or a byte array? fix this not to loose accuracy*/ ACTIVE_STACK_SETTOP (stix, STIX_SMOOI_TO_OOP(handle)); return 1; @@ -1464,7 +1464,7 @@ static int prim_ffi_close (stix_t* stix, stix_ooi_t nargs) ACTIVE_STACK_POP (stix); - handle = STIX_OOP_TO_SMOOI(arg); /* TODO: how to store void* ??? */ + handle = (void*)STIX_OOP_TO_SMOOI(arg); /* TODO: how to store void* ???. fix this not to loose accuracy */ if (stix->vmprim.mod_close) stix->vmprim.mod_close (stix, handle); return 1; } @@ -1677,7 +1677,7 @@ printf ("wrong function name...\n"); return 0; } - sym = stix->vmprim.mod_getsym (stix, STIX_OOP_TO_SMOOI(hnd), ((stix_oop_char_t)fun)->slot); + sym = stix->vmprim.mod_getsym (stix, (void*)STIX_OOP_TO_SMOOI(hnd), ((stix_oop_char_t)fun)->slot); if (!sym) { return 0; @@ -1876,7 +1876,7 @@ static stix_prim_impl_t query_prim_module (stix_t* stix, const stix_ooch_t* name /* i copy-insert 'md' into the table before calling 'load'. * to pass the same address to load(), query(), etc */ - pair = stix_rbt_insert (&stix->pmtable, name, mod_name_len, &md, STIX_SIZEOF(md)); + pair = stix_rbt_insert (&stix->pmtable, (void*)name, mod_name_len, &md, STIX_SIZEOF(md)); if (pair == STIX_NULL) { stix->errnum = STIX_ENOMEM; @@ -2534,6 +2534,7 @@ printf ("]\n"); stix_ooi_t prim_name_index; stix_oop_t name; stix_prim_impl_t handler; + register stix_oow_t w; prim_name_index = STIX_METHOD_GET_PREAMBLE_INDEX(preamble); DBGOUT_EXEC_1 ("METHOD_PREAMBLE_NAMED_PRIMITIVE %d", (int)prim_name_index); @@ -2545,8 +2546,9 @@ printf ("]\n"); STIX_ASSERT (STIX_CLASSOF(stix,name) == stix->_symbol); /* merge two SmallIntegers to get a full pointer */ - handler = (stix_oow_t)STIX_OOP_TO_SMOOI(newmth->preamble_data[0]) << (STIX_OOW_BITS / 2) | + w = (stix_oow_t)STIX_OOP_TO_SMOOI(newmth->preamble_data[0]) << (STIX_OOW_BITS / 2) | (stix_oow_t)STIX_OOP_TO_SMOOI(newmth->preamble_data[1]); + handler = (stix_prim_impl_t)w; if (!handler) handler = query_prim_module (stix, ((stix_oop_char_t)name)->slot, STIX_OBJ_GET_SIZE(name)); if (handler) diff --git a/stix/lib/main.c b/stix/lib/main.c index 1208720..fe27c72 100644 --- a/stix/lib/main.c +++ b/stix/lib/main.c @@ -46,6 +46,8 @@ # include #elif defined(__DOS__) /* nothing to include */ +#elif defined(macintosh) + /* nothing to include */ #else # include # include diff --git a/stix/lib/stix-cmn.h b/stix/lib/stix-cmn.h index 3479be5..a62459c 100644 --- a/stix/lib/stix-cmn.h +++ b/stix/lib/stix-cmn.h @@ -35,6 +35,8 @@ # include "stix-cfg.h" #elif defined(_WIN32) # include "stix-msw.h" +#elif defined(macintosh) +# include "stix-mac.h" /* class mac os */ #else # error UNSUPPORTED SYSTEM #endif diff --git a/stix/lib/stix-mac.h b/stix/lib/stix-mac.h new file mode 100644 index 0000000..cc404a5 --- /dev/null +++ b/stix/lib/stix-mac.h @@ -0,0 +1,63 @@ +/* + * $Id$ + * + Copyright (c) 2014-2015 Chung, Hyung-Hwan. All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +/* This file is for class Mac OS */ + +/* Mac OS on PPC and m68k uses the big endian mode */ +#define STIX_ENDIAN_BIG + +#if defined(__MWERKS__) +# define STIX_SIZEOF_CHAR 1 +# define STIX_SIZEOF_SHORT 2 +# define STIX_SIZEOF_INT 4 +# define STIX_SIZEOF_LONG 4 +# define STIX_SIZEOF_LONG_LONG 8 +# define STIX_SIZEOF_VOID_P 4 +# define STIX_SIZEOF_FLOAT 4 +# define STIX_SIZEOF_DOUBLE 8 +# define STIX_SIZEOF_LONG_DOUBLE 8 +# define STIX_SIZEOF_WCHAR_T 2 + +# define STIX_SIZEOF___INT8 1 +# define STIX_SIZEOF___INT16 2 +# define STIX_SIZEOF___INT32 4 +# define STIX_SIZEOF___INT64 8 +# define STIX_SIZEOF___INT128 0 + +# define STIX_SIZEOF_OFF64_T 0 +# define STIX_SIZEOF_OFF_T 8 + +# define STIX_SIZEOF_MBSTATE_T STIX_SIZEOF_LONG +# define STIX_MBLEN_MAX 16 + + /* these two have only to be large enough */ +# define STIX_SIZEOF_STRUCT_SOCKADDR_IN 32 +# define STIX_SIZEOF_STRUCT_SOCKADDR_IN6 64 +# define STIX_SIZEOF_SOCKLEN_T 4 + +#else +# error Define the size of various data types. +#endif +