From: Tadashi Saito Date: 2008-10-25T02:44:25+09:00 Subject: [ruby-dev:36914] prefix math_* funcs 斎藤と申します。 complex.cで使うために、いくつか数学関数からstaticがとれたようですが、 外部に出すならば rb_ 接頭辞を付けてほしいです。 Index: complex.c =================================================================== --- complex.c (revision 19925) +++ complex.c (working copy) @@ -414,31 +414,31 @@ return rb_funcall2(rb_cComplex, id_convert, argc, argv); } -extern VALUE math_atan2(VALUE obj, VALUE x, VALUE y); -extern VALUE math_cos(VALUE obj, VALUE x); -extern VALUE math_cosh(VALUE obj, VALUE x); -extern VALUE math_exp(VALUE obj, VALUE x); -extern VALUE math_hypot(VALUE obj, VALUE x, VALUE y); -extern VALUE math_log(int argc, VALUE *argv); -extern VALUE math_sin(VALUE obj, VALUE x); -extern VALUE math_sinh(VALUE obj, VALUE x); -extern VALUE math_sqrt(VALUE obj, VALUE x); +extern VALUE rb_math_atan2(VALUE obj, VALUE x, VALUE y); +extern VALUE rb_math_cos(VALUE obj, VALUE x); +extern VALUE rb_math_cosh(VALUE obj, VALUE x); +extern VALUE rb_math_exp(VALUE obj, VALUE x); +extern VALUE rb_math_hypot(VALUE obj, VALUE x, VALUE y); +extern VALUE rb_math_log(int argc, VALUE *argv); +extern VALUE rb_math_sin(VALUE obj, VALUE x); +extern VALUE rb_math_sinh(VALUE obj, VALUE x); +extern VALUE rb_math_sqrt(VALUE obj, VALUE x); -#define m_atan2_bang(x,y) math_atan2(Qnil,x,y) -#define m_cos_bang(x) math_cos(Qnil,x) -#define m_cosh_bang(x) math_cosh(Qnil,x) -#define m_exp_bang(x) math_exp(Qnil,x) -#define m_hypot(x,y) math_hypot(Qnil,x,y) +#define m_atan2_bang(x,y) rb_math_atan2(Qnil,x,y) +#define m_cos_bang(x) rb_math_cos(Qnil,x) +#define m_cosh_bang(x) rb_math_cosh(Qnil,x) +#define m_exp_bang(x) rb_math_exp(Qnil,x) +#define m_hypot(x,y) rb_math_hypot(Qnil,x,y) static VALUE m_log_bang(VALUE x) { - return math_log(1, &x); + return rb_math_log(1, &x); } -#define m_sin_bang(x) math_sin(Qnil,x) -#define m_sinh_bang(x) math_sinh(Qnil,x) -#define m_sqrt_bang(x) math_sqrt(Qnil,x) +#define m_sin_bang(x) rb_math_sin(Qnil,x) +#define m_sinh_bang(x) rb_math_sinh(Qnil,x) +#define m_sqrt_bang(x) rb_math_sqrt(Qnil,x) static VALUE m_cos(VALUE x) Index: math.c =================================================================== --- math.c (revision 19925) +++ math.c (working copy) @@ -82,7 +82,7 @@ */ VALUE -math_atan2(VALUE obj, VALUE y, VALUE x) +rb_math_atan2(VALUE obj, VALUE y, VALUE x) { Need_Float2(y, x); return DBL2NUM(atan2(RFLOAT_VALUE(y), RFLOAT_VALUE(x))); @@ -98,7 +98,7 @@ */ VALUE -math_cos(VALUE obj, VALUE x) +rb_math_cos(VALUE obj, VALUE x) { Need_Float(x); return DBL2NUM(cos(RFLOAT_VALUE(x))); @@ -113,7 +113,7 @@ */ VALUE -math_sin(VALUE obj, VALUE x) +rb_math_sin(VALUE obj, VALUE x) { Need_Float(x); @@ -182,7 +182,7 @@ */ static VALUE -math_atan(VALUE obj, VALUE x) +rb_math_atan(VALUE obj, VALUE x) { Need_Float(x); return DBL2NUM(atan(RFLOAT_VALUE(x))); @@ -204,7 +204,7 @@ */ VALUE -math_cosh(VALUE obj, VALUE x) +rb_math_cosh(VALUE obj, VALUE x) { Need_Float(x); @@ -228,7 +228,7 @@ */ VALUE -math_sinh(VALUE obj, VALUE x) +rb_math_sinh(VALUE obj, VALUE x) { Need_Float(x); return DBL2NUM(sinh(RFLOAT_VALUE(x))); @@ -318,7 +318,7 @@ */ VALUE -math_exp(VALUE obj, VALUE x) +rb_math_exp(VALUE obj, VALUE x) { Need_Float(x); return DBL2NUM(exp(RFLOAT_VALUE(x))); @@ -344,7 +344,7 @@ */ VALUE -math_log(int argc, VALUE *argv) +rb_math_log(int argc, VALUE *argv) { VALUE x, base; double d; @@ -439,7 +439,7 @@ */ VALUE -math_sqrt(VALUE obj, VALUE x) +rb_math_sqrt(VALUE obj, VALUE x) { double d; @@ -541,7 +541,7 @@ */ VALUE -math_hypot(VALUE obj, VALUE x, VALUE y) +rb_math_hypot(VALUE obj, VALUE x, VALUE y) { Need_Float2(x, y); return DBL2NUM(hypot(RFLOAT_VALUE(x), RFLOAT_VALUE(y))); @@ -678,34 +678,34 @@ rb_define_const(rb_mMath, "E", DBL2NUM(exp(1.0))); #endif - rb_define_module_function(rb_mMath, "atan2", math_atan2, 2); - rb_define_module_function(rb_mMath, "cos", math_cos, 1); - rb_define_module_function(rb_mMath, "sin", math_sin, 1); + rb_define_module_function(rb_mMath, "atan2", rb_math_atan2, 2); + rb_define_module_function(rb_mMath, "cos", rb_math_cos, 1); + rb_define_module_function(rb_mMath, "sin", rb_math_sin, 1); rb_define_module_function(rb_mMath, "tan", math_tan, 1); rb_define_module_function(rb_mMath, "acos", math_acos, 1); rb_define_module_function(rb_mMath, "asin", math_asin, 1); - rb_define_module_function(rb_mMath, "atan", math_atan, 1); + rb_define_module_function(rb_mMath, "atan", rb_math_atan, 1); - rb_define_module_function(rb_mMath, "cosh", math_cosh, 1); - rb_define_module_function(rb_mMath, "sinh", math_sinh, 1); + rb_define_module_function(rb_mMath, "cosh", rb_math_cosh, 1); + rb_define_module_function(rb_mMath, "sinh", rb_math_sinh, 1); rb_define_module_function(rb_mMath, "tanh", math_tanh, 1); rb_define_module_function(rb_mMath, "acosh", math_acosh, 1); rb_define_module_function(rb_mMath, "asinh", math_asinh, 1); rb_define_module_function(rb_mMath, "atanh", math_atanh, 1); - rb_define_module_function(rb_mMath, "exp", math_exp, 1); - rb_define_module_function(rb_mMath, "log", math_log, -1); + rb_define_module_function(rb_mMath, "exp", rb_math_exp, 1); + rb_define_module_function(rb_mMath, "log", rb_math_log, -1); rb_define_module_function(rb_mMath, "log2", math_log2, 1); rb_define_module_function(rb_mMath, "log10", math_log10, 1); - rb_define_module_function(rb_mMath, "sqrt", math_sqrt, 1); + rb_define_module_function(rb_mMath, "sqrt", rb_math_sqrt, 1); rb_define_module_function(rb_mMath, "cbrt", math_cbrt, 1); rb_define_module_function(rb_mMath, "frexp", math_frexp, 1); rb_define_module_function(rb_mMath, "ldexp", math_ldexp, 2); - rb_define_module_function(rb_mMath, "hypot", math_hypot, 2); + rb_define_module_function(rb_mMath, "hypot", rb_math_hypot, 2); rb_define_module_function(rb_mMath, "erf", math_erf, 1); rb_define_module_function(rb_mMath, "erfc", math_erfc, 1); ーー 斎藤ただし