Added DllMain() function to Windows "shared" library (DLL).
This commit is contained in:
parent
c57fce910e
commit
a1d8935b2b
@ -24,7 +24,7 @@ endif
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(firstword $(filter %-mingw32 %-cygwin,$(DUMPMACHINE))),)
|
ifeq ($(firstword $(filter %-mingw32 %-cygwin,$(DUMPMACHINE))),)
|
||||||
DLL_LDFLAGS = -fPIC -shared
|
DLL_LDFLAGS = -shared
|
||||||
DLL_SUFFIX := .so
|
DLL_SUFFIX := .so
|
||||||
else
|
else
|
||||||
DLL_LDFLAGS = -shared -Wl,--out-implib,$@.a
|
DLL_LDFLAGS = -shared -Wl,--out-implib,$@.a
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
include ../config.mk
|
include ../config.mk
|
||||||
|
|
||||||
CFLAGS = -std=c99 -D_DEFAULT_SOURCE -Wpedantic -Iinclude $(XCFLAGS)
|
CFLAGS = -std=c99 -D_DEFAULT_SOURCE -Wpedantic -Iinclude -fPIC $(XCFLAGS)
|
||||||
|
|
||||||
SRC_PATH := src
|
SRC_PATH := src
|
||||||
OBJ_PATH := obj
|
OBJ_PATH := obj
|
||||||
@ -21,9 +21,9 @@ test: build
|
|||||||
build: $(ALL_PATH) $(LIB_FILE) $(DLL_FILE)
|
build: $(ALL_PATH) $(LIB_FILE) $(DLL_FILE)
|
||||||
|
|
||||||
$(LIB_FILE): $(OBJ_FILE)
|
$(LIB_FILE): $(OBJ_FILE)
|
||||||
$(AR) rcs $@ $^
|
$(AR) rcs $@ $(filter-out $(OBJ_PATH)/dll%,$^)
|
||||||
|
|
||||||
$(DLL_FILE): $(SRC_FILE)
|
$(DLL_FILE): $(OBJ_FILE)
|
||||||
$(CC) $(CFLAGS) $(DLL_LDFLAGS) -o $@ $^
|
$(CC) $(CFLAGS) $(DLL_LDFLAGS) -o $@ $^
|
||||||
|
|
||||||
$(OBJ_FILE):
|
$(OBJ_FILE):
|
||||||
|
@ -46,6 +46,7 @@
|
|||||||
<ClInclude Include="src\generic_hash_set.h" />
|
<ClInclude Include="src\generic_hash_set.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ClCompile Include="src\dll_main.c" />
|
||||||
<ClCompile Include="src\hash_map_16.c" />
|
<ClCompile Include="src\hash_map_16.c" />
|
||||||
<ClCompile Include="src\hash_map_32.c" />
|
<ClCompile Include="src\hash_map_32.c" />
|
||||||
<ClCompile Include="src\hash_map_64.c" />
|
<ClCompile Include="src\hash_map_64.c" />
|
||||||
|
@ -53,5 +53,8 @@
|
|||||||
<ClCompile Include="src\hash_set_16.c">
|
<ClCompile Include="src\hash_set_16.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="src\dll_main.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
29
libhashset/src/dll_main.c
Normal file
29
libhashset/src/dll_main.c
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
/******************************************************************************/
|
||||||
|
/* HashSet for C99, by LoRd_MuldeR <MuldeR2@GMX.de> */
|
||||||
|
/* This work has been released under the CC0 1.0 Universal license! */
|
||||||
|
/******************************************************************************/
|
||||||
|
|
||||||
|
#if defined(_WIN32)
|
||||||
|
|
||||||
|
#define WIN32_LEAN_AND_MEAN 1
|
||||||
|
#include <Windows.h>
|
||||||
|
|
||||||
|
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
|
||||||
|
{
|
||||||
|
switch (ul_reason_for_call)
|
||||||
|
{
|
||||||
|
case DLL_PROCESS_ATTACH:
|
||||||
|
case DLL_THREAD_ATTACH:
|
||||||
|
case DLL_THREAD_DETACH:
|
||||||
|
case DLL_PROCESS_DETACH:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
#elif defined(__GNUC__)
|
||||||
|
|
||||||
|
void __attribute__((constructor)) libhashet_init(void) { /*noop*/ }
|
||||||
|
void __attribute__((destructor)) libhashet_exit(void) { /*noop*/ }
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in New Issue
Block a user