diff --git a/sdk/lib/crt/crt.cmake b/sdk/lib/crt/crt.cmake index a6a7e5dc137..144a6000976 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 00000000000..56550073af8 --- /dev/null +++ b/sdk/lib/crt/stdlib/clang-alias.s @@ -0,0 +1,22 @@ +#include + +.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 7637a5e9b6d..3c4b613a3a6 100644 --- a/sdk/lib/crt/stdlib/rot.c +++ b/sdk/lib/crt/stdlib/rot.c @@ -10,11 +10,18 @@ #include -#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 */