Skip to content

Commit

Permalink
* internal.h (numberof): Gathered from various files.
Browse files Browse the repository at this point in the history
* array.c, math.c, thread_pthread.c, iseq.c, enum.c, string.c, io.c,
  load.c, compile.c, struct.c, eval.c, gc.c, parse.y, process.c,
  error.c, ruby.c: Remove the definitions of numberof.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41142 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
akr committed Jun 7, 2013
1 parent 8e65ff7 commit bd15d4c
Show file tree
Hide file tree
Showing 18 changed files with 10 additions and 32 deletions.
8 changes: 8 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
Fri Jun 7 18:58:56 2013 Tanaka Akira <akr@fsij.org>

* internal.h (numberof): Gathered from various files.

* array.c, math.c, thread_pthread.c, iseq.c, enum.c, string.c, io.c,
load.c, compile.c, struct.c, eval.c, gc.c, parse.y, process.c,
error.c, ruby.c: Remove the definitions of numberof.

Fri Jun 7 18:24:39 2013 Tanaka Akira <akr@fsij.org>

* bignum.c (rb_absint_size): Declare a variable, i, just before used
Expand Down
2 changes: 0 additions & 2 deletions array.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
#endif
#include <assert.h>

#define numberof(array) (int)(sizeof(array) / sizeof((array)[0]))

VALUE rb_cArray;

static ID id_cmp, id_div, id_power;
Expand Down
1 change: 0 additions & 1 deletion compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include "insns.inc"
#include "insns_info.inc"

#define numberof(array) (int)(sizeof(array) / sizeof((array)[0]))
#define FIXNUM_INC(n, i) ((n)+(INT2FIX(i)&~FIXNUM_FLAG))
#define FIXNUM_OR(n, i) ((n)|INT2FIX(i))

Expand Down
2 changes: 0 additions & 2 deletions enum.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@

#define STATIC_ASSERT(name, expr) typedef int static_assert_##name##_check[1 - 2*!(expr)]

#define numberof(array) (int)(sizeof(array) / sizeof((array)[0]))

VALUE rb_f_send(int argc, VALUE *argv, VALUE recv);

VALUE rb_mEnumerable;
Expand Down
2 changes: 0 additions & 2 deletions error.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
#include <unistd.h>
#endif

#define numberof(array) (int)(sizeof(array) / sizeof((array)[0]))

#ifndef EXIT_SUCCESS
#define EXIT_SUCCESS 0
#endif
Expand Down
2 changes: 0 additions & 2 deletions eval.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
#include "vm_core.h"
#include "probes_helper.h"

#define numberof(array) (int)(sizeof(array) / sizeof((array)[0]))

NORETURN(void rb_raise_jump(VALUE));

NODE *rb_vm_get_cref(const rb_iseq_t *, const VALUE *);
Expand Down
2 changes: 0 additions & 2 deletions gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2825,8 +2825,6 @@ mark_const_tbl(rb_objspace_t *objspace, st_table *tbl)
((start) = STACK_END, (end) = STACK_START) : ((start) = STACK_START, (end) = STACK_END+(appendix)))
#endif

#define numberof(array) (int)(sizeof(array) / sizeof((array)[0]))

static void
mark_current_machine_context(rb_objspace_t *objspace, rb_thread_t *th)
{
Expand Down
2 changes: 2 additions & 0 deletions internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ extern "C" {
#endif
#endif

#define numberof(array) ((int)(sizeof(array) / sizeof((array)[0])))

#define GCC_VERSION_SINCE(major, minor, patchlevel) \
(defined(__GNUC__) && !defined(__INTEL_COMPILER) && \
((__GNUC__ > (major)) || \
Expand Down
2 changes: 0 additions & 2 deletions io.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,6 @@
off_t __syscall(quad_t number, ...);
#endif

#define numberof(array) (int)(sizeof(array) / sizeof((array)[0]))

#define IO_RBUF_CAPA_MIN 8192
#define IO_CBUF_CAPA_MIN (128*1024)
#define IO_RBUF_CAPA_FOR(fptr) (NEED_READCONV(fptr) ? IO_CBUF_CAPA_MIN : IO_RBUF_CAPA_MIN)
Expand Down
2 changes: 0 additions & 2 deletions iseq.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
#include "vm_core.h"
#include "iseq.h"

#define numberof(array) (int)(sizeof(array) / sizeof((array)[0]))

#include "insns.inc"
#include "insns_info.inc"

Expand Down
2 changes: 0 additions & 2 deletions load.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

VALUE ruby_dln_librefs;

#define numberof(array) (int)(sizeof(array) / sizeof((array)[0]))

#define IS_RBEXT(e) (strcmp((e), ".rb") == 0)
#define IS_SOEXT(e) (strcmp((e), ".so") == 0 || strcmp((e), ".o") == 0)
#ifdef DLEXT2
Expand Down
2 changes: 0 additions & 2 deletions math.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
extern int signbit(double);
#endif

#define numberof(array) (int)(sizeof(array) / sizeof((array)[0]))

VALUE rb_mMath;
VALUE rb_eMathDomainError;

Expand Down
2 changes: 0 additions & 2 deletions parse.y
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@
#include <ctype.h>
#include "probes.h"

#define numberof(array) (int)(sizeof(array) / sizeof((array)[0]))

#define YYMALLOC(size) rb_parser_malloc(parser, (size))
#define YYREALLOC(ptr, size) rb_parser_realloc(parser, (ptr), (size))
#define YYCALLOC(nelem, size) rb_parser_calloc(parser, (nelem), (size))
Expand Down
2 changes: 0 additions & 2 deletions process.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@
#include <grp.h>
#endif

#define numberof(array) (int)(sizeof(array)/sizeof((array)[0]))

#if defined(HAVE_TIMES) || defined(_WIN32)
static VALUE rb_cProcessTms;
#endif
Expand Down
2 changes: 0 additions & 2 deletions ruby.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@
char *getenv();
#endif

#define numberof(array) (int)(sizeof(array) / sizeof((array)[0]))

#if defined DISABLE_RUBYGEMS && DISABLE_RUBYGEMS
#define DEFAULT_RUBYGEMS_ENABLED "disabled"
#else
Expand Down
2 changes: 0 additions & 2 deletions string.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@

#define STRING_ENUMERATORS_WANTARRAY 0 /* next major */

#define numberof(array) (int)(sizeof(array) / sizeof((array)[0]))

#undef rb_str_new_cstr
#undef rb_tainted_str_new_cstr
#undef rb_usascii_str_new_cstr
Expand Down
1 change: 0 additions & 1 deletion struct.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ static VALUE rb_struct_ref7(VALUE obj) {return RSTRUCT_PTR(obj)[7];}
static VALUE rb_struct_ref8(VALUE obj) {return RSTRUCT_PTR(obj)[8];}
static VALUE rb_struct_ref9(VALUE obj) {return RSTRUCT_PTR(obj)[9];}

#define numberof(array) (int)(sizeof(array) / sizeof((array)[0]))
#define N_REF_FUNC numberof(ref_func)

static VALUE (*const ref_func[])(VALUE) = {
Expand Down
4 changes: 0 additions & 4 deletions thread_pthread.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,6 @@ static pthread_t timer_thread_id;
# define USE_SLEEPY_TIMER_THREAD 0
#endif

#ifndef numberof
#define numberof(array) (int)(sizeof(array) / sizeof((array)[0]))
#endif

static void
gvl_acquire_common(rb_vm_t *vm)
{
Expand Down

0 comments on commit bd15d4c

Please sign in to comment.