Skip to content

Commit

Permalink
Fix x86 override logic. (#102)
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronRobinsonMSFT committed Dec 9, 2021
1 parent 52edb71 commit d48209b
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/platform/platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,12 +283,19 @@ DNNE_API void DNNE_CALLTYPE set_failure_callback(failure_fn cb)

// Provide mechanism for users to override default behavior of certain functions.
// - See https://stackoverflow.com/questions/51656838/attribute-weak-and-static-libraries
// - See https://devblogs.microsoft.com/oldnewthing/20200731-00/?p=104024
// - Use the MSC macro to enable Windows builds without MSVC.
#ifdef _MSC_VER
#define DNNE_DEFAULT_IMPL(methodName, ...) default_ ## methodName(__VA_ARGS__)

// List of overridable APIs
#pragma comment(linker, "/alternatename:dnne_abort=default_dnne_abort")
// Note the default calling convention is cdecl on x86 for DNNE_APIs.
// This means, on x86, we mangle the alternative name in the linker command.
#ifdef _M_IX86
#pragma comment(linker, "/alternatename:_dnne_abort=_default_dnne_abort")
#else
#pragma comment(linker, "/alternatename:dnne_abort=default_dnne_abort")
#endif
#else
#define DNNE_DEFAULT_IMPL(methodName, ...) __attribute__((weak)) methodName(__VA_ARGS__)
#endif
Expand Down

0 comments on commit d48209b

Please sign in to comment.