Skip to content

Commit

Permalink
Fixed problems preventing C extensions from building on some platforms.
Browse files Browse the repository at this point in the history
  • Loading branch information
jdantonio committed Jul 30, 2014
1 parent 2e33d01 commit 62e3e64
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 15 deletions.
2 changes: 1 addition & 1 deletion ext/concurrent_ruby_ext/atomic_boolean.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include "atomic_boolean.h"
#include "atomic_reference.h"
#include "common.h"
#include "ruby_193_compatible.h"

void atomic_boolean_mark(void *value) {
rb_gc_mark_maybe((VALUE) value);
Expand Down
2 changes: 1 addition & 1 deletion ext/concurrent_ruby_ext/atomic_fixnum.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include "atomic_fixnum.h"
#include "atomic_reference.h"
#include "common.h"
#include "ruby_193_compatible.h"

void atomic_fixnum_mark(void *value) {
rb_gc_mark_maybe((VALUE) value);
Expand Down
13 changes: 0 additions & 13 deletions ext/concurrent_ruby_ext/common.h

This file was deleted.

28 changes: 28 additions & 0 deletions ext/concurrent_ruby_ext/ruby_193_compatible.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#ifndef rb_check_arity

// https://github.com/ruby/ruby/blob/ruby_2_0_0/include/ruby/intern.h
// rb_check_arity was added in Ruby 2.0

#define UNLIMITED_ARGUMENTS (-1)

static inline void rb_error_arity(int argc, int min, int max)
{
VALUE err_mess = 0;
if (min == max) {
err_mess = rb_sprintf("wrong number of arguments (%d for %d)", argc, min);
}
else if (max == UNLIMITED_ARGUMENTS) {
err_mess = rb_sprintf("wrong number of arguments (%d for %d+)", argc, min);
}
else {
err_mess = rb_sprintf("wrong number of arguments (%d for %d..%d)", argc, min, max);
}
rb_raise(rb_eTypeError, err_mess);
}

#define rb_check_arity(argc, min, max) do { \
if (((argc) < (min)) || ((argc) > (max) && (max) != UNLIMITED_ARGUMENTS)) \
rb_error_arity(argc, min, max); \
} while(0)

#endif

0 comments on commit 62e3e64

Please sign in to comment.