summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--configure.in17
-rw-r--r--string.c24
3 files changed, 31 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog
index b877f1fa5..c91fe516e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Thu Aug 14 00:43:53 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * configure.in (rb_cv_gcc_function_alias): checks alias attribute.
+
+ * string.c (alias_func): replaced with RUBY_ALIAS_FUNCTION.
+
Wed Aug 13 23:42:49 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* common.mk (parse.h): fake rule.
diff --git a/configure.in b/configure.in
index bd38c2b8b..1ad99ca5e 100644
--- a/configure.in
+++ b/configure.in
@@ -445,6 +445,23 @@ RUBY_FUNC_ATTRIBUTE(stdcall)
RUBY_FUNC_ATTRIBUTE(cdecl)
RUBY_FUNC_ATTRIBUTE(fastcall)
+if test "$GCC" = yes; then
+ AC_CACHE_CHECK([for function alias], [rb_cv_gcc_function_alias],
+ [rb_cv_gcc_function_alias=no
+ for a in alias weak,alias; do
+ AC_TRY_LINK([void foo(void) {}
+ void bar(void) __attribute__(($a("foo")));], [bar()],
+ [rb_cv_gcc_function_alias=$a; break])
+ done])
+ if test "$rb_cv_gcc_function_alias" = no; then
+ AC_DEFINE([RUBY_ALIAS_FUNCTION(old_prot, new_name, args)],
+ [VALUE old_prot {return new_name args;}])
+ else
+ AC_DEFINE_UNQUOTED([RUBY_ALIAS_FUNCTION(old_prot, new_name, args)],
+ [VALUE old_prot __attribute__(($rb_cv_gcc_function_alias(@%:@new_name)));])
+ fi
+fi
+
AC_CACHE_CHECK([for RUBY_EXTERN], rb_cv_ruby_extern,
[rb_cv_ruby_extern=no
for mac in "__attribute__((dllimport))" "__declspec(dllimport)"; do
diff --git a/string.c b/string.c
index 27b813e4f..75b6b1ec6 100644
--- a/string.c
+++ b/string.c
@@ -43,14 +43,6 @@
VALUE rb_cString;
VALUE rb_cSymbol;
-#ifdef __GNUC__
-#define alias_func(old_prot, new_name, args) \
-VALUE old_prot __attribute__((weak, alias(#new_name)));
-#else
-#define alias_func(old_prot, new_name, args) \
-VALUE old_prot {return new_name args;}
-#endif
-
#define STR_TMPLOCK FL_USER7
#define STR_NOEMBED FL_USER1
#define STR_SHARED FL_USER2 /* = ELTS_SHARED */
@@ -440,7 +432,7 @@ rb_str_new_cstr(const char *ptr)
return rb_str_new(ptr, strlen(ptr));
}
-alias_func(rb_str_new2(const char *ptr), rb_str_new_cstr, (ptr))
+RUBY_ALIAS_FUNCTION(rb_str_new2(const char *ptr), rb_str_new_cstr, (ptr))
#define rb_str_new2 rb_str_new_cstr
VALUE
@@ -451,7 +443,7 @@ rb_usascii_str_new_cstr(const char *ptr)
return str;
}
-alias_func(rb_usascii_str_new2(const char *ptr), rb_usascii_str_new_cstr, (ptr))
+RUBY_ALIAS_FUNCTION(rb_usascii_str_new2(const char *ptr), rb_usascii_str_new_cstr, (ptr))
#define rb_usascii_str_new2 rb_usascii_str_new_cstr
VALUE
@@ -472,7 +464,7 @@ rb_tainted_str_new_cstr(const char *ptr)
return str;
}
-alias_func(rb_tainted_str_new2(const char *ptr), rb_tainted_str_new_cstr, (ptr))
+RUBY_ALIAS_FUNCTION(rb_tainted_str_new2(const char *ptr), rb_tainted_str_new_cstr, (ptr))
#define rb_tainted_str_new2 rb_tainted_str_new_cstr
static VALUE
@@ -516,7 +508,7 @@ rb_str_new_shared(VALUE str)
return str2;
}
-alias_func(rb_str_new3(VALUE str), rb_str_new_shared, (str))
+RUBY_ALIAS_FUNCTION(rb_str_new3(VALUE str), rb_str_new_shared, (str))
#define rb_str_new3 rb_str_new_shared
static VALUE
@@ -579,7 +571,7 @@ rb_str_new_frozen(VALUE orig)
return str;
}
-alias_func(rb_str_new4(VALUE orig), rb_str_new_frozen, (orig))
+RUBY_ALIAS_FUNCTION(rb_str_new4(VALUE orig), rb_str_new_frozen, (orig))
#define rb_str_new4 rb_str_new_frozen
VALUE
@@ -588,7 +580,7 @@ rb_str_new_with_class(VALUE obj, const char *ptr, long len)
return str_new(rb_obj_class(obj), ptr, len);
}
-alias_func(rb_str_new5(VALUE obj, const char *ptr, long len),
+RUBY_ALIAS_FUNCTION(rb_str_new5(VALUE obj, const char *ptr, long len),
rb_str_new_with_class, (obj, ptr, len))
#define rb_str_new5 rb_str_new_with_class
@@ -622,7 +614,7 @@ rb_str_buf_new_cstr(const char *ptr)
return str;
}
-alias_func(rb_str_buf_new2(const char *ptr), rb_str_buf_new_cstr, (ptr))
+RUBY_ALIAS_FUNCTION(rb_str_buf_new2(const char *ptr), rb_str_buf_new_cstr, (ptr))
#define rb_str_buf_new2 rb_str_buf_new_cstr
VALUE
@@ -1365,7 +1357,7 @@ rb_str_freeze(VALUE str)
return rb_obj_freeze(str);
}
-alias_func(rb_str_dup_frozen(VALUE str), rb_str_new_frozen, (str))
+RUBY_ALIAS_FUNCTION(rb_str_dup_frozen(VALUE str), rb_str_new_frozen, (str))
#define rb_str_dup_frozen rb_str_new_frozen
VALUE