cvsuser 04/10/14 02:40:26
Modified: config/gen/makefiles dynclasses_pl.in
src nci_test.c
t/pmc nci.t
Log:
[PATCH] [perl #31976] dlvar - writing into external library
Courtesy of Bernhard Schmalhofer <[EMAIL PROTECTED]>
[PATCH] Re: [perl #31978] [BUG] dynclasses broken
The below patch should fix this.
Courtesy of Jeff Clites <[EMAIL PROTECTED]>
Revision Changes Path
1.3 +7 -27 parrot/config/gen/makefiles/dynclasses_pl.in
Index: dynclasses_pl.in
===================================================================
RCS file: /cvs/public/parrot/config/gen/makefiles/dynclasses_pl.in,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -w -r1.2 -r1.3
--- dynclasses_pl.in 8 Oct 2004 07:08:31 -0000 1.2
+++ dynclasses_pl.in 14 Oct 2004 09:40:12 -0000 1.3
@@ -13,14 +13,6 @@
our $PMC2C = "$PERL ${build_dir}${slash}classes${slash}pmc2c2.pl";
# Actual commands
-sub compile_loadable_cmd {
- my ($target, $source) = @_;
- "$LD $CFLAGS $LDFLAGS $LD_LOAD_FLAGS " .
- "${cc_o_out}" . $target . " " .
- "-I${build_dir}${slash}include -I${build_dir}${slash}classes " .
- $source;
-};
-
sub compile_cmd {
my ($target, $source) = @_;
"$CC $CFLAGS " .
@@ -58,14 +50,8 @@
} elsif ($mode eq 'compile') {
my ($group_files, $pmc_group) = gather_groups(@pmcs);
- my @grouped_pmcs = grep { exists $pmc_group->{$_} } @pmcs;
- my @ungrouped_pmcs = grep { ! exists $pmc_group->{$_} } @pmcs;
-
- # Convert X.c -> X.so for all non-grouped X.c
- compile_loadable($_) foreach (@ungrouped_pmcs);
-
- # Convert X.c -> X.o for all grouped X.c
- compile($_) foreach (@grouped_pmcs);
+ # Convert X.c -> X.o for all X.c
+ compile($_) foreach (@pmcs);
# lib-GROUP.c
for my $group (keys %$group_files) {
@@ -80,6 +66,11 @@
partial_link($group, "lib-$group", @$pmcs)
or die "partial link of $group failed ($?)\n";
}
+
+ # Link non-grouped PMCs individually
+ my @ungrouped_pmcs = grep { ! exists $pmc_group->{$_} } @pmcs;
+ partial_link($_, $_) foreach (@ungrouped_pmcs);
+
} elsif ($mode eq 'copy') {
# Copy *.so -> destination, where destination is the first
# argument, given as --destination=DIRECTORY
@@ -166,17 +157,6 @@
}
}
-sub compile_loadable {
- my ($src_stem, $dest_stem) = @_;
- $dest_stem ||= $src_stem;
- if (needs_build("$dest_stem$LOAD_EXT", "$src_stem.c")) {
- run(compile_loadable_cmd("$dest_stem$LOAD_EXT", "$src_stem.c"))
- or die "compile $src_stem.c failed ($?)\n";
- } else {
- print "$dest_stem$LOAD_EXT is up to date\n";
- }
-}
-
sub partial_link {
my ($group, @stems) = @_;
my @sources = map { "$_$O" } @stems;
1.36 +3 -3 parrot/src/nci_test.c
Index: nci_test.c
===================================================================
RCS file: /cvs/public/parrot/src/nci_test.c,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -w -r1.35 -r1.36
--- nci_test.c 13 Oct 2004 07:36:01 -0000 1.35
+++ nci_test.c 14 Oct 2004 09:40:16 -0000 1.36
@@ -1,6 +1,6 @@
/*
Copyright: 2001-2004 The Perl Foundation. All Rights Reserved.
-$Id: nci_test.c,v 1.35 2004/10/13 07:36:01 leo Exp $
+$Id: nci_test.c,v 1.36 2004/10/14 09:40:16 leo Exp $
=head1 NAME
@@ -426,11 +426,11 @@
return;
}
-static int int_cb_D4 = 1;
+int int_cb_D4 = -55555;
void
nci_cb_D4(cb_D4_func times_ten, void* user_data) {
int cnt;
- for ( cnt = 0; cnt < 10; cnt++ )
+ for ( cnt = 0; cnt < 9; cnt++ )
{
(times_ten)(user_data, &int_cb_D4);
int_cb_D4++;
1.57 +36 -10 parrot/t/pmc/nci.t
Index: nci.t
===================================================================
RCS file: /cvs/public/parrot/t/pmc/nci.t,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -w -r1.56 -r1.57
--- nci.t 13 Oct 2004 07:36:03 -0000 1.56
+++ nci.t 14 Oct 2004 09:40:26 -0000 1.57
@@ -1,7 +1,7 @@
#! perl -w
# Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
-# $Id: nci.t,v 1.56 2004/10/13 07:36:03 leo Exp $
+# $Id: nci.t,v 1.57 2004/10/14 09:40:26 leo Exp $
=head1 NAME
@@ -1588,6 +1588,21 @@
user_data = new Integer
user_data = 42
+ # load libnci
+ .local pmc libnci
+ libnci = loadlib "libnci"
+
+ # reset int_cb_D4 to 1
+ .local pmc int_cb_D4
+ int_cb_D4 = dlvar libnci, "int_cb_D4"
+ .local pmc int_cb_D4_decl
+ int_cb_D4_decl = new PerlArray
+ push int_cb_D4_decl, .DATATYPE_INT
+ push int_cb_D4_decl, 0
+ push int_cb_D4_decl, 0
+ assign int_cb_D4, int_cb_D4_decl
+ int_cb_D4[0] = 1
+
# A Sub that can be given to the library
# this callback function will eventually by called by the library
.local pmc cb
@@ -1595,20 +1610,23 @@
.local pmc cb_wrapped
cb_wrapped = new_callback cb, user_data, "Up" # Z in pdd16
print "created a callback sub\n"
- .local pmc synchronous
- synchronous = new Integer
- synchronous = 1
- setprop user_data, "_synchronous", synchronous
- print "marked callback as synchronous\n"
# now call the external sub, that takes a callback and user data
- .local pmc libnci
- libnci = loadlib "libnci"
.local pmc nci_cb_D4
nci_cb_D4 = dlfunc libnci, "nci_cb_D4", "vpP"
print "loaded a function that takes a callback\n"
nci_cb_D4( cb_wrapped, user_data )
+ # reset int_cb_D4 to 1
+ int_cb_D4[0] = 1
+
+ .local pmc synchronous
+ synchronous = new Integer
+ synchronous = 1
+ setprop user_data, "_synchronous", synchronous
+ print "marked callback as synchronous\n"
+ nci_cb_D4( cb_wrapped, user_data )
+
end
.end
@@ -1632,8 +1650,17 @@
CODE
created a callback sub
-marked callback as synchronous
loaded a function that takes a callback
+external data: 10
+external data: 100
+external data: 1000
+external data: 10000
+external data: 100000
+external data: 1000000
+external data: 10000000
+external data: 100000000
+external data: 1000000000
+marked callback as synchronous
external data: 1
external data: 11
external data: 111
@@ -1643,7 +1670,6 @@
external data: 1111111
external data: 11111111
external data: 111111111
-external data: 1111111111
OUTPUT
output_is(<<'CODE', <<'OUTPUT', 'nci_pip - array of structs');