[前][次][番号順一覧][スレッド一覧]

ruby-changes:49726

From: shyouhei <ko1@a...>
Date: Mon, 15 Jan 2018 15:48:04 +0900 (JST)
Subject: [ruby-changes:49726] shyouhei:r61843 (trunk): take alignof instead of sizeof

shyouhei	2018-01-15 15:47:56 +0900 (Mon, 15 Jan 2018)

  New Revision: 61843

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=61843

  Log:
    take alignof instead of sizeof
    
    win32ole.c includes ALLOCA_N(struct myCPINFOEX, 1).  On such case
    it is not a wise idea to align to the size of that struct.

  Modified files:
    trunk/include/ruby/ruby.h
Index: include/ruby/ruby.h
===================================================================
--- include/ruby/ruby.h	(revision 61842)
+++ include/ruby/ruby.h	(revision 61843)
@@ -1603,12 +1603,12 @@ rb_num2char_inline(VALUE x) https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L1603
 # undef HAVE_BUILTIN___BUILTIN_ALLOCA_WITH_ALIGN
 #endif
 
-#ifdef HAVE_BUILTIN___BUILTIN_ALLOCA_WITH_ALIGN
+#if defined(HAVE_BUILTIN___BUILTIN_ALLOCA_WITH_ALIGN) && defined(RUBY_ALIGNOF)
 /* I don't know why but __builtin_alloca_with_align's second argument
    takes bits rather than bytes. */
 #define ALLOCA_N(type, n) \
     (type*)__builtin_alloca_with_align((sizeof(type)*(n)), \
-        sizeof(type) * CHAR_BIT)
+        RUBY_ALIGNOF(type) * CHAR_BIT)
 #else
 #define ALLOCA_N(type,n) ((type*)alloca(sizeof(type)*(n)))
 #endif

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]