ruby-changes:60788
From: =E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3 <ko1@a...>
Date: Thu, 16 Apr 2020 14:22:44 +0900 (JST)
Subject: [ruby-changes:60788] 48273534c7 (master): Support for FreeBSD <sys/cdefs.h>
https://git.ruby-lang.org/ruby.git/commit/?id=48273534c7 From 48273534c7aa6552c9155366a39f54ce10653c5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3?= <shyouhei@r...> Date: Thu, 16 Apr 2020 14:17:15 +0900 Subject: Support for FreeBSD <sys/cdefs.h> FreeBSD's <sys/cdefs.h> is broken. Cygwin is also affected by that. We need to avoid using them. See also: https://github.com/freebsd/freebsd/commit/d1c67819db000c02d3a9c79f3651c10aeedad1a0 https://sourceware.org/git/?p=newlib-cygwin.git;a=commit;f=newlib/libc/include/sys/cdefs.h;h=44d6d53977e6bc82c2b1e6dbe8ae7f310b260604 diff --git a/include/ruby/3/has/attribute.h b/include/ruby/3/has/attribute.h index 14c4ff5..39ce321 100644 --- a/include/ruby/3/has/attribute.h +++ b/include/ruby/3/has/attribute.h @@ -24,8 +24,18 @@ https://github.com/ruby/ruby/blob/trunk/include/ruby/3/has/attribute.h#L24 #include "ruby/3/compiler_since.h" #include "ruby/3/token_paste.h" +#ifndef __has_attribute +# /* Don't bother. */ +#elif RUBY3_COMPILER_IS(GCC) && ! __has_attribute(pure) +# /* FreeBSD's <sys/cdefs.h> defines its own *broken* version of +# * __has_attribute. Cygwin copied that content to be a victim of the broken- +# * ness. We don't take them into account. */ +#else +# define RUBY3_HAVE___HAS_ATTRIBUTE 1 +#endif + /** Wraps (or simulates) `__has_attribute`. */ -#if defined(__has_attribute) +#if defined(RUBY3_HAVE___HAS_ATTRIBUTE) # define RUBY3_HAS_ATTRIBUTE(_) __has_attribute(_) #elif RUBY3_COMPILER_IS(GCC) diff --git a/include/ruby/3/has/builtin.h b/include/ruby/3/has/builtin.h index 92a528d..cce6435 100644 --- a/include/ruby/3/has/builtin.h +++ b/include/ruby/3/has/builtin.h @@ -24,11 +24,22 @@ https://github.com/ruby/ruby/blob/trunk/include/ruby/3/has/builtin.h#L24 #include "ruby/3/compiler_since.h" #include "ruby/3/token_paste.h" -/** Wraps (or simulates) `__has_builtin`. */ -#if defined(__has_builtin) && ! RUBY3_COMPILER_IS(Intel) +#ifndef __has_builtin +# /* Don't bother. */ +#elif RUBY3_COMPILER_IS(Intel) # /* :TODO: Intel C Compiler has __has_builtin (since 19.1 maybe?), and is # * reportedly broken. We have to skip them. However the situation can # * change. They might improve someday. We need to revisit here later. */ +#elif RUBY3_COMPILER_IS(GCC) && ! __has_builtin(__builtin_alloca) +# /* FreeBSD's <sys/cdefs.h> defines its own *broken* version of __has_builtin. +# * Cygwin copied that content to be a victim of the broken-ness. We don't +# * take them into account. */ +#else +# define RUBY3_HAVE___HAS_BUILTIN 1 +#endif + +/** Wraps (or simulates) `__has_builtin`. */ +#if defined(RUBY3_HAVE___HAS_BUILTIN) # define RUBY3_HAS_BUILTIN(_) __has_builtin(_) #elif RUBY3_COMPILER_IS(GCC) -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/