From 801b6d92d419166cce05e00720ada721f82e8cf3 Mon Sep 17 00:00:00 2001 From: "hyunghwan.chung" Date: Fri, 13 May 2016 15:10:34 +0000 Subject: [PATCH] fixed some minor build flaws --- stix/kernel/Apex.st | 20 +++++ stix/kernel/Collection-Array.st | 63 --------------- stix/kernel/Collection-ByteArray.st | 13 --- stix/kernel/Collection-Set.st | 31 -------- stix/kernel/Collection.st | 119 ++++++++++++++++++++++++++++ stix/kernel/Object.st | 4 - stix/kernel/Stix.st | 6 +- stix/kernel/UndefinedObject.st | 12 --- stix/lib/exec.c | 86 ++++++++++++++------ stix/lib/heap.c | 2 +- stix/lib/stix-cmn.h | 7 +- stix/lib/stix-dos.h | 27 +++++++ stix/lib/stix-prv.h | 4 +- stix/lib/stix.h | 4 +- 14 files changed, 240 insertions(+), 158 deletions(-) delete mode 100644 stix/kernel/Collection-Array.st delete mode 100644 stix/kernel/Collection-ByteArray.st delete mode 100644 stix/kernel/Collection-Set.st delete mode 100644 stix/kernel/Object.st delete mode 100644 stix/kernel/UndefinedObject.st diff --git a/stix/kernel/Apex.st b/stix/kernel/Apex.st index 30cce85..2fa478f 100644 --- a/stix/kernel/Apex.st +++ b/stix/kernel/Apex.st @@ -297,3 +297,23 @@ self class cannotInstantiate } } + +#class Object(Apex) +{ + +} + +#class UndefinedObject(Apex) +{ + #method isNil + { + ^true + } + + #method notNil + { + ^false. + } +} + + diff --git a/stix/kernel/Collection-Array.st b/stix/kernel/Collection-Array.st deleted file mode 100644 index 0c9fd7a..0000000 --- a/stix/kernel/Collection-Array.st +++ /dev/null @@ -1,63 +0,0 @@ -#class(#pointer) Array(Collection) -{ - #method size - { - ^self basicSize. - } - - #method ubound - { - ^(self basicSize - 1). - } - - #method at: anInteger - { - ^self basicAt: anInteger. - } - - #method at: anInteger put: aValue - { - ^self basicAt: anInteger put: aValue. - } - - #method first - { - ^self at: 0. - } - - #method last - { - ^self at: (self ubound). - } - - #method do: aBlock - { - 0 to: (self ubound) do: [:i | aBlock value: (self at: i)]. - } - - #method copy: anArray - { - 0 to: (anArray ubound) do: [:i | self at: i put: (anArray at: i) ]. - } -} - -#class(#character) String(Array) -{ - #method , aString - { - ## concatenate two strings. -## TOOD: make this a primitive for performance. - | newsize newstr self_ubound| - newsize := self basicSize + aString basicSize. - ##newstr := self class basicNew: newsize. - newstr := String basicNew: newsize. ## TODO: redefine , for symbol... it's a work arouind... symbols are not contacated to a symbol at this moment. - self_ubound := self ubound. - 0 to: self_ubound do: [:i | newstr at: i put: (self at: i)]. - 0 to: (aString ubound) do: [:i | newstr at: (i + self_ubound + 1) put: (aString at: i)]. - ^newstr - } -} - -#class(#character) Symbol(String) -{ -} diff --git a/stix/kernel/Collection-ByteArray.st b/stix/kernel/Collection-ByteArray.st deleted file mode 100644 index 11647a1..0000000 --- a/stix/kernel/Collection-ByteArray.st +++ /dev/null @@ -1,13 +0,0 @@ -#class(#byte) ByteArray(Collection) -{ - #method at: anInteger - { - ^self basicAt: anInteger. - } - - #method at: anInteger put: aValue - { - ^self basicAt: anInteger put: aValue. - } - -} diff --git a/stix/kernel/Collection-Set.st b/stix/kernel/Collection-Set.st deleted file mode 100644 index 2af6663..0000000 --- a/stix/kernel/Collection-Set.st +++ /dev/null @@ -1,31 +0,0 @@ -#class Set(Collection) -{ - #dcl tally bucket. -} - -#class SymbolSet(Set) -{ -} - -#class Dictionary(Set) -{ -} - -#class SystemDictionary(Dictionary) -{ -} - - -#class Namespace(Set) -{ -} - -#class PoolDictionary(Set) -{ -} - -#class MethodDictionary(Dictionary) -{ - -} - diff --git a/stix/kernel/Collection.st b/stix/kernel/Collection.st index 21b94b4..8363dcb 100644 --- a/stix/kernel/Collection.st +++ b/stix/kernel/Collection.st @@ -1,3 +1,122 @@ #class Collection(Object) { } + +## ------------------------------------------------------------------------------- + +#class(#pointer) Array(Collection) +{ + #method size + { + ^self basicSize. + } + + #method ubound + { + ^(self basicSize - 1). + } + + #method at: anInteger + { + ^self basicAt: anInteger. + } + + #method at: anInteger put: aValue + { + ^self basicAt: anInteger put: aValue. + } + + #method first + { + ^self at: 0. + } + + #method last + { + ^self at: (self ubound). + } + + #method do: aBlock + { + 0 to: (self ubound) do: [:i | aBlock value: (self at: i)]. + } + + #method copy: anArray + { + 0 to: (anArray ubound) do: [:i | self at: i put: (anArray at: i) ]. + } +} + +## ------------------------------------------------------------------------------- + +#class(#character) String(Array) +{ + #method , aString + { + ## concatenate two strings. +## TOOD: make this a primitive for performance. + | newsize newstr self_ubound| + newsize := self basicSize + aString basicSize. + ##newstr := self class basicNew: newsize. + newstr := String basicNew: newsize. ## TODO: redefine , for symbol... it's a work arouind... symbols are not contacated to a symbol at this moment. + self_ubound := self ubound. + 0 to: self_ubound do: [:i | newstr at: i put: (self at: i)]. + 0 to: (aString ubound) do: [:i | newstr at: (i + self_ubound + 1) put: (aString at: i)]. + ^newstr + } +} + +## ------------------------------------------------------------------------------- + +#class(#character) Symbol(String) +{ +} + +## ------------------------------------------------------------------------------- + +#class(#byte) ByteArray(Collection) +{ + #method at: anInteger + { + ^self basicAt: anInteger. + } + + #method at: anInteger put: aValue + { + ^self basicAt: anInteger put: aValue. + } +} + +## ------------------------------------------------------------------------------- + +#class Set(Collection) +{ + #dcl tally bucket. +} + +#class SymbolSet(Set) +{ +} + +#class Dictionary(Set) +{ +} + +#class SystemDictionary(Dictionary) +{ +} + + +#class Namespace(Set) +{ +} + +#class PoolDictionary(Set) +{ +} + +#class MethodDictionary(Dictionary) +{ + +} + diff --git a/stix/kernel/Object.st b/stix/kernel/Object.st deleted file mode 100644 index f255d48..0000000 --- a/stix/kernel/Object.st +++ /dev/null @@ -1,4 +0,0 @@ -#class Object(Apex) -{ - -} diff --git a/stix/kernel/Stix.st b/stix/kernel/Stix.st index 8663927..a44d889 100644 --- a/stix/kernel/Stix.st +++ b/stix/kernel/Stix.st @@ -1,6 +1,4 @@ #include 'Apex.st'. -#include 'Object.st'. -#include 'UndefinedObject.st'. #include 'Class.st'. #include 'Boolean.st'. @@ -249,9 +247,7 @@ #include 'Collection.st'. -#include 'Collection-ByteArray.st'. -#include 'Collection-Array.st'. -#include 'Collection-Set.st'. +## #include 'Collec~1.st'. #class(#pointer) CompiledMethod(Object) { diff --git a/stix/kernel/UndefinedObject.st b/stix/kernel/UndefinedObject.st deleted file mode 100644 index 06be4d5..0000000 --- a/stix/kernel/UndefinedObject.st +++ /dev/null @@ -1,12 +0,0 @@ -#class UndefinedObject(Apex) -{ - #method isNil - { - ^true - } - - #method notNil - { - ^false. - } -} diff --git a/stix/lib/exec.c b/stix/lib/exec.c index 6a23d3c..4e563bd 100644 --- a/stix/lib/exec.c +++ b/stix/lib/exec.c @@ -26,18 +26,21 @@ #include "stix-prv.h" -/* TODO: remove this header after having changed clock_gettime() to a - * platform independent function */ -#if defined(HAVE_TIME_H) -# include -#endif - -#if defined(HAVE_SYS_TIME_H) -# include -#endif #if defined(_WIN32) # include +#elif defined(__MSDOS__) +# include +#else + /* TODO: remove this header after having changed clock_gettime() to a + * platform independent function */ +# if defined(HAVE_TIME_H) +# include +# endif + +# if defined(HAVE_SYS_TIME_H) +# include +# endif #endif #define PROC_STATE_RUNNING 3 @@ -183,13 +186,30 @@ static void vm_cleanup (stix_t* stix) { CloseHandle (stix->waitable_timer); stix->waitable_timer = STIX_NULL; - } + } #endif } static STIX_INLINE void vm_gettime (stix_t* stix, stix_ntime_t* now) { -#if defined(HAVE_CLOCK_GETTIME) +#if defined(__MSDOS__) && defined(_INTELC32_) + clock_t c; + +/* TODO: handle overflow?? */ + c = clock (); + now->sec = c / CLOCKS_PER_SEC; + #if (CLOCKS_PER_SEC == 1000) + now->nsec = STIX_MSEC_TO_NSEC(c % CLOCKS_PER_SEC); + #elif (CLOCKS_PER_SEC == 1000000L) + now->nsec = STIX_USEC_TO_NSEC(c % CLOCKS_PER_SEC); + #elif (CLOCKS_PER_SEC == 1000000000L) + now->nsec = (c % CLOCKS_PER_SEC); + #else + # error UNSUPPORTED CLOCKS_PER_SEC + #endif +printf ("%05ld %010ld\n", (long)now->sec, (long)now->nsec); + +#elif defined(HAVE_CLOCK_GETTIME) struct timespec ts; #if defined(CLOCK_MONOTONIC) clock_gettime (CLOCK_MONOTONIC, &ts); @@ -221,6 +241,26 @@ static STIX_INLINE void vm_sleep (stix_t* stix, const stix_ntime_t* dur) Sleep (STIX_SECNSEC_TO_MSEC(dur->sec,dur->nsec)); } +#elif defined(__MSDOS__) && defined(_INTELC32_) + + clock_t c; + + c = clock (); + c += dur->sec * CLOCKS_PER_SEC; + #if (CLOCKS_PER_SEC == 1000) + c += STIX_NSEC_TO_MSEC(dur->nsec); + #elif (CLOCKS_PER_SEC == 1000000L) + c += STIX_NSEC_TO_USEC(dur->nsec); + #elif (CLOCKS_PER_SEC == 1000000000L) + c += dur->nsec; + #else + # error UNSUPPORTED CLOCKS_PER_SEC + #endif + +/* TODO: handle clock overvlow */ +/* TODO: check if there is abortion request or interrupt */ + while (c > clock()) ; + #else struct timespec ts; ts.tv_sec = dur->sec; @@ -495,7 +535,7 @@ static void resume_process (stix_t* stix, stix_oop_process_t proc) { /* SUSPENED ---> RUNNING */ -//printf ("TO RESUME PROCESS = %p %d SUSPENED ----> RUNNING\n", proc, (int)STIX_OOP_TO_SMOOI(proc->state)); +/*printf ("TO RESUME PROCESS = %p %d SUSPENED ----> RUNNING\n", proc, (int)STIX_OOP_TO_SMOOI(proc->state));*/ STIX_ASSERT ((stix_oop_t)proc->prev == stix->_nil); STIX_ASSERT ((stix_oop_t)proc->next == stix->_nil); @@ -530,11 +570,11 @@ static void suspend_process (stix_t* stix, stix_oop_process_t proc) nrp = find_next_runnable_process (stix); -//printf ("TO SUSPEND...%p %d\n", proc, (int)STIX_OOP_TO_SMOOI(proc->state)); +/*printf ("TO SUSPEND...%p %d\n", proc, (int)STIX_OOP_TO_SMOOI(proc->state));*/ if (nrp == proc) { /* no runnable process after suspension */ -//printf ("NO RUNNABLE PROCESS AFTER SUPSENDISION\n"); +/*printf ("NO RUNNABLE PROCESS AFTER SUPSENDISION\n");*/ sleep_active_process (stix, PROC_STATE_RUNNABLE); unchain_from_processor (stix, proc, PROC_STATE_SUSPENDED); @@ -545,7 +585,7 @@ static void suspend_process (stix_t* stix, stix_oop_process_t proc) } else { -//printf ("SWITCHING TO XXXXXXXXXXXXXXXXXXXXx\n"); +/*printf ("SWITCHING TO XXXXXXXXXXXXXXXXXXXXx\n");*/ /* keep the unchained process at the runnable state for * the immediate call to switch_to_process() below */ unchain_from_processor (stix, proc, PROC_STATE_RUNNABLE); @@ -617,7 +657,7 @@ static stix_oop_process_t signal_semaphore (stix_t* stix, stix_oop_semaphore_t s if ((stix_oop_t)sem->waiting_head == stix->_nil) { -//printf ("signal semaphore...1111\n"); +/*printf ("signal semaphore...1111\n");*/ /* no process is waiting on this semaphore */ count = STIX_OOP_TO_SMOOI(sem->count); count++; @@ -634,7 +674,7 @@ static stix_oop_process_t signal_semaphore (stix_t* stix, stix_oop_semaphore_t s unchain_from_semaphore (stix, proc); resume_process (stix, proc); /* TODO: error check */ -//printf ("signal semaphore...2222 DONE -> resumed process -> proc state %d\n", (int)STIX_OOP_TO_SMOOI(proc->state)); +/*printf ("signal semaphore...2222 DONE -> resumed process -> proc state %d\n", (int)STIX_OOP_TO_SMOOI(proc->state));*/ /* return the resumed process */ return proc; @@ -652,14 +692,14 @@ static void await_semaphore (stix_t* stix, stix_oop_semaphore_t sem) /* it's already signalled */ count--; sem->count = STIX_SMOOI_TO_OOP(count); -//printf (">>>>>>>>>>>>>> AWAIT SEMAPHORE - NO SUSPENDING ...................\n"); +/*printf (">>>>>>>>>>>>>> AWAIT SEMAPHORE - NO SUSPENDING ...................\n");*/ } else { /* not signaled. need to wait */ proc = stix->processor->active; -//printf (">>>>>>>>>>>>>> AWAIT SEMAPHORE - SUEPENDING ACTIVE PROCESS..........state=>[%d].....PROC %p\n", (int)STIX_OOP_TO_SMOOI(proc->state), proc); +/*printf (">>>>>>>>>>>>>> AWAIT SEMAPHORE - SUEPENDING ACTIVE PROCESS..........state=>[%d].....PROC %p\n", (int)STIX_OOP_TO_SMOOI(proc->state), proc);*/ /* suspend the active process */ suspend_process (stix, proc); @@ -668,7 +708,7 @@ static void await_semaphore (stix_t* stix, stix_oop_semaphore_t sem) STIX_ASSERT (sem->waiting_tail == proc); -//printf (">>>>>>>>>>>>>> AWAIT SEMAPHORE - SUEPENDING ACTIVE PROCESS....XX......state=>[%d]..PROC %p\n", (int)STIX_OOP_TO_SMOOI(proc->state), proc); +/*printf (">>>>>>>>>>>>>> AWAIT SEMAPHORE - SUEPENDING ACTIVE PROCESS....XX......state=>[%d]..PROC %p\n", (int)STIX_OOP_TO_SMOOI(proc->state), proc);*/ STIX_ASSERT (stix->processor->active != proc); } } @@ -1824,12 +1864,12 @@ static int prim_processor_add_timed_semaphore (stix_t* stix, stix_ooi_t nargs) /* TODO: make clock_gettime to be platform independent * * this code assumes that the monotonic clock returns a small value - * that can fit into a small integer, even after some addtions... */ + * that can fit into a SmallInteger, even after some addtions... */ vm_gettime (stix, &now); STIX_ADDNTIMESNS (&ft, &now, STIX_OOP_TO_SMOOI(sec), STIX_OOP_TO_SMOOI(nsec)); if (ft.sec < 0 || ft.sec > STIX_SMOOI_MAX) { - /* soft error - cannot represent the e:xpiry time in + /* soft error - cannot represent the exxpiry time in * a small integer. */ return 0; } @@ -3805,7 +3845,7 @@ printf (">>>>>>>>>>>>>>>> METHOD RETURN FROM WITHIN A BLOCK. NON-LOCAL RETURN.. { /* the sender of the intial context is nil. * use this fact to tell an initial context from a normal context. */ - STIX_ASSERT (stix->active_context->receiver_or_source == stix->_nil); + /* STIX_ASSERT (stix->active_context->receiver_or_source == stix->_nil);*/ /* when sender is nil, the following condition must be true. * but it's not always true the other way around */ diff --git a/stix/lib/heap.c b/stix/lib/heap.c index eae41e7..31cc7e5 100644 --- a/stix/lib/heap.c +++ b/stix/lib/heap.c @@ -65,7 +65,7 @@ void* stix_allocheapmem (stix_t* stix, stix_heap_t* heap, stix_oow_t size) { stix_uint8_t* ptr; -//printf ("heap ptr %p %p %lld %lld\n", heap->ptr, heap->limit, (long long int)size, (long long int)(heap->limit - heap->ptr)); +/*printf ("heap ptr %p %p %lld %lld\n", heap->ptr, heap->limit, (long long int)size, (long long int)(heap->limit - heap->ptr));*/ /* check the heap size limit */ if (heap->ptr >= heap->limit || heap->limit - heap->ptr < size) { diff --git a/stix/lib/stix-cmn.h b/stix/lib/stix-cmn.h index 0a260d7..e62b55a 100644 --- a/stix/lib/stix-cmn.h +++ b/stix/lib/stix-cmn.h @@ -611,7 +611,12 @@ struct stix_cmgr_t /* ========================================================================= * COMPILER FEATURE TEST MACROS * =========================================================================*/ -#if defined(__has_builtin) +#if defined(_INTELC32_) && !defined(__has_builtin) + /* intel c code builder 1.0 ended up with an error without this override */ + #define __has_builtin(x) 0 +#endif + +#if defined(__has_builtin) #if __has_builtin(__builtin_ctz) #define STIX_HAVE_BUILTIN_CTZ #endif diff --git a/stix/lib/stix-dos.h b/stix/lib/stix-dos.h index 68b3957..5ebeca3 100644 --- a/stix/lib/stix-dos.h +++ b/stix/lib/stix-dos.h @@ -134,6 +134,33 @@ # define STIX_SIZEOF_MBSTATE_T STIX_SIZEOF_LONG # define STIX_MBLEN_MAX 8 +#elif defined(_INTELC32_) + + /* Intel C Code Builder 1.0 */ +# 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 0 + +# 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 1 + +# define STIX_SIZEOF___INT8 0 +# define STIX_SIZEOF___INT16 0 +# define STIX_SIZEOF___INT32 0 +# define STIX_SIZEOF___INT64 0 +# define STIX_SIZEOF___INT128 0 + +# define STIX_SIZEOF_OFF64_T 0 +# define STIX_SIZEOF_OFF_T 4 + +# define STIX_SIZEOF_MBSTATE_T STIX_SIZEOF_LONG +# define STIX_MBLEN_MAX 8 + #else # error Define the size of various data types. #endif diff --git a/stix/lib/stix-prv.h b/stix/lib/stix-prv.h index afbd836..a5a303b 100644 --- a/stix/lib/stix-prv.h +++ b/stix/lib/stix-prv.h @@ -54,7 +54,7 @@ /* this is for gc debugging */ /*#define STIX_DEBUG_PROCESSOR*/ -#define STIX_DEBUG_GC_001 +/*#define STIX_DEBUG_GC_001*/ /*#define STIX_DEBUG_GC_002*/ #define STIX_DEBUG_COMP_001 /*#define STIX_DEBUG_COMP_002*/ @@ -96,14 +96,12 @@ # else # define STIX_MEMCMP(dst,src,size) memcmp(dst,src,size) # endif - #elif defined(__GNUC__) && (__GNUC__ >= 3 || (defined(__GNUC_MINOR) && __GNUC__ == 2 && __GNUC_MINOR__ >= 91)) /* gcc 2.91 or higher */ # define STIX_MEMSET(dst,src,size) __builtin_memset(dst,src,size) # define STIX_MEMCPY(dst,src,size) __builtin_memcpy(dst,src,size) # define STIX_MEMMOVE(dst,src,size) __builtin_memmove(dst,src,size) # define STIX_MEMCMP(dst,src,size) __builtin_memcmp(dst,src,size) - #else # define STIX_MEMSET(dst,src,size) memset(dst,src,size) # define STIX_MEMCPY(dst,src,size) memcpy(dst,src,size) diff --git a/stix/lib/stix.h b/stix/lib/stix.h index eef0f03..24050d2 100644 --- a/stix/lib/stix.h +++ b/stix/lib/stix.h @@ -88,7 +88,7 @@ enum stix_trait_t STIX_NOGC = (1 << 0), /* wait for running process when exiting from the main method */ - STIX_AWAIT_PROCS = (1 << 1), + STIX_AWAIT_PROCS = (1 << 1) }; typedef enum stix_trait_t stix_trait_t; @@ -204,7 +204,7 @@ enum stix_obj_type_t STIX_OBJ_TYPE_CHAR, STIX_OBJ_TYPE_BYTE, STIX_OBJ_TYPE_HALFWORD, - STIX_OBJ_TYPE_WORD, + STIX_OBJ_TYPE_WORD /* STIX_OBJ_TYPE_UINT8,