Skip to content

Commit 50ae750

Browse files
committed
use _Static_assert with clang
* gc.c (__has_feature): move into internal.h. * internal.h (__has_feature): ditto. * internal.h (__has_extension): new macro. * internal.h (STATIC_ASSERT): use _Static_assert with clang. [ruby-core:69931] [Bug ruby#11343] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51242 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent 0641e1f commit 50ae750

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

ChangeLog

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
Wed Jul 15 00:03:36 2015 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
2+
3+
* gc.c (__has_feature): move into internal.h.
4+
5+
* internal.h (__has_feature): ditto.
6+
7+
* internal.h (__has_extension): new macro.
8+
9+
* internal.h (STATIC_ASSERT): use _Static_assert with
10+
clang. [ruby-core:69931] [Bug #11343]
11+
112
Wed Jul 15 00:00:00 2015 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
213

314
* random.c (fill_random_bytes_syscall): fix compile error with

gc.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,6 @@
3535

3636
#undef rb_data_object_wrap
3737

38-
#ifndef __has_feature
39-
# define __has_feature(x) 0
40-
#endif
41-
4238
#ifndef HAVE_MALLOC_USABLE_SIZE
4339
# ifdef _WIN32
4440
# define HAVE_MALLOC_USABLE_SIZE

internal.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,15 @@ extern "C" {
7373
(__GNUC__ == (major) && __GNUC_MINOR__ > (minor)) || \
7474
(__GNUC__ == (major) && __GNUC_MINOR__ == (minor) && __GNUC_PATCHLEVEL__ >= (patchlevel))))
7575

76-
#if GCC_VERSION_SINCE(4, 6, 0)
76+
#ifndef __has_feature
77+
# define __has_feature(x) 0
78+
#endif
79+
80+
#ifndef __has_extension
81+
# define __has_extension __has_feature
82+
#endif
83+
84+
#if GCC_VERSION_SINCE(4, 6, 0) || __has_extension(c_static_assert)
7785
# define STATIC_ASSERT(name, expr) _Static_assert(expr, #name ": " #expr)
7886
#else
7987
# define STATIC_ASSERT(name, expr) typedef int static_assert_##name##_check[1 - 2*!(expr)]

0 commit comments

Comments
 (0)