Skip to content

Commit bbe805f

Browse files
committed
internal.h: roomof
* internal.h (roomof): extract from type_roomof, and move from bignum.c. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50986 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent e948296 commit bbe805f

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
Sun Jun 21 20:28:09 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
2+
3+
* internal.h (roomof): extract from type_roomof, and move from
4+
bignum.c.
5+
16
Sun Jun 21 18:32:37 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
27

38
* ruby_atomic.h (ATOMIC_PTR_CAS): define by generic CAS macro, not

bignum.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ STATIC_ASSERT(sizeof_long_and_sizeof_bdigit, SIZEOF_BDIGIT % SIZEOF_LONG == 0);
9898
rb_absint_size(x, NULL))
9999

100100
#define BIGDIVREM_EXTRA_WORDS 1
101-
#define roomof(n, m) ((long)(((n)+(m)-1) / (m)))
102101
#define bdigit_roomof(n) roomof(n, SIZEOF_BDIGIT)
103102
#define BARY_ARGS(ary) ary, numberof(ary)
104103

internal.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,8 @@ struct MEMO {
611611

612612
#define MEMO_NEW(a, b, c) ((struct MEMO *)rb_imemo_new(imemo_memo, (VALUE)(a), (VALUE)(b), (VALUE)(c), 0))
613613

614-
#define type_roomof(x, y) ((sizeof(x) + sizeof(y) - 1) / sizeof(y))
614+
#define roomof(x, y) (((x) + (y) - 1) / (y))
615+
#define type_roomof(x, y) roomof(sizeof(x), sizeof(y))
615616
#define MEMO_FOR(type, value) ((type *)RARRAY_PTR(value))
616617
#define NEW_MEMO_FOR(type, value) \
617618
((value) = rb_ary_tmp_new_fill(type_roomof(type, VALUE)), MEMO_FOR(type, value))

0 commit comments

Comments
 (0)