]> gitweb.factorcode.org Git - factor.git/commitdiff
Add dll exports for compiling on win32
authorMackenzie Straight <eizneckam@gmail.com>
Mon, 13 Dec 2004 21:17:05 +0000 (21:17 +0000)
committerMackenzie Straight <eizneckam@gmail.com>
Mon, 13 Dec 2004 21:17:05 +0000 (21:17 +0000)
factor.sln [new file with mode: 0644]
factor.vcproj [new file with mode: 0644]
native/arithmetic.h
native/factor.h
native/ffi.c
native/types.h
native/win32/io.c
native/win32/write.c

diff --git a/factor.sln b/factor.sln
new file mode 100644 (file)
index 0000000..cf6a0ee
--- /dev/null
@@ -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 (file)
index 0000000..b45205b
--- /dev/null
@@ -0,0 +1,454 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+       ProjectType="Visual C++"
+       Version="7.10"
+       Name="factor"
+       ProjectGUID="{3AE5FAF6-99AC-4B8F-9107-8A346B3D87A4}"
+       Keyword="Win32Proj">
+       <Platforms>
+               <Platform
+                       Name="Win32"/>
+       </Platforms>
+       <Configurations>
+               <Configuration
+                       Name="Debug|Win32"
+                       OutputDirectory="Debug"
+                       IntermediateDirectory="Debug"
+                       ConfigurationType="1"
+                       CharacterSet="2">
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               Optimization="0"
+                               PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+                               MinimalRebuild="TRUE"
+                               BasicRuntimeChecks="3"
+                               RuntimeLibrary="5"
+                               UsePrecompiledHeader="0"
+                               WarningLevel="1"
+                               Detect64BitPortabilityProblems="TRUE"
+                               DebugInformationFormat="4"/>
+                       <Tool
+                               Name="VCCustomBuildTool"/>
+                       <Tool
+                               Name="VCLinkerTool"
+                               OutputFile="$(OutDir)/factor.exe"
+                               LinkIncremental="2"
+                               GenerateDebugInformation="TRUE"
+                               ProgramDatabaseFile="$(OutDir)/factor.pdb"
+                               SubSystem="1"
+                               TargetMachine="1"/>
+                       <Tool
+                               Name="VCMIDLTool"/>
+                       <Tool
+                               Name="VCPostBuildEventTool"/>
+                       <Tool
+                               Name="VCPreBuildEventTool"/>
+                       <Tool
+                               Name="VCPreLinkEventTool"/>
+                       <Tool
+                               Name="VCResourceCompilerTool"/>
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"/>
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"/>
+                       <Tool
+                               Name="VCWebDeploymentTool"/>
+                       <Tool
+                               Name="VCManagedWrapperGeneratorTool"/>
+                       <Tool
+                               Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+               </Configuration>
+               <Configuration
+                       Name="Release|Win32"
+                       OutputDirectory="Release"
+                       IntermediateDirectory="Release"
+                       ConfigurationType="1"
+                       CharacterSet="2">
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               Optimization="3"
+                               GlobalOptimizations="TRUE"
+                               InlineFunctionExpansion="1"
+                               OmitFramePointers="TRUE"
+                               PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+                               StringPooling="TRUE"
+                               RuntimeLibrary="4"
+                               EnableFunctionLevelLinking="TRUE"
+                               UsePrecompiledHeader="0"
+                               WarningLevel="3"
+                               Detect64BitPortabilityProblems="TRUE"
+                               DebugInformationFormat="3"/>
+                       <Tool
+                               Name="VCCustomBuildTool"/>
+                       <Tool
+                               Name="VCLinkerTool"
+                               OutputFile="$(OutDir)/factor.exe"
+                               LinkIncremental="1"
+                               GenerateDebugInformation="TRUE"
+                               SubSystem="1"
+                               OptimizeReferences="2"
+                               EnableCOMDATFolding="2"
+                               TargetMachine="1"/>
+                       <Tool
+                               Name="VCMIDLTool"/>
+                       <Tool
+                               Name="VCPostBuildEventTool"/>
+                       <Tool
+                               Name="VCPreBuildEventTool"/>
+                       <Tool
+                               Name="VCPreLinkEventTool"/>
+                       <Tool
+                               Name="VCResourceCompilerTool"/>
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"/>
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"/>
+                       <Tool
+                               Name="VCWebDeploymentTool"/>
+                       <Tool
+                               Name="VCManagedWrapperGeneratorTool"/>
+                       <Tool
+                               Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+               </Configuration>
+       </Configurations>
+       <References>
+       </References>
+       <Files>
+               <Filter
+                       Name="Source Files"
+                       Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm">
+                       <File
+                               RelativePath="native\arithmetic.c">
+                       </File>
+                       <File
+                               RelativePath="native\array.c">
+                       </File>
+                       <File
+                               RelativePath="native\bignum.c">
+                       </File>
+                       <File
+                               RelativePath="native\boolean.c">
+                       </File>
+                       <File
+                               RelativePath="native\compiler.c">
+                       </File>
+                       <File
+                               RelativePath="native\complex.c">
+                       </File>
+                       <File
+                               RelativePath="native\cons.c">
+                       </File>
+                       <File
+                               RelativePath="native\error.c">
+                       </File>
+                       <File
+                               RelativePath="native\factor.c">
+                       </File>
+                       <File
+                               RelativePath="native\ffi.c">
+                       </File>
+                       <File
+                               RelativePath="native\fixnum.c">
+                       </File>
+                       <File
+                               RelativePath="native\float.c">
+                       </File>
+                       <File
+                               RelativePath="native\gc.c">
+                       </File>
+                       <File
+                               RelativePath="native\image.c">
+                       </File>
+                       <File
+                               RelativePath="native\memory.c">
+                       </File>
+                       <File
+                               RelativePath="native\misc.c">
+                       </File>
+                       <File
+                               RelativePath="native\port.c">
+                       </File>
+                       <File
+                               RelativePath="native\primitives.c">
+                       </File>
+                       <File
+                               RelativePath="native\ratio.c">
+                       </File>
+                       <File
+                               RelativePath="native\relocate.c">
+                       </File>
+                       <File
+                               RelativePath="native\run.c">
+                       </File>
+                       <File
+                               RelativePath="native\s48_bignum.c">
+                       </File>
+                       <File
+                               RelativePath="native\sbuf.c">
+                       </File>
+                       <File
+                               RelativePath="native\stack.c">
+                       </File>
+                       <File
+                               RelativePath="native\string.c">
+                       </File>
+                       <File
+                               RelativePath="native\types.c">
+                       </File>
+                       <File
+                               RelativePath="native\vector.c">
+                       </File>
+                       <File
+                               RelativePath="native\word.c">
+                       </File>
+                       <Filter
+                               Name="win32"
+                               Filter="">
+                               <File
+                                       RelativePath="native\win32\file.c">
+                               </File>
+                               <File
+                                       RelativePath="native\win32\io.c">
+                               </File>
+                               <File
+                                       RelativePath=".\native\win32\misc.c">
+                                       <FileConfiguration
+                                               Name="Debug|Win32">
+                                               <Tool
+                                                       Name="VCCLCompilerTool"
+                                                       ObjectFile="$(IntDir)/$(InputName)1.obj"/>
+                                       </FileConfiguration>
+                                       <FileConfiguration
+                                               Name="Release|Win32">
+                                               <Tool
+                                                       Name="VCCLCompilerTool"
+                                                       ObjectFile="$(IntDir)/$(InputName)1.obj"/>
+                                       </FileConfiguration>
+                               </File>
+                               <File
+                                       RelativePath="native\win32\read.c">
+                               </File>
+                               <File
+                                       RelativePath="native\win32\write.c">
+                               </File>
+                       </Filter>
+                       <Filter
+                               Name="unix"
+                               Filter="">
+                               <File
+                                       RelativePath="native\unix\file.c">
+                                       <FileConfiguration
+                                               Name="Debug|Win32"
+                                               ExcludedFromBuild="TRUE">
+                                               <Tool
+                                                       Name="VCCLCompilerTool"
+                                                       ObjectFile="$(IntDir)/$(InputName)1.obj"/>
+                                       </FileConfiguration>
+                                       <FileConfiguration
+                                               Name="Release|Win32"
+                                               ExcludedFromBuild="TRUE">
+                                               <Tool
+                                                       Name="VCCLCompilerTool"
+                                                       ObjectFile="$(IntDir)/$(InputName)1.obj"/>
+                                       </FileConfiguration>
+                               </File>
+                               <File
+                                       RelativePath="native\unix\io.c">
+                                       <FileConfiguration
+                                               Name="Debug|Win32"
+                                               ExcludedFromBuild="TRUE">
+                                               <Tool
+                                                       Name="VCCLCompilerTool"
+                                                       ObjectFile="$(IntDir)/$(InputName)1.obj"/>
+                                       </FileConfiguration>
+                                       <FileConfiguration
+                                               Name="Release|Win32"
+                                               ExcludedFromBuild="TRUE">
+                                               <Tool
+                                                       Name="VCCLCompilerTool"
+                                                       ObjectFile="$(IntDir)/$(InputName)1.obj"/>
+                                       </FileConfiguration>
+                               </File>
+                               <File
+                                       RelativePath="native\unix\read.c">
+                                       <FileConfiguration
+                                               Name="Debug|Win32"
+                                               ExcludedFromBuild="TRUE">
+                                               <Tool
+                                                       Name="VCCLCompilerTool"
+                                                       ObjectFile="$(IntDir)/$(InputName)1.obj"/>
+                                       </FileConfiguration>
+                                       <FileConfiguration
+                                               Name="Release|Win32"
+                                               ExcludedFromBuild="TRUE">
+                                               <Tool
+                                                       Name="VCCLCompilerTool"
+                                                       ObjectFile="$(IntDir)/$(InputName)1.obj"/>
+                                       </FileConfiguration>
+                               </File>
+                               <File
+                                       RelativePath="native\unix\signal.c">
+                                       <FileConfiguration
+                                               Name="Debug|Win32"
+                                               ExcludedFromBuild="TRUE">
+                                               <Tool
+                                                       Name="VCCLCompilerTool"/>
+                                       </FileConfiguration>
+                                       <FileConfiguration
+                                               Name="Release|Win32"
+                                               ExcludedFromBuild="TRUE">
+                                               <Tool
+                                                       Name="VCCLCompilerTool"/>
+                                       </FileConfiguration>
+                               </File>
+                               <File
+                                       RelativePath="native\unix\socket.c">
+                                       <FileConfiguration
+                                               Name="Debug|Win32"
+                                               ExcludedFromBuild="TRUE">
+                                               <Tool
+                                                       Name="VCCLCompilerTool"/>
+                                       </FileConfiguration>
+                                       <FileConfiguration
+                                               Name="Release|Win32"
+                                               ExcludedFromBuild="TRUE">
+                                               <Tool
+                                                       Name="VCCLCompilerTool"/>
+                                       </FileConfiguration>
+                               </File>
+                               <File
+                                       RelativePath="native\unix\write.c">
+                                       <FileConfiguration
+                                               Name="Debug|Win32"
+                                               ExcludedFromBuild="TRUE">
+                                               <Tool
+                                                       Name="VCCLCompilerTool"
+                                                       ObjectFile="$(IntDir)/$(InputName)1.obj"/>
+                                       </FileConfiguration>
+                                       <FileConfiguration
+                                               Name="Release|Win32"
+                                               ExcludedFromBuild="TRUE">
+                                               <Tool
+                                                       Name="VCCLCompilerTool"
+                                                       ObjectFile="$(IntDir)/$(InputName)1.obj"/>
+                                       </FileConfiguration>
+                               </File>
+                       </Filter>
+               </Filter>
+               <Filter
+                       Name="Header Files"
+                       Filter="h;hpp;hxx;hm;inl;inc">
+                       <File
+                               RelativePath="native\arithmetic.h">
+                       </File>
+                       <File
+                               RelativePath="native\array.h">
+                       </File>
+                       <File
+                               RelativePath="native\bignum.h">
+                       </File>
+                       <File
+                               RelativePath="native\boolean.h">
+                       </File>
+                       <File
+                               RelativePath="native\compiler.h">
+                       </File>
+                       <File
+                               RelativePath="native\complex.h">
+                       </File>
+                       <File
+                               RelativePath="native\cons.h">
+                       </File>
+                       <File
+                               RelativePath="native\error.h">
+                       </File>
+                       <File
+                               RelativePath="native\factor.h">
+                       </File>
+                       <File
+                               RelativePath="native\ffi.h">
+                       </File>
+                       <File
+                               RelativePath="native\file.h">
+                       </File>
+                       <File
+                               RelativePath="native\fixnum.h">
+                       </File>
+                       <File
+                               RelativePath="native\float.h">
+                       </File>
+                       <File
+                               RelativePath="native\gc.h">
+                       </File>
+                       <File
+                               RelativePath="native\image.h">
+                       </File>
+                       <File
+                               RelativePath="native\io.h">
+                       </File>
+                       <File
+                               RelativePath="native\memory.h">
+                       </File>
+                       <File
+                               RelativePath="native\misc.h">
+                       </File>
+                       <File
+                               RelativePath="native\port.h">
+                       </File>
+                       <File
+                               RelativePath="native\primitives.h">
+                       </File>
+                       <File
+                               RelativePath="native\ratio.h">
+                       </File>
+                       <File
+                               RelativePath="native\read.h">
+                       </File>
+                       <File
+                               RelativePath="native\relocate.h">
+                       </File>
+                       <File
+                               RelativePath="native\run.h">
+                       </File>
+                       <File
+                               RelativePath="native\s48_bignum.h">
+                       </File>
+                       <File
+                               RelativePath="native\s48_bignumint.h">
+                       </File>
+                       <File
+                               RelativePath="native\sbuf.h">
+                       </File>
+                       <File
+                               RelativePath="native\signal.h">
+                       </File>
+                       <File
+                               RelativePath="native\socket.h">
+                       </File>
+                       <File
+                               RelativePath="native\stack.h">
+                       </File>
+                       <File
+                               RelativePath="native\string.h">
+                       </File>
+                       <File
+                               RelativePath="native\types.h">
+                       </File>
+                       <File
+                               RelativePath="native\vector.h">
+                       </File>
+                       <File
+                               RelativePath="native\word.h">
+                       </File>
+                       <File
+                               RelativePath="native\write.h">
+                       </File>
+               </Filter>
+               <Filter
+                       Name="Resource Files"
+                       Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe">
+               </Filter>
+       </Files>
+       <Globals>
+       </Globals>
+</VisualStudioProject>
index 840810d54ae2eb6deee5f3407a7e3d7dbdaecd5c..747bc381e57f20f0e5624e4bf24cb93193d5deb2 100644 (file)
@@ -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);
index bf0a6e2c0ed02db03603ea8a3b28cba99c5e0d33..f6308835cdff49d6db09ffafab6dc982c5cfff7f 100644 (file)
@@ -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;
index 10e472b02b887548d798ce3136c55a63d077f88f..628faea611c4f0eed0d6f7ca78f8bd891c15e9e2 100644 (file)
@@ -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
index 6bc956bc8a1f08669cbaa2ff4bfdb02a8332e3e3..d03d4c6a363698b923511543f25ff9efc32a517f 100644 (file)
@@ -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)
index 950fcf98055893298717961a7f38037076787a4d..8ff58cb90de319731b0b29ebe53bbb7d5f5b3c0d 100644 (file)
@@ -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);
index c0872d1a0b1dbf9db643f3727bb677f766327fef..9b3e66bb101b694da870580caa35f2c11ed15fa5 100644 (file)
@@ -2,6 +2,8 @@
 
 void primitive_add_write_io_task (void)
 {
+       maybe_garbage_collection();
+
        callback_list = cons(dpop(), callback_list); 
        dpop();
 }