https://git.reactos.org/?p=reactos.git;a=commitdiff;h=dc77e7d37904fc9f31703…
commit dc77e7d37904fc9f3170379481fa2ff185e7d555
Author: Timo Kreuzer <timo.kreuzer(a)reactos.org>
AuthorDate: Sun Feb 3 23:36:49 2019 +0100
Commit: Timo Kreuzer <timo.kreuzer(a)reactos.org>
CommitDate: Tue Feb 12 19:31:33 2019 +0100
[CRT] Use alias names for rot functions when compiling with Clang-CL
Clang-CL does not support #pragma function like CL. The alternative to this approach
is to disable all intrinsics for this single source file, but that is not trivial to do,
as it can only be done by removing a compiler switch, which we have no CMake support for.
Therefore this solution is simpler and as good.
---
sdk/lib/crt/crt.cmake | 4 ++++
sdk/lib/crt/stdlib/clang-alias.s | 22 ++++++++++++++++++++++
sdk/lib/crt/stdlib/rot.c | 10 ++++++++--
3 files changed, 34 insertions(+), 2 deletions(-)
diff --git a/sdk/lib/crt/crt.cmake b/sdk/lib/crt/crt.cmake
index a6a7e5dc13..144a600097 100644
--- a/sdk/lib/crt/crt.cmake
+++ b/sdk/lib/crt/crt.cmake
@@ -441,6 +441,10 @@ if(ARCH STREQUAL "i386")
list(APPEND CRT_ASM_SOURCE
except/i386/cpp.s)
endif()
+ if(USE_CLANG_CL)
+ list(APPEND CRT_ASM_SOURCE
+ stdlib/clang-alias.s)
+ endif()
elseif(ARCH STREQUAL "amd64")
list(APPEND CRT_ASM_SOURCE
except/amd64/seh.s
diff --git a/sdk/lib/crt/stdlib/clang-alias.s b/sdk/lib/crt/stdlib/clang-alias.s
new file mode 100644
index 0000000000..56550073af
--- /dev/null
+++ b/sdk/lib/crt/stdlib/clang-alias.s
@@ -0,0 +1,22 @@
+#include <asm.inc>
+
+.code
+
+MACRO(DEFINE_ALIAS, alias, orig, type)
+EXTERN &orig:&type
+ALIAS <&alias> = <&orig>
+ENDM
+
+#ifdef _M_X64
+DEFINE_ALIAS _rotl, __function_rotl
+DEFINE_ALIAS _rotr, __function_rotr
+DEFINE_ALIAS _lrotl, __function_lrotl
+DEFINE_ALIAS _lrotr, __function_lrotr
+#else
+DEFINE_ALIAS __rotl, ___function_rotl
+DEFINE_ALIAS __rotr, ___function_rotr
+DEFINE_ALIAS __lrotl, ___function_lrotl
+DEFINE_ALIAS __lrotr, ___function_lrotr
+#endif
+
+END
diff --git a/sdk/lib/crt/stdlib/rot.c b/sdk/lib/crt/stdlib/rot.c
index 7637a5e9b6..3c4b613a3a 100644
--- a/sdk/lib/crt/stdlib/rot.c
+++ b/sdk/lib/crt/stdlib/rot.c
@@ -10,11 +10,18 @@
#include <stdlib.h>
-#ifdef _MSC_VER
+#ifdef __clang__
+#define _rotl __function_rotl
+#define _rotr __function_rotr
+#define _lrotl __function_lrotl
+#define _lrotr __function_lrotr
+#elif defined(_MSC_VER)
#pragma function(_rotr, _rotl, _rotr, _lrotl, _lrotr)
#endif
unsigned int _rotr( unsigned int value, int shift );
+unsigned long _lrotr(unsigned long value, int shift);
+
/*
* @implemented
*/
@@ -43,7 +50,6 @@ unsigned int _rotr( unsigned int value, int shift )
return (value >> shift) | (value << (max_bits-shift));
}
-
/*
* @implemented
*/