diff --git a/hashset.sln b/hashset.sln index 5d4463c..f72c424 100644 --- a/hashset.sln +++ b/hashset.sln @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 16 VisualStudioVersion = 16.0.33027.164 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "hahset", "hashset\hashset.vcxproj", "{0B7ABB95-B60F-418B-8386-930B1629058F}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "hashset", "hashset\hashset.vcxproj", "{0B7ABB95-B60F-418B-8386-930B1629058F}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libhashset", "libhashset\libhashset.vcxproj", "{8CF3BD19-28B1-435D-B719-E00B052DFC3A}" EndProject @@ -11,26 +11,36 @@ Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x64 = Debug|x64 Debug|x86 = Debug|x86 - Release|x64 = Release|x64 - Release|x86 = Release|x86 + Shared|x64 = Shared|x64 + Shared|x86 = Shared|x86 + Static|x64 = Static|x64 + Static|x86 = Static|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {0B7ABB95-B60F-418B-8386-930B1629058F}.Debug|x64.ActiveCfg = Debug|x64 {0B7ABB95-B60F-418B-8386-930B1629058F}.Debug|x64.Build.0 = Debug|x64 {0B7ABB95-B60F-418B-8386-930B1629058F}.Debug|x86.ActiveCfg = Debug|Win32 {0B7ABB95-B60F-418B-8386-930B1629058F}.Debug|x86.Build.0 = Debug|Win32 - {0B7ABB95-B60F-418B-8386-930B1629058F}.Release|x64.ActiveCfg = Release|x64 - {0B7ABB95-B60F-418B-8386-930B1629058F}.Release|x64.Build.0 = Release|x64 - {0B7ABB95-B60F-418B-8386-930B1629058F}.Release|x86.ActiveCfg = Release|Win32 - {0B7ABB95-B60F-418B-8386-930B1629058F}.Release|x86.Build.0 = Release|Win32 + {0B7ABB95-B60F-418B-8386-930B1629058F}.Shared|x64.ActiveCfg = Shared|x64 + {0B7ABB95-B60F-418B-8386-930B1629058F}.Shared|x64.Build.0 = Shared|x64 + {0B7ABB95-B60F-418B-8386-930B1629058F}.Shared|x86.ActiveCfg = Shared|Win32 + {0B7ABB95-B60F-418B-8386-930B1629058F}.Shared|x86.Build.0 = Shared|Win32 + {0B7ABB95-B60F-418B-8386-930B1629058F}.Static|x64.ActiveCfg = Static|x64 + {0B7ABB95-B60F-418B-8386-930B1629058F}.Static|x64.Build.0 = Static|x64 + {0B7ABB95-B60F-418B-8386-930B1629058F}.Static|x86.ActiveCfg = Static|Win32 + {0B7ABB95-B60F-418B-8386-930B1629058F}.Static|x86.Build.0 = Static|Win32 {8CF3BD19-28B1-435D-B719-E00B052DFC3A}.Debug|x64.ActiveCfg = Debug|x64 {8CF3BD19-28B1-435D-B719-E00B052DFC3A}.Debug|x64.Build.0 = Debug|x64 {8CF3BD19-28B1-435D-B719-E00B052DFC3A}.Debug|x86.ActiveCfg = Debug|Win32 {8CF3BD19-28B1-435D-B719-E00B052DFC3A}.Debug|x86.Build.0 = Debug|Win32 - {8CF3BD19-28B1-435D-B719-E00B052DFC3A}.Release|x64.ActiveCfg = Release|x64 - {8CF3BD19-28B1-435D-B719-E00B052DFC3A}.Release|x64.Build.0 = Release|x64 - {8CF3BD19-28B1-435D-B719-E00B052DFC3A}.Release|x86.ActiveCfg = Release|Win32 - {8CF3BD19-28B1-435D-B719-E00B052DFC3A}.Release|x86.Build.0 = Release|Win32 + {8CF3BD19-28B1-435D-B719-E00B052DFC3A}.Shared|x64.ActiveCfg = Shared|x64 + {8CF3BD19-28B1-435D-B719-E00B052DFC3A}.Shared|x64.Build.0 = Shared|x64 + {8CF3BD19-28B1-435D-B719-E00B052DFC3A}.Shared|x86.ActiveCfg = Shared|Win32 + {8CF3BD19-28B1-435D-B719-E00B052DFC3A}.Shared|x86.Build.0 = Shared|Win32 + {8CF3BD19-28B1-435D-B719-E00B052DFC3A}.Static|x64.ActiveCfg = Static|x64 + {8CF3BD19-28B1-435D-B719-E00B052DFC3A}.Static|x64.Build.0 = Static|x64 + {8CF3BD19-28B1-435D-B719-E00B052DFC3A}.Static|x86.ActiveCfg = Static|Win32 + {8CF3BD19-28B1-435D-B719-E00B052DFC3A}.Static|x86.Build.0 = Static|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/hashset/hashset.vcxproj b/hashset/hashset.vcxproj index f39d009..89f1db0 100644 --- a/hashset/hashset.vcxproj +++ b/hashset/hashset.vcxproj @@ -5,16 +5,24 @@ Debug Win32 - - Release + + Shared + Win32 + + + Shared + x64 + + + Static Win32 Debug x64 - - Release + + Static x64 @@ -41,7 +49,14 @@ v142 Unicode - + + Application + false + v142 + true + Unicode + + Application false v142 @@ -54,7 +69,14 @@ v142 Unicode - + + Application + false + v142 + true + Unicode + + Application false v142 @@ -69,13 +91,19 @@ - + + + + - + + + + @@ -84,7 +112,12 @@ $(SolutionDir)\bin\$(Platform)\$(Configuration)\ $(ProjectDir)\obj\$(Platform)\$(Configuration)\ - + + false + $(SolutionDir)\bin\$(Platform)\$(Configuration)\ + $(ProjectDir)\obj\$(Platform)\$(Configuration)\ + + false $(SolutionDir)\bin\$(Platform)\$(Configuration)\ $(ProjectDir)\obj\$(Platform)\$(Configuration)\ @@ -94,7 +127,12 @@ $(SolutionDir)\bin\$(Platform)\$(Configuration)\ $(ProjectDir)\obj\$(Platform)\$(Configuration)\ - + + false + $(SolutionDir)\bin\$(Platform)\$(Configuration)\ + $(ProjectDir)\obj\$(Platform)\$(Configuration)\ + + false $(SolutionDir)\bin\$(Platform)\$(Configuration)\ $(ProjectDir)\obj\$(Platform)\$(Configuration)\ @@ -114,7 +152,7 @@ 5.1 - + Level4 true @@ -145,6 +183,37 @@ delayimp.lib;%(AdditionalDependencies) + + + Level4 + true + true + false + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + AnySuitable + true + MultiThreadedDLL + false + StreamingSIMDExtensions + false + MaxSpeed + Speed + true + $(SolutionDir)\libhashset\include + + + Console + true + true + false + UseLinkTimeCodeGeneration + 5.1 + true + advapi32.dll + delayimp.lib;%(AdditionalDependencies) + + Level3 @@ -159,7 +228,7 @@ 5.2 - + Level4 true @@ -188,6 +257,35 @@ delayimp.lib;%(AdditionalDependencies) + + + Level4 + true + true + false + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + AnySuitable + true + MultiThreadedDLL + false + false + MaxSpeed + Speed + true + $(SolutionDir)\libhashset\include + + + Console + true + true + false + UseLinkTimeCodeGeneration + 5.2 + advapi32.dll + delayimp.lib;%(AdditionalDependencies) + + diff --git a/hashset/src/main.c b/hashset/src/main.c index 6d26c5b..6c5a38b 100644 --- a/hashset/src/main.c +++ b/hashset/src/main.c @@ -61,11 +61,11 @@ static INLINE uint64_t random_next(random_t *const rnd) return rnd->buffer[rnd->offset++]; } -#define PRINT_SET_INFO() do \ +#define PRINT_SET_INFO(X) do \ {\ if (!hash_set_info(hash_set, &capacity, &valid, &deleted, &limit)) \ { \ - printf("capacity: %010zu, valid: %010zu, deleted: %010zu, limit: %010zu\n", capacity, valid, deleted, limit); \ + printf("[#%d] capacity: %010zu, valid: %010zu, deleted: %010zu, limit: %010zu\n", (X), capacity, valid, deleted, limit); \ } \ } \ while(0) @@ -93,7 +93,7 @@ static int test_function_1(hash_set_t *const hash_set) return EXIT_FAILURE; } } - PRINT_SET_INFO(); + PRINT_SET_INFO(1); } if (hash_set_size(hash_set) != MAXIMUM - 4U) @@ -142,7 +142,7 @@ static int test_function_1(hash_set_t *const hash_set) return EXIT_FAILURE; } } - PRINT_SET_INFO(); + PRINT_SET_INFO(1); } if (hash_set_size(hash_set) != 1U) @@ -179,8 +179,8 @@ static int test_function_1(hash_set_t *const hash_set) return EXIT_FAILURE; } - PRINT_SET_INFO(); - puts("--------"); + PRINT_SET_INFO(1); + puts("---------"); } return EXIT_SUCCESS; @@ -225,7 +225,7 @@ static int test_function_2(hash_set_t *const hash_set) printf("Insert operation has failed! (error: %d)\n", error); return EXIT_FAILURE; } - PRINT_SET_INFO(); + PRINT_SET_INFO(2); } } while (!hash_set_iterate(hash_set, &offset, &value)) @@ -246,7 +246,7 @@ static int test_function_2(hash_set_t *const hash_set) printf("Remove operation has failed! (error: %d)\n", error); return EXIT_FAILURE; } - PRINT_SET_INFO(); + PRINT_SET_INFO(2); test[j] = UINT8_C(0); } } @@ -257,8 +257,8 @@ static int test_function_2(hash_set_t *const hash_set) } } - PRINT_SET_INFO(); - puts("--------"); + PRINT_SET_INFO(2); + puts("---------"); return EXIT_SUCCESS; } @@ -289,7 +289,7 @@ static int test_function_3(hash_set_t *const hash_set) } else { - PRINT_SET_INFO(); + PRINT_SET_INFO(3); printf("Collision detected! [%016llX]\n", rnd); break; } @@ -299,13 +299,13 @@ static int test_function_3(hash_set_t *const hash_set) const clock_t clock_now = clock(); if ((clock_now < last_update) || (clock_now >= last_update + CLOCKS_PER_SEC)) { - PRINT_SET_INFO(); + PRINT_SET_INFO(3); last_update = clock_now; } } } - PRINT_SET_INFO(); + PRINT_SET_INFO(3); if (hash_set_clear(hash_set)) { @@ -313,8 +313,8 @@ static int test_function_3(hash_set_t *const hash_set) return EXIT_FAILURE; } - PRINT_SET_INFO(); - puts("--------"); + PRINT_SET_INFO(3); + puts("---------"); return EXIT_SUCCESS; } @@ -334,7 +334,7 @@ static int test_function_4(hash_set_t *const hash_set) const errno_t error = hash_set_insert(hash_set, value); if (error) { - PRINT_SET_INFO(); + PRINT_SET_INFO(4); printf("Insert operation has failed! (error: %d)\n", error); return EXIT_FAILURE; } @@ -343,7 +343,7 @@ static int test_function_4(hash_set_t *const hash_set) const clock_t clock_now = clock(); if ((clock_now < last_update) || (clock_now >= last_update + CLOCKS_PER_SEC)) { - PRINT_SET_INFO(); + PRINT_SET_INFO(4); last_update = clock_now; } } @@ -354,7 +354,7 @@ static int test_function_4(hash_set_t *const hash_set) const errno_t error = hash_set_remove(hash_set, value); if (error) { - PRINT_SET_INFO(); + PRINT_SET_INFO(4); printf("Remove operation has failed! (error: %d)\n", error); return EXIT_FAILURE; } @@ -363,21 +363,20 @@ static int test_function_4(hash_set_t *const hash_set) const clock_t clock_now = clock(); if ((clock_now < last_update) || (clock_now >= last_update + CLOCKS_PER_SEC)) { - PRINT_SET_INFO(); + PRINT_SET_INFO(4); last_update = clock_now; } } } - PRINT_SET_INFO(); - if (hash_set_size(hash_set) != 0U) { puts("Invalid size!"); return EXIT_FAILURE; } - puts("--------"); + PRINT_SET_INFO(4); + puts("---------"); return EXIT_SUCCESS; } diff --git a/libhashset/include/hash_set.h b/libhashset/include/hash_set.h index 93e265a..449c943 100644 --- a/libhashset/include/hash_set.h +++ b/libhashset/include/hash_set.h @@ -3,35 +3,44 @@ /* This work has been released under the CC0 1.0 Universal license! */ /******************************************************************************/ -#ifndef _HASHSET_INCLUDED -#define _HASHSET_INCLUDED +#ifndef _LIBHASHSET_INCLUDED +#define _LIBHASHSET_INCLUDED #include #include +#if defined(_MSC_VER) && defined(_DLL) +# ifdef _LIBHASHSET_EXPORTS +# define HASHSET_API extern __declspec(dllexport) +# else +# define HASHSET_API extern __declspec(dllimport) +# endif +#else +# define HASHSET_API extern +#endif + #ifdef __cplusplus extern "C" { #endif #if !defined(_MSC_VER) && !defined(__MINGW32__) && !defined(_ERRNO_T_DEFINED) typedef int errno_t; -#define _ERRNO_T_DEFINED 1 #endif struct _hash_set; typedef struct _hash_set hash_set_t; -hash_set_t *hash_set_create(const size_t initial_capacity, const double load_factor); -void hash_set_destroy(hash_set_t *const instance); +HASHSET_API hash_set_t *hash_set_create(const size_t initial_capacity, const double load_factor); +HASHSET_API void hash_set_destroy(hash_set_t *const instance); -errno_t hash_set_insert(hash_set_t *const instance, const uint64_t value); -errno_t hash_set_remove(hash_set_t *const instance, const uint64_t value); -errno_t hash_set_clear(hash_set_t *const instance); +HASHSET_API errno_t hash_set_insert(hash_set_t *const instance, const uint64_t value); +HASHSET_API errno_t hash_set_remove(hash_set_t *const instance, const uint64_t value); +HASHSET_API errno_t hash_set_clear(hash_set_t *const instance); -errno_t hash_set_contains(const hash_set_t *const instance, const uint64_t value); -errno_t hash_set_iterate(const hash_set_t *const instance, size_t *const offset, uint64_t *const value); -size_t hash_set_size(const hash_set_t *const instance); -errno_t hash_set_info(const hash_set_t *const instance, size_t *const capacity, size_t *const valid, size_t *const deleted, size_t *const limit); +HASHSET_API errno_t hash_set_contains(const hash_set_t *const instance, const uint64_t value); +HASHSET_API errno_t hash_set_iterate(const hash_set_t *const instance, size_t *const offset, uint64_t *const value); +HASHSET_API size_t hash_set_size(const hash_set_t *const instance); +HASHSET_API errno_t hash_set_info(const hash_set_t *const instance, size_t *const capacity, size_t *const valid, size_t *const deleted, size_t *const limit); #ifdef __cplusplus } diff --git a/libhashset/libhashset.vcxproj b/libhashset/libhashset.vcxproj index dff899b..bdd8da4 100644 --- a/libhashset/libhashset.vcxproj +++ b/libhashset/libhashset.vcxproj @@ -5,16 +5,24 @@ Debug Win32 - - Release + + Shared + Win32 + + + Shared + x64 + + + Static Win32 Debug x64 - - Release + + Static x64 @@ -38,26 +46,40 @@ v142 Unicode - + StaticLibrary false v142 true Unicode + + DynamicLibrary + false + v142 + true + Unicode + StaticLibrary true v142 Unicode - + StaticLibrary false v142 true Unicode + + DynamicLibrary + false + v142 + true + Unicode + @@ -66,13 +88,19 @@ - + + + + - + + + + @@ -82,24 +110,36 @@ $(ProjectDir)\obj\$(Platform)\$(Configuration)\ libhashset-1.$(PlatformToolset).$(PlatformTarget).debug - + false $(SolutionDir)\bin\$(Platform)\$(Configuration)\ $(ProjectDir)\obj\$(Platform)\$(Configuration)\ libhashset-1.$(PlatformToolset).$(PlatformTarget) + + false + $(SolutionDir)\bin\$(Platform)\$(Configuration)\ + $(ProjectDir)\obj\$(Platform)\$(Configuration)\ + libhashset-1.$(PlatformTarget) + true $(SolutionDir)\bin\$(Platform)\$(Configuration)\ $(ProjectDir)\obj\$(Platform)\$(Configuration)\ libhashset-1.$(PlatformToolset).$(PlatformTarget).debug - + false $(SolutionDir)\bin\$(Platform)\$(Configuration)\ $(ProjectDir)\obj\$(Platform)\$(Configuration)\ libhashset-1.$(PlatformToolset).$(PlatformTarget) + + false + $(SolutionDir)\bin\$(Platform)\$(Configuration)\ + $(ProjectDir)\obj\$(Platform)\$(Configuration)\ + libhashset-1.$(PlatformTarget) + Level3 @@ -115,7 +155,7 @@ true - + Level3 true @@ -146,6 +186,38 @@ true + + + Level3 + true + true + false + true + NotUsing + MaxSpeed + AnySuitable + Speed + true + true + MultiThreadedDLL + false + false + StreamingSIMDExtensions + $(ProjectDir)\include + WIN32;NDEBUG;_DLL;_LIBHASHSET_EXPORTS;%(PreprocessorDefinitions) + + + Console + true + true + false + UseLinkTimeCodeGeneration + 5.1 + + + true + + Level3 @@ -161,7 +233,7 @@ true - + Level3 true @@ -191,6 +263,37 @@ true + + + Level3 + true + true + false + NDEBUG;_DLL;_LIBHASHSET_EXPORTS;%(PreprocessorDefinitions) + true + NotUsing + MaxSpeed + AnySuitable + Speed + true + true + MultiThreadedDLL + false + false + $(ProjectDir)\include + + + Console + true + true + false + UseLinkTimeCodeGeneration + 5.2 + + + true + +