From 4435110231b91d4abcb62560f0345eb642a3b776 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Fri, 2 Dec 2005 04:40:44 +0000 Subject: [PATCH] string hashing kludge; amd64 cpu detection --- library/bootstrap/boot-stage2.factor | 10 +++++----- native/factor.c | 5 ++++- native/platform.h | 4 ++++ native/run.h | 3 +++ native/string.c | 6 +++--- 5 files changed, 19 insertions(+), 9 deletions(-) diff --git a/library/bootstrap/boot-stage2.factor b/library/bootstrap/boot-stage2.factor index ec79b96f54..8bbfd7f33f 100644 --- a/library/bootstrap/boot-stage2.factor +++ b/library/bootstrap/boot-stage2.factor @@ -25,11 +25,11 @@ t [ "/library/alien/malloc.factor" "/library/io/buffer.factor" - "/library/sdl/load.factor" - "/library/opengl/load.factor" - "/library/freetype/load.factor" - "/library/ui/load.factor" - "/library/help/load.factor" + ! "/library/sdl/load.factor" + ! "/library/opengl/load.factor" + ! "/library/freetype/load.factor" + ! "/library/ui/load.factor" + ! "/library/help/load.factor" ] pull-in ! Handle -libraries:... overrides diff --git a/native/factor.c b/native/factor.c index eef65405a8..1b2fcb45a4 100644 --- a/native/factor.c +++ b/native/factor.c @@ -20,6 +20,10 @@ void init_factor(char* image, CELL ds_size, CELL cs_size, userenv[OS_ENV] = tag_object(from_c_string(FACTOR_OS_STRING)); userenv[GEN_ENV] = tag_fixnum(gen_count); userenv[CARD_OFF_ENV] = tag_cell(cards_offset); + userenv[IMAGE_ENV] = tag_object(from_c_string(image)); + userenv[CELL_SIZE_ENV] = tag_fixnum(sizeof(CELL)); + userenv[INT_SIZE_ENV] = tag_fixnum(sizeof(int)); + userenv[LONG_SIZE_ENV] = tag_fixnum(sizeof(long)); } INLINE bool factor_arg(const char* str, const char* arg, CELL* value) @@ -98,7 +102,6 @@ int main(int argc, char** argv) args = cons(tag_object(from_c_string(argv[argc])),args); } - userenv[IMAGE_ENV] = tag_object(from_c_string(image)); userenv[ARGS_ENV] = args; platform_run(); diff --git a/native/platform.h b/native/platform.h index 6369d6f132..1f0ebe0f35 100644 --- a/native/platform.h +++ b/native/platform.h @@ -2,6 +2,8 @@ #define FACTOR_X86 #elif defined(__POWERPC__) || defined(__ppc__) || defined(_ARCH_PPC) #define FACTOR_PPC +#elif defined(__amd64__) || defined(__x86_64__) + #define FACTOR_AMD64 #endif #ifdef __APPLE__ @@ -15,6 +17,8 @@ #define FACTOR_CPU_STRING "x86" #elif defined(FACTOR_PPC) #define FACTOR_CPU_STRING "ppc" +#elif defined(FACTOR_AMD64) + #define FACTOR_CPU_STRING "amd64" #else #define FACTOR_CPU_STRING "unknown" #endif diff --git a/native/run.h b/native/run.h index 2568b1e5cf..1f52395559 100644 --- a/native/run.h +++ b/native/run.h @@ -16,6 +16,9 @@ #define OUT_ENV 14 #define GEN_ENV 15 /* set to gen_count */ #define IMAGE_ENV 16 /* image name */ +#define CELL_SIZE_ENV 17 /* sizeof(CELL) */ +#define INT_SIZE_ENV 18 /* sizeof(int) */ +#define LONG_SIZE_ENV 19 /* sizeof(long) */ /* TAGGED user environment data; see getenv/setenv prims */ DLLEXPORT CELL userenv[USER_ENV]; diff --git a/native/string.c b/native/string.c index d353c98021..280e157637 100644 --- a/native/string.c +++ b/native/string.c @@ -17,12 +17,12 @@ F_STRING* allot_string(CELL capacity) /* call this after constructing a string */ void rehash_string(F_STRING* str) { - F_FIXNUM hash = 0; + s32 hash = 0; CELL i; CELL capacity = string_capacity(str); for(i = 0; i < capacity; i++) - hash = 31*hash + string_nth(str,i); - str->hashcode = tag_fixnum(hash); + hash = (31*hash + string_nth(str,i)); + str->hashcode = (s32)tag_fixnum(hash); } void primitive_rehash_string(void)