diff --git a/factor.sln b/factor.sln new file mode 100644 index 0000000000..cf6a0ee1f9 --- /dev/null +++ b/factor.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "factor", "factor.vcproj", "{3AE5FAF6-99AC-4B8F-9107-8A346B3D87A4}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {3AE5FAF6-99AC-4B8F-9107-8A346B3D87A4}.Debug.ActiveCfg = Debug|Win32 + {3AE5FAF6-99AC-4B8F-9107-8A346B3D87A4}.Debug.Build.0 = Debug|Win32 + {3AE5FAF6-99AC-4B8F-9107-8A346B3D87A4}.Release.ActiveCfg = Release|Win32 + {3AE5FAF6-99AC-4B8F-9107-8A346B3D87A4}.Release.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/factor.vcproj b/factor.vcproj new file mode 100644 index 0000000000..b45205b0a8 --- /dev/null +++ b/factor.vcproj @@ -0,0 +1,454 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/native/arithmetic.h b/native/arithmetic.h index 840810d54a..747bc381e5 100644 --- a/native/arithmetic.h +++ b/native/arithmetic.h @@ -1,6 +1,6 @@ #include "factor.h" -CELL arithmetic_type(CELL obj1, CELL obj2); +DLLEXPORT CELL arithmetic_type(CELL obj1, CELL obj2); void primitive_arithmetic_type(void); bool realp(CELL tagged); diff --git a/native/factor.h b/native/factor.h index bf0a6e2c0e..f6308835cd 100644 --- a/native/factor.h +++ b/native/factor.h @@ -5,6 +5,12 @@ #define FACTOR_X86 #endif +#if defined(WIN32) + #define DLLEXPORT __declspec(dllexport) +#else + #define DLLEXPORT +#endif + /* CELL must be 32 bits and your system must have 32-bit pointers */ typedef unsigned long int CELL; #define CELLS ((signed)sizeof(CELL)) @@ -13,7 +19,7 @@ typedef unsigned long int CELL; CELL ds_bot; /* raw pointer to datastack top */ -CELL ds; +DLLEXPORT CELL ds; /* raw pointer to callstack bottom */ CELL cs_bot; diff --git a/native/ffi.c b/native/ffi.c index 10e472b02b..628faea611 100644 --- a/native/ffi.c +++ b/native/ffi.c @@ -53,7 +53,7 @@ void primitive_dlsym(void) void primitive_dlsym_self(void) { -#ifdef FFI +#if defined(FFI) void* sym = dlsym(NULL,unbox_c_string()); if(sym == NULL) { @@ -61,6 +61,14 @@ void primitive_dlsym_self(void) from_c_string(dlerror()))); } dpush(tag_cell((CELL)sym)); +#elif defined(WIN32) + void *sym = GetProcAddress(GetModuleHandle(NULL), unbox_c_string()); + if(sym == NULL) + { + general_error(ERROR_FFI, tag_object( + from_c_string("bad symbol"))); + } + dpush(tag_cell((CELL)sym)); #else general_error(ERROR_FFI_DISABLED,F); #endif diff --git a/native/types.h b/native/types.h index 6bc956bc8a..d03d4c6a36 100644 --- a/native/types.h +++ b/native/types.h @@ -43,7 +43,7 @@ CELL T; #define NUMBER_TYPE 103 /* F_COMPLEX or REAL */ #define TEXT_TYPE 104 /* F_FIXNUM or F_STRING */ -CELL type_of(CELL tagged); +DLLEXPORT CELL type_of(CELL tagged); bool typep(CELL type, CELL tagged); INLINE CELL tag_header(CELL cell) diff --git a/native/win32/io.c b/native/win32/io.c index 950fcf9805..8ff58cb90d 100644 --- a/native/win32/io.c +++ b/native/win32/io.c @@ -23,6 +23,8 @@ void primitive_close (void) void primitive_next_io_task (void) { + maybe_garbage_collection(); + if (callback_list != F) { F_CONS *cons = untag_cons(callback_list); diff --git a/native/win32/write.c b/native/win32/write.c index c0872d1a0b..9b3e66bb10 100644 --- a/native/win32/write.c +++ b/native/win32/write.c @@ -2,6 +2,8 @@ void primitive_add_write_io_task (void) { + maybe_garbage_collection(); + callback_list = cons(dpop(), callback_list); dpop(); }