diff --git a/kernels/prim_ops/register_prim_ops.cpp b/kernels/prim_ops/register_prim_ops.cpp index 323c372f73a..7872b0d173f 100644 --- a/kernels/prim_ops/register_prim_ops.cpp +++ b/kernels/prim_ops/register_prim_ops.cpp @@ -148,7 +148,7 @@ static Kernel prim_ops[] = { EValue& out = *stack[2]; if (a.isInt() && b.isInt()) { const int64_t quot = a.toInt() / b.toInt(); - if (std::signbit(a.toInt()) == std::signbit(b.toInt())) { + if ((a.toInt() < 0) == (b.toInt() < 0)) { out = EValue(quot); return; } diff --git a/runtime/executor/program.cpp b/runtime/executor/program.cpp index 0a15b0d0f7f..a4c81e7ea55 100644 --- a/runtime/executor/program.cpp +++ b/runtime/executor/program.cpp @@ -27,8 +27,6 @@ #define ET_ENABLE_PROGRAM_VERIFICATION 1 #endif -#pragma clang diagnostic ignored "-Wshadow" - namespace executorch { namespace runtime { diff --git a/runtime/platform/compiler.h b/runtime/platform/compiler.h index 2ef2c62e4b4..bc07470387a 100644 --- a/runtime/platform/compiler.h +++ b/runtime/platform/compiler.h @@ -36,7 +36,7 @@ #error "You need C++17 to compile ExecuTorch" #endif -#if defined(_WIN32) && (defined(min) || defined(max)) +#if defined(_MSC_VER) && (defined(min) || defined(max)) #error \ "Macro clash with min and max -- define NOMINMAX when compiling your program on Windows" #endif @@ -100,22 +100,38 @@ #endif // (__cplusplus) >= 202002L /// Define a C symbol with weak linkage. +#ifdef _MSC_VER +// There currently doesn't seem to be a great way to do this in Windows and +// given that weak linkage is not really critical on Windows, we'll just leave +// it as a stub. +#define ET_WEAK +#else #define ET_WEAK __attribute__((weak)) +#endif /** * Annotation marking a function as printf-like, providing compiler support * for format string argument checking. */ +#ifdef _MSC_VER +#include +#define ET_PRINTFLIKE(_string_index, _va_index) _Printf_format_string_ +#else #define ET_PRINTFLIKE(_string_index, _va_index) \ __attribute__((format(printf, _string_index, _va_index))) - -/// Name of the source file without a directory string. -#define ET_SHORT_FILENAME (__builtin_strrchr("/" __FILE__, '/') + 1) +#endif #ifndef __has_builtin #define __has_builtin(x) (0) #endif +#if __has_builtin(__builtin_strrchr) +/// Name of the source file without a directory string. +#define ET_SHORT_FILENAME (__builtin_strrchr("/" __FILE__, '/') + 1) +#else +#define ET_SHORT_FILENAME __FILE__ +#endif + #if __has_builtin(__builtin_LINE) /// Current line as an integer. #define ET_LINE __builtin_LINE() @@ -141,7 +157,7 @@ #endif // ifndef // Define size_t and ssize_t. -#ifndef _WIN32 +#ifndef _MSC_VER #include #else #include