Fixed windows linking

This commit is contained in:
WolverinDEV 2019-07-06 22:31:50 +02:00
parent 542ffdc62c
commit cab68d412f
3 changed files with 36 additions and 10 deletions

4
.build_win32_amd64.txt Normal file
View File

@ -0,0 +1,4 @@
1
success
542ffdc62c3efd2f659a1c14f3a15fe54c83e643
06 Jul 2019 22:26:45

View File

@ -26,6 +26,19 @@ else()
set(SOURCE ${SOURCE} src/sha512.c)
endif()
if (MSVC)
set(CompilerFlags
CMAKE_CXX_FLAGS
CMAKE_CXX_FLAGS_DEBUG
CMAKE_CXX_FLAGS_RELEASE
CMAKE_C_FLAGS
CMAKE_C_FLAGS_DEBUG
CMAKE_C_FLAGS_RELEASE
)
foreach(CompilerFlag ${CompilerFlags})
string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}")
endforeach()
endif()
#Some programs need for full support the header files too
set(HEADERS
include/ed25519.h

View File

@ -13,25 +13,34 @@ typedef struct sha512_functions_ {
int(*_ed_sha512_update)(sha512_context*, const unsigned char *, size_t);
} sha512_functions;
#ifdef __cplusplus
extern "C" {
#endif
#ifdef WIN32
__declspec(dllexport)
#endif
extern sha512_functions _ed_sha512_functions;
#ifdef __cplusplus
}
#endif
inline void _ed_sha512_validate() {
assert(_ed_sha512_functions._ed_sha512_init);
assert(_ed_sha512_functions._ed_sha512_final);
assert(_ed_sha512_functions._ed_sha512_update);
assert(_ed_sha512_functions._ed_sha512_init);
assert(_ed_sha512_functions._ed_sha512_final);
assert(_ed_sha512_functions._ed_sha512_update);
}
inline int _ed_sha512(const unsigned char *message, size_t message_len, unsigned char *out) {
_ed_sha512_validate();
_ed_sha512_validate();
int result = 1;
sha512_context ctx;
result &= _ed_sha512_functions._ed_sha512_init(&ctx);
result &= _ed_sha512_functions._ed_sha512_update(&ctx, message, message_len);
result &= _ed_sha512_functions._ed_sha512_final(&ctx, out);
return result;
int result = 1;
sha512_context ctx;
result &= _ed_sha512_functions._ed_sha512_init(&ctx);
result &= _ed_sha512_functions._ed_sha512_update(&ctx, message, message_len);
result &= _ed_sha512_functions._ed_sha512_final(&ctx, out);
return result;
}
#endif