[PATCH] D13413: Use MSVC-equivalents of attributes

angelsl via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 5 09:47:37 PDT 2015


angelsl updated this revision to Diff 36526.
angelsl added a comment.

Corrections made.

Didn't know that attributes could go before the declaration.


http://reviews.llvm.org/D13413

Files:
  lib/builtins/extendhfsf2.c
  lib/builtins/int_lib.h
  lib/builtins/int_util.h
  lib/builtins/truncsfhf2.c

Index: lib/builtins/truncsfhf2.c
===================================================================
--- lib/builtins/truncsfhf2.c
+++ lib/builtins/truncsfhf2.c
@@ -13,7 +13,7 @@
 
 // Use a forwarding definition and noinline to implement a poor man's alias,
 // as there isn't a good cross-platform way of defining one.
-COMPILER_RT_ABI __attribute__((noinline)) uint16_t __truncsfhf2(float a) {
+COMPILER_RT_ABI NOINLINE uint16_t __truncsfhf2(float a) {
     return __truncXfYf2__(a);
 }
 
Index: lib/builtins/int_util.h
===================================================================
--- lib/builtins/int_util.h
+++ lib/builtins/int_util.h
@@ -23,12 +23,12 @@
 #define compilerrt_abort() compilerrt_abort_impl(__FILE__, __LINE__, \
                                                  __func__)
 
-void compilerrt_abort_impl(const char *file, int line,
-                           const char *function) __attribute__((noreturn));
+NORETURN void compilerrt_abort_impl(const char *file, int line,
+                           const char *function);
 
 #define COMPILE_TIME_ASSERT(expr) COMPILE_TIME_ASSERT1(expr, __COUNTER__)
 #define COMPILE_TIME_ASSERT1(expr, cnt) COMPILE_TIME_ASSERT2(expr, cnt)
 #define COMPILE_TIME_ASSERT2(expr, cnt) \
-    typedef char ct_assert_##cnt[(expr) ? 1 : -1] __attribute__((unused))
+    typedef char ct_assert_##cnt[(expr) ? 1 : -1] UNUSED
 
 #endif /* INT_UTIL_H */
Index: lib/builtins/int_lib.h
===================================================================
--- lib/builtins/int_lib.h
+++ lib/builtins/int_lib.h
@@ -35,13 +35,23 @@
 # define COMPILER_RT_ABI __attribute__((pcs("aapcs")))
 #else
 # define ARM_EABI_FNALIAS(aeabi_name, name)
-# if defined(__arm__) && defined(_WIN32)
+# if defined(__arm__) && defined(_WIN32) && !defined(_MSC_VER)
 #   define COMPILER_RT_ABI __attribute__((pcs("aapcs")))
 # else
 #   define COMPILER_RT_ABI
 # endif
 #endif
 
+#ifdef _MSC_VER
+#define NOINLINE __declspec(noinline)
+#define NORETURN __declspec(noreturn)
+#define UNUSED
+#else
+#define NOINLINE __attribute__((noinline))
+#define NORETURN __attribute__((noreturn))
+#define UNUSED __attribute__((unused))
+#endif
+
 #if defined(__NetBSD__) && (defined(_KERNEL) || defined(_STANDALONE))
 /*
  * Kernel and boot environment can't use normal headers,
Index: lib/builtins/extendhfsf2.c
===================================================================
--- lib/builtins/extendhfsf2.c
+++ lib/builtins/extendhfsf2.c
@@ -14,7 +14,7 @@
 
 // Use a forwarding definition and noinline to implement a poor man's alias,
 // as there isn't a good cross-platform way of defining one.
-COMPILER_RT_ABI __attribute__((noinline)) float __extendhfsf2(uint16_t a) {
+COMPILER_RT_ABI NOINLINE float __extendhfsf2(uint16_t a) {
     return __extendXfYf2__(a);
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D13413.36526.patch
Type: text/x-patch
Size: 2789 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151005/c802d31d/attachment.bin>


More information about the llvm-commits mailing list