Skip to content

1.fix error on build msgpack with UE4#779

Merged
redboltz merged 2 commits intomsgpack:masterfrom
RPG3D:master
May 5, 2019
Merged

1.fix error on build msgpack with UE4#779
redboltz merged 2 commits intomsgpack:masterfrom
RPG3D:master

Conversation

@RPG3D
Copy link
Copy Markdown
Contributor

@RPG3D RPG3D commented May 2, 2019

No description provided.

# define _msgpack_sync_decr_and_fetch(ptr) InterlockedDecrement(ptr)
# define _msgpack_sync_incr_and_fetch(ptr) InterlockedIncrement(ptr)
# define _msgpack_sync_decr_and_fetch(ptr) _InterlockedDecrement(ptr)
# define _msgpack_sync_incr_and_fetch(ptr) _InterlockedIncrement(ptr)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the difference between InterlockedDecrement and _InterlockedDecrement ?
It seems that both function exists.

I don't know much about Windows APIs. I'd like to know _InterlockedDecrement is always better choice than InterlockedDecrement.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the difference between InterlockedDecrement and _InterlockedDecrement ?
It seems that both function exists.
I don't know much about Windows APIs. I'd like to know _InterlockedDecrement is always better choice than InterlockedDecrement.

https://docs.microsoft.com/en-us/previous-versions/ms919120(v=msdn.10)
https://docs.microsoft.com/en-us/cpp/intrinsics/interlockeddecrement-intrinsic-functions?view=vs-2019

seamed InterlockedDecrement is for Windows CE

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. It seems that the code should be as follows:

#if WINCE /* Some how get WinCE or Not */
#   define _msgpack_sync_decr_and_fetch(ptr) InterlockedDecrement(ptr)
#   define _msgpack_sync_incr_and_fetch(ptr) InterlockedIncrement(ptr)
#else  /* WINCE */
#   define _msgpack_sync_decr_and_fetch(ptr) _InterlockedDecrement(ptr)
#   define _msgpack_sync_incr_and_fetch(ptr) _InterlockedIncrement(ptr)
#endif  /* WINCE */

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

InterlockedDecrement and its friends are Win32 API so it is available on any Desktop Windows and UWP as well: https://docs.microsoft.com/en-us/windows/desktop/api/winnt/nf-winnt-interlockeddecrement it IS available Windows other than WinCE, but NOT x64.

_InterlockedDecrement and its friends are compiler intrinsic, which is always available on modern Windows platforms(x86, x64 and ARM32). So I guess it is okay to just ignore WinCE here as it is almost being obsolete.

In case we need some completeness here, check against x64 (and ARM) then use _InterlockedDecrement only on there.

ref: https://github.com/ivmai/libatomic_ops/blob/347d9784ec721e78fb6111cceac6847728b361d4/src/atomic_ops.h#L387

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@okuoku, thank you for the comment. @RPG3D, could you update the PR?

Copy link
Copy Markdown
Contributor Author

@RPG3D RPG3D May 4, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@redboltz check the code again

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RPG3D, it looks good to me. Thank you for updating!

@redboltz redboltz merged commit ce088e7 into msgpack:master May 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants