Get rid of the declaration of rb_str_cat2().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2475 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ttate 2002-05-20 09:38:23 +00:00
Родитель 077d92a044
Коммит a2db8e72c1
4 изменённых файлов: 37 добавлений и 48 удалений

Просмотреть файл

@ -17,7 +17,7 @@ if( ARGV.include?("--help") )
<max_cbent>: maximum number of callback entries <max_cbent>: maximum number of callback entries
--enable-asm use the embedded assembler for passing arguments. --enable-asm use the embedded assembler for passing arguments.
(this option is available for i386 machine now.) (this option is available for i386 machine now.)
--enable-dlstack use a stack emulation for constructing function call. [experimental] --enable-dlstack use a stack emulation for constructing function call.
EOF EOF
exit(0) exit(0)
end end
@ -33,7 +33,7 @@ if (Config::CONFIG['CC'] =~ /gcc/) && (Config::CONFIG['arch'] =~ /i.86/)
else else
$with_asm = false $with_asm = false
end end
$with_dlstack = false $with_dlstack = ! $with_asm
$with_type_int = try_run(<<EOF) $with_type_int = try_run(<<EOF)
int main(){ return sizeof(int) == sizeof(long); } int main(){ return sizeof(int) == sizeof(long); }
@ -165,11 +165,6 @@ else
exit(0) exit(0)
end end
method(:have_func).arity == 1 or have_func("rb_str_cat2", "ruby.h")
if method(:have_func).arity == 1 or !have_func("rb_block_given_p", "ruby.h")
$dlconfig_h << "#define rb_block_given_p rb_iterator_p\n"
end
def File.update(file, str) def File.update(file, str)
begin begin
open(file){|f|f.read} == str open(file){|f|f.read} == str

Просмотреть файл

@ -7,14 +7,6 @@
VALUE rb_cDLSymbol; VALUE rb_cDLSymbol;
#ifndef HAVE_RB_STR_CAT2
static VALUE
rb_str_cat2(VALUE str, const char *s)
{
return rb_str_cat(str, s, strlen(s));
}
#endif
static const char * static const char *
char2type(int ch) char2type(int ch)
{ {

Просмотреть файл

@ -148,30 +148,32 @@ test_append(char *ary[], int len, char *astr)
}; };
}; };
void int
test_init(int *argc, char **argv[]) test_init(int *argc, char **argv[])
{ {
int i; int i;
printf("test_init(0x%x,0x%x)\n",argc,argv); char s[256];
printf("\t*(0x%x) => %d\n",argc,*argc);
for( i=0; i < (*argc); i++ ){ for( i=0; i < (*argc); i++ ){
printf("\t(*(0x%x)[%d]) => %s\n", argv, i, (*argv)[i]); sprintf(s, "arg%d", i);
}; if( strcmp((*argv)[i], s) != 0 ){
}; return 1;
}
}
return 0;
}
FILE * FILE *
test_open(const char *filename, const char *mode) test_open(const char *filename, const char *mode)
{ {
FILE *file; FILE *file;
file = fopen(filename,mode); file = fopen(filename,mode);
printf("test_open(%s,%s):0x%x\n",filename,mode,file);
return file; return file;
}; };
void void
test_close(FILE *file) test_close(FILE *file)
{ {
printf("test_close(0x%x)\n",file);
fclose(file); fclose(file);
}; };
@ -182,26 +184,29 @@ test_gets(char *s, int size, FILE *f)
}; };
typedef int callback1_t(int, char *); typedef int callback1_t(int, char *);
#define CALLBACK_MSG "callback message"
int int
test_callback1(int err, const char *msg) test_callback1(int err, const char *msg)
{ {
printf("internal callback function (err = %d, msg = '%s')\n", if( strcmp(msg, CALLBACK_MSG) == 0 ){
err, msg ? msg : "(null)"); return 1;
return 1; }
}; else{
return 0;
}
}
int int
test_call_func1(callback1_t *func) test_call_func1(callback1_t *func)
{ {
if( func ){ if( func ){
return (*func)(0, "this is test_call_func1."); return (*func)(0, CALLBACK_MSG);
} }
else{ else{
printf("test_call_func1(func = 0)\n"); return 0;
return -1;
} }
}; }
struct test_data * struct test_data *
test_data_init() test_data_init()
@ -227,16 +232,6 @@ test_data_add(struct test_data *list, const char *name)
list->next = data; list->next = data;
}; };
void
test_data_print(struct test_data *list)
{
struct test_data *data;
for( data = list->next; data; data = data->next ){
printf("name = %s\n", data->name);
};
};
struct test_data * struct test_data *
test_data_aref(struct test_data *list, int i) test_data_aref(struct test_data *list, int i)
{ {

Просмотреть файл

@ -3,11 +3,16 @@
require 'dl' require 'dl'
require 'dl/import' require 'dl/import'
$FAIL = 0
$TOTAL = 0
def assert(label, ty, *conds) def assert(label, ty, *conds)
$TOTAL += 1
cond = !conds.include?(false) cond = !conds.include?(false)
if( cond ) if( cond )
printf("succeed in `#{label}'\n") printf("succeed in `#{label}'\n")
else else
$FAIL += 1
case ty case ty
when :may when :may
printf("fail in `#{label}' ... expected\n") printf("fail in `#{label}' ... expected\n")
@ -158,12 +163,12 @@ DL.dlopen($LIB){|h|
debug r,rs debug r,rs
assert("strcat", :must, rs[0].to_s == "abcx") assert("strcat", :must, rs[0].to_s == "abcx")
init = h["test_init","0iP"] init = h["test_init","IiP"]
debug init debug init
argc = 3 argc = 3
argv = ["arg0","arg1","arg2"].to_ptr argv = ["arg0","arg1","arg2"].to_ptr
r,rs = init[argc, argv.ref] r,rs = init[argc, argv.ref]
debug r,rs assert("init", :must, r == 0)
} }
@ -203,9 +208,11 @@ assert("callback1", :must, r == 1)
callback2 = DL.set_callback("LLP", 0){|arg1,arg2| callback2 = DL.set_callback("LLP", 0){|arg1,arg2|
ptr = arg2 # DL::PtrData.new(arg2) ptr = arg2 # DL::PtrData.new(arg2)
msg = ptr.to_s msg = ptr.to_s
print("user defined callback function", if( msg == "callback message" )
"(err = #{arg1}, msg = '#{msg}')\n") 2
2 else
0
end
} }
debug callback2 debug callback2
r,rs = h["test_call_func1", "IP"][callback2] r,rs = h["test_call_func1", "IP"][callback2]
@ -249,14 +256,12 @@ assert("set value", :must, ptr[:l] == lval) unless (Fixnum === :-)
data_init = h["test_data_init", "P"] data_init = h["test_data_init", "P"]
data_add = h["test_data_add", "0PS"] data_add = h["test_data_add", "0PS"]
data_print = h["test_data_print", "0P"]
data_aref = h["test_data_aref", "PPI"] data_aref = h["test_data_aref", "PPI"]
r,rs = data_init[] r,rs = data_init[]
ptr = r ptr = r
data_add[ptr, "name1"] data_add[ptr, "name1"]
data_add[ptr, "name2"] data_add[ptr, "name2"]
data_add[ptr, "name3"] data_add[ptr, "name3"]
data_print[ptr]
r,rs = data_aref[ptr, 1] r,rs = data_aref[ptr, 1]
ptr = r ptr = r
@ -288,3 +293,5 @@ assert("struct!", :must,
ptr["l"] == 4) ptr["l"] == 4)
GC.start GC.start
printf("fail/total = #{$FAIL}/#{$TOTAL}\n")