From cc2551b02ba4c81724571125149b852aed40ecfa Mon Sep 17 00:00:00 2001 From: tevador <37503146+tevador@users.noreply.github.com> Date: Mon, 10 Jun 2019 15:58:51 +0200 Subject: [PATCH] Support building a shared library (#53) --- randomx.sln | 10 ++ src/randomx.h | 30 ++-- vcxproj/randomx-dll.vcxproj | 211 ++++++++++++++++++++++++++++ vcxproj/randomx-dll.vcxproj.filters | 173 +++++++++++++++++++++++ 4 files changed, 411 insertions(+), 13 deletions(-) create mode 100644 vcxproj/randomx-dll.vcxproj create mode 100644 vcxproj/randomx-dll.vcxproj.filters diff --git a/randomx.sln b/randomx.sln index bbe9986..3da2b50 100644 --- a/randomx.sln +++ b/randomx.sln @@ -29,6 +29,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "perf-simulation", "vcxproj\ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "runtime-distr", "vcxproj\runtime-distr.vcxproj", "{F207EC8C-C55F-46C0-8851-887A71574F54}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "randomx-dll", "vcxproj\randomx-dll.vcxproj", "{59560AD8-18E3-463E-A941-BBD808EC7C83}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x64 = Debug|x64 @@ -133,6 +135,14 @@ Global {F207EC8C-C55F-46C0-8851-887A71574F54}.Release|x64.Build.0 = Release|x64 {F207EC8C-C55F-46C0-8851-887A71574F54}.Release|x86.ActiveCfg = Release|Win32 {F207EC8C-C55F-46C0-8851-887A71574F54}.Release|x86.Build.0 = Release|Win32 + {59560AD8-18E3-463E-A941-BBD808EC7C83}.Debug|x64.ActiveCfg = Debug|x64 + {59560AD8-18E3-463E-A941-BBD808EC7C83}.Debug|x64.Build.0 = Debug|x64 + {59560AD8-18E3-463E-A941-BBD808EC7C83}.Debug|x86.ActiveCfg = Debug|Win32 + {59560AD8-18E3-463E-A941-BBD808EC7C83}.Debug|x86.Build.0 = Debug|Win32 + {59560AD8-18E3-463E-A941-BBD808EC7C83}.Release|x64.ActiveCfg = Release|x64 + {59560AD8-18E3-463E-A941-BBD808EC7C83}.Release|x64.Build.0 = Release|x64 + {59560AD8-18E3-463E-A941-BBD808EC7C83}.Release|x86.ActiveCfg = Release|Win32 + {59560AD8-18E3-463E-A941-BBD808EC7C83}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/randomx.h b/src/randomx.h index c1de61f..8f9b30c 100644 --- a/src/randomx.h +++ b/src/randomx.h @@ -34,6 +34,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define RANDOMX_HASH_SIZE 32 #define RANDOMX_DATASET_ITEM_SIZE 64 +#ifndef RANDOMX_EXPORT +#define RANDOMX_EXPORT +#endif + typedef enum { RANDOMX_FLAG_DEFAULT = 0, RANDOMX_FLAG_LARGE_PAGES = 1, @@ -62,7 +66,7 @@ extern "C" { * NULL is returned if memory allocation fails or if the RANDOMX_FLAG_JIT * is set and JIT compilation is not supported on the current platform. */ -randomx_cache *randomx_alloc_cache(randomx_flags flags); +RANDOMX_EXPORT randomx_cache *randomx_alloc_cache(randomx_flags flags); /** * Initializes the cache memory and SuperscalarHash using the provided key value. @@ -71,14 +75,14 @@ randomx_cache *randomx_alloc_cache(randomx_flags flags); * @param key is a pointer to memory which contains the key value. Must not be NULL. * @param keySize is the number of bytes of the key. */ -void randomx_init_cache(randomx_cache *cache, const void *key, size_t keySize); +RANDOMX_EXPORT void randomx_init_cache(randomx_cache *cache, const void *key, size_t keySize); /** * Releases all memory occupied by the randomx_cache structure. * * @param cache is a pointer to a previously allocated randomx_cache structure. */ -void randomx_release_cache(randomx_cache* cache); +RANDOMX_EXPORT void randomx_release_cache(randomx_cache* cache); /** * Creates a randomx_dataset structure and allocates memory for RandomX Dataset. @@ -89,14 +93,14 @@ void randomx_release_cache(randomx_cache* cache); * @return Pointer to an allocated randomx_dataset structure. * NULL is returned if memory allocation fails. */ -randomx_dataset *randomx_alloc_dataset(randomx_flags flags); +RANDOMX_EXPORT randomx_dataset *randomx_alloc_dataset(randomx_flags flags); /** * Gets the number of items contained in the dataset. * * @return the number of items contained in the dataset. */ -unsigned long randomx_dataset_item_count(void); +RANDOMX_EXPORT unsigned long randomx_dataset_item_count(void); /** * Initializes dataset items. @@ -109,7 +113,7 @@ unsigned long randomx_dataset_item_count(void); * @param startItem is the item number where intialization should start. * @param itemCount is the number of items that should be initialized. */ -void randomx_init_dataset(randomx_dataset *dataset, randomx_cache *cache, unsigned long startItem, unsigned long itemCount); +RANDOMX_EXPORT void randomx_init_dataset(randomx_dataset *dataset, randomx_cache *cache, unsigned long startItem, unsigned long itemCount); /** * Returns a pointer to the internal memory buffer of the dataset structure. The size @@ -119,14 +123,14 @@ void randomx_init_dataset(randomx_dataset *dataset, randomx_cache *cache, unsign * * @return Pointer to the internal memory buffer of the dataset structure. */ -void *randomx_get_dataset_memory(randomx_dataset *dataset); +RANDOMX_EXPORT void *randomx_get_dataset_memory(randomx_dataset *dataset); /** * Releases all memory occupied by the randomx_dataset structure. * * @param dataset is a pointer to a previously allocated randomx_dataset structure. */ -void randomx_release_dataset(randomx_dataset *dataset); +RANDOMX_EXPORT void randomx_release_dataset(randomx_dataset *dataset); /** * Creates and initializes a RandomX virtual machine. @@ -151,7 +155,7 @@ void randomx_release_dataset(randomx_dataset *dataset); * (3) cache parameter is NULL and RANDOMX_FLAG_FULL_MEM is not set * (4) dataset parameter is NULL and RANDOMX_FLAG_FULL_MEM is set */ -randomx_vm *randomx_create_vm(randomx_flags flags, randomx_cache *cache, randomx_dataset *dataset); +RANDOMX_EXPORT randomx_vm *randomx_create_vm(randomx_flags flags, randomx_cache *cache, randomx_dataset *dataset); /** * Reinitializes a virtual machine with a new Cache. This function should be called anytime @@ -161,7 +165,7 @@ randomx_vm *randomx_create_vm(randomx_flags flags, randomx_cache *cache, randomx * without RANDOMX_FLAG_FULL_MEM. Must not be NULL. * @param cache is a pointer to an initialized randomx_cache structure. Must not be NULL. */ -void randomx_vm_set_cache(randomx_vm *machine, randomx_cache* cache); +RANDOMX_EXPORT void randomx_vm_set_cache(randomx_vm *machine, randomx_cache* cache); /** * Reinitializes a virtual machine with a new Dataset. @@ -170,14 +174,14 @@ void randomx_vm_set_cache(randomx_vm *machine, randomx_cache* cache); * with RANDOMX_FLAG_FULL_MEM. Must not be NULL. * @param dataset is a pointer to an initialized randomx_dataset structure. Must not be NULL. */ -void randomx_vm_set_dataset(randomx_vm *machine, randomx_dataset *dataset); +RANDOMX_EXPORT void randomx_vm_set_dataset(randomx_vm *machine, randomx_dataset *dataset); /** * Releases all memory occupied by the randomx_vm structure. * * @param machine is a pointer to a previously created randomx_vm structure. */ -void randomx_destroy_vm(randomx_vm *machine); +RANDOMX_EXPORT void randomx_destroy_vm(randomx_vm *machine); /** * Calculates a RandomX hash value. @@ -188,7 +192,7 @@ void randomx_destroy_vm(randomx_vm *machine); * @param output is a pointer to memory where the hash will be stored. Must not * be NULL and at least RANDOMX_HASH_SIZE bytes must be available for writing. */ -void randomx_calculate_hash(randomx_vm *machine, const void *input, size_t inputSize, void *output); +RANDOMX_EXPORT void randomx_calculate_hash(randomx_vm *machine, const void *input, size_t inputSize, void *output); #if defined(__cplusplus) } diff --git a/vcxproj/randomx-dll.vcxproj b/vcxproj/randomx-dll.vcxproj new file mode 100644 index 0000000..e0cf2f3 --- /dev/null +++ b/vcxproj/randomx-dll.vcxproj @@ -0,0 +1,211 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 15.0 + {59560AD8-18E3-463E-A941-BBD808EC7C83} + Win32Proj + randomxdll + 10.0.17763.0 + + + + DynamicLibrary + true + v141 + Unicode + + + DynamicLibrary + false + v141 + true + Unicode + + + DynamicLibrary + true + v141 + Unicode + + + DynamicLibrary + false + v141 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + false + + + true + + + true + + + false + randomx + + + + Use + Level3 + MaxSpeed + true + true + true + WIN32;NDEBUG;RANDOMXDLL_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + + + Windows + true + true + true + + + + + Use + Level3 + Disabled + true + WIN32;_DEBUG;RANDOMXDLL_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + + + Windows + true + + + + + Use + Level3 + Disabled + true + _DEBUG;RANDOMXDLL_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + + + Windows + true + + + + + NotUsing + Level3 + MaxSpeed + true + true + false + NDEBUG;RANDOMXDLL_EXPORTS;_WINDOWS;_USRDLL;RANDOMX_EXPORT=__declspec(dllexport) + true + + + Windows + true + true + true + + + + + + + \ No newline at end of file diff --git a/vcxproj/randomx-dll.vcxproj.filters b/vcxproj/randomx-dll.vcxproj.filters new file mode 100644 index 0000000..a30fa8e --- /dev/null +++ b/vcxproj/randomx-dll.vcxproj.filters @@ -0,0 +1,173 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + Source Files + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + \ No newline at end of file