Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This commit enables msgpack to be compiled as a part of Windows Driver. MSVC automatically creates macro
_KERNEL_MODE
when source code is compiled with/kernel
switch (this compiler switch is turned on when driver is compiled).Changes:
msgpack_object_print
andmsgpack_object_bin_print
are disabled, because there is noprintf
in kernel modemsgpack_object_print
andmsgpack_object_bin_print
are moved so they are together (so that one#if !defined(...)
can wrap them)size_t
toint
to disable compiler warning4204
is disabled when compiling with MSVC_msgpack_atomic_counter_header
is set to<ntddk.h>
if_KERNEL_MODE
is defined (it contains prototypes forInterlockedIncrement
andInterlockedDecrement
)TRUE
andFALSE
macros are disabled if_KERNEL_MODE
is defined (they are defined unconditionally in<ntddk.h>
)assert
is redefined toNT_ASSERT
(assert specific to Windows Drivers)_NO_CRT_STDIO_INLINE
is unconditionally defined (it makes_snprintf
symbol to be imported from ntoskrnl.exe)snprintf
is redefined to_snprintf
(because ntoskrnl.exe does not exportsnprintf
, only_snprintf
, but they have same behavior)NOTE: After these changes, linker still complains that symbols
malloc
,realloc
andfree
can't be found. The cleanest solution would be to provide interface for setting custom allocators. Nonetheless, simply creating custom version of these functions resolves that problem too.