Prefer alignof() over _Alignof()

to allow C++ programs include <ruby.h>. [Bug #14668]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63123 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
shyouhei 2018-04-09 02:40:12 +00:00
parent 784fdba37c
commit 9930481a23
2 changed files with 9 additions and 2 deletions

View File

@ -984,6 +984,7 @@ AC_CHECK_HEADERS(net/socket.h)
AC_CHECK_HEADERS(process.h)
AC_CHECK_HEADERS(pwd.h)
AC_CHECK_HEADERS(setjmpex.h)
AC_CHECK_HEADERS(stdalign.h)
AC_CHECK_HEADERS(sys/attr.h)
AC_CHECK_HEADERS(sys/fcntl.h)
AC_CHECK_HEADERS(sys/file.h)
@ -1279,13 +1280,16 @@ AC_CACHE_CHECK([for alignof() syntax], rb_cv_have_alignof,[
rb_cv_have_alignof=no
RUBY_WERROR_FLAG([
for expr in \
"_Alignof" \
"alignof" \
"_Alignof" \
"__alignof" \
"__alignof__" \
;
do
AC_TRY_COMPILE([],[return (int)$expr(int);],
AC_TRY_COMPILE([
@%:@ifdef HAVE_STDALIGN_H
@%:@include <stdalign.h>
@%:@endif],[return (int)$expr(int);],
[rb_cv_have_alignof="$expr"; break], [])
done
])])

View File

@ -135,6 +135,9 @@ extern "C" {
#ifdef HAVE_STDINT_H
# include <stdint.h>
#endif
#ifdef HAVE_STDALIGN_H
# include <stdalign.h>
#endif
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif